Brunot
Loading...
Searching...
No Matches
Mesh Class Reference

#include <Mesh.h>

Public Member Functions

 Mesh (unsigned tilesWide=1, unsigned tilesHigh=1)
 constructs a mesh.
 ~Mesh ()
 Mesh (const Mesh &other)=default
 Mesh (Mesh &&other) noexcept=default
auto operator= (const Mesh &other) -> Mesh &=default
auto operator= (Mesh &&other) noexcept -> Mesh &=default
auto activate () const -> void
auto deactivate () const -> void
auto draw (const Shader &shader, const Texture &texture) const -> void
auto draw (const Shader &shader) const -> void
auto load (Stream &stream) -> void
auto save (Stream &stream) const -> void
auto name () const -> const std::string &
auto setName (const std::string &name) -> void
auto setFrame (unsigned newFrameNum) -> void
 Set the frame of the mesh, automatically calculates correct uv offset. Frames go right to left, then top to bottom.
auto getFrame () const -> unsigned
 get the frame of the mesh. frames go right to left, then top top bottom
auto incrementFrame () -> void
auto decrementFrame () -> void
auto getMaxFrames () const -> unsigned
 get the max number of frames of the mesh, based on the tiles wide and high of the mesh
auto showMenu () -> void
auto setObjectTransform (const AffineMatrix &transform) const -> void
 Sets the uniform for the object.
auto setObjectProjection (const AffineMatrix &projection) const -> void
auto setObjectCamera (const AffineMatrix &camera) const -> void
auto setObjectColor (const Vector4D &color) const -> void

Private Member Functions

auto uploadMeshToGPU () -> void
 Upload mesh data to gpu, when creating mesh, or loading from a file.

Private Attributes

std::string _name
 the name of the mesh, used for serialization
std::shared_ptr< VAOvao
 vertex attribute object, the "mesh" in opengl
std::shared_ptr< IndexBuffertriangleBuffer
std::shared_ptr< VertexBuffervertexBuffer
unsigned spriteTilesCountU = 1
 number of sprite tiles wide the image would be for this mesh
unsigned spriteTilesCountV = 1
 number of sprite tiles high the image would be for this mesh
std::vector< gfx::Vertexvertices
 local copy of the Vertexes uploaded to the gpu
unsigned frame = 0
 frame of animation for calculating uv offsets, clamped to be valid for the sprite sheet size
unsigned maxFrames
 max number of frames that makes sense for the mesh, assuming a tilesheet of spriteTilesCountV by spriteTilesCountU

Friends

auto to_json (json &j, const Mesh &a) ->void
auto from_json (const json &j, Mesh &a) ->void

Constructor & Destructor Documentation

◆ Mesh() [1/3]

Mesh::Mesh ( unsigned tilesWide = 1,
unsigned tilesHigh = 1 )

constructs a mesh.

the mesh is of size 1 / tilesWide x 1 / tilesHigh

Parameters
tilesWidehow many tiles wide the spritesheet is that this mesh works with
tilesHighhow many tiles wide the spritesheet is that this mesh works with
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Mesh()

Mesh::~Mesh ( )
default

◆ Mesh() [2/3]

Mesh::Mesh ( const Mesh & other)
default
Here is the call graph for this function:

◆ Mesh() [3/3]

Mesh::Mesh ( Mesh && other)
defaultnoexcept
Here is the call graph for this function:

Member Function Documentation

◆ activate()

auto Mesh::activate ( ) const->void

◆ deactivate()

auto Mesh::deactivate ( ) const->void
Here is the caller graph for this function:

◆ decrementFrame()

auto Mesh::decrementFrame ( ) ->void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw() [1/2]

auto Mesh::draw ( const Shader & shader) const->void
Here is the call graph for this function:

◆ draw() [2/2]

auto Mesh::draw ( const Shader & shader,
const Texture & texture ) const->void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFrame()

