Claude Chappe' Curse - A C Game
Logo Institut d'Informatique Claude Chappe Logo Université de Le Mans Logo Raeptor Production
 
Loading...
Searching...
No Matches
Model Handling

Group of functions and structures for handling 3D models. More...

Classes

struct  Material
 Structure representing a material with various properties. More...
 
struct  ModelObjectData
 Structure representing the data of a 3D model object. More...
 
struct  ModelKeyframe
 Structure representing the data of a 3D model keyframe. More...
 
struct  Bone
 Structure representing a bone in a 3D model. More...
 
struct  ModelAnimation
 Structure representing the data of a 3D model animation. More...
 
struct  ModelData
 Structure representing the data of a 3D model. More...
 

Typedefs

typedef float Vertex[VERTEX_ATTRIBUTE_COUNT]
 Array of VERTEX_ATTRIBUTE_COUNT floats representing a vertex.
 

Enumerations

enum  VertexAttribute {
  VERTEX_ATTRIBUTE_POSITION_X , VERTEX_ATTRIBUTE_POSITION_Y , VERTEX_ATTRIBUTE_POSITION_Z , VERTEX_ATTRIBUTE_NORMAL_X ,
  VERTEX_ATTRIBUTE_NORMAL_Y , VERTEX_ATTRIBUTE_NORMAL_Z , VERTEX_ATTRIBUTE_TEXTURE_U , VERTEX_ATTRIBUTE_TEXTURE_V ,
  VERTEX_ATTRIBUTE_TANGENT_X , VERTEX_ATTRIBUTE_TANGENT_Y , VERTEX_ATTRIBUTE_TANGENT_Z , VERTEX_ATTRIBUTE_BITANGENT_X ,
  VERTEX_ATTRIBUTE_BITANGENT_Y , VERTEX_ATTRIBUTE_BITANGENT_Z , VERTEX_ATTRIBUTE_BONE_ID_1 , VERTEX_ATTRIBUTE_BONE_ID_2 ,
  VERTEX_ATTRIBUTE_BONE_ID_3 , VERTEX_ATTRIBUTE_BONE_ID_4 , VERTEX_ATTRIBUTE_BONE_WEIGHT_1 , VERTEX_ATTRIBUTE_BONE_WEIGHT_2 ,
  VERTEX_ATTRIBUTE_BONE_WEIGHT_3 , VERTEX_ATTRIBUTE_BONE_WEIGHT_4 , VERTEX_ATTRIBUTE_COUNT
}
 Enumeration of vertex attributes used in 3D models. More...
 
enum  MaterialProperties {
  DIFFUSE_MATERIAL_PROPERTY , SPECULAR_MATERIAL_PROPERTY , AMBIENT_MATERIAL_PROPERTY , EMISSION_MATERIAL_PROPERTY ,
  PARALLAX_MATERIAL_PROPERTY , ROUGHNESS_MATERIAL_PROPERTY , SHEEN_MATERIAL_PROPERTY , METALLIC_MATERIAL_PROPERTY ,
  CLEARCOAT_THICKNESS_MATERIAL_PROPERTY , CLEARCOAT_ROUGHNESS_MATERIAL_PROPERTY , NORMAL_MATERIAL_PROPERTY , REFLECTION_MATERIAL_PROPERTY ,
  ANISOTROPY_MATERIAL_PROPERTY , ANISOTROPY_ROTATION_MATERIAL_PROPERTY , MATERIAL_PROPERTY_COUNT
}
 Enum representing different material properties. More...
 
enum  ModelFlags {
  MODEL_FLAG_NONE = 0 , MODEL_FLAG_GLOW = 1 << 0 , MODEL_FLAG_UNUSED1 = 1 << 1 , MODEL_FLAG_UNUSED2 = 1 << 2 ,
  MODEL_FLAG_UNUSED3 = 1 << 3 , MODEL_FLAG_UNUSED4 = 1 << 4 , MODEL_FLAG_UNUSED5 = 1 << 5 , MODEL_FLAG_UNUSED6 = 1 << 6 ,
  MODEL_FLAG_UNUSED7 = 1 << 7
}
 Enum representing flags for a model. More...
 

Functions

void create_textured_plane (TexturedMesh *texturedMesh, const char *texture)
 Creates a textured plane.
 
