#include <Object.hpp>
Public Member Functions | |
| void | load (std::string str) |
| void | load (std::istream &stream) |
| sf::VertexArray | render (std::vector< std::unique_ptr< Light >> &lights, const std::shared_ptr< Camera > &camera, int winHeight) |
| void | loadTexture (sf::Texture texture) |
| sf::Texture | getTexture () |
| bool | isTextured () |
| void | translate (float x, float y, float z) override |
| void | scale (float m) override |
| void | rotate (float x, float y, float z) override |
| void | transform (const Transformation &t) override |
Private Member Functions | |
| void | sortFaces (const Eigen::Matrix3Xf &projected) |
| Sort the mesh faces by distance from the camera so they render in the correct order. | |
| void | calcNormals () |
| Calculate vertex normals based on the mesh faces. | |
Private Attributes | |
| sf::Texture | texture |
| The texture to render with, if any. | |
| bool | textured |
| Has the object been textured. | |
| Eigen::Matrix3Xf | verts |
| The vertices of the object as points in 3D space. | |
| std::vector< sf::Vector2f > | uvMap |
| A list of normalised UV points to map the texture to the mesh. | |
| std::vector< sf::Vector2f > | uvTexMap |
| A list of scaled points to map this object's texture to the mesh. | |
| std::vector< Eigen::Vector3i > | faces |
| A list of faces made up of three vertices to use. | |
| Eigen::Matrix3Xf | normals |
| The object's vertex normals. | |
| std::vector< Eigen::Vector3i > | texCoords |
| A list of which UVs to use for each face. | |
This class holds data about a 3D mesh. Provides utilities to load a mesh from an obj file.
|
inline |
|
inline |
| void Geno3D::Object::load | ( | std::string | str | ) |
Load the mesh from a string in the format of an obj file.
| str | the string to parse |
| void Geno3D::Object::load | ( | std::istream & | stream | ) |
Load the mesh from a stream in the format of an obj file.
| stream | the stream to load |
References calcNormals(), faces, texCoords, uvMap, and verts.
| void Geno3D::Object::loadTexture | ( | sf::Texture | texture | ) |
Load a texture into the object. This marks the object as being textured so isTextured will return true if this function has been called.
| texture | the texture to load |
| sf::VertexArray Geno3D::Object::render | ( | std::vector< std::unique_ptr< Light >> & | lights, |
| const std::shared_ptr< Camera > & | camera, | ||
| int | winHeight | ||
| ) |
Render the object as an SFML shape. Uses lighting and camera information to generate an sf::VertexArray object which can be rendered to a window.
| lights | a list of the lights in a scene |
| camera | the camera to use for the render |
| winHeight | the height of the window. Used to flip the image y-axis so the render is not inverted. |
References faces, normals, sortFaces(), texCoords, textured, uvTexMap, and verts.
|
overridevirtual |
Rotate by Euler angles, in radians.
| x | the angle to rotate by about the x-axis |
| y | the angle to rotate by about the y-axis |
| z | the angle to rotate by about the z-axis |
Implements Geno3D::Transformable.
|
overridevirtual |
Scale by a factor.
| m | the factor to scale by |
Implements Geno3D::Transformable.
References verts.
|
overridevirtual |
Transform by a compound transformation.
| t | the transformation to apply |
Implements Geno3D::Transformable.
References Geno3D::Transformation::apply(), Geno3D::Transformation::determinant(), normals, and verts.
|
overridevirtual |
Translate by a 3D vector.
| x | the amount to translate in the x-axis |
| y | the amount to translate in the y-axis |
| z | the amount to translate in the z-axis |
Implements Geno3D::Transformable.
References verts.
1.8.6