Skip to content

3D objects

Angel Uriot edited this page Sep 7, 2021 · 17 revisions

This section contains the class Object and two related classes : Material and Mesh.

Material

This class represents how the light behaves on the object in the Phong illumination, it contains the color of the object and 4 other variables : The first 3 (ambient, diffuse and specular) define the opacity of the 3 parts of the Phong illumination, and the last variable is the shininess that defines the size and the smoothness of the reflection. (more information on Wikipedia)

  • Constructors :

    • You can specify the color and each parameter of the Phong illumination.
    • You can also only give the color (in this case the object will not interact with light).
  • Functions :

    • This class only contains getters and setters of the Phong parameters.

Mesh

This class represents a 3D model with all the data necessary for the correct display of the shape : positions, normals and texture coordinates.

  • Attributes :

    • positions (Vector3 array) : The positions data of the mesh.
    • normals (Vector3 array) : The normals data of the mesh.
    • texcoords (Vector2 array) : The texture data of the mesh.
  • Static variables :

    • circle_64 (Mesh) : A circle with 64 edges.
    • empty_circle_64 (Mesh) : An empty circle with 64 edges.
    • cone_64 (Mesh) : A cone with 64 latitudes.
    • cube (Mesh) : A cube.
    • empty_cube (Mesh) : An empty cube.
    • cylinder_64 (Mesh) : A cylinder with 64 latitudes.
    • null (Mesh) : An empty mesh.
    • sphere_64 (Mesh) : A sphere with 64 latitudes and longitudes.
    • square (Mesh) : A square.
    • empty_square (Mesh) : An empty square.
    • screen (Mesh) : A shape that takes all the screen for post processing shaders.
  • Functions :

    • Functions giving the size of each part of the mesh (useful for OpenGL functions).
    • A clear function that empty the mesh.
    • Static functions working as constructors for the default shapes (spheres, cones, cylinders...).
  • Operators :

    • The + operator allows you to merge two meshes.
    • The * operator allows you to apply a matrix to a mesh.

Object

This class represents a 3D object, it can be binded for optimization but it is not essential.

  • Attributes :

    • mesh (Mesh) : The mesh of the object. (Be careful, if you change the mesh directly you must use the update_mesh function to apply the modifications)
    • material (Material) : The material of the object.
  • Constructors :

    • You can specify the mesh and the material of the object.
  • Functions :

    • You can use bind and unbind for optimization but it is not essential.
    • The create function is usefull to initialize an already constructed object.
    • You can change the shader (initially it is the default shader).
    • You can add a texture to the object.
    • The set_mesh function allows to change the mesh and update it directly.
    • You can get and set the position, the size, the rotation and the thickness of the borders of the object.

Clone this wiki locally