Voltray Engine Docs
Loading...
Searching...
No Matches
Mesh.h
Go to the documentation of this file.
1#pragma once
2
3#include "VertexArray.h"
4#include "VertexBuffer.h"
5#include "IndexBuffer.h"
6#include "../Math/Vec3.h"
7#include <vector>
8
16class Mesh
17{
18public:
26 Mesh(float *vertices, unsigned int vSize, unsigned int *indices, unsigned int iCount);
27
33 Mesh(const std::vector<float> &vertices, const std::vector<unsigned int> &indices);
34
42 ~Mesh();
48 void Draw() const;
53 void GetBounds(Vec3 &minBounds, Vec3 &maxBounds) const;
54
59 Vec3 GetCenter() const;
60
65 const std::vector<float> &GetVertices() const { return m_Vertices; }
66
71 const std::vector<unsigned int> &GetIndices() const { return m_Indices; }
72
73private:
74 VertexArray m_VAO;
75 VertexBuffer m_VBO;
76 IndexBuffer m_IBO;
77
78 std::vector<float> m_Vertices;
79 std::vector<unsigned int> m_Indices;
80 mutable Vec3 m_MinBounds, m_MaxBounds;
81 mutable bool m_BoundsCalculated = false;
82};
Manages an OpenGL index buffer object (IBO) for efficient rendering of indexed geometry.
Definition IndexBuffer.h:16
Represents a 3D mesh composed of vertices and indices.
Definition Mesh.h:17
void GetBounds(Vec3 &minBounds, Vec3 &maxBounds) const
Gets the axis-aligned bounding box of the mesh.
Definition Mesh.cpp:53
const std::vector< unsigned int > & GetIndices() const
Gets access to the index data for intersection testing.
Definition Mesh.h:71
~Mesh()
Destroys the Mesh object.
Definition Mesh.cpp:42
Vec3 GetCenter() const
Gets the center point of the mesh bounds.
Definition Mesh.cpp:103
const std::vector< float > & GetVertices() const
Gets access to the vertex data for intersection testing.
Definition Mesh.h:65
void Draw() const
Renders the mesh.
Definition Mesh.cpp:47
Encapsulates an OpenGL Vertex Array Object (VAO).
Definition VertexArray.h:13
Manages an OpenGL Vertex Buffer Object (VBO).
Definition VertexBuffer.h:13
Definition Vec3.h:5