3#include "Topology/TriangleSet.h"
9#include "tinygltf/tiny_gltf.h"
13#define NULL_TIME (-9599.99)
18 typedef unsigned char byte;
25 void getVec3fByAttributeName(tinygltf::Model& model,
const tinygltf::Primitive& primitive,
const std::string& attributeName, std::vector<Vec3f>& vertices);
27 void getVec4ByAttributeName(tinygltf::Model& model,
const tinygltf::Primitive& primitive,
const std::string& attributeName, std::vector<Vec4f>& vec4Data);
29 void getRealByIndex(tinygltf::Model& model,
int index, std::vector<Real>& result);
31 void getVec3fByIndex(tinygltf::Model& model,
int index, std::vector<Vec3f>& result);
35 void getTriangles(tinygltf::Model& model,
const tinygltf::Primitive& primitive, std::vector<TopologyModule::Triangle>& triangles,
int pointOffest);
37 std::string
getTexUri(
const std::vector<tinygltf::Texture>& textures,
const std::vector<tinygltf::Image>& images,
int index);
39 void getVertexBindJoint(tinygltf::Model& model,
const tinygltf::Primitive& primitive,
const std::string& attributeName, std::vector<Vec4f>& vec4Data,
const std::vector<int>& skinJoints);
42 void getNodesAndHierarchy(tinygltf::Model& model, std::map<
scene, std::vector<int>> Scene_JointsNodesId, std::vector<joint>& all_Nodes, std::map<
joint, std::vector<int>>& id_Dir);
44 void traverseNode(tinygltf::Model& model,
joint id, std::vector<joint>& joint_nodes, std::map<
joint, std::vector<int>>& dir, std::vector<joint> currentDir);
47 const std::vector<int>& all_Joints,
48 std::vector<std::vector<int>>& joint_child,
50 std::map<int, Vec3f>& joint_scale,
51 std::map<int, Vec3f>& joint_translation,
52 std::map<int, Mat4f>& joint_matrix,
57 tinygltf::Model model,
58 std::map<joint, Vec3i>& joint_output,
59 std::map<joint, Vec3f>& joint_input,
60 std::map<
joint, std::vector<Vec3f>>& joint_T_f_anim,
61 std::map<
joint, std::vector<Real>>& joint_T_Time,
62 std::map<
joint, std::vector<Vec3f>>& joint_S_f_anim,
63 std::map<
joint, std::vector<Real>>& joint_S_Time,
65 std::map<
joint, std::vector<Real>>& joint_R_Time
69 const std::vector<joint>& all_Joints,
70 std::map<joint, Mat4f>& joint_matrix,
int& maxJointId,
71 tinygltf::Model& model,
73 std::map<joint, Vec3f>& joint_translation,
74 std::map<joint, Vec3f>& joint_scale,
75 std::map<joint, Mat4f>& joint_inverseBindMatrix,
76 std::map<
joint, std::vector<int>> jointId_joint_Dir
80 tinygltf::Model& model,
83 std::map<
joint, std::vector<int>>& jointId_joint_Dir,
84 std::vector<joint>& all_Joints,
85 std::vector<int>& all_Nodes,
86 std::map<
joint, std::vector<int>> nodeId_Dir,
87 std::map<
int, std::vector<int>>& meshId_Dir,
88 std::vector<int>& all_Meshs,
95 tinygltf::Model& model,
96 const std::vector<int>& all_MeshNodeIDs,
101 template<
typename Vec3f,
typename Vec4f,
typename Mat4f,
typename Vec2u>
124 tinygltf::Model& model,
125 std::shared_ptr<TextureMesh> texMesh,
126 const std::string& filepath,
131 std::shared_ptr<SkinInfo> skinData =
nullptr
136 template<
typename Triangle>
144 template<
typename Mat4f,
typename Vec3f >
157 template<
typename Vec3f>
164 template<
typename u
int>
171 template<
typename Vec3f,
typename u
int>
This is an implementation of AdditiveCCD based on peridyno.
void getVertexBindJoint(tinygltf::Model &model, const tinygltf::Primitive &primitive, const std::string &attributeName, std::vector< Vec4f > &vec4Data, const std::vector< int > &skinJoints)
void loadGLTFMaterial(tinygltf::Model &model, std::shared_ptr< TextureMesh > texMesh, FilePath filename)
void buildInverseBindMatrices(const std::vector< joint > &all_Joints, std::map< joint, Mat4f > &joint_matrix, int &maxJointId, tinygltf::Model &model, std::map< joint, Quat< float > > &joint_rotation, std::map< joint, Vec3f > &joint_translation, std::map< joint, Vec3f > &joint_scale, std::map< joint, Mat4f > &joint_inverseBindMatrix, std::map< joint, std::vector< int > > jointId_joint_Dir)
void skinAnimation(DArray< Vec3f > &intialPosition, DArray< Vec3f > &worldPosition, DArray< Mat4f > &joint_inverseBindMatrix, DArray< Mat4f > &WorldMatrix, DArray< Vec4f > &bind_joints_0, DArray< Vec4f > &bind_joints_1, DArray< Vec4f > &weights_0, DArray< Vec4f > &weights_1, Mat4f transform, bool isNormal, Vec2u range)
Array< T, DeviceType::GPU > DArray
void loadGLTFShape(tinygltf::Model &model, std::shared_ptr< TextureMesh > texMesh, const std::string &filepath, DArray< Vec3f > *initialPosition=nullptr, DArray< Vec3f > *initialNormal=nullptr, DArray< Mat4f > *d_mesh_Matrix=nullptr, DArray< int > *d_shape_meshId=nullptr, std::shared_ptr< SkinInfo > skinData=nullptr)
void Shape_PointCounter(DArray< int > &counter, DArray< uint > &point_ShapeIds, uint &target)
void importAnimation(tinygltf::Model model, std::map< joint, Vec3i > &joint_output, std::map< joint, Vec3f > &joint_input, std::map< joint, std::vector< Vec3f > > &joint_T_f_anim, std::map< joint, std::vector< Real > > &joint_T_Time, std::map< joint, std::vector< Vec3f > > &joint_S_f_anim, std::map< joint, std::vector< Real > > &joint_S_Time, std::map< joint, std::vector< Quat< float > > > &joint_R_f_anim, std::map< joint, std::vector< Real > > &joint_R_Time)
void getRealByIndex(tinygltf::Model &model, int index, std::vector< Real > &result)
void loadGLTFTextureMesh(std::shared_ptr< TextureMesh > texMesh, const std::string &filepath)
void shapeTransform(DArray< Vec3f > &intialPosition, DArray< Vec3f > &worldPosition, DArray< Vec3f > &intialNormal, DArray< Vec3f > &Normal, DArray< Mat4f > &WorldMatrix, DArray< uint > &vertexId_shape, DArray< int > &shapeId_MeshId)
void getVec3fByAttributeName(tinygltf::Model &model, const tinygltf::Primitive &primitive, const std::string &attributeName, std::vector< Vec3f > &vertices)
Vector< uint32_t, 2 > Vec2u
void getTriangles(tinygltf::Model &model, const tinygltf::Primitive &primitive, std::vector< TopologyModule::Triangle > &triangles, int pointOffest)
void getMeshMatrix(tinygltf::Model &model, const std::vector< int > &all_MeshNodeIDs, int &maxMeshId, CArray< Mat4f > &mesh_Matrix)
std::vector< int > getJointDirByJointIndex(int Index, std::map< joint, std::vector< int > > jointId_joint_Dir)
Transform< float, 3 > Transform3f
void updateJoint_Mesh_Camera_Dir(tinygltf::Model &model, int &jointNum, int &meshNum, std::map< joint, std::vector< int > > &jointId_joint_Dir, std::vector< joint > &all_Joints, std::vector< int > &all_Nodes, std::map< joint, std::vector< int > > nodeId_Dir, std::map< int, std::vector< int > > &meshId_Dir, std::vector< int > &all_Meshs, int &maxJointId)
void getBoundingBoxByName(tinygltf::Model &model, const tinygltf::Primitive &primitive, const std::string &attributeName, TAlignedBox3D< Real > &bound, Transform3f &transform)
void shapeToCenter(DArray< Vec3f > &iniPos, DArray< Vec3f > &finalPos, DArray< uint > &shapeId, DArray< Vec3f > &t)
void getQuatByIndex(tinygltf::Model &model, int index, std::vector< Quat< float > > &result)
void getNodesAndHierarchy(tinygltf::Model &model, std::map< scene, std::vector< int > > Scene_JointsNodesId, std::vector< joint > &all_Nodes, std::map< joint, std::vector< int > > &id_Dir)
void getVec4ByAttributeName(tinygltf::Model &model, const tinygltf::Primitive &primitive, const std::string &attributeName, std::vector< Vec4f > &vec4Data)
Array< T, DeviceType::CPU > CArray
void getVec3fByIndex(tinygltf::Model &model, int index, std::vector< Vec3f > &result)
std::string getTexUri(const std::vector< tinygltf::Texture > &textures, const std::vector< tinygltf::Image > &images, int index)
void setupPoints(DArray< Vec3f > &newPos, DArray< Vec3f > &pos, DArray< int > &radix)
SquareMatrix< float, 4 > Mat4f
void getJointsTransformData(const std::vector< int > &all_Joints, std::vector< std::vector< int > > &joint_child, std::map< int, Quat< float > > &joint_rotation, std::map< int, Vec3f > &joint_scale, std::map< int, Vec3f > &joint_translation, std::map< int, Mat4f > &joint_matrix, tinygltf::Model model)
void updateVertexIdShape(DArray< Triangle > &triangle, DArray< uint > &ID_shapeId, int &shapeId, int size)
void traverseNode(tinygltf::Model &model, joint id, std::vector< joint > &joint_nodes, std::map< joint, std::vector< int > > &dir, std::vector< joint > currentDir)