![]() |
Jopnal Engine
alpha 0.4
Simple Component Based 2D/3D Game Engine
|
#include <Mesh.hpp>
Classes | |
struct | VertexIndex |
Public Types | |
enum | VertexComponent : uint32 { Position = 1, TexCoords = 1 << 1, Normal = 1 << 2, Tangent = 1 << 3, BiTangent = 1 << 4, Color = 1 << 5 } |
Public Member Functions | |
Mesh (const std::string &name) | |
Constructor. More... | |
Mesh (const Mesh &other, const std::string &newName) | |
Copy constructor. More... | |
bool | load (const void *vertexData, const uint32 vertexBytes, const uint32 vertexComponents, const void *indexData=nullptr, const uint16 indexSize=0, const uint32 indexAmount=0) |
Load mesh from memory. More... | |
bool | load (const std::vector< Vertex > &vertexArray, const std::vector< unsigned int > &indexArray) |
Load mesh from memory using default vertex format. More... | |
void | draw () const |
Draw this mesh. More... | |
void | destroy () |
Destroy this mesh. More... | |
const std::pair< glm::vec3, glm::vec3 > & | getBounds () const |
Get the bounds of this mesh. More... | |
unsigned int | getVertexAmount () const |
Get the vertex amount. More... | |
uint16 | getVertexSize () const |
Get the total vertex size. More... | |
void * | getVertexOffset (const VertexComponent component) const |
Get the byte offset for the given component. More... | |
bool | hasVertexComponent (const uint32 component) const |
Check if this mesh has a vertex component. More... | |
unsigned int | getElementAmount () const |
Get the element (index) amount. More... | |
uint16 | getElementSize () const |
Get the element size. More... | |
unsigned int | getElementEnum () const |
Get the element type OpenGL enum. More... | |
const VertexBuffer & | getIndexBuffer () const |
Returns index buffer. More... | |
const VertexBuffer & | getVertexBuffer () const |
Returns vertex buffer. More... | |
void | updateBounds (const glm::vec3 &min, const glm::vec3 &max) |
Manually update the bounds of this mesh. More... | |
![]() | |
Resource (const std::string &name) | |
Constructor. More... | |
virtual | ~Resource ()=0 |
Virtual destructor. More... | |
const std::string & | getName () const |
Get the name of this resource. More... | |
void | setPersistence (const unsigned short level) |
Set the persistence level. More... | |
unsigned short | getPersistence () const |
Get the persistence level. More... | |
![]() | |
WeakReference< Resource > | getReference () const |
Get a weak reference to the bound object. More... | |
![]() | |
SerializeInfo () | |
void | setSerializePackage (const uint16 package) |
uint16 | getSerializePackage () const |
void | setShouldSerialize (const bool set) |
bool | shouldSerialize () const |
void | setLightSerializeable (const bool set) |
bool | isLightSerializeable () const |
Static Public Member Functions | |
static uint16 | getVertexSize (const uint32 components) |
Get the size of a vertex with the given format. More... | |
static Mesh & | getDefault () |
Get the default mesh. More... | |
Additional Inherited Members | |
![]() | |
Resource (const Resource &other, const std::string &newName) | |
Copy constructor. More... | |
![]() | |
SafeReferenceable (Resource *ref) | |
Constructor. More... | |
SafeReferenceable (SafeReferenceable< Resource > &&other) | |
Move constructor. More... | |
SafeReferenceable & | operator= (SafeReferenceable< Resource > &&other) |
Move assignment operator. More... | |
~SafeReferenceable () | |
Protected destructor. More... | |
enum jop::Mesh::VertexComponent : uint32 |
jop::Mesh::Mesh | ( | const std::string & | name | ) |
Constructor.
Does not initialize any vertices.
name | Name of the resource |
jop::Mesh::Mesh | ( | const Mesh & | other, |
const std::string & | newName | ||
) |
Copy constructor.
other | The other mesh to be copied |
newName | Name of the new mesh |
void jop::Mesh::destroy | ( | ) |
Destroy this mesh.
After this call, this mesh won't be valid and cannot be used in drawing. The vertex & index data is removed from the GPU memory.
void jop::Mesh::draw | ( | ) | const |
Draw this mesh.
Using this function requires that the shader state has been properly configured. This function will set up the vertex attributes pointers, buffer bindings and call glDrawElements or glDrawArrays depending on whether there are indices or not.
const std::pair<glm::vec3, glm::vec3>& jop::Mesh::getBounds | ( | ) | const |
Get the bounds of this mesh.
|
static |
Get the default mesh.
The default mesh is a box with a size of 1.
unsigned int jop::Mesh::getElementAmount | ( | ) | const |
Get the element (index) amount.
unsigned int jop::Mesh::getElementEnum | ( | ) | const |
Get the element type OpenGL enum.
The returned enum can be used with glDrawElements.
uint16 jop::Mesh::getElementSize | ( | ) | const |
const VertexBuffer& jop::Mesh::getIndexBuffer | ( | ) | const |
Returns index buffer.
unsigned int jop::Mesh::getVertexAmount | ( | ) | const |
Get the vertex amount.
const VertexBuffer& jop::Mesh::getVertexBuffer | ( | ) | const |
Returns vertex buffer.
void* jop::Mesh::getVertexOffset | ( | const VertexComponent | component | ) | const |
Get the byte offset for the given component.
component | The vertex component |
Get the size of a vertex with the given format.
components | Vertex components |
bool jop::Mesh::hasVertexComponent | ( | const uint32 | component | ) | const |
Check if this mesh has a vertex component.
component | The component to check |
bool jop::Mesh::load | ( | const void * | vertexData, |
const uint32 | vertexBytes, | ||
const uint32 | vertexComponents, | ||
const void * | indexData = nullptr , |
||
const uint16 | indexSize = 0 , |
||
const uint32 | indexAmount = 0 |
||
) |
Load mesh from memory.
This function takes the vertex data in binary format. The order of vertex components: Position, texture coordinated, normal, tangent, bi-tangent, color
vertexData | Pointer to the vertex data |
vertexBytes | Size of the vertex data buffer in bytes |
vertexComponents | The vertex components |
indexData | Pointer to the index data |
indexSize | Size of a single index in bytes |
indexAmount | Amount of indices |
bool jop::Mesh::load | ( | const std::vector< Vertex > & | vertexArray, |
const std::vector< unsigned int > & | indexArray | ||
) |
Load mesh from memory using default vertex format.
vertexArray | Container holding the vertex data |
indexArray | Container holding index data |
void jop::Mesh::updateBounds | ( | const glm::vec3 & | min, |
const glm::vec3 & | max | ||
) |
Manually update the bounds of this mesh.
min | The minimum coordinated |
max | The maximum coordinates |