Merge branch 'master' into pdb-install-fix

pull/2458/head
Kim Kulling 2019-05-16 14:49:29 +02:00 committed by GitHub
commit 7cd021e704
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 264 additions and 203 deletions

View File

@ -1225,6 +1225,16 @@ aiLight* BlenderImporter::ConvertLight(const Scene& /*in*/, const Object* obj, c
case Lamp::Type_Local: case Lamp::Type_Local:
out->mType = aiLightSource_POINT; out->mType = aiLightSource_POINT;
break; break;
case Lamp::Type_Spot:
out->mType = aiLightSource_SPOT;
// blender orients directional lights as facing toward -z
out->mDirection = aiVector3D(0.f, 0.f, -1.f);
out->mUp = aiVector3D(0.f, 1.f, 0.f);
out->mAngleInnerCone = lamp->spotsize * (1.0f - lamp->spotblend);
out->mAngleOuterCone = lamp->spotsize;
break;
case Lamp::Type_Sun: case Lamp::Type_Sun:
out->mType = aiLightSource_DIRECTIONAL; out->mType = aiLightSource_DIRECTIONAL;
@ -1255,6 +1265,23 @@ aiLight* BlenderImporter::ConvertLight(const Scene& /*in*/, const Object* obj, c
out->mColorAmbient = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy; out->mColorAmbient = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy;
out->mColorSpecular = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy; out->mColorSpecular = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy;
out->mColorDiffuse = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy; out->mColorDiffuse = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy;
// If default values are supplied, compute the coefficients from light's max distance
// Read this: https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/
//
if (lamp->constant_coefficient == 1.0f && lamp->linear_coefficient == 0.0f && lamp->quadratic_coefficient == 0.0f && lamp->dist > 0.0f)
{
out->mAttenuationConstant = 1.0f;
out->mAttenuationLinear = 2.0f / lamp->dist;
out->mAttenuationQuadratic = 1.0f / (lamp->dist * lamp->dist);
}
else
{
out->mAttenuationConstant = lamp->constant_coefficient;
out->mAttenuationLinear = lamp->linear_coefficient;
out->mAttenuationQuadratic = lamp->quadratic_coefficient;
}
return out.release(); return out.release();
} }

View File

