463 std::vector<kVec3> vertices;
464 std::vector<uint32_t> indices;
465 std::vector<kVec2> uvs;
466 std::vector<kVec3> vertexColors;
467 std::vector<kVec3> normals;
468 std::vector<kVec3> tangents;
469 std::vector<kVec3> bitangents;
470 std::vector<kIvec4> boneIDs;
471 std::vector<kVec4> weights;
474 uint32_t indicesEbo = 0;
476 uint32_t vertexBuffer = 0;
477 uint32_t vertexColorBuffer = 0;
478 uint32_t uvBuffer = 0;
479 uint32_t normalBuffer = 0;
480 uint32_t tangentBuffer = 0;
481 uint32_t bitangentBuffer = 0;
482 uint32_t boneIDBuffer = 0;
483 uint32_t weightBuffer = 0;
489 bool isVisible =
true;
490 bool isCastShadow =
true;
491 bool isReceiveShadow =
true;
493 std::map<kString, kBoneInfo> boneInfoMap;
497 bool isSkinned =
false;
Controls playback of animation clips.
Definition kanimator.h:36
void addNormal(kVec3 normal)
Appends a vertex normal.
int getVertexCount()
Returns the number of vertices in this mesh.
kIvec4 getBoneID(size_t vertexIndex)
Returns the bone-ID tuple for a vertex.
void setVertexBoneData(size_t vertexID, int boneID, float weight)
Assigns a single bone influence to a vertex (used during loading).
kVec4 getWeight(size_t vertexIndex)
Returns the bone-weight tuple for a vertex.
void generateVbo()
Uploads all vertex attribute data to the GPU.
kString getRefName()
Returns the reference name.
int & getBoneCount()
Returns a reference to the bone counter used during loading.
std::vector< kVec4 > getWeights()
Returns a copy of the bone-weight buffer.
~kMesh()
Destroys the mesh and releases its GPU buffers.
bool getReceiveShadow()
Returns whether the mesh receives shadows.
void addBitangent(kVec3 bitangent)
Appends a vertex bitangent.
void setWeight(size_t vertexIndex, const kVec4 &weight)
Overwrites the bone-weight tuple for a specific vertex.
void setBoneInfoMap(std::map< kString, kBoneInfo > newBoneInfoMap)
Replaces the bone-name-to-info map.
void setRefName(kString newRefName)
Sets the reference name used to identify shared mesh data.
kMat4 getNormalMatrix()
Returns the stored normal matrix.
kAnimator * getAnimator()
Returns the attached animator.
void computeLocalAABB()
Computes the local-space AABB from the vertex position buffer.
void setPrimitiveType(kString type)
Marks this mesh as one of the built-in procedural primitives ("cube", "sphere", "cylinder",...
void setFileName(kString newFileName)
Sets the source asset file path.
void setReceiveShadow(bool newReceiveShadow)
Controls whether the mesh receives shadows.
kAABB getWorldAABB()
Returns the AABB transformed into world space.
json serialize()
Serialises the mesh to JSON.
void addBoneID(const kIvec4 &boneID)
Appends a bone-ID tuple for the next vertex.
void setWeights(std::vector< kVec4 > newWeights)
Replaces the entire bone-weight buffer.
void setBoneCount(int newBoneCount)
Sets the total number of bones.
void reserveSpace(size_t vertexCount)
Pre-allocates all per-vertex attribute vectors.
bool getCastShadow()
Returns whether the mesh casts shadows.
void generateTangents()
Computes per-vertex tangents and bitangents from positions, UVs, and indices. Must be called after al...
std::vector< kVec2 > getUVs()
Returns a copy of the UV coordinate buffer.
void setNormalMatrix(kMat4 newNormalMatrix)
Stores a precomputed normal matrix.
bool getLoaded()
Returns whether the mesh geometry is fully loaded.
uint32_t getVertexColorBuffer()
Returns the GPU handle for the vertex-colour VBO.
std::vector< kIvec4 > getBoneIDs()
Returns a copy of the bone-ID buffer.
void setCastShadow(bool newCastShadow)
Controls whether the mesh casts shadows.
std::vector< kVec3 > getVertexColors()
Returns a copy of the per-vertex colour buffer.
std::vector< kVec3 > getBitangents()
Returns a copy of the bitangent buffer.
void setBoneIDs(std::vector< kIvec4 > newBoneIDs)
Replaces the entire bone-ID buffer.
void setSkinned(bool newSkinned)
Sets whether this mesh is driven by skeletal animation.
void calculateNormalMatrix()
Recomputes the normal matrix from the current world transform.
void addUV(kVec2 uv)
Appends a UV coordinate.
std::vector< uint32_t > getIndices()
Returns a copy of the index buffer.
void setScale(kVec3 newScale)
Propagates a local scale change to this mesh and its children.
void setRotation(kQuat newRotation)
Propagates a local rotation change to this mesh and its children.
void setPosition(kVec3 newPosition)
Propagates a local position change to this mesh and its children.
void setAnimator(kAnimator *newAnimator)
Attaches a skeletal animator to this mesh.
void addWeight(const kVec4 &weight)
Appends a bone-weight tuple for the next vertex.
void addVertex(kVec3 vertex)
Appends a vertex position.
kAABB getLocalAABB() const
Returns the axis-aligned bounding box in local (object) space.
void draw()
Issues a draw call for this mesh via the current kDriver.
std::vector< kVec3 > getNormals()
Returns a copy of the normal buffer.
bool getVisible()
Returns whether the mesh is visible.
void setVisible(bool newVisible)
Controls the mesh's render visibility.
void setBoneID(size_t vertexIndex, const kIvec4 &boneID)
Overwrites the bone-ID tuple for a specific vertex.
void reserveBoneData(size_t vertexCount)
Pre-allocates bone ID and weight arrays for a given vertex count.
std::vector< kVec3 > getVertices()
Returns a copy of the vertex position buffer.
kMesh(kObject *parentNode=nullptr)
Constructs a mesh node and optionally attaches it to a parent.
std::vector< kVec3 > getTangents()
Returns a copy of the tangent buffer.
void addTangent(kVec3 tangent)
Appends a vertex tangent.
uint32_t getVertexBuffer()
Returns the GPU handle for the position VBO.
void setLoaded(bool newLoaded)
Marks whether the mesh geometry has been fully loaded.
void addIndex(uint32_t index)
Appends an index to the index buffer.
kString getFileName()
Returns the source asset file path.
void addVertexColor(kVec3 color)
Appends a per-vertex colour.
void deserialize(json data)
Restores the mesh from a JSON object.
std::map< kString, kBoneInfo > & getBoneInfoMap()
Returns a reference to the bone-name-to-info map.
bool getSkinned()
Returns whether skeletal skinning is enabled.
uint32_t getVertexArrayObject()
Returns the GPU handle for the Vertex Array Object.
kString getPrimitiveType() const
Returns the procedural-primitive marker, if any.
kObject(kObject *parentNode=nullptr)
Constructs a kObject and optionally attaches it to a parent.
Drives playback of skeletal (bone) animation, and reserves a hook for future non-skeletal (object-tra...
Single skeletal bone with position, rotation, and scale keyframe channels.
Abstract graphics driver interface used by the engine.
Symbol visibility / linkage macro for the Kemena3D library.
#define KEMENA3D_API
Definition kexport.h:35
Base class for all scene-graph nodes in the Kemena3D engine.
nlohmann::json json
Definition kobject.h:30
Top-level Kemena3D engine namespace.
Definition kanimation.h:23
std::string kString
Standard string alias.
Definition kdatatype.h:42
glm::mat3 kMat3
3x3 float matrix.
Definition kdatatype.h:38
glm::quat kQuat
Unit quaternion.
Definition kdatatype.h:40
glm::vec2 kVec2
2-component float vector.
Definition kdatatype.h:32
glm::vec4 kVec4
4-component float vector.
Definition kdatatype.h:34
glm::vec3 kVec3
3-component float vector.
Definition kdatatype.h:33
glm::ivec4 kIvec4
4-component integer vector.
Definition kdatatype.h:37
glm::mat4 kMat4
4x4 float matrix.
Definition kdatatype.h:39
Axis-aligned bounding box (min/max in the same space).
Definition kdatatype.h:572