mirror of
https://github.com/devZoGok/vb01.git
synced 2026-09-02 19:28:43 +00:00
separated mesh data from Mesh class
This commit is contained in:
@@ -1,24 +1,18 @@
|
||||
#include "quad.h"
|
||||
|
||||
namespace vb01{
|
||||
Quad::Quad(Vector3 size, bool spatial) : Mesh(){
|
||||
Quad::Quad(Vector3 size, bool spatial){
|
||||
this->spatial = spatial;
|
||||
this->staticVerts = false;
|
||||
|
||||
int numPolyVerts = 3;
|
||||
numTris = 2;
|
||||
indices = new u32[numTris * numPolyVerts];
|
||||
vertices = new Vertex[numTris * numPolyVerts];
|
||||
|
||||
setSize(size);
|
||||
|
||||
Mesh::construct();
|
||||
}
|
||||
|
||||
void Quad::setSize(Vector3 size){
|
||||
this->size = size;
|
||||
|
||||
Vertex v1, v2, v3, v4, v5, v6;
|
||||
MeshData::Vertex v1, v2, v3, v4, v5, v6;
|
||||
|
||||
if(spatial){
|
||||
v1.pos = Vector3(size.x / 2, size.y / 2, 0);
|
||||
v2.pos = Vector3(-size.x / 2, size.y / 2, 0);
|
||||
@@ -35,6 +29,7 @@ namespace vb01{
|
||||
v5.pos = Vector3(size.x, size.y, 0);
|
||||
v6.pos = Vector3(size.x, 0, 0);
|
||||
}
|
||||
|
||||
v1.norm = Vector3(0, 0, -1);
|
||||
v1.uv = Vector2(1, 1);
|
||||
|
||||
@@ -52,7 +47,9 @@ namespace vb01{
|
||||
|
||||
v6.norm = Vector3(0, 0, -1);
|
||||
v6.uv = Vector2(1, 1);
|
||||
|
||||
|
||||
int numTris = 2;
|
||||
u32 *indices = new u32[numTris * 3];
|
||||
indices[0] = 0;
|
||||
indices[1] = 1;
|
||||
indices[2] = 2;
|
||||
@@ -60,12 +57,14 @@ namespace vb01{
|
||||
indices[4] = 4;
|
||||
indices[5] = 5;
|
||||
|
||||
MeshData::Vertex *vertices = new MeshData::Vertex[numTris * 3];
|
||||
vertices[0] = v1;
|
||||
vertices[1] = v2;
|
||||
vertices[2] = v3;
|
||||
vertices[3] = v4;
|
||||
vertices[4] = v5;
|
||||
vertices[5] = v6;
|
||||
}
|
||||
|
||||
meshBase = MeshData(vertices, indices, numTris * 3);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user