void create_screen_plane (Mesh *mesh)
 Creates a screen plane.
 
void render_model (mat4 modelMatrix, Shader activeShader, Model *model)
 Renders a 3D model using the specified shader and transformation matrix.
 

Detailed Description

Group of functions and structures for handling 3D models.

Typedef Documentation

◆ Vertex

Vertex

Array of VERTEX_ATTRIBUTE_COUNT floats representing a vertex.

Enumeration Type Documentation

◆ VertexAttribute

Enumeration of vertex attributes used in 3D models.

This enumeration defines various attributes that can be associated with a vertex in a 3D model. These attributes include positions, normals, texture coordinates, tangents, bitangents, and bone data.

Enumerator
VERTEX_ATTRIBUTE_POSITION_X 

X coordinate of the vertex position

VERTEX_ATTRIBUTE_POSITION_Y 

Y coordinate of the vertex position

VERTEX_ATTRIBUTE_POSITION_Z 

Z coordinate of the vertex position

VERTEX_ATTRIBUTE_NORMAL_X 

X component of the vertex normal

VERTEX_ATTRIBUTE_NORMAL_Y 

Y component of the vertex normal

VERTEX_ATTRIBUTE_NORMAL_Z 

Z component of the vertex normal

VERTEX_ATTRIBUTE_TEXTURE_U 

U coordinate of the vertex texture

VERTEX_ATTRIBUTE_TEXTURE_V 

V coordinate of the vertex texture

VERTEX_ATTRIBUTE_TANGENT_X 

X component of the vertex tangent

VERTEX_ATTRIBUTE_TANGENT_Y 

Y component of the vertex tangent

VERTEX_ATTRIBUTE_TANGENT_Z 

Z component of the vertex tangent

VERTEX_ATTRIBUTE_BITANGENT_X 

X component of the vertex bitangent

VERTEX_ATTRIBUTE_BITANGENT_Y 

Y component of the vertex bitangent

VERTEX_ATTRIBUTE_BITANGENT_Z 

Z component of the vertex bitangent

VERTEX_ATTRIBUTE_BONE_ID_1 

ID of the first bone influencing the vertex

VERTEX_ATTRIBUTE_BONE_ID_2 

ID of the second bone influencing the vertex

VERTEX_ATTRIBUTE_BONE_ID_3 

ID of the third bone influencing the vertex

VERTEX_ATTRIBUTE_BONE_ID_4 

ID of the fourth bone influencing the vertex

VERTEX_ATTRIBUTE_BONE_WEIGHT_1 

Weight of the first bone influencing the vertex

VERTEX_ATTRIBUTE_BONE_WEIGHT_2 

Weight of the second bone influencing the vertex

VERTEX_ATTRIBUTE_BONE_WEIGHT_3 

Weight of the third bone influencing the vertex

VERTEX_ATTRIBUTE_BONE_WEIGHT_4 

Weight of the fourth bone influencing the vertex

VERTEX_ATTRIBUTE_COUNT 

Total number of vertex attributes

◆ MaterialProperties

Enum representing different material properties.

This enum is used to identify various material properties such as diffuse, specular, ambient, emission, etc. Each property can be associated with a texture map or a flat color.

Enumerator
DIFFUSE_MATERIAL_PROPERTY 

Diffuse material property (Kd / map_Kd)

SPECULAR_MATERIAL_PROPERTY 

Specular material property (Ks / map_Ks)

AMBIENT_MATERIAL_PROPERTY 

Ambient material property (Ka)

EMISSION_MATERIAL_PROPERTY 

Emission material property (Ke / map_Ke)

PARALLAX_MATERIAL_PROPERTY 

Parallax material property (Px / map_Px)

ROUGHNESS_MATERIAL_PROPERTY 

Roughness material property (Pr / map_Pr)

SHEEN_MATERIAL_PROPERTY 

Sheen material property (Ps / map_Ps)

METALLIC_MATERIAL_PROPERTY 

Metallic material property (Pm / map_Pm)

CLEARCOAT_THICKNESS_MATERIAL_PROPERTY 

Clearcoat thickness material property (Pc)

CLEARCOAT_ROUGHNESS_MATERIAL_PROPERTY 

Clearcoat roughness material property (Pcr)

