drawWireframe
This commit is contained in:
@@ -42,7 +42,7 @@ CPMAddPackage(
|
||||
|
||||
CPMAddPackage(
|
||||
NAME J3ML
|
||||
URL https://git.redacted.cc/josh/j3ml/archive/Prerelease-6.zip
|
||||
URL https://git.redacted.cc/josh/j3ml/archive/Prerelease-7.zip
|
||||
)
|
||||
|
||||
# BSD 2-clause license.
|
||||
|
@@ -19,5 +19,6 @@ public:
|
||||
void scale(GLfloat multiplier);
|
||||
void rotate(LinearAlgebra::Vector3 angle);
|
||||
void load(const std::string& filename);
|
||||
void drawWireframe();
|
||||
void draw();
|
||||
};
|
@@ -21,6 +21,6 @@ int World::getEntityCount() {
|
||||
|
||||
VertexArray World::getPlayerBaseGeometry() {
|
||||
if (playerBaseGeometry.vertices.empty())
|
||||
playerBaseGeometry.load("assets/models/cube.obj");
|
||||
playerBaseGeometry.load("assets/models/cone.obj");
|
||||
return playerBaseGeometry;
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ void Player::render() {
|
||||
glRotatef(angle.x,1.0f, 0.0f, 0.0f);
|
||||
glRotatef(-angle.y,0.0f, 1.0f, 0.0f);
|
||||
glRotatef(angle.z,0.0f, 0.0f, 1.0f);
|
||||
geometry.draw();
|
||||
geometry.drawWireframe();
|
||||
|
||||
glPopMatrix();
|
||||
glPushMatrix();
|
||||
|
@@ -57,7 +57,8 @@ void VertexArray::draw() {
|
||||
glEnd();
|
||||
}
|
||||
|
||||
//Render wireframe if we have no faces.
|
||||
//This only works for *really* simple shapes.
|
||||
//Primarily for the bounding box.
|
||||
if (indices.empty()) {
|
||||
glBegin(GL_LINES);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
@@ -74,6 +75,22 @@ void VertexArray::draw() {
|
||||
}
|
||||
}
|
||||
|
||||
void VertexArray::drawWireframe() {
|
||||
glBegin(GL_LINES);
|
||||
for (size_t i = 0; i < indices.size(); i += 2) {
|
||||
if (i + 1 < indices.size()) {
|
||||
int index1 = static_cast<int>(indices[i]);
|
||||
int index2 = static_cast<int>(indices[i + 1]);
|
||||
|
||||
if (index1 >= 0 && index1 < vertices.size() && index2 >= 0 && index2 < vertices.size()) {
|
||||
glVertex3f(vertices[index1].x, vertices[index1].y, vertices[index1].z);
|
||||
glVertex3f(vertices[index2].x, vertices[index2].y, vertices[index2].z);
|
||||
}
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
//TODO: Fix gimbal lock when rotating in X or Z.
|
||||
void VertexArray::rotate(LinearAlgebra::Vector3 angle) {
|
||||
if (vertices.empty())
|
||||
|
Reference in New Issue
Block a user