Josh's Graphics Library
VertexArray.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
5#include <J3ML/LinearAlgebra/Vector3.hpp>
6#include <J3ML/Geometry/Triangle.hpp>
7#include <J3ML/Geometry/Sphere.hpp>
8#include <J3ML/Geometry/AABB.hpp>
9#include <J3ML/Geometry/OBB.hpp>
10
11namespace JGL {
13 typedef Vector3 Vertex;
15 typedef Vector3 Normal;
17 typedef Vector2 TextureCoordinate;
19 class VertexArray;
20}
21
23private:
24 Sphere me_sphere;
25 OBB me_obb;
26protected:
27 virtual void CreateMESphere();
28 virtual void CreateMEOBB();
29protected:
34protected:
39 std::vector<Vertex> local_vertices;
40 std::vector<unsigned int> local_indices;
41 std::vector<TextureCoordinate> local_texture_coordinates;
42 std::vector<Normal> local_normals;
43public:
45 [[nodiscard]] VRamList GetVertices() const;
46 [[nodiscard]] VRamList GetIndices() const;
47 [[nodiscard]] VRamList GetNormals() const;
48 [[nodiscard]] VRamList GetTextureCoordinates() const;
49
51 [[nodiscard]] std::vector<Vertex> GetLocalVertices() const;
52 [[nodiscard]] std::vector<unsigned int> GetLocalIndices() const;
53 [[nodiscard]] std::vector<TextureCoordinate> GetLocalTextureCoordinates() const;
54 [[nodiscard]] std::vector<Normal> GetLocalNormals() const;
55public:
59 [[nodiscard]] Sphere GetMESphere(const Vector3& scale = Vector3::One, const Vector3& translate_part = Vector3::Zero) const;
63 [[nodiscard]] Sphere GetMESphere(const Matrix4x4& instance_matrix, bool translate = false) const;
64
69 [[nodiscard]] OBB GetMEOBB(const Matrix3x3& rotation_matrix, const Vector3& scale = Vector3::One, const Vector3& translate_part = Vector3::Zero) const;
73 [[nodiscard]] OBB GetMEOBB(const Matrix4x4& instance_matrix, bool translate = false) const;
74
79 [[nodiscard]] AABB GetMEAABB(const Matrix3x3& rotation_matrix, const Vector3& scale = Vector3::One, const Vector3& translate_part = Vector3::Zero) const;
80 [[nodiscard]] AABB GetMEAABB(const Matrix4x4& instance_matrix, bool translate = false) const;
81public:
83 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,
84 const TextureCoordinate* texture_coordinates = nullptr, const long& vt_length = 0);
85};
86
A wrapped for "Vertex Buffer Object" In OpenGL, Store things in VRam.
Definition: VRamList.h:14
Definition: VertexArray.h:22
VRamList vertices
Definition: VertexArray.h:30
std::vector< unsigned int > GetLocalIndices() const
Definition: VertexArray.cpp:25
std::vector< unsigned int > local_indices
Definition: VertexArray.h:40
VRamList GetNormals() const
Definition: VertexArray.cpp:13
VRamList indices
Definition: VertexArray.h:31
std::vector< Vertex > GetLocalVertices() const
These are for cpu side calculations.
Definition: VertexArray.cpp:21
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 insta...
Definition: VertexArray.cpp:37
VRamList texture_coordinates
Definition: VertexArray.h:33
std::vector< TextureCoordinate > GetLocalTextureCoordinates() const
Definition: VertexArray.cpp:29
virtual void CreateMESphere()
Definition: VertexArray.cpp:61
VRamList GetIndices() const
Definition: VertexArray.cpp:9
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.
Definition: VertexArray.cpp:143
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...
Definition: VertexArray.cpp:133
VRamList GetVertices() const
Don't use these for anything other than drawing because the GPU is gonna spin during read-back.
Definition: VertexArray.cpp:5
VRamList GetTextureCoordinates() const
Definition: VertexArray.cpp:17
std::vector< Normal > GetLocalNormals() const
Definition: VertexArray.cpp:33
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...
Definition: VertexArray.cpp:119
std::vector< Normal > local_normals
Definition: VertexArray.h:42
virtual void CreateMEOBB()
Definition: VertexArray.cpp:92
std::vector< TextureCoordinate > local_texture_coordinates
Definition: VertexArray.h:41
VRamList normals
Definition: VertexArray.h:32
std::vector< Vertex > local_vertices
Intended for low quality version in system memory for calculations to be done on the CPU.
Definition: VertexArray.h:39
OpenGL Wrapper for rendering 2D & 3D graphics in both a 2D and 3D context.
Definition: JGL.h:31
Vector3 Normal
A direction vector which describes which way a triangle is facing.
Definition: VertexArray.h:15
Vector3 Vertex
A point that is part of an object in 3D space.
Definition: VertexArray.h:13
Vector2 TextureCoordinate
2D positions that describe how a texture is to be wrapped around a 3D object.
Definition: VertexArray.h:17