remove some warnings
This commit is contained in:
@@ -27,7 +27,7 @@ extern bool enableExperimentalCpuConcaveCollision;
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuRigidBodyPipeline.h"
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuNarrowPhase.h"
|
||||
|
||||
///work-in-progress
|
||||
///work-in-progress
|
||||
///This ReadBulletSample is kept as simple as possible without dependencies to the Bullet SDK.
|
||||
///It can be used to load .bullet data for other physics SDKs
|
||||
///For a more complete example how to load and convert Bullet data using the Bullet SDK check out
|
||||
@@ -66,23 +66,23 @@ void createScene( GLInstancingRenderer& renderer,b3GpuNarrowPhase& np, b3GpuRigi
|
||||
//const char* fileName="../../bin/1000 convex.bullet";
|
||||
//const char* fileName="../../bin/1000 stack.bullet";
|
||||
//const char* fileName="../../bin/3000 fall.bullet";
|
||||
|
||||
|
||||
|
||||
//const char* fileName="../../bin/testFile.bullet";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
FILE* f = fopen(fileName,"rb");
|
||||
if (f)
|
||||
{
|
||||
fclose(f);
|
||||
|
||||
|
||||
bool verboseDumpAllTypes = false;
|
||||
|
||||
bParse::b3BulletFile* bulletFile2 = new bParse::b3BulletFile(fileName);
|
||||
|
||||
bool ok = (bulletFile2->getFlags()& bParse::FD_OK)!=0;
|
||||
|
||||
|
||||
if (ok)
|
||||
bulletFile2->parse(verboseDumpAllTypes);
|
||||
else
|
||||
@@ -99,7 +99,7 @@ void createScene( GLInstancingRenderer& renderer,b3GpuNarrowPhase& np, b3GpuRigi
|
||||
printf("Error parsing file %s.\n",fileName);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
if (verboseDumpAllTypes)
|
||||
{
|
||||
bulletFile2->dumpChunks(bulletFile2->getFileDNA());
|
||||
@@ -107,7 +107,7 @@ void createScene( GLInstancingRenderer& renderer,b3GpuNarrowPhase& np, b3GpuRigi
|
||||
|
||||
|
||||
b3BulletDataExtractor extractor(renderer,np,rbWorld);
|
||||
|
||||
|
||||
extractor.convertAllObjects(bulletFile2);
|
||||
delete bulletFile2;
|
||||
return;
|
||||
@@ -163,7 +163,7 @@ CONCAVE_SHAPES_START_HERE,
|
||||
GIMPACT_SHAPE_PROXYTYPE,
|
||||
///Multimaterial mesh
|
||||
MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE,
|
||||
|
||||
|
||||
EMPTY_SHAPE_PROXYTYPE,
|
||||
STATIC_PLANE_PROXYTYPE,
|
||||
CUSTOM_CONCAVE_SHAPE_TYPE,
|
||||
@@ -177,7 +177,7 @@ CONCAVE_SHAPES_END_HERE,
|
||||
INVALID_SHAPE_PROXYTYPE,
|
||||
|
||||
MAX_BROADPHASE_COLLISION_TYPES
|
||||
|
||||
|
||||
};
|
||||
|
||||
b3BulletDataExtractor::b3BulletDataExtractor(GLInstancingRenderer& renderer, b3GpuNarrowPhase& np, b3GpuRigidBodyPipeline& rbWorld)
|
||||
@@ -214,7 +214,7 @@ void b3BulletDataExtractor::convertAllObjects(bParse::b3BulletFile* bulletFile2)
|
||||
|
||||
for (i=0;i<bulletFile2->m_rigidBodies.size();i++)
|
||||
{
|
||||
|
||||
|
||||
Bullet3SerializeBullet2::b3RigidBodyFloatData* colObjData = (Bullet3SerializeBullet2::b3RigidBodyFloatData*)bulletFile2->m_rigidBodies[i];
|
||||
Bullet3SerializeBullet2::b3CollisionShapeData* shapeData = (Bullet3SerializeBullet2::b3CollisionShapeData*)colObjData->m_collisionObjectData.m_collisionShape;
|
||||
for (int j=0;j<m_instanceGroups.size();j++)
|
||||
@@ -237,7 +237,7 @@ void b3BulletDataExtractor::convertAllObjects(bParse::b3BulletFile* bulletFile2)
|
||||
for (int j=0;j<m_instanceGroups[i]->m_rigidBodies.size();j++)
|
||||
{
|
||||
Bullet3SerializeBullet2::b3RigidBodyFloatData* colObjData = (Bullet3SerializeBullet2::b3RigidBodyFloatData*)m_instanceGroups[i]->m_rigidBodies[j];
|
||||
|
||||
|
||||
b3Matrix3x3 mat;
|
||||
mat.deSerializeFloat((const b3Matrix3x3FloatData&)colObjData->m_collisionObjectData.m_worldTransform.m_basis);
|
||||
b3Quaternion orn;
|
||||
@@ -259,23 +259,23 @@ void b3BulletDataExtractor::convertAllObjects(bParse::b3BulletFile* bulletFile2)
|
||||
}
|
||||
if (keepStaticObjects || colObjData->m_inverseMass!=0.f)
|
||||
{
|
||||
|
||||
|
||||
m_rbPipeline.registerPhysicsInstance(mass,pos,quaternion,m_instanceGroups[i]->m_collisionShapeIndex,0,true);
|
||||
m_renderer.registerGraphicsInstance(m_instanceGroups[i]->m_collisionShapeIndex,pos,quaternion,color,m_graphicsShapes[i]->m_scaling);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0;i<bulletFile2->m_collisionObjects.size();i++)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
m_rbPipeline.writeAllInstancesToGpu();
|
||||
}
|
||||
@@ -303,7 +303,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
|
||||
case CONVEX_HULL_SHAPE_PROXYTYPE:
|
||||
{
|
||||
Bullet3SerializeBullet2::b3ConvexInternalShapeData* bsd = (Bullet3SerializeBullet2::b3ConvexInternalShapeData*)shapeData;
|
||||
|
||||
|
||||
switch (shapeData->m_shapeType)
|
||||
{
|
||||
case BOX_SHAPE_PROXYTYPE:
|
||||
@@ -331,7 +331,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
|
||||
b3Vector3 pt = b3MakeVector3(convexData->m_unscaledPointsFloatPtr[i].m_floats[0],
|
||||
convexData->m_unscaledPointsFloatPtr[i].m_floats[1],
|
||||
convexData->m_unscaledPointsFloatPtr[i].m_floats[2]);//convexData->m_unscaledPointsFloatPtr[i].m_floats[3]);
|
||||
|
||||
|
||||
tmpPoints.push_back(pt*localScaling);
|
||||
}
|
||||
}
|
||||
@@ -378,7 +378,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case CYLINDER_SHAPE_PROXYTYPE:
|
||||
@@ -408,9 +408,9 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case MULTI_SPHERE_SHAPE_PROXYTYPE:
|
||||
@@ -426,7 +426,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
|
||||
shape = new b3MultiSphereShape(&tmpPos[0],&radii[0],numSpheres);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
default:
|
||||
@@ -453,13 +453,13 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
|
||||
//dat.
|
||||
|
||||
}
|
||||
|
||||
|
||||
///trimesh->m_meshInterface.m_meshPartsPtr
|
||||
//trimesh->m_meshInterface.m_scaling
|
||||
}
|
||||
//trimesh->m_meshInterface
|
||||
//b3TriangleIndexVertexArray* meshInterface = createMeshInterface(trimesh->m_meshInterface);
|
||||
|
||||
|
||||
|
||||
//scaling
|
||||
//b3Vector3 scaling; scaling.deSerializeFloat(trimesh->m_meshInterface.m_scaling);
|
||||
@@ -489,7 +489,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
|
||||
{
|
||||
printf("error: couldn't create childShape for compoundShape\n");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
shape = compoundShape;
|
||||
|
||||
@@ -519,7 +519,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
default:
|
||||
{
|
||||
printf("unsupported shape type (%d)\n",shapeData->m_shapeType);
|
||||
@@ -527,7 +527,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
|
||||
}
|
||||
|
||||
return shapeIndex;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int b3BulletDataExtractor::createBoxShape( const Bullet3SerializeBullet2::b3Vector3FloatData& halfDimensions, const Bullet3SerializeBullet2::b3Vector3FloatData& localScaling, float collisionMargin)
|
||||
@@ -544,7 +544,7 @@ int b3BulletDataExtractor::createBoxShape( const Bullet3SerializeBullet2::b3Vect
|
||||
{
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
|
||||
|
||||
GraphicsShape* gfxShape = new GraphicsShape;
|
||||
gfxShape->m_vertices = cube_vertices;
|
||||
gfxShape->m_numvertices = numVertices;
|
||||
@@ -569,7 +569,7 @@ int b3BulletDataExtractor::createSphereShape( float radius, const Bullet3Seriali
|
||||
|
||||
int b3BulletDataExtractor::createPlaneShape( const Bullet3SerializeBullet2::b3Vector3FloatData& planeNormal, float planeConstant, const Bullet3SerializeBullet2::b3Vector3FloatData& localScaling)
|
||||
{
|
||||
printf("createPlaneShape with normal %f,%f,%f and planeConstant\n",planeNormal.m_floats[0], planeNormal.m_floats[1],planeNormal.m_floats[2],planeConstant);
|
||||
printf("createPlaneShape with normal %f,%f,%f and planeConstant %f\n",planeNormal.m_floats[0], planeNormal.m_floats[1],planeNormal.m_floats[2],planeConstant);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -582,7 +582,7 @@ GraphicsShape* b3BulletDataExtractor::createGraphicsShapeFromConvexHull(const b3
|
||||
b3ConvexUtility* utilPtr = new b3ConvexUtility();
|
||||
bool merge = true;
|
||||
utilPtr->initializePolyhedralFeatures(tmpPoints,numPoints,merge);
|
||||
|
||||
|
||||
b3AlignedObjectArray<GraphicsVertex>* vertices = new b3AlignedObjectArray<GraphicsVertex>;
|
||||
{
|
||||
int numVertices = utilPtr->m_vertices.size();
|
||||
@@ -594,7 +594,7 @@ GraphicsShape* b3BulletDataExtractor::createGraphicsShapeFromConvexHull(const b3
|
||||
b3Vector3 normal=b3MakeVector3(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
|
||||
if (face.m_indices.size()>2)
|
||||
{
|
||||
|
||||
|
||||
GraphicsVertex vtx;
|
||||
const b3Vector3& orgVertex = utilPtr->m_vertices[face.m_indices[0]];
|
||||
vtx.xyzw[0] = orgVertex[0];vtx.xyzw[1] = orgVertex[1];vtx.xyzw[2] = orgVertex[2];vtx.xyzw[3] = 0.f;
|
||||
@@ -602,7 +602,7 @@ GraphicsShape* b3BulletDataExtractor::createGraphicsShapeFromConvexHull(const b3
|
||||
vtx.uv[0] = 0.5f;vtx.uv[1] = 0.5f;
|
||||
int newvtxindex0 = vertices->size();
|
||||
vertices->push_back(vtx);
|
||||
|
||||
|
||||
for (int j=1;j<face.m_indices.size()-1;j++)
|
||||
{
|
||||
indicesPtr->push_back(newvtxindex0);
|
||||
@@ -630,15 +630,15 @@ GraphicsShape* b3BulletDataExtractor::createGraphicsShapeFromConvexHull(const b3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
GraphicsShape* gfxShape = new GraphicsShape;
|
||||
gfxShape->m_vertices = &vertices->at(0).xyzw[0];
|
||||
gfxShape->m_numvertices = vertices->size();
|
||||
gfxShape->m_indices = &indicesPtr->at(0);
|
||||
gfxShape->m_numIndices = indicesPtr->size();
|
||||
for (int i=0;i<4;i++)
|
||||
gfxShape->m_scaling[i] = 1;//bake the scaling into the vertices
|
||||
gfxShape->m_scaling[i] = 1;//bake the scaling into the vertices
|
||||
return gfxShape;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
|
||||
GLInstanceGraphicsShape* createGraphicsShapeFromWavefrontObj(std::vector<tinyobj::shape_t>& shapes)
|
||||
{
|
||||
|
||||
|
||||
b3AlignedObjectArray<GLInstanceVertex>* vertices = new b3AlignedObjectArray<GLInstanceVertex>;
|
||||
{
|
||||
// int numVertices = obj->vertexCount;
|
||||
// int numIndices = 0;
|
||||
b3AlignedObjectArray<int>* indicesPtr = new b3AlignedObjectArray<int>;
|
||||
|
||||
|
||||
for (int s=0;s<shapes.size();s++)
|
||||
{
|
||||
tinyobj::shape_t& shape = shapes[s];
|
||||
@@ -42,18 +42,18 @@ GLInstanceGraphicsShape* createGraphicsShapeFromWavefrontObj(std::vector<tinyobj
|
||||
|
||||
for (int f=0;f<faceCount;f+=3)
|
||||
{
|
||||
|
||||
|
||||
//b3Vector3 normal(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
|
||||
if (1)
|
||||
{
|
||||
b3Vector3 normal=b3MakeVector3(0,1,0);
|
||||
int vtxBaseIndex = vertices->size();
|
||||
|
||||
|
||||
|
||||
indicesPtr->push_back(vtxBaseIndex);
|
||||
indicesPtr->push_back(vtxBaseIndex+1);
|
||||
indicesPtr->push_back(vtxBaseIndex+2);
|
||||
|
||||
|
||||
GLInstanceVertex vtx0;
|
||||
vtx0.xyzw[0] = shape.mesh.positions[shape.mesh.indices[f]*3+0];
|
||||
vtx0.xyzw[1] = shape.mesh.positions[shape.mesh.indices[f]*3+1];
|
||||
@@ -101,15 +101,15 @@ GLInstanceGraphicsShape* createGraphicsShapeFromWavefrontObj(std::vector<tinyobj
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
GLInstanceGraphicsShape* gfxShape = new GLInstanceGraphicsShape;
|
||||
gfxShape->m_vertices = vertices;
|
||||
gfxShape->m_numvertices = vertices->size();
|
||||
gfxShape->m_indices = indicesPtr;
|
||||
gfxShape->m_numIndices = indicesPtr->size();
|
||||
for (int i=0;i<4;i++)
|
||||
gfxShape->m_scaling[i] = 1;//bake the scaling into the vertices
|
||||
gfxShape->m_scaling[i] = 1;//bake the scaling into the vertices
|
||||
return gfxShape;
|
||||
}
|
||||
}
|
||||
@@ -117,15 +117,15 @@ GLInstanceGraphicsShape* createGraphicsShapeFromWavefrontObj(std::vector<tinyobj
|
||||
|
||||
void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fileName, const b3Vector3& shift, const b3Vector3& scaling)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char relativeFileName[1024];
|
||||
const char* prefix[]={"./data/","../data/","../../data/","../../../data/","../../../../data/"};
|
||||
int prefixIndex=-1;
|
||||
{
|
||||
|
||||
|
||||
int numPrefixes = sizeof(prefix)/sizeof(char*);
|
||||
|
||||
for (int i=0;i<numPrefixes;i++)
|
||||
@@ -145,7 +145,7 @@ void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fil
|
||||
if (prefixIndex<0)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
int index=10;
|
||||
|
||||
{
|
||||
@@ -154,7 +154,7 @@ void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fil
|
||||
std::string err = tinyobj::LoadObj(shapes, relativeFileName, prefix[prefixIndex]);
|
||||
|
||||
GLInstanceGraphicsShape* shape = createGraphicsShapeFromWavefrontObj(shapes);
|
||||
|
||||
|
||||
|
||||
b3AlignedObjectArray<b3Vector3> verts;
|
||||
for (int i=0;i<shape->m_numvertices;i++)
|
||||
@@ -167,9 +167,9 @@ void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fil
|
||||
shape->m_vertices->at(i).xyzw[2]);
|
||||
verts.push_back(vtx*scaling);
|
||||
}
|
||||
|
||||
|
||||
int colIndex = m_data->m_np->registerConcaveMesh(&verts,shape->m_indices,b3MakeVector3(1,1,1));
|
||||
|
||||
|
||||
{
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
@@ -180,10 +180,10 @@ void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fil
|
||||
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&shape->m_vertices->at(0).xyzw[0], shape->m_numvertices, &shape->m_indices->at(0), shape->m_numIndices);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
|
||||
b3Vector4 color=b3MakeVector4(0.3,0.3,1,1.f);//0.5);//1.f
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
float mass = 0.f;
|
||||
b3Vector3 position=b3MakeVector3(0,0,0);
|
||||
@@ -200,8 +200,8 @@ void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fil
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -218,11 +218,11 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
|
||||
//char* fileName = "teddy.obj";//"plane.obj";
|
||||
// char* fileName = "sponza_closed.obj";//"plane.obj";
|
||||
//char* fileName = "leoTest1.obj";
|
||||
char* fileName = "samurai_monastry.obj";
|
||||
const char* fileName = "samurai_monastry.obj";
|
||||
// char* fileName = "teddy2_VHACD_CHs.obj";
|
||||
|
||||
|
||||
b3Vector3 shift1=b3MakeVector3(0,0,0);//0,230,80);//150,-100,-120);
|
||||
|
||||
|
||||
b3Vector4 scaling=b3MakeVector4(10,10,10,1);
|
||||
|
||||
// createConcaveMesh(ci,"plane100.obj",shift1,scaling);
|
||||
@@ -233,8 +233,8 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
// b3Vector3 shift3(130,-150,-75);//0,230,80);//150,-100,-120);
|
||||
// createConcaveMesh(ci,"leoTest1.obj",shift3,scaling);
|
||||
createConcaveMesh(ci,fileName,shift1,scaling);
|
||||
|
||||
createConcaveMesh(ci,fileName,shift1,scaling);
|
||||
|
||||
} else
|
||||
{
|
||||
|
||||
@@ -250,17 +250,17 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position=b3MakeVector3(0,-2,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
|
||||
b3Vector4 color=b3MakeVector4(0,0,1,1);
|
||||
|
||||
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(0.f,position,orn,colIndex,index,false);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
createDynamicObjects(ci);
|
||||
|
||||
|
||||
m_data->m_rigidBodyPipeline->writeAllInstancesToGpu();
|
||||
|
||||
float camPos[4]={0,0,0,0};//65.5,4.5,65.5,0};
|
||||
@@ -285,15 +285,15 @@ void ConcaveScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int group=1;
|
||||
int mask=1;
|
||||
|
||||
|
||||
|
||||
|
||||
int index=0;
|
||||
|
||||
|
||||
|
||||
if (1)
|
||||
{
|
||||
int curColor = 0;
|
||||
b3Vector4 colors[4] =
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3MakeVector4(1,1,1,1),
|
||||
b3MakeVector4(1,1,0.3,1),
|
||||
@@ -345,14 +345,14 @@ void ConcaveScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
23+j*CONCAVE_GAPY,
|
||||
-(ci.arraySizeZ/2)*CONCAVE_GAPZ+k*CONCAVE_GAPZ);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
|
||||
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
|
||||
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@@ -377,10 +377,10 @@ void ConcaveCompoundScene::setupScene(const ConstructionInfo& ci)
|
||||
void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
{
|
||||
|
||||
char* fileName = "teddy2_VHACD_CHs.obj";
|
||||
const char* fileName = "teddy2_VHACD_CHs.obj";
|
||||
//char* fileName = "cube_offset.obj";
|
||||
|
||||
|
||||
|
||||
b3Vector3 shift=b3MakeVector3(0,0,0);//0,230,80);//150,-100,-120);
|
||||
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
|
||||
const char* prefix[]={"./data/","../data/","../../data/","../../../data/","../../../../data/"};
|
||||
@@ -388,12 +388,12 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
|
||||
char relativeFileName[1024];
|
||||
{
|
||||
|
||||
|
||||
int numPrefixes = sizeof(prefix)/sizeof(char*);
|
||||
|
||||
for (int i=0;i<numPrefixes;i++)
|
||||
{
|
||||
|
||||
|
||||
sprintf(relativeFileName,"%s%s",prefix[i],fileName);
|
||||
FILE* f = 0;
|
||||
f = fopen(relativeFileName,"r");
|
||||
@@ -422,7 +422,7 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
b3AlignedObjectArray<GLInstanceVertex> vertexArray;
|
||||
b3AlignedObjectArray<int> indexArray;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
@@ -436,8 +436,8 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
b3Assert(stride2 == strideInBytes);
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
b3AlignedObjectArray<b3GpuChildShape> childShapes;
|
||||
|
||||
int numChildShapes = shapes.size();
|
||||
@@ -455,7 +455,7 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
|
||||
//for now, only support polyhedral child shapes
|
||||
b3GpuChildShape child;
|
||||
|
||||
|
||||
b3Vector3 pos=b3MakeVector3(0,0,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
for (int v=0;v<4;v++)
|
||||
@@ -463,21 +463,21 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
child.m_childPosition[v] = pos[v];
|
||||
child.m_childOrientation[v] = orn[v];
|
||||
}
|
||||
|
||||
|
||||
b3Transform tr;
|
||||
tr.setIdentity();
|
||||
tr.setOrigin(pos);
|
||||
tr.setRotation(orn);
|
||||
|
||||
int baseIndex = vertexArray.size();
|
||||
|
||||
|
||||
for (int f=0;f<numFaces;f++)
|
||||
{
|
||||
for (int i=0;i<3;i++)
|
||||
{
|
||||
indexArray.push_back(baseIndex+shape.mesh.indices[f*3+i]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
b3Vector3 center=b3MakeVector3(0,0,0);
|
||||
@@ -488,8 +488,8 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
for (int v=0;v<numVertices;v++)
|
||||
{
|
||||
GLInstanceVertex vert;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vert.uv[0] = 0.5f;
|
||||
vert.uv[1] = 0.5f;
|
||||
@@ -540,20 +540,20 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
colIndex = childColIndex;
|
||||
}
|
||||
colIndex= m_data->m_np->registerCompoundShape(&childShapes);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&vertexArray[0].xyzw[0],vertexArray.size(),&indexArray[0],indexArray.size());
|
||||
|
||||
b3Vector4 colors[4] =
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,0,1,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
};
|
||||
|
||||
|
||||
int curColor = 0;
|
||||
for (int i=0;i<1;i++)//ci.arraySizeX;i++)
|
||||
{
|
||||
@@ -569,14 +569,14 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
|
||||
// b3Quaternion orn(0,0,0,1);
|
||||
b3Quaternion orn(b3MakeVector3(0,0,1),1.8);
|
||||
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
|
||||
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@@ -588,14 +588,14 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
|
||||
void ConcaveCompoundScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
{
|
||||
|
||||
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
|
||||
b3AlignedObjectArray<GLInstanceVertex> vertexArray;
|
||||
b3AlignedObjectArray<int> indexArray;
|
||||
|
||||
|
||||
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int group=1;
|
||||
@@ -610,14 +610,14 @@ void ConcaveCompoundScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
|
||||
{
|
||||
int childColIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
|
||||
|
||||
|
||||
b3Vector3 childPositions[3] = {
|
||||
b3MakeVector3(0,-2,0),
|
||||
b3MakeVector3(0,0,0),
|
||||
b3MakeVector3(0,0,2)
|
||||
};
|
||||
|
||||
|
||||
b3AlignedObjectArray<b3GpuChildShape> childShapes;
|
||||
int numChildShapes = 3;
|
||||
for (int i=0;i<numChildShapes;i++)
|
||||
@@ -657,20 +657,20 @@ b3Vector3 childPositions[3] = {
|
||||
|
||||
}
|
||||
colIndex= m_data->m_np->registerCompoundShape(&childShapes);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&vertexArray[0].xyzw[0],vertexArray.size(),&indexArray[0],indexArray.size());
|
||||
|
||||
b3Vector4 colors[4] =
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,0,1,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
};
|
||||
|
||||
|
||||
int curColor = 0;
|
||||
for (int i=0;i<ci.arraySizeX;i++)
|
||||
{
|
||||
@@ -684,14 +684,14 @@ b3Vector3 childPositions[3] = {
|
||||
b3Vector3 position=b3MakeVector3((-ci.arraySizeX/2+i)*ci.gapX,50+j*ci.gapY,(-ci.arraySizeZ/2+k)*ci.gapZ);
|
||||
//b3Quaternion orn(0,0,0,1);
|
||||
b3Quaternion orn(b3MakeVector3(1,0,0),0.7);
|
||||
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
|
||||
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@@ -714,7 +714,7 @@ void ConcaveSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
void ConcaveSphereScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
{
|
||||
b3Vector4 colors[4] =
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
@@ -737,20 +737,20 @@ void ConcaveSphereScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
{
|
||||
float mass = 1.f;
|
||||
|
||||
|
||||
|
||||
b3Vector3 position=b3MakeVector3(-(ci.arraySizeX/2)*8+i*8,50+j*8,-(ci.arraySizeZ/2)*8+k*8);
|
||||
|
||||
|
||||
//b3Vector3 position(0,-41,0);//0,0,0);//i*radius*3,-41+j*radius*3,k*radius*3);
|
||||
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling=b3MakeVector4(radius,radius,radius,1);
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(prevGraphicsShapeIndex,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
|
||||
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user