Add ability to generate cube with the radius of individual axis.

VAO now takes in that generated cube alongside triangles.
main
Brett 2022-11-13 03:00:30 -05:00
parent b486bd375f
commit 9e533a86f6
10 changed files with 162 additions and 20 deletions

View File

@ -34,3 +34,10 @@
1310 1378 1668324206276041556 Step_3 f055ce2b85635598 1310 1378 1668324206276041556 Step_3 f055ce2b85635598
1 1298 1668324222400504969 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d 1 1298 1668324222400504969 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
1298 1369 1668324222472507037 Step_3 f055ce2b85635598 1298 1369 1668324222472507037 Step_3 f055ce2b85635598
1 1075 1668324349212149162 CMakeFiles/Step_3.dir/src/graphics/gl/gl.cpp.o 330ad35a6abf06c3
1 1305 1668324349440155714 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
1305 1374 1668324349508157669 Step_3 f055ce2b85635598
1 1177 1668326424977049673 CMakeFiles/Step_3.dir/src/graphics/gl/gl.cpp.o 330ad35a6abf06c3
1 1405 1668326425205056279 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
1 1911 1668326425713070995 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
1912 2024 1668326425821074124 Step_3 f055ce2b85635598

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

View File

@ -1,3 +1,3 @@
Start testing: Nov 13 02:23 EST Start testing: Nov 13 03:00 EST
---------------------------------------------------------- ----------------------------------------------------------
End testing: Nov 13 02:23 EST End testing: Nov 13 03:00 EST

View File

