added mesh rendering
This commit is contained in:
@@ -22,22 +22,20 @@ void CBrushEntity::Spawn()
|
||||
for (auto tri: m_mesh)
|
||||
{
|
||||
V_memcpy(&triangles[i],tri.location,36);
|
||||
i+=1;
|
||||
i+=3;
|
||||
}
|
||||
V_printf("indicides %i\n",indicies.GetSize());
|
||||
V_printf("vertices %i\n",triangles.GetSize());
|
||||
|
||||
px_collider_params params = {};
|
||||
params.friction = 0;
|
||||
params.friction = 0.6;
|
||||
m_collider = px_trimesh((Point<float>*)triangles.GetMemory(), triangles.GetSize(), (uint32_t(*)[3])indicies.GetMemory(), indicies.GetSize()/3 ,params);
|
||||
//m_collider = px_box(4, 10, 1, params);
|
||||
px_matrix mat = {};
|
||||
mat.m[0] = 1;
|
||||
mat.m[4] = 1;
|
||||
mat.m[9] = 1;
|
||||
mat.m[5] = 1;
|
||||
mat.m[10] = 1;
|
||||
mat.m[15] = 1;
|
||||
px_rigidbody_params param = {};
|
||||
param.gravity_scale = 1;
|
||||
m_body = px_staticbody(px, m_collider, mat);
|
||||
px_fixedbody(px, m_collider);
|
||||
};
|
||||
|
||||
void CBrushEntity::Destroy()
|
||||
@@ -67,7 +65,7 @@ void C_BrushEntity::Spawn()
|
||||
pAlbedo = ITextureManager::LoadTexture("gfx/bricks.png");
|
||||
CBrushEntity* pBrushEntity = (CBrushEntity*)pEntity;
|
||||
uint32_t numVertices = 15*pBrushEntity->m_mesh.GetSize();
|
||||
vertexBuffer = IBrushRenderer::CreateVertexBuffer(numVertices*4);
|
||||
vertexBuffer = IRenderer::CreateVertexBuffer(numVertices*4);
|
||||
Vertex_t *pTriangles = (Vertex_t*)vertexBuffer->Map();
|
||||
uint32_t i = 0;
|
||||
for (auto &triangle: pBrushEntity->m_mesh)
|
||||
@@ -103,7 +101,7 @@ void C_BrushEntity::Destroy()
|
||||
void C_BrushEntity::Think( float fDelta )
|
||||
{
|
||||
material.m.albedo = ITextureManager::GetTexture(pAlbedo);
|
||||
IBrushRenderer::SetMaterial(&material);
|
||||
IRenderer::SetMaterial(&material);
|
||||
mesh->Draw();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user