Josh's Graphics Library
JGL::VertexArray Class Reference

#include <VertexArray.h>

Collaboration diagram for JGL::VertexArray:

Public Member Functions

VRamList GetVertices () const
 Don't use these for anything other than drawing because the GPU is gonna spin during read-back. More...
 
VRamList GetIndices () const
 
VRamList GetNormals () const
 
VRamList GetTextureCoordinates () const
 
std::vector< VertexGetLocalVertices () const
 These are for cpu side calculations. More...
 
std::vector< unsigned int > GetLocalIndices () const
 
std::vector< TextureCoordinateGetLocalTextureCoordinates () const
 
std::vector< NormalGetLocalNormals () const
 
Sphere GetMESphere (const Vector3 &scale=Vector3::One, const Vector3 &translate_part=Vector3::Zero) const
 Provides the minimally enclosing bounding sphere of the vertex array given information from the instance. More...
 
Sphere GetMESphere (const Matrix4x4 &instance_matrix, bool translate=false) const
 Provides the minimally enclosing bounding sphere of the vertex array given information from the instance. More...
 
OBB GetMEOBB (const Matrix3x3 &rotation_matrix, const Vector3 &scale=Vector3::One, const Vector3 &translate_part=Vector3::Zero) const
 Provides the minimally enclosing oriented bounding box of the vertex array given information from the instance. More...
 
OBB GetMEOBB (const Matrix4x4 &instance_matrix, bool translate=false) const
 Provides the minimally enclosing oriented bounding box of the vertex array given information from the instance. More...
 
AABB GetMEAABB (const Matrix3x3 &rotation_matrix, const Vector3 &scale=Vector3::One, const Vector3 &translate_part=Vector3::Zero) const
 Provides the minimally enclosing axis-aligned bounding box of the vertex array given information from the instance. More...
 
AABB GetMEAABB (const Matrix4x4 &instance_matrix, bool translate=false) const
 
 VertexArray (const Vector3 *vertex_positions, const long &vp_length, const unsigned int *vertex_indices=nullptr, const long &vi_length=0, const Normal *vertex_normals=nullptr, const long &vn_length=0, const TextureCoordinate *texture_coordinates=nullptr, const long &vt_length=0)
 Vertices are required, Everything else is optional. More...
 

Protected Member Functions

virtual void CreateMESphere ()
 
virtual void CreateMEOBB ()
 

Protected Attributes

VRamList vertices
 
VRamList indices
 
VRamList normals
 
VRamList texture_coordinates
 
std::vector< Vertexlocal_vertices
 Intended for low quality version in system memory for calculations to be done on the CPU. More...
 
std::vector< unsigned int > local_indices
 
std::vector< TextureCoordinatelocal_texture_coordinates
 
std::vector< Normallocal_normals
 

Constructor & Destructor Documentation

◆ VertexArray()

VertexArray::VertexArray ( const Vector3 *  vertex_positions,
const long &  vp_length,
const unsigned int *  vertex_indices = nullptr,
const long &  vi_length = 0,
const Normal vertex_normals = nullptr,
const long &  vn_length = 0,
const TextureCoordinate texture_coordinates = nullptr,
const long &  vt_length = 0 
)

Vertices are required, Everything else is optional.

Member Function Documentation

◆ CreateMEOBB()

void VertexArray::CreateMEOBB ( )
protectedvirtual

◆ CreateMESphere()

void VertexArray::CreateMESphere ( )
protectedvirtual

◆ GetIndices()

VRamList VertexArray::GetIndices ( ) const

◆ GetLocalIndices()

std::vector< unsigned int > VertexArray::GetLocalIndices ( ) const

◆ GetLocalNormals()

std::vector< Normal > VertexArray::GetLocalNormals ( ) const

◆ GetLocalTextureCoordinates()

std::vector< TextureCoordinate > VertexArray::GetLocalTextureCoordinates ( ) const

◆ GetLocalVertices()