@ -211,9 +211,12 @@ template <> void Structure :: Convert<Lamp> (
ReadField<ErrorPolicy_Warn>(dest.b,"b",db); ReadField<ErrorPolicy_Warn>(dest.b,"b",db);
ReadField<ErrorPolicy_Warn>(dest.k,"k",db); ReadField<ErrorPolicy_Warn>(dest.k,"k",db);
ReadField<ErrorPolicy_Igno>(dest.energy,"energy",db); ReadField<ErrorPolicy_Igno>(dest.energy,"energy",db);
ReadField<ErrorPolicy_Igno>(dest.dist,"dist",db); ReadField<ErrorPolicy_Warn>(dest.dist,"dist",db);
ReadField<ErrorPolicy_Igno>(dest.spotsize,"spotsize",db); ReadField<ErrorPolicy_Igno>(dest.spotsize,"spotsize",db);
ReadField<ErrorPolicy_Igno>(dest.spotblend,"spotblend",db); ReadField<ErrorPolicy_Igno>(dest.spotblend,"spotblend",db);
ReadField<ErrorPolicy_Warn>(dest.constant_coefficient, "coeff_const", db);
ReadField<ErrorPolicy_Warn>(dest.linear_coefficient, "coeff_lin", db);
ReadField<ErrorPolicy_Warn>(dest.quadratic_coefficient, "coeff_quad", db);
ReadField<ErrorPolicy_Igno>(dest.att1,"att1",db); ReadField<ErrorPolicy_Igno>(dest.att1,"att1",db);
ReadField<ErrorPolicy_Igno>(dest.att2,"att2",db); ReadField<ErrorPolicy_Igno>(dest.att2,"att2",db);
ReadField<ErrorPolicy_Igno>(temp,"falloff_type",db); ReadField<ErrorPolicy_Igno>(temp,"falloff_type",db);

View File

@ -538,6 +538,10 @@ struct Lamp : ElemBase {
float energy, dist, spotsize, spotblend; float energy, dist, spotsize, spotblend;
//float haint; //float haint;
float constant_coefficient;
float linear_coefficient;
float quadratic_coefficient;
float att1, att2; float att1, att2;
//struct CurveMapping *curfalloff; //struct CurveMapping *curfalloff;
FalloffType falloff_type; FalloffType falloff_type;

View File

@ -64,13 +64,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp; using namespace Assimp;
namespace Assimp namespace Assimp {
{
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp // Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp
void ExportSceneCollada(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) void ExportSceneCollada(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) {
{
std::string path = DefaultIOSystem::absolutePath(std::string(pFile)); std::string path = DefaultIOSystem::absolutePath(std::string(pFile));
std::string file = DefaultIOSystem::completeBaseName(std::string(pFile)); std::string file = DefaultIOSystem::completeBaseName(std::string(pFile));
@ -93,12 +91,12 @@ void ExportSceneCollada(const char* pFile, IOSystem* pIOSystem, const aiScene* p
} // end of namespace Assimp } // end of namespace Assimp
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor for a specific scene to export // Constructor for a specific scene to export
ColladaExporter::ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file) : mIOSystem(pIOSystem), mPath(path), mFile(file) ColladaExporter::ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file)
{ : mIOSystem(pIOSystem)
, mPath(path)
, mFile(file) {
// make sure that all formatting happens using the standard, C locale and not the user's current locale // make sure that all formatting happens using the standard, C locale and not the user's current locale
mOutput.imbue( std::locale("C") ); mOutput.imbue( std::locale("C") );
mOutput.precision(16); mOutput.precision(16);
@ -115,8 +113,7 @@ ColladaExporter::ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, co
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Destructor // Destructor
ColladaExporter::~ColladaExporter() ColladaExporter::~ColladaExporter() {
{
if ( mSceneOwned ) { if ( mSceneOwned ) {
delete mScene; delete mScene;
} }
@ -124,8 +121,7 @@ ColladaExporter::~ColladaExporter()
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Starts writing the contents // Starts writing the contents
void ColladaExporter::WriteFile() void ColladaExporter::WriteFile() {
{
// write the DTD // write the DTD
mOutput << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>" << endstr; mOutput << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>" << endstr;
// COLLADA element start // COLLADA element start
@ -158,8 +154,7 @@ void ColladaExporter::WriteFile()
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Writes the asset header // Writes the asset header
void ColladaExporter::WriteHeader() void ColladaExporter::WriteHeader() {
{
static const ai_real epsilon = ai_real( 0.00001 ); static const ai_real epsilon = ai_real( 0.00001 );
static const aiQuaternion x_rot(aiMatrix3x3( static const aiQuaternion x_rot(aiMatrix3x3(
0, -1, 0, 0, -1, 0,
@ -240,52 +235,61 @@ void ColladaExporter::WriteHeader()
// If no Scene metadata, use root node metadata // If no Scene metadata, use root node metadata
aiMetadata* meta = mScene->mMetaData; aiMetadata* meta = mScene->mMetaData;
if (!meta) if (nullptr == meta) {
meta = mScene->mRootNode->mMetaData; meta = mScene->mRootNode->mMetaData;
}
aiString value; aiString value;
if (!meta || !meta->Get("Author", value)) if (!meta || !meta->Get("Author", value)) {
mOutput << startstr << "<author>" << "Assimp" << "</author>" << endstr; mOutput << startstr << "<author>" << "Assimp" << "</author>" << endstr;
else } else {
mOutput << startstr << "<author>" << XMLEscape(value.C_Str()) << "</author>" << endstr; mOutput << startstr << "<author>" << XMLEscape(value.C_Str()) << "</author>" << endstr;
}
if (!meta || !meta->Get("AuthoringTool", value)) if (nullptr == meta || !meta->Get("AuthoringTool", value)) {
mOutput << startstr << "<authoring_tool>" << "Assimp Exporter" << "</authoring_tool>" << endstr; mOutput << startstr << "<authoring_tool>" << "Assimp Exporter" << "</authoring_tool>" << endstr;
else } else {
mOutput << startstr << "<authoring_tool>" << XMLEscape(value.C_Str()) << "</authoring_tool>" << endstr; mOutput << startstr << "<authoring_tool>" << XMLEscape(value.C_Str()) << "</authoring_tool>" << endstr;
}
if (meta) if (meta) {
{ if (meta->Get("Comments", value)) {
if (meta->Get("Comments", value))
mOutput << startstr << "<comments>" << XMLEscape(value.C_Str()) << "</comments>" << endstr; mOutput << startstr << "<comments>" << XMLEscape(value.C_Str()) << "</comments>" << endstr;
if (meta->Get("Copyright", value)) }
if (meta->Get("Copyright", value)) {
mOutput << startstr << "<copyright>" << XMLEscape(value.C_Str()) << "</copyright>" << endstr; mOutput << startstr << "<copyright>" << XMLEscape(value.C_Str()) << "</copyright>" << endstr;
if (meta->Get("SourceData", value)) }
if (meta->Get("SourceData", value)) {
mOutput << startstr << "<source_data>" << XMLEscape(value.C_Str()) << "</source_data>" << endstr; mOutput << startstr << "<source_data>" << XMLEscape(value.C_Str()) << "</source_data>" << endstr;
} }
}
PopTag(); PopTag();
mOutput << startstr << "</contributor>" << endstr; mOutput << startstr << "</contributor>" << endstr;
if (!meta || !meta->Get("Created", value)) if (nullptr == meta || !meta->Get("Created", value)) {
mOutput << startstr << "<created>" << date_str << "</created>" << endstr; mOutput << startstr << "<created>" << date_str << "</created>" << endstr;
else } else {
mOutput << startstr << "<created>" << XMLEscape(value.C_Str()) << "</created>" << endstr; mOutput << startstr << "<created>" << XMLEscape(value.C_Str()) << "</created>" << endstr;
}
// Modified date is always the date saved // Modified date is always the date saved
mOutput << startstr << "<modified>" << date_str << "</modified>" << endstr; mOutput << startstr << "<modified>" << date_str << "</modified>" << endstr;
if (meta) if (meta) {
{ if (meta->Get("Keywords", value)) {
if (meta->Get("Keywords", value))
mOutput << startstr << "<keywords>" << XMLEscape(value.C_Str()) << "</keywords>" << endstr; mOutput << startstr << "<keywords>" << XMLEscape(value.C_Str()) << "</keywords>" << endstr;
if (meta->Get("Revision", value)) }
if (meta->Get("Revision", value)) {
mOutput << startstr << "<revision>" << XMLEscape(value.C_Str()) << "</revision>" << endstr; mOutput << startstr << "<revision>" << XMLEscape(value.C_Str()) << "</revision>" << endstr;
if (meta->Get("Subject", value)) }
if (meta->Get("Subject", value)) {
mOutput << startstr << "<subject>" << XMLEscape(value.C_Str()) << "</subject>" << endstr; mOutput << startstr << "<subject>" << XMLEscape(value.C_Str()) << "</subject>" << endstr;
if (meta->Get("Title", value)) }
if (meta->Get("Title", value)) {
mOutput << startstr << "<title>" << XMLEscape(value.C_Str()) << "</title>" << endstr; mOutput << startstr << "<title>" << XMLEscape(value.C_Str()) << "</title>" << endstr;
} }
}
mOutput << startstr << "<unit name=\"meter\" meter=\"" << scale << "\" />" << endstr; mOutput << startstr << "<unit name=\"meter\" meter=\"" << scale << "\" />" << endstr;
mOutput << startstr << "<up_axis>" << up_axis << "</up_axis>" << endstr; mOutput << startstr << "<up_axis>" << up_axis << "</up_axis>" << endstr;
@ -305,6 +309,9 @@ void ColladaExporter::WriteTextures() {
// so we just write the textures in the current directory. // so we just write the textures in the current directory.
aiTexture* texture = mScene->mTextures[i]; aiTexture* texture = mScene->mTextures[i];
if ( nullptr == texture ) {
continue;
}
ASSIMP_itoa10(str, buffer_size, i + 1); ASSIMP_itoa10(str, buffer_size, i + 1);
@ -458,6 +465,7 @@ void ColladaExporter::WritePointLight(const aiLight *const light){
mOutput << startstr << "</point>" << endstr; mOutput << startstr << "</point>" << endstr;
} }
void ColladaExporter::WriteDirectionalLight(const aiLight *const light){ void ColladaExporter::WriteDirectionalLight(const aiLight *const light){
const aiColor3D &color= light->mColorDiffuse; const aiColor3D &color= light->mColorDiffuse;
mOutput << startstr << "<directional>" << endstr; mOutput << startstr << "<directional>" << endstr;
@ -470,6 +478,7 @@ void ColladaExporter::WriteDirectionalLight(const aiLight *const light){
mOutput << startstr << "</directional>" << endstr; mOutput << startstr << "</directional>" << endstr;
} }
void ColladaExporter::WriteSpotLight(const aiLight *const light){ void ColladaExporter::WriteSpotLight(const aiLight *const light){
const aiColor3D &color= light->mColorDiffuse; const aiColor3D &color= light->mColorDiffuse;
@ -526,18 +535,16 @@ void ColladaExporter::WriteAmbienttLight(const aiLight *const light){
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Reads a single surface entry from the given material keys // Reads a single surface entry from the given material keys
void ColladaExporter::ReadMaterialSurface( Surface& poSurface, const aiMaterial* pSrcMat, aiTextureType pTexture, const char* pKey, size_t pType, size_t pIndex) void ColladaExporter::ReadMaterialSurface( Surface& poSurface, const aiMaterial* pSrcMat,
{ aiTextureType pTexture, const char* pKey, size_t pType, size_t pIndex) {
if( pSrcMat->GetTextureCount( pTexture) > 0 ) if( pSrcMat->GetTextureCount( pTexture) > 0 ) {
{
aiString texfile; aiString texfile;
unsigned int uvChannel = 0; unsigned int uvChannel = 0;
pSrcMat->GetTexture( pTexture, 0, &texfile, NULL, &uvChannel); pSrcMat->GetTexture( pTexture, 0, &texfile, NULL, &uvChannel);
std::string index_str(texfile.C_Str()); std::string index_str(texfile.C_Str());
if(index_str.size() != 0 && index_str[0] == '*') if(index_str.size() != 0 && index_str[0] == '*') {
{
unsigned int index; unsigned int index;
index_str = index_str.substr(1, std::string::npos); index_str = index_str.substr(1, std::string::npos);
@ -555,15 +562,13 @@ void ColladaExporter::ReadMaterialSurface( Surface& poSurface, const aiMaterial*
} else { } else {
throw DeadlyExportError("could not find embedded texture at index " + index_str); throw DeadlyExportError("could not find embedded texture at index " + index_str);
} }
} else } else {
{
poSurface.texture = texfile.C_Str(); poSurface.texture = texfile.C_Str();
} }
poSurface.channel = uvChannel; poSurface.channel = uvChannel;
poSurface.exist = true; poSurface.exist = true;
} else } else {
{
if( pKey ) if( pKey )
poSurface.exist = pSrcMat->Get( pKey, static_cast<unsigned int>(pType), static_cast<unsigned int>(pIndex), poSurface.color) == aiReturn_SUCCESS; poSurface.exist = pSrcMat->Get( pKey, static_cast<unsigned int>(pType), static_cast<unsigned int>(pIndex), poSurface.color) == aiReturn_SUCCESS;
} }
@ -571,15 +576,13 @@ void ColladaExporter::ReadMaterialSurface( Surface& poSurface, const aiMaterial*
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Reimplementation of isalnum(,C locale), because AppVeyor does not see standard version. // Reimplementation of isalnum(,C locale), because AppVeyor does not see standard version.
static bool isalnum_C(char c) static bool isalnum_C(char c) {
{
return ( nullptr != strchr("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",c) ); return ( nullptr != strchr("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",c) );
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Writes an image entry for the given surface // Writes an image entry for the given surface
void ColladaExporter::WriteImageEntry( const Surface& pSurface, const std::string& pNameAdd) void ColladaExporter::WriteImageEntry( const Surface& pSurface, const std::string& pNameAdd) {
{
if( !pSurface.texture.empty() ) if( !pSurface.texture.empty() )
{ {
mOutput << startstr << "<image id=\"" << XMLEscape(pNameAdd) << "\">" << endstr; mOutput << startstr << "<image id=\"" << XMLEscape(pNameAdd) << "\">" << endstr;
@ -833,8 +836,9 @@ void ColladaExporter::WriteControllerLibrary()
mOutput << startstr << "<library_controllers>" << endstr; mOutput << startstr << "<library_controllers>" << endstr;
PushTag(); PushTag();
for( size_t a = 0; a < mScene->mNumMeshes; ++a) for( size_t a = 0; a < mScene->mNumMeshes; ++a) {
WriteController( a); WriteController( a);
}
PopTag(); PopTag();
mOutput << startstr << "</library_controllers>" << endstr; mOutput << startstr << "</library_controllers>" << endstr;

View File

@ -59,12 +59,11 @@ namespace FBX {
class Node; class Node;
} }
class FBX::Node class FBX::Node {
{ public:
public: // public data members
// TODO: accessors // TODO: accessors
std::string name; // node name std::string name; // node name
std::vector<FBX::Property> properties; // node properties std::vector<FBX::FBXExportProperty> properties; // node properties
std::vector<FBX::Node> children; // child nodes std::vector<FBX::Node> children; // child nodes
// some nodes always pretend they have children... // some nodes always pretend they have children...
@ -215,7 +214,7 @@ public: // static member functions
Assimp::StreamWriterLE& s, Assimp::StreamWriterLE& s,
bool binary, int indent bool binary, int indent
) { ) {
FBX::Property p(value); FBX::FBXExportProperty p(value);
FBX::Node node(name, p); FBX::Node node(name, p);
node.Dump(s, binary, indent); node.Dump(s, binary, indent);
} }

View File

@ -53,95 +53,114 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sstream> // ostringstream #include <sstream> // ostringstream
namespace Assimp { namespace Assimp {
namespace FBX {
// constructors for single element properties // constructors for single element properties
FBX::Property::Property(bool v) FBXExportProperty::FBXExportProperty(bool v)
: type('C'), data(1) : type('C')
{ , data(1) {
data = {uint8_t(v)}; data = {
uint8_t(v)
};
} }
FBX::Property::Property(int16_t v) : type('Y'), data(2) FBXExportProperty::FBXExportProperty(int16_t v)
{ : type('Y')
, data(2) {
uint8_t* d = data.data(); uint8_t* d = data.data();
(reinterpret_cast<int16_t*>(d))[0] = v; (reinterpret_cast<int16_t*>(d))[0] = v;
} }
FBX::Property::Property(int32_t v) : type('I'), data(4) FBXExportProperty::FBXExportProperty(int32_t v)
{ : type('I')
, data(4) {
uint8_t* d = data.data(); uint8_t* d = data.data();
(reinterpret_cast<int32_t*>(d))[0] = v; (reinterpret_cast<int32_t*>(d))[0] = v;
} }
FBX::Property::Property(float v) : type('F'), data(4) FBXExportProperty::FBXExportProperty(float v)
{ : type('F')
, data(4) {
uint8_t* d = data.data(); uint8_t* d = data.data();
(reinterpret_cast<float*>(d))[0] = v; (reinterpret_cast<float*>(d))[0] = v;
} }
FBX::Property::Property(double v) : type('D'), data(8) FBXExportProperty::FBXExportProperty(double v)
{ : type('D')
, data(8) {
uint8_t* d = data.data(); uint8_t* d = data.data();
(reinterpret_cast<double*>(d))[0] = v; (reinterpret_cast<double*>(d))[0] = v;
} }
FBX::Property::Property(int64_t v) : type('L'), data(8) FBXExportProperty::FBXExportProperty(int64_t v)
{ : type('L')
, data(8) {
uint8_t* d = data.data(); uint8_t* d = data.data();
(reinterpret_cast<int64_t*>(d))[0] = v; (reinterpret_cast<int64_t*>(d))[0] = v;
} }
// constructors for array-type properties // constructors for array-type properties
FBX::Property::Property(const char* c, bool raw) FBXExportProperty::FBXExportProperty(const char* c, bool raw)
: Property(std::string(c), raw) : FBXExportProperty(std::string(c), raw) {
{} // empty
}
// strings can either be saved as "raw" (R) data, or "string" (S) data // strings can either be saved as "raw" (R) data, or "string" (S) data
FBX::Property::Property(const std::string& s, bool raw) FBXExportProperty::FBXExportProperty(const std::string& s, bool raw)
: type(raw ? 'R' : 'S'), data(s.size()) : type(raw ? 'R' : 'S')
{ , data(s.size()) {
for (size_t i = 0; i < s.size(); ++i) { for (size_t i = 0; i < s.size(); ++i) {
data[i] = uint8_t(s[i]); data[i] = uint8_t(s[i]);
} }
} }
FBX::Property::Property(const std::vector<uint8_t>& r) FBXExportProperty::FBXExportProperty(const std::vector<uint8_t>& r)
: type('R'), data(r) : type('R')
{} , data(r) {
// empty
}
FBX::Property::Property(const std::vector<int32_t>& va) FBXExportProperty::FBXExportProperty(const std::vector<int32_t>& va)
: type('i'), data(4*va.size()) : type('i')
{ , data(4 * va.size() ) {
int32_t* d = reinterpret_cast<int32_t*>(data.data()); int32_t* d = reinterpret_cast<int32_t*>(data.data());
for (size_t i = 0; i < va.size(); ++i) { d[i] = va[i]; } for (size_t i = 0; i < va.size(); ++i) {
d[i] = va[i];
}
} }
FBX::Property::Property(const std::vector<int64_t>& va) FBXExportProperty::FBXExportProperty(const std::vector<int64_t>& va)
: type('l'), data(8*va.size()) : type('l')
{ , data(8 * va.size()) {
int64_t* d = reinterpret_cast<int64_t*>(data.data()); int64_t* d = reinterpret_cast<int64_t*>(data.data());
for (size_t i = 0; i < va.size(); ++i) { d[i] = va[i]; } for (size_t i = 0; i < va.size(); ++i) {
d[i] = va[i];
}
} }
FBX::Property::Property(const std::vector<float>& va) FBXExportProperty::FBXExportProperty(const std::vector<float>& va)
: type('f'), data(4*va.size()) : type('f')
{ , data(4 * va.size()) {
float* d = reinterpret_cast<float*>(data.data()); float* d = reinterpret_cast<float*>(data.data());
for (size_t i = 0; i < va.size(); ++i) { d[i] = va[i]; } for (size_t i = 0; i < va.size(); ++i) {
d[i] = va[i];
}
} }
FBX::Property::Property(const std::vector<double>& va) FBXExportProperty::FBXExportProperty(const std::vector<double>& va)
: type('d'), data(8*va.size()) : type('d')
{ , data(8 * va.size()) {
double* d = reinterpret_cast<double*>(data.data()); double* d = reinterpret_cast<double*>(data.data());
for (size_t i = 0; i < va.size(); ++i) { d[i] = va[i]; } for (size_t i = 0; i < va.size(); ++i) {
d[i] = va[i];
}
} }
FBX::Property::Property(const aiMatrix4x4& vm) FBXExportProperty::FBXExportProperty(const aiMatrix4x4& vm)
: type('d'), data(8*16) : type('d')
{ , data(8 * 16) {
double* d = reinterpret_cast<double*>(data.data()); double* d = reinterpret_cast<double*>(data.data());
for (unsigned int c = 0; c < 4; ++c) { for (unsigned int c = 0; c < 4; ++c) {
for (unsigned int r = 0; r < 4; ++r) { for (unsigned int r = 0; r < 4; ++r) {
@ -152,22 +171,27 @@ FBX::Property::Property(const aiMatrix4x4& vm)
// public member functions // public member functions
size_t FBX::Property::size() size_t FBXExportProperty::size() {
{
switch (type) { switch (type) {
case 'C': case 'Y': case 'I': case 'F': case 'D': case 'L': case 'C':
case 'Y':
case 'I':
case 'F':
case 'D':
case 'L':
return data.size() + 1; return data.size() + 1;
case 'S': case 'R': case 'S':
case 'R':
return data.size() + 5; return data.size() + 5;
case 'i': case 'd': case 'i':
case 'd':
return data.size() + 13; return data.size() + 13;
default: default:
throw DeadlyExportError("Requested size on property of unknown type"); throw DeadlyExportError("Requested size on property of unknown type");
} }
} }
void FBX::Property::DumpBinary(Assimp::StreamWriterLE &s) void FBXExportProperty::DumpBinary(Assimp::StreamWriterLE& s) {
{
s.PutU1(type); s.PutU1(type);
uint8_t* d = data.data(); uint8_t* d = data.data();
size_t N; size_t N;
@ -231,8 +255,7 @@ void FBX::Property::DumpBinary(Assimp::StreamWriterLE &s)
} }
} }
void FBX::Property::DumpAscii(Assimp::StreamWriterLE &outstream, int indent) void FBXExportProperty::DumpAscii(Assimp::StreamWriterLE& outstream, int indent) {
{
std::ostringstream ss; std::ostringstream ss;
ss.imbue(std::locale::classic()); ss.imbue(std::locale::classic());
ss.precision(15); // this seems to match official FBX SDK exports ss.precision(15); // this seems to match official FBX SDK exports
@ -240,8 +263,7 @@ void FBX::Property::DumpAscii(Assimp::StreamWriterLE &outstream, int indent)
outstream.PutString(ss.str()); outstream.PutString(ss.str());
} }
void FBX::Property::DumpAscii(std::ostream& s, int indent) void FBXExportProperty::DumpAscii(std::ostream& s, int indent) {
{
// no writing type... or anything. just shove it into the stream. // no writing type... or anything. just shove it into the stream.
uint8_t* d = data.data(); uint8_t* d = data.data();
size_t N; size_t N;
@ -359,6 +381,9 @@ void FBX::Property::DumpAscii(std::ostream& s, int indent)
throw runtime_error(err.str()); throw runtime_error(err.str());
} }
} }
}
} // Namespace FBX
} // Namespace Assimp
#endif // ASSIMP_BUILD_NO_FBX_EXPORTER #endif // ASSIMP_BUILD_NO_FBX_EXPORTER
#endif // ASSIMP_BUILD_NO_EXPORT #endif // ASSIMP_BUILD_NO_EXPORT

View File

@ -47,7 +47,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_FBX_EXPORTER #ifndef ASSIMP_BUILD_NO_FBX_EXPORTER
#include <assimp/types.h> // aiMatrix4x4 #include <assimp/types.h> // aiMatrix4x4
#include <assimp/StreamWriter.h> // StreamWriterLE #include <assimp/StreamWriter.h> // StreamWriterLE
@ -58,10 +57,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp { namespace Assimp {
namespace FBX { namespace FBX {
class Property;
}
/** FBX::Property /** @brief FBX::Property
* *
* Holds a value of any of FBX's recognized types, * Holds a value of any of FBX's recognized types,
* each represented by a particular one-character code. * each represented by a particular one-character code.
@ -79,35 +76,34 @@ namespace FBX {
* S : string (array of 1-byte char) * S : string (array of 1-byte char)
* R : raw data (array of bytes) * R : raw data (array of bytes)
*/ */
class FBX::Property class FBXExportProperty {
{
public: public:
// constructors for basic types. // constructors for basic types.
// all explicit to avoid accidental typecasting // all explicit to avoid accidental typecasting
explicit Property(bool v); explicit FBXExportProperty(bool v);
// TODO: determine if there is actually a byte type, // TODO: determine if there is actually a byte type,
// or if this always means <bool>. 'C' seems to imply <char>, // or if this always means <bool>. 'C' seems to imply <char>,
// so possibly the above was intended to represent both. // so possibly the above was intended to represent both.
explicit Property(int16_t v); explicit FBXExportProperty(int16_t v);
explicit Property(int32_t v); explicit FBXExportProperty(int32_t v);
explicit Property(float v); explicit FBXExportProperty(float v);
explicit Property(double v); explicit FBXExportProperty(double v);
explicit Property(int64_t v); explicit FBXExportProperty(int64_t v);
// strings can either be stored as 'R' (raw) or 'S' (string) type // strings can either be stored as 'R' (raw) or 'S' (string) type
explicit Property(const char* c, bool raw=false); explicit FBXExportProperty(const char* c, bool raw = false);
explicit Property(const std::string& s, bool raw=false); explicit FBXExportProperty(const std::string& s, bool raw = false);
explicit Property(const std::vector<uint8_t>& r); explicit FBXExportProperty(const std::vector<uint8_t>& r);
explicit Property(const std::vector<int32_t>& va); explicit FBXExportProperty(const std::vector<int32_t>& va);
explicit Property(const std::vector<int64_t>& va); explicit FBXExportProperty(const std::vector<int64_t>& va);
explicit Property(const std::vector<double>& va); explicit FBXExportProperty(const std::vector<double>& va);
explicit Property(const std::vector<float>& va); explicit FBXExportProperty(const std::vector<float>& va);
explicit Property(const aiMatrix4x4& vm); explicit FBXExportProperty(const aiMatrix4x4& vm);
// this will catch any type not defined above, // this will catch any type not defined above,
// so that we don't accidentally convert something we don't want. // so that we don't accidentally convert something we don't want.
// for example (const char*) --> (bool)... seriously wtf C++ // for example (const char*) --> (bool)... seriously wtf C++
template <class T> template <class T>
explicit Property(T v) : type('X') { explicit FBXExportProperty(T v) : type('X') {
static_assert(std::is_void<T>::value, "TRIED TO CREATE FBX PROPERTY WITH UNSUPPORTED TYPE, CHECK YOUR PROPERTY INSTANTIATION"); static_assert(std::is_void<T>::value, "TRIED TO CREATE FBX PROPERTY WITH UNSUPPORTED TYPE, CHECK YOUR PROPERTY INSTANTIATION");
} // note: no line wrap so it appears verbatim on the compiler error } // note: no line wrap so it appears verbatim on the compiler error
@ -124,7 +120,10 @@ private:
char type; char type;
std::vector<uint8_t> data; std::vector<uint8_t> data;
}; };
}
} // Namespace FBX
} // Namespace Assimp
#endif // ASSIMP_BUILD_NO_FBX_EXPORTER #endif // ASSIMP_BUILD_NO_FBX_EXPORTER
#endif // AI_FBXEXPORTPROPERTY_H_INC #endif // AI_FBXEXPORTPROPERTY_H_INC

View File

@ -2271,8 +2271,8 @@ void FBXExporter::WriteModelNode(
// not sure what these are for, // not sure what these are for,
// but they seem to be omnipresent // but they seem to be omnipresent
m.AddChild("Shading", Property(true)); m.AddChild("Shading", FBXExportProperty(true));
m.AddChild("Culling", Property("CullingOff")); m.AddChild("Culling", FBXExportProperty("CullingOff"));
m.Dump(outstream, binary, 1); m.Dump(outstream, binary, 1);
} }
@ -2385,7 +2385,7 @@ void FBXExporter::WriteModelNodes(
na.AddProperties( na.AddProperties(
node_attribute_uid, FBX::SEPARATOR + "NodeAttribute", "LimbNode" node_attribute_uid, FBX::SEPARATOR + "NodeAttribute", "LimbNode"
); );
na.AddChild("TypeFlags", Property("Skeleton")); na.AddChild("TypeFlags", FBXExportProperty("Skeleton"));
na.Dump(outstream, binary, 1); na.Dump(outstream, binary, 1);
// and connect them // and connect them
connections.emplace_back("C", "OO", node_attribute_uid, node_uid); connections.emplace_back("C", "OO", node_attribute_uid, node_uid);

View File

@ -1,7 +1,7 @@
// Microsoft Visual C++ generated resource script. // Microsoft Visual C++ generated resource script.
// //
#include "resource.h" #include "resource.h"
#include "..\..\revision.h" #include "revision.h"
#define APSTUDIO_READONLY_SYMBOLS #define APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

View File

@ -16,7 +16,7 @@ OutputBaseFileName=assimp-sdk-5.0.0-setup
VersionInfoVersion=4.1.0.0 VersionInfoVersion=4.1.0.0
VersionInfoTextVersion=4.1.0 VersionInfoTextVersion=4.1.0
VersionInfoCompany=Assimp Development Team VersionInfoCompany=Assimp Development Team
ArchitecturesInstallIn64BitMode=x86 ;ArchitecturesInstallIn64BitMode=x64
[Types] [Types]
Name: "full"; Description: "Full installation" Name: "full"; Description: "Full installation"

View File

@ -1,6 +1,6 @@
ply ply
format ascii 1.0 format ascii 1.0
comment Created by Open Asset Import Library - http://assimp.sf.net (v4.1.412856994) comment Created by Open Asset Import Library - http://assimp.sf.net (v4.1.3297435427)
element vertex 8 element vertex 8
property float x property float x
property float y property float y