Remove ball (meshes must be loaded from file)

This commit is contained in:
Dane Johnson
2021-01-20 17:05:59 -06:00
parent 0c9935a3c0
commit 391060d9ba
10 changed files with 35 additions and 76 deletions

View File

@@ -1,39 +0,0 @@
#include "Ball.h"
Ball::Ball() {
IndexList indices;
VertexList vertices;
// It's a cube really
// Front
vertices.push_back(Vertex(1.0f, 1.0f, 1.0f, 0.0f, 1.0f));
vertices.push_back(Vertex(1.0f, -1.0f, 1.0f, 0.0f, 0.0f));
vertices.push_back(Vertex(-1.0f, 1.0f, 1.0f, 1.0f, 1.0f));
vertices.push_back(Vertex(-1.0f, -1.0f, 1.0f, 1.0f, 0.0f));
// Back
vertices.push_back(Vertex(1.0f, 1.0f, -1.0f, 0.0f, 0.0f));
vertices.push_back(Vertex(1.0f, -1.0f, -1.0f, 0.0f, 1.0f));
vertices.push_back(Vertex(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f));
vertices.push_back(Vertex(-1.0f, -1.0f, -1.0f, 1.0f, 1.0f));
//Front
indices.push_back(Index(0, 1, 2));
indices.push_back(Index(1, 2, 3));
//Back
indices.push_back(Index(4, 5, 6));
indices.push_back(Index(5, 6, 7));
// Top
indices.push_back(Index(0, 4, 6));
indices.push_back(Index(0, 2, 6));
// Bottom
indices.push_back(Index(1, 3, 7));
indices.push_back(Index(1, 5, 7));
// Left side
indices.push_back(Index(0, 1, 5));
indices.push_back(Index(0, 4, 5));
// Right side
indices.push_back(Index(2, 3, 7));
indices.push_back(Index(2, 6, 7));
submeshes.push_back(new SubMesh(vertices, indices));
}

View File

@@ -1,11 +0,0 @@
#ifndef BALL_H
#define BALL_H
#include "Mesh.h"
class Ball : public Mesh {
public:
Ball();
};
#endif /* BALL_H */

View File

@@ -80,6 +80,8 @@ Mesh* Mesh::FromFile(const char *filename) {
my_mesh->submeshes.push_back(aiMesh2SubMesh(mesh_to_import));
}
my_mesh->SetupMesh();
return my_mesh;
}

View File

@@ -25,10 +25,11 @@ public:
VertexList vertices;
IndexList indices;
Material material;
void SetupSubMesh();
void Draw(Shader *shader);
private:
Id VAO, VBO, EBO;
void SetupSubMesh();
friend class Mesh;
};
typedef std::vector<SubMesh*> SubMeshList;
@@ -41,9 +42,9 @@ public:
static Mesh *FromFile(const char *filename);
virtual bool IsDrawable() const {return true;}
virtual void Draw(Shader *shader);
virtual void SetupMesh();
protected:
SubMeshList submeshes;
virtual void SetupMesh();
private:
static SubMesh *aiMesh2SubMesh(aiMesh *mesh);
};

View File

@@ -13,10 +13,10 @@
#include "Screen.h"
#include "Ball.h"
#include "Camera.h"
#include "Input.h"
#include "Node.h"
#include "Mesh.h"
#include "Scripting/Lua.h"
// Thirdparty Includes