Just pushing what I have.
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 47s
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 47s
This commit is contained in:
164
assets/models/cone.obj
Normal file
164
assets/models/cone.obj
Normal file
@@ -0,0 +1,164 @@
|
||||
# Blender v3.6.4 OBJ File: ''
|
||||
# www.blender.org
|
||||
o Cone
|
||||
v 0.000000 -1.000000 -1.000000
|
||||
v 0.195090 -1.000000 -0.980785
|
||||
v 0.382683 -1.000000 -0.923880
|
||||
v 0.555570 -1.000000 -0.831470
|
||||
v 0.707107 -1.000000 -0.707107
|
||||
v 0.831470 -1.000000 -0.555570
|
||||
v 0.923880 -1.000000 -0.382683
|
||||
v 0.980785 -1.000000 -0.195090
|
||||
v 1.000000 -1.000000 0.000000
|
||||
v 0.980785 -1.000000 0.195090
|
||||
v 0.923880 -1.000000 0.382683
|
||||
v 0.831470 -1.000000 0.555570
|
||||
v 0.707107 -1.000000 0.707107
|
||||
v 0.555570 -1.000000 0.831470
|
||||
v 0.382683 -1.000000 0.923880
|
||||
v 0.195090 -1.000000 0.980785
|
||||
v 0.000000 -1.000000 1.000000
|
||||
v -0.195090 -1.000000 0.980785
|
||||
v -0.382683 -1.000000 0.923880
|
||||
v -0.555570 -1.000000 0.831470
|
||||
v -0.707107 -1.000000 0.707107
|
||||
v -0.831470 -1.000000 0.555570
|
||||
v -0.923880 -1.000000 0.382683
|
||||
v -0.980785 -1.000000 0.195090
|
||||
v -1.000000 -1.000000 0.000000
|
||||
v -0.980785 -1.000000 -0.195090
|
||||
v -0.923880 -1.000000 -0.382683
|
||||
v -0.831470 -1.000000 -0.555570
|
||||
v -0.707107 -1.000000 -0.707107
|
||||
v -0.555570 -1.000000 -0.831470
|
||||
v -0.382683 -1.000000 -0.923880
|
||||
v -0.195090 -1.000000 -0.980785
|
||||
v 0.000000 1.000000 0.000000
|
||||
vt 0.250000 0.490000
|
||||
vt 0.250000 0.250000
|
||||
vt 0.296822 0.485388
|
||||
vt 0.341844 0.471731
|
||||
vt 0.383337 0.449553
|
||||
vt 0.419706 0.419706
|
||||
vt 0.449553 0.383337
|
||||
vt 0.471731 0.341844
|
||||
vt 0.485388 0.296822
|
||||
vt 0.490000 0.250000
|
||||
vt 0.485388 0.203178
|
||||
vt 0.471731 0.158156
|
||||
vt 0.449553 0.116663
|
||||
vt 0.419706 0.080294
|
||||
vt 0.383337 0.050447
|
||||
vt 0.341844 0.028269
|
||||
vt 0.296822 0.014612
|
||||
vt 0.250000 0.010000
|
||||
vt 0.203178 0.014612
|
||||
vt 0.158156 0.028269
|
||||
vt 0.116663 0.050447
|
||||
vt 0.080294 0.080294
|
||||
vt 0.050447 0.116663
|
||||
vt 0.028269 0.158156
|
||||
vt 0.014612 0.203178
|
||||
vt 0.010000 0.250000
|
||||
vt 0.014612 0.296822
|
||||
vt 0.028269 0.341844
|
||||
vt 0.050447 0.383337
|
||||
vt 0.080294 0.419706
|
||||
vt 0.116663 0.449553
|
||||
vt 0.158156 0.471731
|
||||
vt 0.796822 0.014612
|
||||
vt 0.514612 0.203178
|
||||
vt 0.703178 0.485388
|
||||
vt 0.203178 0.485388
|
||||
vt 0.750000 0.490000
|
||||
vt 0.796822 0.485388
|
||||
vt 0.841844 0.471731
|
||||
vt 0.883337 0.449553
|
||||
vt 0.919706 0.419706
|
||||
vt 0.949553 0.383337
|
||||
vt 0.971731 0.341844
|
||||
vt 0.985388 0.296822
|
||||
vt 0.990000 0.250000
|
||||
vt 0.985388 0.203178
|
||||
vt 0.971731 0.158156
|
||||
vt 0.949553 0.116663
|
||||
vt 0.919706 0.080294
|
||||
vt 0.883337 0.050447
|
||||
vt 0.841844 0.028269
|
||||
vt 0.750000 0.010000
|
||||
vt 0.703178 0.014612
|
||||
vt 0.658156 0.028269
|
||||
vt 0.616663 0.050447
|
||||
vt 0.580294 0.080294
|
||||
vt 0.550447 0.116663
|
||||
vt 0.528269 0.158156
|
||||
vt 0.510000 0.250000
|
||||
vt 0.514612 0.296822
|
||||
vt 0.528269 0.341844
|
||||
vt 0.550447 0.383337
|
||||
vt 0.580294 0.419706
|
||||
vt 0.616663 0.449553
|
||||
vt 0.658156 0.471731
|
||||
s off
|
||||
f 1/1 33/2 2/3
|
||||
f 2/3 33/2 3/4
|
||||
f 3/4 33/2 4/5
|
||||
f 4/5 33/2 5/6
|
||||
f 5/6 33/2 6/7
|
||||
f 6/7 33/2 7/8
|
||||
f 7/8 33/2 8/9
|
||||
f 8/9 33/2 9/10
|
||||
f 9/10 33/2 10/11
|
||||
f 10/11 33/2 11/12
|
||||
f 11/12 33/2 12/13
|
||||
f 12/13 33/2 13/14
|
||||
f 13/14 33/2 14/15
|
||||
f 14/15 33/2 15/16
|
||||
f 15/16 33/2 16/17
|
||||
f 16/17 33/2 17/18
|
||||
f 17/18 33/2 18/19
|
||||
f 18/19 33/2 19/20
|
||||
f 19/20 33/2 20/21
|
||||
f 20/21 33/2 21/22
|
||||
f 21/22 33/2 22/23
|
||||
f 22/23 33/2 23/24
|
||||
f 23/24 33/2 24/25
|
||||
f 24/25 33/2 25/26
|
||||
f 25/26 33/2 26/27
|
||||
f 26/27 33/2 27/28
|
||||
f 27/28 33/2 28/29
|
||||
f 28/29 33/2 29/30
|
||||
f 29/30 33/2 30/31
|
||||
f 30/31 33/2 31/32
|
||||
f 16/33 24/34 32/35
|
||||
f 31/32 33/2 32/36
|
||||
f 32/36 33/2 1/1
|
||||
f 32/35 1/37 2/38
|
||||
f 2/38 3/39 4/40
|
||||
f 4/40 5/41 6/42
|
||||
f 6/42 7/43 8/44
|
||||
f 8/44 9/45 10/46
|
||||
f 10/46 11/47 12/48
|
||||
f 12/48 13/49 14/50
|
||||
f 14/50 15/51 16/33
|
||||
f 16/33 17/52 18/53
|
||||
f 18/53 19/54 20/55
|
||||
f 20/55 21/56 22/57
|
||||
f 22/57 23/58 24/34
|
||||
f 24/34 25/59 26/60
|
||||
f 26/60 27/61 28/62
|
||||
f 28/62 29/63 30/64
|
||||
f 30/64 31/65 32/35
|
||||
f 32/35 2/38 8/44
|
||||
f 2/38 4/40 8/44
|
||||
f 4/40 6/42 8/44
|
||||
f 8/44 10/46 16/33
|
||||
f 10/46 12/48 16/33
|
||||
f 12/48 14/50 16/33
|
||||
f 16/33 18/53 24/34
|
||||
f 18/53 20/55 24/34
|
||||
f 20/55 22/57 24/34
|
||||
f 24/34 26/60 32/35
|
||||
f 26/60 28/62 32/35
|
||||
f 28/62 30/64 32/35
|
||||
f 32/35 8/44 16/33
|
@@ -1,4 +1,4 @@
|
||||
# Blender 3.6.19
|
||||
# Blender v3.6.4 OBJ File: ''
|
||||
# www.blender.org
|
||||
o Cube
|
||||
v 1.000000 1.000000 -1.000000
|
||||
@@ -9,12 +9,6 @@ v -1.000000 1.000000 -1.000000
|
||||
v -1.000000 -1.000000 -1.000000
|
||||
v -1.000000 1.000000 1.000000
|
||||
v -1.000000 -1.000000 1.000000
|
||||
vn -0.0000 1.0000 -0.0000
|
||||
vn -0.0000 -0.0000 1.0000
|
||||
vn -1.0000 -0.0000 -0.0000
|
||||
vn -0.0000 -1.0000 -0.0000
|
||||
vn 1.0000 -0.0000 -0.0000
|
||||
vn -0.0000 -0.0000 -1.0000
|
||||
vt 0.875000 0.500000
|
||||
vt 0.625000 0.750000
|
||||
vt 0.625000 0.500000
|
||||
@@ -29,16 +23,16 @@ vt 0.125000 0.500000
|
||||
vt 0.625000 0.250000
|
||||
vt 0.875000 0.750000
|
||||
vt 0.625000 1.000000
|
||||
s 0
|
||||
f 5/1/1 3/2/1 1/3/1
|
||||
f 3/2/2 8/4/2 4/5/2
|
||||
f 7/6/3 6/7/3 8/8/3
|
||||
f 2/9/4 8/10/4 6/11/4
|
||||
f 1/3/5 4/5/5 2/9/5
|
||||
f 5/12/6 2/9/6 6/7/6
|
||||
f 5/1/1 7/13/1 3/2/1
|
||||
f 3/2/2 7/14/2 8/4/2
|
||||
f 7/6/3 5/12/3 6/7/3
|
||||
f 2/9/4 4/5/4 8/10/4
|
||||
f 1/3/5 3/2/5 4/5/5
|
||||
f 5/12/6 1/3/6 2/9/6
|
||||
s off
|
||||
f 5/1 3/2 1/3
|
||||
f 3/2 8/4 4/5
|
||||
f 7/6 6/7 8/8
|
||||
f 2/9 8/10 6/11
|
||||
f 1/3 4/5 2/9
|
||||
f 5/12 2/9 6/7
|
||||
f 5/1 7/13 3/2
|
||||
f 3/2 7/14 8/4
|
||||
f 7/6 5/12 6/7
|
||||
f 2/9 4/5 8/10
|
||||
f 1/3 3/2 4/5
|
||||
f 5/12 1/3 2/9
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include <J3ML/Geometry/Triangle2D.hpp>
|
||||
#include <JGL/types/Font.h>
|
||||
#include <JGL/types/VRamList.h>
|
||||
#include <JGL/types/VertexArray.h>
|
||||
|
||||
// Fonts that are included by default.
|
||||
namespace JGL::Fonts {
|
||||
@@ -670,6 +671,7 @@ namespace JGL::J3D {
|
||||
/// @param draw_back_face
|
||||
void DrawString(const Color4& color, const std::string& text, const Vector3& pos, float scale, u32 size, const Font& font = Fonts::Jupiteroid, const EulerAngleXYZ& angle = {0, 0, 0}, bool draw_back_face = false);
|
||||
|
||||
void DrawVertexArray(const Color4& color, const VertexArray& vertex_array, const Vector3& position);
|
||||
/// Draws a string of text in 3D space that is always facing the exact direction of the camera projection.
|
||||
void DrawBillboardString();
|
||||
|
||||
|
@@ -34,7 +34,7 @@ public:
|
||||
/** Copying around the VBO data to a new VBO like this is slow.
|
||||
* Pass to function by const reference or pointer always. */
|
||||
VRamList(const VRamList& rhs);
|
||||
VRamList() = default;
|
||||
VRamList() : list_handle(0), num_elements(0), element_array_buffer(false), spin_lock(false) {}
|
||||
public:
|
||||
[[nodiscard]] GLuint GetHandle() const;
|
||||
/// Returns the number of elements in the list.
|
||||
|
@@ -29,10 +29,10 @@ protected:
|
||||
protected:
|
||||
std::vector<Animation> animations{};
|
||||
protected:
|
||||
VRamList vertices;
|
||||
VRamList indices;
|
||||
VRamList normals;
|
||||
VRamList texture_coordinates;
|
||||
VRamList* vertices;
|
||||
VRamList* indices;
|
||||
VRamList* normals;
|
||||
VRamList* texture_coordinates;
|
||||
protected:
|
||||
/** For models which are not animated, This is intended for a low quality version in
|
||||
* system memory for calculations to be done on the CPU. For models that are, the default pose of the model is here.
|
||||
@@ -43,10 +43,10 @@ protected:
|
||||
std::vector<Normal> local_normals{};
|
||||
public:
|
||||
/** Don't use these for anything other than drawing because the GPU is gonna spin during read-back */
|
||||
[[nodiscard]] VRamList GetVertices() const;
|
||||
[[nodiscard]] VRamList GetIndices() const;
|
||||
[[nodiscard]] VRamList GetNormals() const;
|
||||
[[nodiscard]] VRamList GetTextureCoordinates() const;
|
||||
[[nodiscard]] const VRamList* GetVertices() const;
|
||||
[[nodiscard]] const VRamList* GetIndices() const;
|
||||
[[nodiscard]] const VRamList* GetNormals() const;
|
||||
[[nodiscard]] const VRamList* GetTextureCoordinates() const;
|
||||
|
||||
/** These are for cpu side calculations */
|
||||
[[nodiscard]] std::vector<Vertex> GetLocalVertices() const;
|
||||
@@ -83,6 +83,7 @@ public:
|
||||
[[nodiscard]] AABB GetMEAABB(const Matrix3x3& rotation_matrix, const Vector3& scale = Vector3::One, const Vector3& translate_part = Vector3::Zero) const;
|
||||
[[nodiscard]] AABB GetMEAABB(const Matrix4x4& instance_matrix, bool translate = false) const;
|
||||
public:
|
||||
VertexArray() = default;
|
||||
/// Vertices are required, Everything else is optional.
|
||||
VertexArray(const Vertex* 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);
|
||||
|
@@ -1,9 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace JGL {
|
||||
class VertexArray;
|
||||
|
||||
VertexArray LoadWavefrontOBJ(const std::string& file_text);
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
#include "../include/WavefrontOBJ.h"
|
||||
#include "JGL/types/VertexArray.h"
|
||||
#include "JGL/logger/logger.h"
|
||||
#include <JGL/types/VertexArray.h>
|
||||
#include <JGL/logger/logger.h>
|
||||
|
||||
std::pair<float, unsigned long> ParseNumber(const std::string& file_text, const unsigned long& offset) {
|
||||
std::string number;
|
||||
@@ -108,18 +108,15 @@ VertexArray JGL::LoadWavefrontOBJ(const std::string &file_text) {
|
||||
|
||||
std::vector<TextureCoordinate> temp_uvs;
|
||||
std::vector<Normal> temp_normals;
|
||||
|
||||
std::vector<Vertex> vertices;
|
||||
std::vector<Normal> normals;
|
||||
std::vector<TextureCoordinate> uvs;
|
||||
std::vector<unsigned int> indices;
|
||||
std::vector<Vertex> temp_vertices;
|
||||
|
||||
unsigned long offset = 0;
|
||||
|
||||
while (offset < file_text.size()) {
|
||||
char c = file_text[offset];
|
||||
|
||||
// Skip comments and empty lines
|
||||
// TODO the entire line a comment is on should be skipped.
|
||||
// Skip forward to the character after the next newline.
|
||||
if (c == '#' || c == '\n' || c == '\r') {
|
||||
offset++;
|
||||
continue;
|
||||
@@ -131,13 +128,14 @@ VertexArray JGL::LoadWavefrontOBJ(const std::string &file_text) {
|
||||
|
||||
auto vertex_result = ParseVector3(file_text, offset);
|
||||
if (vertex_result.second != offset) {
|
||||
vertices.push_back(vertex_result.first);
|
||||
temp_vertices.push_back(vertex_result.first);
|
||||
offset = vertex_result.second;
|
||||
}
|
||||
}
|
||||
|
||||
// Normals.
|
||||
else if (c == 'v' && offset + 2 < file_text.size() && file_text[offset + 1] == 'n' && file_text[offset + 2] == ' ') {
|
||||
else if (c == 'v' && offset + 2 < file_text.size() && file_text[offset + 1] == 'n' &&
|
||||
file_text[offset + 2] == ' ') {
|
||||
offset += 3;
|
||||
|
||||
auto normal_result = ParseVector3(file_text, offset);
|
||||
@@ -148,7 +146,8 @@ VertexArray JGL::LoadWavefrontOBJ(const std::string &file_text) {
|
||||
}
|
||||
|
||||
// Texture Coordinates
|
||||
else if (c == 'v' && offset + 2 < file_text.size() && file_text[offset + 1] == 't' && file_text[offset + 2] == ' ') {
|
||||
else if (c == 'v' && offset + 2 < file_text.size() && file_text[offset + 1] == 't' &&
|
||||
file_text[offset + 2] == ' ') {
|
||||
offset += 3;
|
||||
|
||||
auto uv_result = ParseVector2(file_text, offset);
|
||||
@@ -167,22 +166,38 @@ VertexArray JGL::LoadWavefrontOBJ(const std::string &file_text) {
|
||||
faceline_data.push_back(faceline_result.first);
|
||||
offset = faceline_result.second;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
offset++;
|
||||
}
|
||||
|
||||
// Pick everything out of the face lines how OpenGL expects it to be.
|
||||
for (const auto& face : faceline_data) {
|
||||
for (const auto& vp : face){
|
||||
// Pick everything out of the face lines and set up how OpenGL expects.
|
||||
std::vector<Vertex> final_vertices;
|
||||
std::vector<TextureCoordinate> final_uvs;
|
||||
std::vector<Normal> final_normals;
|
||||
std::vector<unsigned int> final_indices;
|
||||
for (const auto &face: faceline_data) {
|
||||
for (const auto &vp: face) {
|
||||
Vertex vertex;
|
||||
TextureCoordinate uv;
|
||||
Normal normal;
|
||||
|
||||
if (vp.x != -1)
|
||||
indices.push_back(vp.x -1);
|
||||
vertex = temp_vertices[vp.x - 1];
|
||||
if (vp.y != -1)
|
||||
uvs.push_back(temp_uvs[vp.y -1]);
|
||||
uv = temp_uvs[vp.y - 1];
|
||||
if (vp.z != -1)
|
||||
normals.push_back(temp_normals[vp.z -1]);
|
||||
normal = temp_normals[vp.z - 1];
|
||||
|
||||
final_vertices.push_back(vertex);
|
||||
final_uvs.push_back(uv);
|
||||
final_normals.push_back(normal);
|
||||
final_indices.push_back((unsigned int) final_vertices.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return VertexArray(vertices.data(), vertices.size(), indices.data(), indices.size(), normals.data(), normals.size(), uvs.data(), uvs.size());
|
||||
}
|
||||
return VertexArray(
|
||||
final_vertices.data(), final_vertices.size(),
|
||||
final_indices.data(), final_indices.size(),
|
||||
final_normals.data(), final_normals.size(),
|
||||
final_uvs.data(), final_uvs.size());
|
||||
}
|
@@ -582,4 +582,27 @@ void JGL::J3D::DrawCubicBezierCurve(const Color4& color, const Vector3& controlA
|
||||
|
||||
// Have to manually draw the last segment of the curve.
|
||||
DrawLine(color, last, first, thickness);
|
||||
}
|
||||
|
||||
void JGL::J3D::DrawVertexArray(const Color4& color, const VertexArray& vertex_array, const Vector3& position) {
|
||||
if (!inJ3D)
|
||||
Logger::Error("Drawing J3D element before J3D begin.");
|
||||
glColor4ubv(color.ptr());
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertex_array.GetVertices()->GetHandle());
|
||||
glVertexPointer(3, GL_FLOAT, 0, nullptr);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
//glScalef(1,1,1);
|
||||
glDrawArrays(GL_TRIANGLES, 0, vertex_array.GetVertices()->GetLength());
|
||||
glPopMatrix();
|
||||
|
||||
//glDrawElements(GL_LINES, vertex_array.GetIndices()->GetLength(), GL_UNSIGNED_INT, nullptr);
|
||||
//std::cout << vertex_array.GetVertices()->GetLength() << std::endl;
|
||||
glColor4fv(OpenGLState::oldColor);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
|
||||
}
|
@@ -170,6 +170,10 @@ std::vector<GLfloat> JGL::VRamList::GetDataF() const {
|
||||
if (element_array_buffer)
|
||||
JGL::Logger::Warning("Getting data as GLfloat but the buffer data is GLuint?");
|
||||
|
||||
bool vertex_array_enabled = glIsEnabled(GL_VERTEX_ARRAY);
|
||||
if (!vertex_array_enabled)
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
GLint current_buffer = 0;
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, ¤t_buffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, list_handle);
|
||||
@@ -184,6 +188,8 @@ std::vector<GLfloat> JGL::VRamList::GetDataF() const {
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, current_buffer);
|
||||
|
||||
if (!vertex_array_enabled)
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -289,7 +295,6 @@ JGL::VRamList::VRamList(const JGL::VRamList& rhs) {
|
||||
if (rhs.element_array_buffer) {
|
||||
auto data_array = rhs.GetDataUI();
|
||||
this->load(data_array.data(), data_array.size());
|
||||
return;
|
||||
}
|
||||
|
||||
auto data_array = rhs.GetDataF();
|
||||
|
@@ -4,19 +4,19 @@
|
||||
|
||||
using namespace JGL;
|
||||
|
||||
VRamList VertexArray::GetVertices() const {
|
||||
const VRamList* VertexArray::GetVertices() const {
|
||||
return vertices;
|
||||
}
|
||||
|
||||
VRamList VertexArray::GetIndices() const {
|
||||
const VRamList* VertexArray::GetIndices() const {
|
||||
return indices;
|
||||
}
|
||||
|
||||
JGL::VRamList VertexArray::GetNormals() const {
|
||||
const VRamList* VertexArray::GetNormals() const {
|
||||
return normals;
|
||||
}
|
||||
|
||||
VRamList VertexArray::GetTextureCoordinates() const {
|
||||
const VRamList* VertexArray::GetTextureCoordinates() const {
|
||||
return texture_coordinates;
|
||||
}
|
||||
|
||||
@@ -146,46 +146,33 @@ VertexArray::VertexArray(const Vector3* vertex_positions, const long& vp_length,
|
||||
const Normal* vertex_normals, const long& vn_length, const TextureCoordinate* texture_coordinates, const long& vt_length) {
|
||||
|
||||
// TODO decimator. This is a total waste of memory as it sits.
|
||||
vertices = VRamList(vertex_positions, vp_length);
|
||||
this->vertices = new VRamList(vertex_positions, vp_length);
|
||||
|
||||
local_vertices.resize(vp_length);
|
||||
memcpy(local_vertices.data(), vertex_positions, sizeof(Vector3) * vp_length);
|
||||
|
||||
if (vertex_indices && vi_length) {
|
||||
indices = VRamList(vertex_indices, vi_length);
|
||||
indices = new VRamList(vertex_indices, vi_length);
|
||||
local_indices.resize(vi_length);
|
||||
memcpy(local_indices.data(), vertex_indices, sizeof(unsigned int) * vi_length);
|
||||
}
|
||||
|
||||
if (vertex_normals && vn_length) {
|
||||
normals = VRamList(vertex_normals, vn_length);
|
||||
normals = new VRamList(vertex_normals, vn_length);
|
||||
local_normals.resize(vn_length);
|
||||
memcpy(local_normals.data(), vertex_indices, sizeof(Normal) * vn_length);
|
||||
}
|
||||
|
||||
if (texture_coordinates && vt_length) {
|
||||
this->texture_coordinates = VRamList(texture_coordinates, vt_length);
|
||||
this->texture_coordinates = new VRamList(texture_coordinates, vt_length);
|
||||
local_texture_coordinates.resize(vt_length);
|
||||
memcpy(local_texture_coordinates.data(), texture_coordinates, sizeof(TextureCoordinate) * vt_length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
VertexArray::VertexArray(const std::vector<Vertex>& vertex_positions, const std::vector<unsigned int>& vertex_indices,
|
||||
const std::vector<Normal>& vertex_normals, const std::vector<TextureCoordinate>& texture_coordinates) {
|
||||
vertices = VRamList(vertex_positions.data(), vertex_positions.size());
|
||||
local_vertices = vertex_positions;
|
||||
|
||||
if (!vertex_indices.empty()) {
|
||||
indices = VRamList(vertex_indices.data(), vertex_indices.size());
|
||||
local_indices = vertex_indices;
|
||||
}
|
||||
|
||||
if (!vertex_normals.empty()) {
|
||||
normals = VRamList(vertex_normals.data(), vertex_normals.size());
|
||||
local_normals = vertex_normals;
|
||||
}
|
||||
|
||||
if (!texture_coordinates.empty()){
|
||||
this->texture_coordinates = VRamList(texture_coordinates.data(), texture_coordinates.size());
|
||||
local_texture_coordinates = texture_coordinates;
|
||||
}
|
||||
VertexArray::VertexArray(const std::vector<Vertex>& vertex_positions, const std::vector<unsigned int>& vertex_indices, const std::vector<Normal>& vertex_normals, const std::vector<TextureCoordinate>& texture_coordinates) {
|
||||
*this = VertexArray(vertex_positions.data(), vertex_positions.size(), vertex_indices.data(), vertex_indices.size(), vertex_normals.data(), vertex_normals.size(), texture_coordinates.data(), texture_coordinates.size());
|
||||
}
|
||||
|
||||
bool VertexArray::Static() {
|
||||
|
Reference in New Issue
Block a user