- fbx: read local transforms (different modes of rotation not yet implemented, though).
parent
3179e949bb
commit
4db113395c
|
@ -154,7 +154,7 @@ private:
|
|||
nd->mName.Set(model->Name());
|
||||
nd->mParent = &parent;
|
||||
|
||||
// XXX handle transformation
|
||||
ConvertTransformation(*model,*nd);
|
||||
|
||||
ConvertModel(*model, *nd);
|
||||
ConvertNodes(model->ID(), *nd);
|
||||
|
@ -170,6 +170,46 @@ private:
|
|||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void ConvertTransformation(const Model& model, aiNode& nd)
|
||||
{
|
||||
const PropertyTable& props = model.Props();
|
||||
|
||||
bool ok;
|
||||
|
||||
aiVector3D Translation = PropertyGet<aiVector3D>(props,"Lcl Translation",ok);
|
||||
if(!ok) {
|
||||
Translation = aiVector3D(0.0f,0.0f,0.0f);
|
||||
}
|
||||
|
||||
aiVector3D Scaling = PropertyGet<aiVector3D>(props,"Lcl Scaling",ok);
|
||||
if(!ok) {
|
||||
Scaling = aiVector3D(1.0f,1.0f,1.0f);
|
||||
}
|
||||
|
||||
// XXX euler angles, radians, xyz order?
|
||||
aiVector3D Rotation = PropertyGet<aiVector3D>(props,"Lcl Rotation",ok);
|
||||
if(!ok) {
|
||||
Rotation = aiVector3D(0.0f,0.0f,0.0f);
|
||||
}
|
||||
|
||||
aiMatrix4x4 temp;
|
||||
nd.mTransformation = aiMatrix4x4::Scaling(Scaling,temp);
|
||||
if(fabs(Rotation.x) > 1e-6f) {
|
||||
nd.mTransformation *= aiMatrix4x4::RotationX(Rotation.x,temp);
|
||||
}
|
||||
if(fabs(Rotation.y) > 1e-6f) {
|
||||
nd.mTransformation *= aiMatrix4x4::RotationY(Rotation.y,temp);
|
||||
}
|
||||
if(fabs(Rotation.z) > 1e-6f) {
|
||||
nd.mTransformation *= aiMatrix4x4::RotationZ(Rotation.z,temp);
|
||||
}
|
||||
nd.mTransformation.a4 = Translation.x;
|
||||
nd.mTransformation.b4 = Translation.y;
|
||||
nd.mTransformation.c4 = Translation.z;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void ConvertModel(const Model& model, aiNode& nd)
|
||||
{
|
||||
|
|
|
@ -74,6 +74,7 @@ Model::Model(uint64_t id, const Element& element, const Document& doc, const std
|
|||
culling = ParseTokenAsString(GetRequiredToken(*Culling,0));
|
||||
}
|
||||
|
||||
props = GetPropertyTable(doc,"Model.FbxNode",element,sc);
|
||||
ResolveLinks(element,doc);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,14 @@ Property* ReadTypedProperty(const Element& element)
|
|||
else if (!strcmp(cs,"ULongLong")) {
|
||||
return new TypedProperty<uint64_t>(ParseTokenAsID(*tok[4]));
|
||||
}
|
||||
else if (!strcmp(cs,"Vector3D") || !strcmp(cs,"ColorRGB") || !strcmp(cs,"Vector") || !strcmp(cs,"Color")) {
|
||||
else if (!strcmp(cs,"Vector3D") ||
|
||||
!strcmp(cs,"ColorRGB") ||
|
||||
!strcmp(cs,"Vector") ||
|
||||
!strcmp(cs,"Color") ||
|
||||
!strcmp(cs,"Lcl Translation") ||
|
||||
!strcmp(cs,"Lcl Rotation") ||
|
||||
!strcmp(cs,"Lcl Scaling")
|
||||
) {
|
||||
return new TypedProperty<aiVector3D>(aiVector3D(
|
||||
ParseTokenAsFloat(*tok[4]),
|
||||
ParseTokenAsFloat(*tok[5]),
|
||||
|
@ -187,7 +194,6 @@ const Property* PropertyTable::Get(const std::string& name) const
|
|||
}
|
||||
}
|
||||
|
||||
ai_assert((*it).second);
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue