expose gravity to host
prettify convex demo
This commit is contained in:
@@ -21,74 +21,6 @@
|
||||
#include "OpenGLWindow/GLInstanceGraphicsShape.h"
|
||||
|
||||
|
||||
#if 0
|
||||
GraphicsShape* createGraphicsShapeFromCompoundShape(btCompoundShape* compound)
|
||||
{
|
||||
GraphicsShape* gfxShape = new GraphicsShape();
|
||||
btAlignedObjectArray<GLInstanceVertex>* vertexArray = new btAlignedObjectArray<GLInstanceVertex>;
|
||||
btAlignedObjectArray<int>* indexArray = new btAlignedObjectArray<int>;
|
||||
|
||||
|
||||
|
||||
//create a graphics shape for each child, combine them into a single graphics shape using their child transforms
|
||||
for (int i=0;i<compound->getNumChildShapes();i++)
|
||||
{
|
||||
btAssert(compound->getChildShape(i)->isPolyhedral());
|
||||
if (compound->getChildShape(i)->isPolyhedral())
|
||||
{
|
||||
btPolyhedralConvexShape* convexHull = (btPolyhedralConvexShape*) compound->getChildShape(i);
|
||||
btTransform tr = compound->getChildTransform(i);
|
||||
|
||||
const btConvexPolyhedron* polyhedron = convexHull->getConvexPolyhedron();
|
||||
GraphicsShape* childGfxShape = createGraphicsShapeFromConvexHull(polyhedron);
|
||||
int baseIndex = vertexArray->size();
|
||||
|
||||
for (int j=0;j<childGfxShape->m_numIndices;j++)
|
||||
indexArray->push_back(childGfxShape->m_indices[j]+baseIndex);
|
||||
|
||||
GLInstanceVertex* orgVerts = (GLInstanceVertex*)childGfxShape->m_vertices;
|
||||
|
||||
for (int j=0;j<childGfxShape->m_numvertices;j++)
|
||||
{
|
||||
GLInstanceVertex vtx;
|
||||
btVector3 pos(orgVerts[j].xyzw[0],orgVerts[j].xyzw[1],orgVerts[j].xyzw[2]);
|
||||
pos = tr*pos;
|
||||
vtx.xyzw[0] = childGfxShape->m_scaling[0]*pos.x();
|
||||
vtx.xyzw[1] = childGfxShape->m_scaling[1]*pos.y();
|
||||
vtx.xyzw[2] = childGfxShape->m_scaling[2]*pos.z();
|
||||
vtx.xyzw[3] = 10.f;
|
||||
|
||||
vtx.uv[0] = 0.5f;
|
||||
vtx.uv[1] = 0.5f;
|
||||
|
||||
btVector3 normal(orgVerts[j].normal[0],orgVerts[j].normal[1],orgVerts[j].normal[2]);
|
||||
normal = tr.getBasis()*normal;
|
||||
vtx.normal[0] = normal.x();
|
||||
vtx.normal[1] = normal.y();
|
||||
vtx.normal[2] = normal.z();
|
||||
vertexArray->push_back(vtx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
btPolyhedralConvexShape* convexHull = (btPolyhedralConvexShape*) compound->getChildShape(0);
|
||||
const btConvexPolyhedron* polyhedron = convexHull->getConvexPolyhedron();
|
||||
GraphicsShape* childGfxShape = createGraphicsShapeFromConvexHull(polyhedron);
|
||||
|
||||
gfxShape->m_indices = &indexArray->at(0);
|
||||
gfxShape->m_numIndices = indexArray->size();
|
||||
gfxShape->m_vertices = &vertexArray->at(0).xyzw[0];
|
||||
gfxShape->m_numvertices = vertexArray->size();
|
||||
gfxShape->m_scaling[0] = 1;
|
||||
gfxShape->m_scaling[1] = 1;
|
||||
gfxShape->m_scaling[2] = 1;
|
||||
gfxShape->m_scaling[3] = 1;
|
||||
|
||||
return gfxShape;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void GpuCompoundScene::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user