Go to the documentation of this file.
19 template<
class Archive>
void serialize(Archive& archive,
small3d::Vec3& v) { archive(v.x, v.y, v.z); }
20 template<
class Archive>
void serialize(Archive& archive,
small3d::Vec4& v) { archive(v.x, v.y, v.z, v.w); }
21 template<
class Archive>
void serialize(Archive& archive,
small3d::Mat4& m) { archive(m[0], m[1], m[2], m[3]); }
38 uint32_t positionBufferObjectId = 0;
39 uint32_t indexBufferObjectId = 0;
40 uint32_t normalsBufferObjectId = 0;
41 uint32_t uvBufferObjectId = 0;
42 uint32_t jointBufferObjectId = 0;
43 uint32_t weightBufferObjectId = 0;
45 uint32_t currentAnimation = 0;
46 std::vector<uint64_t> numPoses;
50 Mat4 origTransformation =
Mat4(1.0f);
54 Quat origRotation = { 0.0f, 0.0f, 0.0f, 1.0f };
57 Vec3 origTranslation =
Vec3(0.0f, 0.0f, 0.0f);
60 Vec3 origScale =
Vec3(1.0f, 1.0f, 1.0f);
75 std::vector<Quat> rotationAnimation;
76 std::vector<Vec3> translationAnimation;
77 std::vector<Vec3> scaleAnimation;
78 std::vector<float> times;
79 template <
class Archive>
80 void serialize(Archive& archive) {
81 archive(input, rotationAnimation, translationAnimation, scaleAnimation, times);
90 std::vector<AnimationComponent> animationComponents;
91 template <
class Archive>
92 void serialize(Archive& archive) {
93 archive(name, animationComponents);
103 Mat4 inverseBindMatrix =
Mat4(1.0f);
104 Quat rotation = { 1.0f, 0.0f, 0.0f, 0.0f };
105 Vec3 scale =
Vec3(1.0f, 1.0f, 1.0f);
106 Vec3 translation =
Vec3(0.0f, 0.0f, 0.0f);
108 std::vector<uint32_t> children;
109 std::vector<Animation> animations;
111 template <
class Archive>
112 void serialize(Archive& archive) {
113 archive(node, name, inverseBindMatrix, rotation, scale, translation,
114 transformation, children, animations);
235 Model(
File& file,
const std::string& meshName =
"");
245 Model(
File&& file,
const std::string& meshName =
"");
275 Mat4 getTransform(uint32_t animationIdx, uint64_t currentPose,
float seconds = 0.0f);
287 Mat4 getJointTransform(
size_t jointIdx, uint32_t animationIdx, uint64_t currentPose,
float seconds = 0.0f);
299 void saveBinary(
const std::string& binaryFilePath);
301 template <
class Archive>
302 void serialize(Archive& archive) {
303 archive(currentAnimation,
std::vector< float > normalsData
Array, to be treated as a 3 column table. Each "row" contains the x, y and z components of the vector...
Definition: Model.hpp:165
4 component vector
Definition: Math.hpp:56
Material material
The material of the model.
Definition: Model.hpp:68
.glb (glTF) file parser class. It can load meshes, textures and linear animations from samplers with ...
Definition: GlbFile.hpp:30
std::vector< uint8_t > jointData
Array, to be treated as a 4 column table. Each "row" potentially contains up to 4 joints that can inf...
Definition: Model.hpp:189
Vectors, matrices and other math things.
std::vector< uint16_t > indexData
3 column table. Each element refers to a "row" in the vertex data table. Each "row" in the index data...
Definition: Model.hpp:152
void setAnimation(uint32_t animationIdx)
Set the current animation.
Definition: Model.cpp:50
Model()
Default constructor.
Definition: Model.cpp:25
std::vector< Animation > animations
Animations of the model (there are also joint animations)
Definition: Model.hpp:215
Vec3 scale
Use this to scale the model and not origScale.
Definition: Model.hpp:121
static const uint32_t MAX_JOINTS_SUPPORTED
Maximum number of supported joints.
Definition: Model.hpp:127
animation
Definition: Model.hpp:88
A 3D model. It can be loaded from a WavefrontFile or GlbFile. It can also be constructed procedurally...
Definition: Model.hpp:34
uint64_t getNumPoses()
Get the number of animation poses in the current animation.
Definition: Model.cpp:42
std::vector< float > weightData
Array, to be treated as a 4 column table. Each "row" contains the weights by which each of the corres...
Definition: Model.hpp:200
joint
Definition: Model.hpp:100
uint32_t textureCoordsDataByteSize
Size of the texture coordinates data, in bytes.
Definition: Model.hpp:183
Image loading and manipulation.
animation component
Definition: Model.hpp:73
uint32_t vertexDataByteSize
Size of the vertex data, in bytes.
Definition: Model.hpp:145
Renderer class (OpenGL 3.3 / OpenGL ES 3.0)
Definition: Renderer.hpp:38
Mat4 getTransform(uint32_t animationIdx, uint64_t currentPose, float seconds=0.0f)
Get a transform of the model.
Definition: Model.cpp:58
std::shared_ptr< Image > defaultTextureImage
Image found in the file the model was loaded from (empty image if not - check the size)....
Definition: Model.hpp:133
std::vector< float > vertexData
The vertex data. This is an array, which is to be treated as a 4 column table, holding the x,...
Definition: Model.hpp:140
File parser virtual class.
uint32_t jointDataByteSize
Size of the joint data, in bytes.
Definition: Model.hpp:194
Definition: BinaryFile.hpp:15
uint32_t indexDataByteSize
Size of the index data, in bytes.
Definition: Model.hpp:157
void saveBinary(const std::string &binaryFilePath)
Save model data in binary format.
Definition: Model.cpp:266
Abstract file parser class.
Definition: File.hpp:23
bool noShadow
Should the model produce a shadow?
Definition: Model.hpp:220
size_t getNumAnimations()
Get the number of available animations.
Definition: Model.cpp:46
std::vector< Joint > joints
The model's joints.
Definition: Model.hpp:210
3 component float vector
Definition: Math.hpp:19
std::vector< float > textureCoordsData
Array, to be treated as a 2 column table. Each "row" contains the x and y components of the pixel coo...
Definition: Model.hpp:178
uint32_t normalsDataByteSize
Size of the normals data, in bytes.
Definition: Model.hpp:170
Vec3 getOriginalScale()
Get the Model's original scale (usually the one read from the file the Model was loaded from.
Definition: Model.cpp:262
4x4 float matrix
Definition: Math.hpp:99
A 3D model material.
Definition: Material.hpp:23
uint32_t weightDataByteSize
Size of the weight data, in bytes.
Definition: Model.hpp:205
Mat4 getJointTransform(size_t jointIdx, uint32_t animationIdx, uint64_t currentPose, float seconds=0.0f)
Get a joint transform, also calculating the transorms of the parent joints in the same tree and the a...
Definition: Model.cpp:147