// // FBXReader.h // interface // // Created by Andrzej Kapolka on 9/18/13. // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // #ifndef __interface__FBXReader__ #define __interface__FBXReader__ #include #include #include #include #include #include #include class FBXNode; typedef QList FBXNodeList; /// The names of the blendshapes expected by Faceshift, terminated with an empty string. extern const char* FACESHIFT_BLENDSHAPES[]; class Extents { public: /// set minimum and maximum to FLT_MAX and -FLT_MAX respectively void reset(); /// \param point new point to compare against existing limits /// compare point to current limits and expand them if necessary to contain point void addPoint(const glm::vec3& point); /// \param point /// \return true if point is within current limits bool containsPoint(const glm::vec3& point) const; glm::vec3 minimum; glm::vec3 maximum; }; /// A node within an FBX document. class FBXNode { public: QByteArray name; QVariantList properties; FBXNodeList children; }; /// A single blendshape extracted from an FBX document. class FBXBlendshape { public: QVector indices; QVector vertices; QVector normals; }; /// A single joint (transformation node) extracted from an FBX document. class FBXJoint { public: bool isFree; QVector freeLineage; int parentIndex; float distanceToParent; float boneRadius; glm::vec3 translation; glm::mat4 preTransform; glm::quat preRotation; glm::quat rotation; glm::quat postRotation; glm::mat4 postTransform; glm::mat4 transform; glm::vec3 rotationMin; glm::vec3 rotationMax; glm::quat inverseDefaultRotation; glm::quat inverseBindRotation; glm::mat4 bindTransform; QString name; // temp field for debugging glm::vec3 shapePosition; // in joint frame glm::quat shapeRotation; // in joint frame int shapeType; }; /// A single binding to a joint in an FBX document. class FBXCluster { public: int jointIndex; glm::mat4 inverseBindMatrix; }; /// A single part of a mesh (with the same material). class FBXMeshPart { public: QVector quadIndices; QVector triangleIndices; glm::vec3 diffuseColor; glm::vec3 specularColor; float shininess; QByteArray diffuseFilename; QByteArray normalFilename; }; /// A single mesh (with optional blendshapes) extracted from an FBX document. class FBXMesh { public: QVector parts; QVector vertices; QVector normals; QVector tangents; QVector colors; QVector texCoords; QVector clusterIndices; QVector clusterWeights; QVector clusters; bool isEye; QVector blendshapes; float springiness; QVector > springEdges; QVector, 4> > vertexConnections; }; /// An attachment to an FBX document. class FBXAttachment { public: int jointIndex; QUrl url; glm::vec3 translation; glm::quat rotation; glm::vec3 scale; }; /// A set of meshes extracted from an FBX document. class FBXGeometry { public: QVector joints; QHash jointIndices; QVector meshes; glm::mat4 offset; int leftEyeJointIndex; int rightEyeJointIndex; int neckJointIndex; int rootJointIndex; int leanJointIndex; int headJointIndex; int leftHandJointIndex; int rightHandJointIndex; QVector leftFingerJointIndices; QVector rightFingerJointIndices; QVector leftFingertipJointIndices; QVector rightFingertipJointIndices; glm::vec3 palmDirection; glm::vec3 neckPivot; Extents bindExtents; Extents staticExtents; Extents meshExtents; QVector attachments; }; Q_DECLARE_METATYPE(FBXGeometry) /// Reads an FST mapping from the supplied data. QVariantHash readMapping(const QByteArray& data); /// Reads FBX geometry from the supplied model and mapping data. /// \exception QString if an error occurs in parsing FBXGeometry readFBX(const QByteArray& model, const QVariantHash& mapping); /// Reads SVO geometry from the supplied model data. FBXGeometry readSVO(const QByteArray& model); #endif /* defined(__interface__FBXReader__) */