NORMAL_MATERIAL_PROPERTY 

Normal material property (bump / map_Bump)

REFLECTION_MATERIAL_PROPERTY 

Reflection material property (refl)

ANISOTROPY_MATERIAL_PROPERTY 

Anisotropy material property (aniso)

ANISOTROPY_ROTATION_MATERIAL_PROPERTY 

Anisotropy rotation material property (anisor)

MATERIAL_PROPERTY_COUNT 

Total count of material properties

◆ ModelFlags

enum ModelFlags

Enum representing flags for a model.

This enum is used to set various flags for a model, such as glow effect.

Enumerator
MODEL_FLAG_NONE 

No flags

MODEL_FLAG_GLOW 

Glow effect flag

MODEL_FLAG_UNUSED1 

Unused flag 1

MODEL_FLAG_UNUSED2 

Unused flag 2

MODEL_FLAG_UNUSED3 

Unused flag 3

MODEL_FLAG_UNUSED4 

Unused flag 4

MODEL_FLAG_UNUSED5 

Unused flag 5

MODEL_FLAG_UNUSED6 

Unused flag 6

MODEL_FLAG_UNUSED7 

Unused flag 7

Function Documentation

◆ create_textured_plane()

void create_textured_plane ( TexturedMesh texturedMesh,
const char *  texture 
)

Creates a textured plane.

This function initializes a textured plane with the given texture.

Parameters
texturedMeshPointer to the TexturedMesh structure to be initialized.
texturePath to the texture file.

Creates a textured plane mesh using the specified texture file.

Parameters
texturedMesh{TexturedMesh*} A pointer to a TexturedMesh structure that will hold the created mesh's VAO, texture, and length.
texture{char*} The file path of the texture image to be applied to the plane.

This function generates a textured plane by creating a Vertex Array Object (VAO) and binding it with a Vertex Buffer Object (VBO) containing the vertex data for a rectangular plane. The plane is positioned in the 3D space with a specified texture applied to it.

The plane is defined by a series of vertices that include position, normal, and texture coordinate data:

  • The vertices are defined to form two triangles (6 vertices total) making up the rectangular plane.

If the texture is successfully loaded, an OpenGL texture is generated, and its parameters are set, including wrapping and filtering modes. If the texture fails to load, an error message is printed.

The function initializes the following attributes in the TexturedMesh structure:

  • VAO: The generated Vertex Array Object for the mesh.
  • texture: The generated texture ID.
  • length: The number of triangles in the mesh (6 vertices = 2 triangles).

Example Usage: TexturedMesh myPlane; create_textured_plane(&myPlane, "path/to/texture.png"); // Use myPlane for rendering...

Return: This function does not return a value but modifies the TexturedMesh structure pointed to by texturedMesh.

◆ create_screen_plane()

void create_screen_plane ( Mesh mesh)

Creates a screen plane.

This function initializes a screen plane.

Parameters
meshPointer to the Mesh structure to be initialized.

Creates a fullscreen quad (screen plane) mesh for rendering.

Parameters
mesh{Mesh*} A pointer to a Mesh structure that will hold the created mesh's VAO and length.

This function generates a fullscreen quad mesh suitable for rendering images or effects that cover the entire screen. The quad is defined by six vertices forming two triangles.

The vertex data includes positions in normalized device coordinates (NDC) and corresponding texture coordinates, allowing for the mapping of textures across the full screen.

The function initializes the following attributes in the Mesh structure:

  • VAO: The generated Vertex Array Object for the mesh.
  • length: The number of vertices in the mesh (6 vertices total).

Example Usage: Mesh screenPlane; create_screen_plane(&screenPlane); // Use screenPlane for rendering...

Return: This function does not return a value but modifies the Mesh structure pointed to by mesh.

◆ render_model()

void render_model ( mat4  modelMatrix,
Shader  activeShader,
Model model 
)

Renders a 3D model using the specified shader and transformation matrix.

This function takes a transformation matrix, an active shader, and a model, and renders the model using the provided shader and transformation matrix.

Parameters
modelMatrixA 4x4 transformation matrix (mat4) that defines the model's position, rotation, and scale in the world space.
activeShaderThe shader program to be used for rendering the model.
modelA pointer to the Model structure that contains the model's data, such as vertices, indices, textures, etc.