std::vector< Vertex > VertexArray::GetLocalVertices ( ) const

These are for cpu side calculations.

◆ GetMEAABB() [1/2]

AABB VertexArray::GetMEAABB ( const Matrix3x3 &  rotation_matrix,
const Vector3 &  scale = Vector3::One,
const Vector3 &  translate_part = Vector3::Zero 
) const

Provides the minimally enclosing axis-aligned bounding box of the vertex array given information from the instance.

Parameters
rotation_matrixA Matrix3x3 representing rotation in 3D space.
scaleThe scale of the instance.
translate_partThe center of the box would be shifted in 3D space by this. Primarily for world space.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMEAABB() [2/2]

AABB VertexArray::GetMEAABB ( const Matrix4x4 &  instance_matrix,
bool  translate = false 
) const
Here is the call graph for this function:

◆ GetMEOBB() [1/2]

OBB VertexArray::GetMEOBB ( const Matrix3x3 &  rotation_matrix,
const Vector3 &  scale = Vector3::One,
const Vector3 &  translate_part = Vector3::Zero 
) const

Provides the minimally enclosing oriented bounding box of the vertex array given information from the instance.

Parameters
rotation_matrixA Matrix3x3 representing rotation in 3D space.
scaleThe scale of the instance.
translate_partThe center of the box would be shifted in 3D space by this. Primarily for world space.
Here is the caller graph for this function:

◆ GetMEOBB() [2/2]

OBB VertexArray::GetMEOBB ( const Matrix4x4 &  instance_matrix,
bool  translate = false 
) const

Provides the minimally enclosing oriented bounding box of the vertex array given information from the instance.

Parameters
instance_matrixA Matrix4x4 which contains scale, rotation, and translation.
translateWhether or not to translate to world space by the translate part of the Matrix.
Here is the call graph for this function:

◆ GetMESphere() [1/2]

Sphere VertexArray::GetMESphere ( const Matrix4x4 &  instance_matrix,
bool  translate = false 
) const

Provides the minimally enclosing bounding sphere of the vertex array given information from the instance.

Parameters
instance_matrixA Matrix4x4 which contains scale, rotation, and translation.
translateWhether or not to translate to world space by the translate part of the Matrix.
Here is the call graph for this function:

◆ GetMESphere() [2/2]

Sphere VertexArray::GetMESphere ( const Vector3 &  scale = Vector3::One,
const Vector3 &  translate_part = Vector3::Zero 
) const

Provides the minimally enclosing bounding sphere of the vertex array given information from the instance.

Parameters
scaleThe scale of the instance.
translate_partThe center of the sphere would be shifted in 3D space by this. Primarily for world space.
Here is the caller graph for this function:

◆ GetNormals()

JGL::VRamList VertexArray::GetNormals ( ) const

◆ GetTextureCoordinates()

VRamList VertexArray::GetTextureCoordinates ( ) const

◆ GetVertices()

VRamList VertexArray::GetVertices ( ) const

Don't use these for anything other than drawing because the GPU is gonna spin during read-back.

Member Data Documentation

◆ indices

VRamList JGL::VertexArray::indices
protected

◆ local_indices

std::vector<unsigned int> JGL::VertexArray::local_indices
protected

◆ local_normals

std::vector<Normal> JGL::VertexArray::local_normals
protected

◆ local_texture_coordinates

std::vector<TextureCoordinate> JGL::VertexArray::local_texture_coordinates
protected

◆ local_vertices

std::vector<Vertex> JGL::VertexArray::local_vertices
protected

Intended for low quality version in system memory for calculations to be done on the CPU.

In some scenarios like complex collision, You'd have to loop over every vertex. It makes more sense for performance and memory reasons to store a much lower quality version in system memory.

◆ normals

VRamList JGL::VertexArray::normals
protected

◆ texture_coordinates

VRamList JGL::VertexArray::texture_coordinates
protected

◆ vertices

VRamList JGL::VertexArray::vertices
protected

The documentation for this class was generated from the following files: