Move HFM prefixed classes to hfm namespace and add HFM prefixed names as typedefs

This commit is contained in:
sabrina-shanman 2018-11-02 16:56:43 -07:00
parent 2801f324b7
commit a98a9b1c0c
3 changed files with 82 additions and 54 deletions

View file

@ -17,9 +17,9 @@
#include <QFileInfo> #include <QFileInfo>
#include <QVariantHash> #include <QVariantHash>
#include "ui/ModelsBrowser.h" #include <HFM.h>
class HFMModel; #include "ui/ModelsBrowser.h"
class ModelPackager : public QObject { class ModelPackager : public QObject {
public: public:

View file

@ -25,8 +25,39 @@
#include <graphics/Geometry.h> #include <graphics/Geometry.h>
#include <graphics/Material.h> #include <graphics/Material.h>
// High Fidelity Model namespace
namespace hfm {
class Blendshape;
struct JointShapeInfo;
class Joint;
class Cluster;
class Texture;
class MeshPart;
class Material;
class Mesh;
class AnimationFrame;
class Light;
class Model;
};
typedef hfm::Blendshape HFMBlendshape;
typedef hfm::JointShapeInfo HFMJointShapeInfo;
typedef hfm::Joint HFMJoint;
typedef hfm::Cluster HFMCluster;
typedef hfm::Texture HFMTexture;
typedef hfm::MeshPart HFMMeshPart;
typedef hfm::Material HFMMaterial;
typedef hfm::Mesh HFMMesh;
typedef hfm::AnimationFrame HFMAnimationFrame;
typedef hfm::Light HFMLight;
typedef hfm::Model HFMModel;
const int MAX_NUM_PIXELS_FOR_FBX_TEXTURE = 2048 * 2048;
namespace hfm {
/// A single blendshape. /// A single blendshape.
class HFMBlendshape { class Blendshape {
public: public:
QVector<int> indices; QVector<int> indices;
QVector<glm::vec3> vertices; QVector<glm::vec3> vertices;
@ -34,7 +65,7 @@ public:
QVector<glm::vec3> tangents; QVector<glm::vec3> tangents;
}; };
struct HFMJointShapeInfo { struct JointShapeInfo {
// same units and frame as HFMJoint.translation // same units and frame as HFMJoint.translation
glm::vec3 avgPoint; glm::vec3 avgPoint;
std::vector<float> dots; std::vector<float> dots;
@ -43,10 +74,9 @@ struct HFMJointShapeInfo {
}; };
/// A single joint (transformation node). /// A single joint (transformation node).
class HFMJoint { class Joint {
public: public:
JointShapeInfo shapeInfo;
HFMJointShapeInfo shapeInfo;
QVector<int> freeLineage; QVector<int> freeLineage;
bool isFree; bool isFree;
int parentIndex; int parentIndex;
@ -82,7 +112,7 @@ public:
/// A single binding to a joint. /// A single binding to a joint.
class HFMCluster { class Cluster {
public: public:
int jointIndex; int jointIndex;
@ -90,10 +120,8 @@ public:
Transform inverseBindTransform; Transform inverseBindTransform;
}; };
const int MAX_NUM_PIXELS_FOR_FBX_TEXTURE = 2048 * 2048;
/// A texture map. /// A texture map.
class HFMTexture { class Texture {
public: public:
QString id; QString id;
QString name; QString name;
@ -111,7 +139,7 @@ public:
}; };
/// A single part of a mesh (with the same material). /// A single part of a mesh (with the same material).
class HFMMeshPart { class MeshPart {
public: public:
QVector<int> quadIndices; // original indices from the FBX mesh QVector<int> quadIndices; // original indices from the FBX mesh
@ -121,10 +149,10 @@ public:
QString materialID; QString materialID;
}; };
class HFMMaterial { class Material {
public: public:
HFMMaterial() {}; Material() {};
HFMMaterial(const glm::vec3& diffuseColor, const glm::vec3& specularColor, const glm::vec3& emissiveColor, Material(const glm::vec3& diffuseColor, const glm::vec3& specularColor, const glm::vec3& emissiveColor,
float shininess, float opacity) : float shininess, float opacity) :
diffuseColor(diffuseColor), diffuseColor(diffuseColor),
specularColor(specularColor), specularColor(specularColor),
@ -158,17 +186,17 @@ public:
QString shadingModel; QString shadingModel;
graphics::MaterialPointer _material; graphics::MaterialPointer _material;
HFMTexture normalTexture; Texture normalTexture;
HFMTexture albedoTexture; Texture albedoTexture;
HFMTexture opacityTexture; Texture opacityTexture;
HFMTexture glossTexture; Texture glossTexture;
HFMTexture roughnessTexture; Texture roughnessTexture;
HFMTexture specularTexture; Texture specularTexture;
HFMTexture metallicTexture; Texture metallicTexture;
HFMTexture emissiveTexture; Texture emissiveTexture;
HFMTexture occlusionTexture; Texture occlusionTexture;
HFMTexture scatteringTexture; Texture scatteringTexture;
HFMTexture lightmapTexture; Texture lightmapTexture;
glm::vec2 lightmapParams{ 0.0f, 1.0f }; glm::vec2 lightmapParams{ 0.0f, 1.0f };
@ -187,10 +215,10 @@ public:
}; };
/// A single mesh (with optional blendshapes). /// A single mesh (with optional blendshapes).
class HFMMesh { class Mesh {
public: public:
QVector<HFMMeshPart> parts; QVector<MeshPart> parts;
QVector<glm::vec3> vertices; QVector<glm::vec3> vertices;
QVector<glm::vec3> normals; QVector<glm::vec3> normals;
@ -202,12 +230,12 @@ public:
QVector<uint16_t> clusterWeights; QVector<uint16_t> clusterWeights;
QVector<int32_t> originalIndices; QVector<int32_t> originalIndices;
QVector<HFMCluster> clusters; QVector<Cluster> clusters;
Extents meshExtents; Extents meshExtents;
glm::mat4 modelTransform; glm::mat4 modelTransform;
QVector<HFMBlendshape> blendshapes; QVector<Blendshape> blendshapes;
unsigned int meshIndex; // the order the meshes appeared in the object file unsigned int meshIndex; // the order the meshes appeared in the object file
@ -218,29 +246,23 @@ public:
void createBlendShapeTangents(bool generateTangents); void createBlendShapeTangents(bool generateTangents);
}; };
class ExtractedMesh {
public:
HFMMesh mesh;
QMultiHash<int, int> newIndices;
QVector<QHash<int, int> > blendshapeIndexMaps;
QVector<QPair<int, int> > partMaterialTextures;
QHash<QString, size_t> texcoordSetMap;
};
/**jsdoc /**jsdoc
* @typedef {object} FBXAnimationFrame * @typedef {object} FBXAnimationFrame
* @property {Quat[]} rotations * @property {Quat[]} rotations
* @property {Vec3[]} translations * @property {Vec3[]} translations
*/ */
/// A single animation frame. /// A single animation frame.
class HFMAnimationFrame { class AnimationFrame {
public: public:
QVector<glm::quat> rotations; QVector<glm::quat> rotations;
QVector<glm::vec3> translations; QVector<glm::vec3> translations;
}; };
Q_DECLARE_METATYPE(AnimationFrame)
Q_DECLARE_METATYPE(QVector<AnimationFrame>)
/// A light. /// A light.
class HFMLight { class Light {
public: public:
QString name; QString name;
Transform transform; Transform transform;
@ -248,7 +270,7 @@ public:
float fogValue; float fogValue;
glm::vec3 color; glm::vec3 color;
HFMLight() : Light() :
name(), name(),
transform(), transform(),
intensity(1.0f), intensity(1.0f),
@ -257,13 +279,10 @@ public:
{} {}
}; };
Q_DECLARE_METATYPE(HFMAnimationFrame)
Q_DECLARE_METATYPE(QVector<HFMAnimationFrame>)
/// The runtime model format. /// The runtime model format.
class HFMModel { class Model {
public: public:
using Pointer = std::shared_ptr<HFMModel>; using Pointer = std::shared_ptr<Model>;
QString originalURL; QString originalURL;
QString author; QString author;
@ -273,10 +292,10 @@ public:
QHash<QString, int> jointIndices; ///< 1-based, so as to more easily detect missing indices QHash<QString, int> jointIndices; ///< 1-based, so as to more easily detect missing indices
bool hasSkeletonJoints; bool hasSkeletonJoints;
QVector<HFMMesh> meshes; QVector<Mesh> meshes;
QVector<QString> scripts; QVector<QString> scripts;
QHash<QString, HFMMaterial> materials; QHash<QString, Material> materials;
glm::mat4 offset; // This includes offset, rotation, and scale as specified by the FST file glm::mat4 offset; // This includes offset, rotation, and scale as specified by the FST file
@ -303,7 +322,7 @@ public:
Extents bindExtents; Extents bindExtents;
Extents meshExtents; Extents meshExtents;
QVector<HFMAnimationFrame> animationFrames; QVector<AnimationFrame> animationFrames;
int getJointIndex(const QString& name) const { return jointIndices.value(name) - 1; } int getJointIndex(const QString& name) const { return jointIndices.value(name) - 1; }
QStringList getJointNames() const; QStringList getJointNames() const;
@ -323,7 +342,18 @@ public:
QList<QString> blendshapeChannelNames; QList<QString> blendshapeChannelNames;
}; };
Q_DECLARE_METATYPE(HFMModel) Q_DECLARE_METATYPE(Model)
Q_DECLARE_METATYPE(HFMModel::Pointer) Q_DECLARE_METATYPE(Model::Pointer)
};
class ExtractedMesh {
public:
hfm::Mesh mesh;
QMultiHash<int, int> newIndices;
QVector<QHash<int, int> > blendshapeIndexMaps;
QVector<QPair<int, int> > partMaterialTextures;
QHash<QString, size_t> texcoordSetMap;
};
#endif // hifi_HFM_h_ #endif // hifi_HFM_h_

View file

@ -11,8 +11,6 @@
#include <render/ShapePipeline.h> #include <render/ShapePipeline.h>
class HFMModel;
class TestFbx : public GpuTestBase { class TestFbx : public GpuTestBase {
size_t _partCount { 0 }; size_t _partCount { 0 };
graphics::Material _material; graphics::Material _material;