auto Mesh::getFrame ( ) const->unsigned

get the frame of the mesh. frames go right to left, then top top bottom

Here is the caller graph for this function:

◆ getMaxFrames()

auto Mesh::getMaxFrames ( ) const->unsigned

get the max number of frames of the mesh, based on the tiles wide and high of the mesh

Here is the caller graph for this function:

◆ incrementFrame()

auto Mesh::incrementFrame ( ) ->void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load()

auto Mesh::load ( Stream & stream) ->void
Here is the caller graph for this function:

◆ name()

auto Mesh::name ( ) const->conststd::string &
nodiscard
Here is the caller graph for this function:

◆ operator=() [1/2]

auto Mesh::operator= ( const Mesh & other) ->Mesh &=default
default
Here is the call graph for this function:

◆ operator=() [2/2]

auto Mesh::operator= ( Mesh && other) ->Mesh &=default
defaultnoexcept
Here is the call graph for this function:

◆ save()

auto Mesh::save ( Stream & stream) const->void
Here is the caller graph for this function:

◆ setFrame()

auto Mesh::setFrame ( unsigned newFrameNum) ->void

Set the frame of the mesh, automatically calculates correct uv offset. Frames go right to left, then top to bottom.

Here is the caller graph for this function:

◆ setName()

auto Mesh::setName ( const std::string & name) ->void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setObjectCamera()

auto Mesh::setObjectCamera ( const AffineMatrix & camera) const->void
Here is the caller graph for this function:

◆ setObjectColor()

auto Mesh::setObjectColor ( const Vector4D & color) const->void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setObjectProjection()

auto Mesh::setObjectProjection ( const AffineMatrix & projection) const->void
Here is the caller graph for this function:

◆ setObjectTransform()

auto Mesh::setObjectTransform ( const AffineMatrix & transform) const->void

Sets the uniform for the object.

The shader that the object is to be rendered with must be active.

Parameters
transformthe transform to set
Here is the call graph for this function:
Here is the caller graph for this function:

◆ showMenu()

auto Mesh::showMenu ( ) ->void
Here is the caller graph for this function:

◆ uploadMeshToGPU()

auto Mesh::uploadMeshToGPU ( ) ->void
private

Upload mesh data to gpu, when creating mesh, or loading from a file.

Here is the caller graph for this function:

◆ from_json

auto from_json ( const json & j,
Mesh & a )->void
friend

◆ to_json

auto to_json ( json & j,
const Mesh & a )->void
friend

Member Data Documentation

◆ _name

std::string Mesh::_name
private

the name of the mesh, used for serialization

◆ frame

unsigned Mesh::frame = 0
private

frame of animation for calculating uv offsets, clamped to be valid for the sprite sheet size

◆ maxFrames

unsigned Mesh::maxFrames
private

max number of frames that makes sense for the mesh, assuming a tilesheet of spriteTilesCountV by spriteTilesCountU

◆ spriteTilesCountU

unsigned Mesh::spriteTilesCountU = 1
private

number of sprite tiles wide the image would be for this mesh

◆ spriteTilesCountV

unsigned Mesh::spriteTilesCountV = 1
private

number of sprite tiles high the image would be for this mesh

◆ triangleBuffer

std::shared_ptr<IndexBuffer> Mesh::triangleBuffer
private

◆ vao

std::shared_ptr<VAO> Mesh::vao
private

vertex attribute object, the "mesh" in opengl

◆ vertexBuffer

std::shared_ptr<VertexBuffer> Mesh::vertexBuffer
private

◆ vertices

std::vector<gfx::Vertex> Mesh::vertices
private

local copy of the Vertexes uploaded to the gpu


The documentation for this class was generated from the following files:
  • /home/egrazil/sites/Brunot/The House/source/Graphics/Mesh.h
  • /home/egrazil/sites/Brunot/The House/source/Graphics/Mesh.cpp