@ -83,6 +83,7 @@ class VAO {
explicit VAO(const std::vector<Raytracing::Triangle> &triangles); explicit VAO(const std::vector<Raytracing::Triangle> &triangles);
VAO(const std::vector<float>& verts, const std::vector<float>& uvs, const std::vector<unsigned int>& indices); VAO(const std::vector<float>& verts, const std::vector<float>& uvs, const std::vector<unsigned int>& indices);
VAO(const std::vector<float>& verts, const std::vector<float>& uvs);
void bind() const; void bind() const;
void unbind(); void unbind();

View File

@ -223,6 +223,21 @@ VAO::~VAO() {
} }
glDeleteBuffers(1, &instanceVBO); glDeleteBuffers(1, &instanceVBO);
} }
VAO::VAO(const std::vector<float>& verts, const std::vector<float>& uvs): VaoID(createVAO()) {
this->drawCount = (int)verts.size();
glBindVertexArray(VaoID);
// enable the attributes, prevents us from having to do this later.
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
// store vertex data
storeData(0, 3, 3 * sizeof(float), 0, (int)verts.size(), verts.data());
// store texture UV data
storeData(1, 2, 2 * sizeof(float), 0, (int)uvs.size(), uvs.data());
// store normal data
//storeData(2, 3, 3 * sizeof(float), 0, (int)normals.size(), normals.data());
unbind();
}
Texture::Texture(){ Texture::Texture(){

View File

@ -14,24 +14,143 @@ extern bool* haltRaytracing;
namespace Raytracing { namespace Raytracing {
// const std::vector<float> vertices = { struct cubeVertexBuilder {
// 1.0f, 1.0f, 0.0f, // top right std::vector<float> cubeVerticesRaw = {
// 1.0f, 0.0f, 0.0f, // bottom right -0.5f, -0.5f, -0.5f,
// 0.0f, 0.0f, 0.0f, // bottom left 0.5f, -0.5f, -0.5f,
// 0.0f, 1.0f, 0.0f // top left 0.5f, 0.5f, -0.5f,
// }; 0.5f, 0.5f, -0.5f,
// -0.5f, 0.5f, -0.5f,
// const std::vector<unsigned int> indices = { -0.5f, -0.5f, -0.5f,
// 3, 1, 0, // first triangle
// 3, 2, 1 // second triangle -0.5f, -0.5f, 0.5f,
// }; 0.5f, -0.5f, 0.5f,
// 0.5f, 0.5f, 0.5f,
// const std::vector<float> texCoords = { 0.5f, 0.5f, 0.5f,
// 1.0f, 1.0f, // top right -0.5f, 0.5f, 0.5f,
// 1.0f, 0.0f, // bottom right -0.5f, -0.5f, 0.5f,
// 0.0f, 0.0f, // bottom left
// 0.0f, 1.0f // top left -0.5f, 0.5f, 0.5f,
// }; -0.5f, 0.5f, -0.5f,
-0.5f, -0.5f, -0.5f,
-0.5f, -0.5f, -0.5f,
-0.5f, -0.5f, 0.5f,
-0.5f, 0.5f, 0.5f,
0.5f, 0.5f, 0.5f,
0.5f, 0.5f, -0.5f,
0.5f, -0.5f, -0.5f,
0.5f, -0.5f, -0.5f,
0.5f, -0.5f, 0.5f,
0.5f, 0.5f, 0.5f,
-0.5f, -0.5f, -0.5f,
0.5f, -0.5f, -0.5f,
0.5f, -0.5f, 0.5f,
0.5f, -0.5f, 0.5f,
-0.5f, -0.5f, 0.5f,
-0.5f, -0.5f, -0.5f,
-0.5f, 0.5f, -0.5f,
0.5f, 0.5f, -0.5f,
0.5f, 0.5f, 0.5f,
0.5f, 0.5f, 0.5f,
-0.5f, 0.5f, 0.5f,
-0.5f, 0.5f, -0.5f,
};
static cubeVertexBuilder getCubeExtends(float xRadius, float yRadius, float zRadius) {
cubeVertexBuilder builder;
builder.cubeVerticesRaw = {
-0.5f, -0.5f, -zRadius,
0.5f, -0.5f, -zRadius,
0.5f, 0.5f, -zRadius,
0.5f, 0.5f, -zRadius,
-0.5f, 0.5f, -zRadius,
-0.5f, -0.5f, -zRadius,
-0.5f, -0.5f, zRadius,
0.5f, -0.5f, zRadius,
0.5f, 0.5f, zRadius,
0.5f, 0.5f, zRadius,
-0.5f, 0.5f, zRadius,
-0.5f, -0.5f, zRadius,
-xRadius, 0.5f, 0.5f,
-xRadius, 0.5f, -0.5f,
-xRadius, -0.5f, -0.5f,
-xRadius, -0.5f, -0.5f,
-xRadius, -0.5f, 0.5f,
-xRadius, 0.5f, 0.5f,
xRadius, 0.5f, 0.5f,
xRadius, 0.5f, -0.5f,
xRadius, -0.5f, -0.5f,
xRadius, -0.5f, -0.5f,
xRadius, -0.5f, 0.5f,
xRadius, 0.5f, 0.5f,
-0.5f, -yRadius, -0.5f,
0.5f, -yRadius, -0.5f,
0.5f, -yRadius, 0.5f,
0.5f, -yRadius, 0.5f,
-0.5f, -yRadius, 0.5f,
-0.5f, -yRadius, -0.5f,
-0.5f, yRadius, -0.5f,
0.5f, yRadius, -0.5f,
0.5f, yRadius, 0.5f,
0.5f, yRadius, 0.5f,
-0.5f, yRadius, 0.5f,
-0.5f, yRadius, -0.5f,
};
return builder;
}
};
std::vector<float> cubeUVs = {
0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
1.0f, 1.0f,
0.0f, 1.0f,
0.0f, 0.0f,
0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
1.0f, 1.0f,
0.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f,
0.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f,
0.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.0f,
1.0f, 0.0f,
0.0f, 0.0f,
0.0f, 1.0f,
0.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.0f,
1.0f, 0.0f,
0.0f, 0.0f,
0.0f, 1.0f
};
const std::vector<float> vertices = { const std::vector<float> vertices = {
1.0f, 1.0f, 0.0f, // top right 1.0f, 1.0f, 0.0f, // top right
1.0f, -1.0f, 0.0f, // bottom right 1.0f, -1.0f, 0.0f, // bottom right