support compound versus compound collision shape acceleration on GPU, using aabb tree versus aabb tree.
Remove constructor from b3Vector3, to make it a POD type, so it can go into a union (and more compatible with OpenCL float4) Use b3MakeVector3 instead of constructor Share some code between C++ and GPU in a shared file: see b3TransformAabb2 in src/Bullet3Collision/BroadPhaseCollision/shared/b3Aabb.h Improve PairBench a bit, show timings and #overlapping pairs. Increase shadowmap default size to 8192x8192 (hope the GPU supports it)
This commit is contained in:
@@ -48,14 +48,14 @@ public:
|
||||
arraySizeZ(10),
|
||||
#else
|
||||
|
||||
arraySizeX(30),
|
||||
arraySizeX(30),
|
||||
arraySizeY(30),
|
||||
arraySizeZ(30),
|
||||
#endif
|
||||
m_useConcaveMesh(false),
|
||||
gapX(14.3),
|
||||
gapY(14.0),
|
||||
gapZ(14.3),
|
||||
gapX(16.3),
|
||||
gapY(6.3),
|
||||
gapZ(16.3),
|
||||
m_useInstancedCollisionShapes(true),
|
||||
m_instancingRenderer(0),
|
||||
m_window(0),
|
||||
|
||||
@@ -243,10 +243,10 @@ void ParticleDemo::setupScene(const ConstructionInfo& ci)
|
||||
void* userPtr = (void*)userIndex;
|
||||
int collidableIndex = userIndex;
|
||||
b3Vector3 aabbMin,aabbMax;
|
||||
b3Vector3 particleRadius(rad,rad,rad);
|
||||
b3Vector3 particleRadius=b3MakeVector3(rad,rad,rad);
|
||||
|
||||
aabbMin = b3Vector3(position[0],position[1],position[2])-particleRadius;
|
||||
aabbMax = b3Vector3(position[0],position[1],position[2])+particleRadius;
|
||||
aabbMin = b3MakeVector3(position[0],position[1],position[2])-particleRadius;
|
||||
aabbMax = b3MakeVector3(position[0],position[1],position[2])+particleRadius;
|
||||
m_data->m_broadphaseGPU->createProxy(aabbMin,aabbMax,collidableIndex,1,1);
|
||||
userIndex++;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "OpenGLWindow/GLInstanceRendererInternalData.h"
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3LauncherCL.h"
|
||||
#include "../../../btgui/Timing/b3Quickprof.h"
|
||||
#include "../gwenUserInterface.h"
|
||||
|
||||
static b3KeyboardCallback oldCallback = 0;
|
||||
extern bool gReset;
|
||||
@@ -49,7 +50,7 @@ __kernel void
|
||||
{
|
||||
int nodeID = get_global_id(0);
|
||||
float timeStepPos = 0.000166666;
|
||||
float mAmplitude = 86.f;
|
||||
float mAmplitude = 51.f;
|
||||
if( nodeID < numNodes )
|
||||
{
|
||||
pBodyTimes[nodeID] += timeStepPos;
|
||||
@@ -102,6 +103,8 @@ struct PairBenchInternalData
|
||||
cl_kernel m_colorPairsKernel;
|
||||
cl_kernel m_updateAabbSimple;
|
||||
|
||||
GwenUserInterface* m_gui;
|
||||
|
||||
b3OpenCLArray<b3Vector4>* m_instancePosOrnColor;
|
||||
b3OpenCLArray<float>* m_bodyTimes;
|
||||
PairBenchInternalData()
|
||||
@@ -149,6 +152,9 @@ static void PairKeyboardCallback(int key, int state)
|
||||
|
||||
void PairBench::initPhysics(const ConstructionInfo& ci)
|
||||
{
|
||||
m_data->m_gui = ci.m_gui;
|
||||
|
||||
|
||||
initCL(ci.preferredOpenCLDeviceIndex,ci.preferredOpenCLPlatformIndex);
|
||||
if (m_clData->m_clContext)
|
||||
{
|
||||
@@ -190,13 +196,13 @@ void PairBench::initPhysics(const ConstructionInfo& ci)
|
||||
{
|
||||
for (int k=0;k<ci.arraySizeZ;k++)
|
||||
{
|
||||
b3Vector3 position(k*3,i*3,j*3);
|
||||
b3Vector3 position=b3MakeVector3(k*3,i*3,j*3);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color(0,1,0,1);
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
b3Vector4 color=b3MakeVector4(0,1,0,1);
|
||||
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
b3Vector3 aabbHalfExtents(1,1,1);
|
||||
b3Vector3 aabbHalfExtents=b3MakeVector3(1,1,1);
|
||||
|
||||
b3Vector3 aabbMin = position-aabbHalfExtents;
|
||||
b3Vector3 aabbMax = position+aabbHalfExtents;
|
||||
@@ -210,7 +216,7 @@ void PairBench::initPhysics(const ConstructionInfo& ci)
|
||||
|
||||
float camPos[4]={15.5,12.5,15.5,0};
|
||||
m_instancingRenderer->setCameraTargetPosition(camPos);
|
||||
m_instancingRenderer->setCameraDistance(60);
|
||||
m_instancingRenderer->setCameraDistance(130);
|
||||
|
||||
m_instancingRenderer->writeTransforms();
|
||||
m_data->m_broadphaseGPU->writeAabbsToGpu();
|
||||
@@ -300,7 +306,11 @@ void PairBench::clientMoveAndDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
bool updateOnGpu=true;
|
||||
|
||||
if (updateOnGpu)
|
||||
{
|
||||
B3_PROFILE("updateOnGpu");
|
||||
b3LauncherCL launcher(m_clData->m_clQueue, m_data->m_updateAabbSimple);
|
||||
launcher.setBuffer(m_data->m_instancePosOrnColor->getBufferCL() );
|
||||
launcher.setConst( numObjects);
|
||||
@@ -308,16 +318,66 @@ void PairBench::clientMoveAndDisplay()
|
||||
launcher.launch1D( numObjects);
|
||||
clFinish(m_clData->m_clQueue);
|
||||
|
||||
}
|
||||
} else
|
||||
{
|
||||
B3_PROFILE("updateOnCpu");
|
||||
int allAabbs = m_data->m_broadphaseGPU->m_allAabbsCPU.size();
|
||||
|
||||
|
||||
|
||||
b3AlignedObjectArray<b3Vector4> posOrnColorsCpu;
|
||||
m_data->m_instancePosOrnColor->copyToHost(posOrnColorsCpu);
|
||||
|
||||
|
||||
|
||||
for (int nodeId=0;nodeId<numObjects;nodeId++)
|
||||
{
|
||||
{
|
||||
b3Vector3 position = posOrnColorsCpu[nodeId];
|
||||
b3Vector3 halfExtents = b3MakeFloat4(1.01f,1.01f,1.01f,0.f);
|
||||
m_data->m_broadphaseGPU->m_allAabbsCPU[nodeId].m_minVec = position-halfExtents;
|
||||
m_data->m_broadphaseGPU->m_allAabbsCPU[nodeId].m_minIndices[3] = nodeId;
|
||||
m_data->m_broadphaseGPU->m_allAabbsCPU[nodeId].m_maxVec = position+halfExtents;
|
||||
m_data->m_broadphaseGPU->m_allAabbsCPU[nodeId].m_signedMaxIndices[3]= nodeId;
|
||||
}
|
||||
}
|
||||
m_data->m_broadphaseGPU->writeAabbsToGpu();
|
||||
|
||||
|
||||
}
|
||||
|
||||
unsigned long dt = 0;
|
||||
{
|
||||
b3Clock cl;
|
||||
dt = cl.getTimeMicroseconds();
|
||||
B3_PROFILE("calculateOverlappingPairs");
|
||||
m_data->m_broadphaseGPU->calculateOverlappingPairs(64*numObjects);
|
||||
int sz = sizeof(b3Int4)*64*numObjects;
|
||||
|
||||
m_data->m_broadphaseGPU->calculateOverlappingPairs(16*numObjects);
|
||||
//int numPairs = m_data->m_broadphaseGPU->getNumOverlap();
|
||||
//printf("numPairs = %d\n", numPairs);
|
||||
dt = cl.getTimeMicroseconds()-dt;
|
||||
}
|
||||
|
||||
|
||||
if (m_data->m_gui)
|
||||
{
|
||||
int allAabbs = m_data->m_broadphaseGPU->m_allAabbsCPU.size();
|
||||
int numOverlap = m_data->m_broadphaseGPU->getNumOverlap();
|
||||
|
||||
float time = dt/1000.f;
|
||||
//printf("time = %f\n", time);
|
||||
|
||||
char msg[1024];
|
||||
sprintf(msg,"#objects = %d, #overlapping pairs = %d, time = %f ms", allAabbs,numOverlap,time );
|
||||
//printf("msg=%s\n",msg);
|
||||
m_data->m_gui->setStatusBarMessage(msg,true);
|
||||
}
|
||||
|
||||
|
||||
if (animate)
|
||||
{
|
||||
B3_PROFILE("animate");
|
||||
GLint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
//color overlapping objects in red
|
||||
|
||||
@@ -108,10 +108,10 @@ int GpuConstraintsDemo::createDynamicsObjects2(const ConstructionInfo& ci, const
|
||||
{
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
b3MakeVector4(1,1,0,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
@@ -127,7 +127,7 @@ int GpuConstraintsDemo::createDynamicsObjects2(const ConstructionInfo& ci, const
|
||||
for (int i=0;i<numVertices;i++)
|
||||
{
|
||||
float* vertex = (float*) &vts[i*strideInBytes];
|
||||
verts.push_back(b3Vector3(vertex[0]*scaling[0],vertex[1]*scaling[1],vertex[2]*scaling[2]));
|
||||
verts.push_back(b3MakeVector3(vertex[0]*scaling[0],vertex[1]*scaling[1],vertex[2]*scaling[2]));
|
||||
}
|
||||
|
||||
bool merge = true;
|
||||
@@ -167,7 +167,7 @@ int GpuConstraintsDemo::createDynamicsObjects2(const ConstructionInfo& ci, const
|
||||
}
|
||||
//b3Vector3 position((j&1)+i*2.2,1+j*2.,(j&1)+k*2.2);
|
||||
//b3Vector3 position((-ci.arraySizeX/2*ci.gapX)+i*ci.gapX,1+j*2.,(-ci.arraySizeZ/2*ci.gapZ)+k*ci.gapZ);
|
||||
b3Vector3 position(-ci.arraySizeX/2*2+1+j*2.,
|
||||
b3Vector3 position=b3MakeVector3(-ci.arraySizeX/2*2+1+j*2.,
|
||||
10+i*ci.gapY,
|
||||
(-ci.arraySizeZ/2*ci.gapZ)+k*ci.gapZ);
|
||||
|
||||
@@ -176,7 +176,7 @@ int GpuConstraintsDemo::createDynamicsObjects2(const ConstructionInfo& ci, const
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
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);
|
||||
|
||||
@@ -193,16 +193,16 @@ int GpuConstraintsDemo::createDynamicsObjects2(const ConstructionInfo& ci, const
|
||||
//c = new b3Point2PointConstraint(pid,prevBody,b3Vector3(-1.1,0,0),b3Vector3(1.1,0,0));
|
||||
float breakingThreshold=44;
|
||||
// c->setBreakingImpulseThreshold(breakingThreshold);
|
||||
b3Vector3 pivotInA(-1.1,0,0);
|
||||
b3Vector3 pivotInB (1.1,0,0);
|
||||
b3Vector3 pivotInA=b3MakeVector3(-1.1,0,0);
|
||||
b3Vector3 pivotInB=b3MakeVector3(1.1,0,0);
|
||||
int cid = m_data->m_rigidBodyPipeline->createPoint2PointConstraint(pid,prevBody,pivotInA,pivotInB,breakingThreshold);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
|
||||
b3Vector3 pivotInA(-1.05,0,0);
|
||||
b3Vector3 pivotInB (1.05,0,0);
|
||||
b3Vector3 pivotInA=b3MakeVector3(-1.05,0,0);
|
||||
b3Vector3 pivotInB=b3MakeVector3(1.05,0,0);
|
||||
|
||||
b3Transform frameInA,frameInB;
|
||||
frameInA.setIdentity();
|
||||
@@ -276,12 +276,12 @@ void GpuConstraintsDemo::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
|
||||
|
||||
{
|
||||
b3Vector4 scaling(400,400,400,1);
|
||||
b3Vector4 scaling=b3MakeVector4(400,400,400,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position(0,-405,0);
|
||||
b3Vector3 position=b3MakeVector3(0,-405,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color(0,0,1,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);
|
||||
|
||||
@@ -85,11 +85,11 @@ GpuDemo::CreateFunc* allDemos[]=
|
||||
{
|
||||
//ConcaveCompound2Scene::MyCreateFunc,
|
||||
|
||||
|
||||
|
||||
//ConcaveSphereScene::MyCreateFunc,
|
||||
|
||||
|
||||
|
||||
|
||||
// ConcaveSphereScene::MyCreateFunc,
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ GpuDemo::CreateFunc* allDemos[]=
|
||||
GpuConvexScene::MyCreateFunc,
|
||||
|
||||
GpuCompoundScene::MyCreateFunc,
|
||||
GpuCompoundPlaneScene::MyCreateFunc,
|
||||
|
||||
GpuSphereScene::MyCreateFunc,
|
||||
|
||||
@@ -112,11 +113,11 @@ GpuDemo::CreateFunc* allDemos[]=
|
||||
|
||||
ConcaveCompoundScene::MyCreateFunc,
|
||||
|
||||
GpuCompoundPlaneScene::MyCreateFunc,
|
||||
|
||||
|
||||
GpuTetraScene::MyCreateFunc,
|
||||
//GpuTetraScene::MyCreateFunc,
|
||||
|
||||
GpuSoftClothDemo::MyCreateFunc,
|
||||
//GpuSoftClothDemo::MyCreateFunc,
|
||||
|
||||
Bullet2FileDemo::MyCreateFunc,
|
||||
|
||||
@@ -546,7 +547,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
|
||||
b3SetCustomPrintfFunc(myprintf);
|
||||
b3Vector3 test(1,2,3);
|
||||
b3Vector3 test=b3MakeVector3(1,2,3);
|
||||
test.x = 1;
|
||||
test.y = 4;
|
||||
|
||||
|
||||
@@ -116,10 +116,10 @@ int GpuRaytraceScene::createDynamicsObjects(const ConstructionInfo& ci2)
|
||||
{
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
b3MakeVector4(1,1,0,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
@@ -143,7 +143,7 @@ int GpuRaytraceScene::createDynamicsObjects(const ConstructionInfo& ci2)
|
||||
{
|
||||
//mass=0.f;
|
||||
}
|
||||
b3Vector3 position((j&1)+i*2.2,1+j*2.,(j&1)+k*2.2);
|
||||
b3Vector3 position=b3MakeVector3((j&1)+i*2.2,1+j*2.,(j&1)+k*2.2);
|
||||
//b3Vector3 position(i*2.2,10+j*1.9,k*2.2);
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
@@ -151,7 +151,7 @@ int GpuRaytraceScene::createDynamicsObjects(const ConstructionInfo& ci2)
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
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);
|
||||
|
||||
@@ -228,7 +228,7 @@ void GpuRaytraceScene::renderScene2()
|
||||
rayForward*= farPlane;
|
||||
|
||||
b3Vector3 rightOffset;
|
||||
b3Vector3 vertical(0.f,1.f,0.f);
|
||||
b3Vector3 vertical=b3MakeVector3(0.f,1.f,0.f);
|
||||
b3Vector3 hor;
|
||||
hor = rayForward.cross(vertical);
|
||||
hor.normalize();
|
||||
@@ -303,7 +303,7 @@ void GpuRaytraceScene::renderScene2()
|
||||
}
|
||||
}
|
||||
|
||||
b3Vector3 lightPos(1000,1000,100);
|
||||
b3Vector3 lightPos=b3MakeVector3(1000,1000,100);
|
||||
|
||||
{
|
||||
B3_PROFILE("cast primary rays");
|
||||
|
||||
@@ -38,7 +38,7 @@ void Bullet2FileDemo::setupScene(const ConstructionInfo& ci)
|
||||
// m_loader = new b3BulletDataExtractor(*ci.m_instancingRenderer,*m_data->m_np,*m_data->m_rigidBodyPipeline);
|
||||
// m_loader->convertAllObjects(bulletFile);
|
||||
|
||||
b3Vector3 pos(-20,10,0);
|
||||
b3Vector3 pos=b3MakeVector3(-20,10,0);
|
||||
ci.m_instancingRenderer->setCameraTargetPosition(pos);
|
||||
ci.m_instancingRenderer->setCameraDistance(10);
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
|
||||
{
|
||||
for ( i=0;i<numPoints;i++)
|
||||
{
|
||||
b3Vector3 pt = b3Vector3(convexData->m_unscaledPointsFloatPtr[i].m_floats[0],
|
||||
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]);
|
||||
|
||||
@@ -591,7 +591,7 @@ GraphicsShape* b3BulletDataExtractor::createGraphicsShapeFromConvexHull(const b3
|
||||
for (int f=0;f<utilPtr->m_faces.size();f++)
|
||||
{
|
||||
const b3MyFace& face = utilPtr->m_faces[f];
|
||||
b3Vector3 normal(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
|
||||
b3Vector3 normal=b3MakeVector3(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
|
||||
if (face.m_indices.size()>2)
|
||||
{
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ GLInstanceGraphicsShape* createGraphicsShapeFromWavefrontObj(std::vector<tinyobj
|
||||
//b3Vector3 normal(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
|
||||
if (1)
|
||||
{
|
||||
b3Vector3 normal(0,1,0);
|
||||
b3Vector3 normal=b3MakeVector3(0,1,0);
|
||||
int vtxBaseIndex = vertices->size();
|
||||
|
||||
|
||||
@@ -81,9 +81,9 @@ GLInstanceGraphicsShape* createGraphicsShapeFromWavefrontObj(std::vector<tinyobj
|
||||
vtx2.uv[1] = 0.5f;
|
||||
|
||||
|
||||
b3Vector3 v0(vtx0.xyzw[0],vtx0.xyzw[1],vtx0.xyzw[2]);
|
||||
b3Vector3 v1(vtx1.xyzw[0],vtx1.xyzw[1],vtx1.xyzw[2]);
|
||||
b3Vector3 v2(vtx2.xyzw[0],vtx2.xyzw[1],vtx2.xyzw[2]);
|
||||
b3Vector3 v0=b3MakeVector3(vtx0.xyzw[0],vtx0.xyzw[1],vtx0.xyzw[2]);
|
||||
b3Vector3 v1=b3MakeVector3(vtx1.xyzw[0],vtx1.xyzw[1],vtx1.xyzw[2]);
|
||||
b3Vector3 v2=b3MakeVector3(vtx2.xyzw[0],vtx2.xyzw[1],vtx2.xyzw[2]);
|
||||
|
||||
normal = (v1-v0).cross(v2-v0);
|
||||
normal.normalize();
|
||||
@@ -163,13 +163,13 @@ void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fil
|
||||
for (int j=0;j<3;j++)
|
||||
shape->m_vertices->at(i).xyzw[j] += shift[j];
|
||||
|
||||
b3Vector3 vtx(shape->m_vertices->at(i).xyzw[0],
|
||||
b3Vector3 vtx=b3MakeVector3(shape->m_vertices->at(i).xyzw[0],
|
||||
shape->m_vertices->at(i).xyzw[1],
|
||||
shape->m_vertices->at(i).xyzw[2]);
|
||||
verts.push_back(vtx*scaling);
|
||||
}
|
||||
|
||||
int colIndex = m_data->m_np->registerConcaveMesh(&verts,shape->m_indices,b3Vector3(1,1,1));
|
||||
int colIndex = m_data->m_np->registerConcaveMesh(&verts,shape->m_indices,b3MakeVector3(1,1,1));
|
||||
|
||||
{
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
@@ -182,12 +182,12 @@ 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(0.3,0.3,1,1.f);//0.5);//1.f
|
||||
b3Vector4 color=b3MakeVector4(0.3,0.3,1,1.f);//0.5);//1.f
|
||||
|
||||
|
||||
{
|
||||
float mass = 0.f;
|
||||
b3Vector3 position(0,0,0);
|
||||
b3Vector3 position=b3MakeVector3(0,0,0);
|
||||
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++;
|
||||
@@ -222,9 +222,9 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
|
||||
char* fileName = "samurai_monastry.obj";
|
||||
// char* fileName = "teddy2_VHACD_CHs.obj";
|
||||
|
||||
b3Vector3 shift1(0,0,0);//0,230,80);//150,-100,-120);
|
||||
b3Vector3 shift1=b3MakeVector3(0,0,0);//0,230,80);//150,-100,-120);
|
||||
|
||||
b3Vector4 scaling(10,10,10,1);
|
||||
b3Vector4 scaling=b3MakeVector4(10,10,10,1);
|
||||
|
||||
// createConcaveMesh(ci,"plane100.obj",shift1,scaling);
|
||||
//createConcaveMesh(ci,"plane100.obj",shift,scaling);
|
||||
@@ -247,12 +247,12 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
|
||||
int mask=1;
|
||||
int index=0;
|
||||
{
|
||||
b3Vector4 scaling(400,1.,400,1);
|
||||
b3Vector4 scaling=b3MakeVector4(400,1.,400,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position(0,-2,0);
|
||||
b3Vector3 position=b3MakeVector3(0,-2,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color(0,0,1,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);
|
||||
@@ -268,7 +268,7 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
|
||||
//float camPos[4]={1,12.5,1.5,0};
|
||||
m_instancingRenderer->setCameraPitch(45);
|
||||
m_instancingRenderer->setCameraTargetPosition(camPos);
|
||||
m_instancingRenderer->setCameraDistance(155);
|
||||
m_instancingRenderer->setCameraDistance(355);
|
||||
char msg[1024];
|
||||
int numInstances = m_data->m_rigidBodyPipeline->getNumBodies();
|
||||
sprintf(msg,"Num objects = %d",numInstances);
|
||||
@@ -296,15 +296,15 @@ void ConcaveScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
int curColor = 0;
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3Vector4(1,1,1,1),
|
||||
b3Vector4(1,1,0.3,1),
|
||||
b3Vector4(0.3,1,1,1),
|
||||
b3Vector4(0.3,0.3,1,1),
|
||||
b3MakeVector4(1,1,1,1),
|
||||
b3MakeVector4(1,1,0.3,1),
|
||||
b3MakeVector4(0.3,1,1,1),
|
||||
b3MakeVector4(0.3,0.3,1,1),
|
||||
};
|
||||
|
||||
|
||||
b3ConvexUtility* utilPtr = new b3ConvexUtility();
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
|
||||
|
||||
{
|
||||
b3AlignedObjectArray<b3Vector3> verts;
|
||||
@@ -313,7 +313,7 @@ void ConcaveScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
for (int i=0;i<numVertices;i++)
|
||||
{
|
||||
float* vertex = (float*) &vts[i*strideInBytes];
|
||||
verts.push_back(b3Vector3(vertex[0]*scaling[0],vertex[1]*scaling[1],vertex[2]*scaling[2]));
|
||||
verts.push_back(b3MakeVector3(vertex[0]*scaling[0],vertex[1]*scaling[1],vertex[2]*scaling[2]));
|
||||
}
|
||||
|
||||
bool merge = true;
|
||||
@@ -342,7 +342,7 @@ void ConcaveScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
float mass = 1;
|
||||
|
||||
//b3Vector3 position(-2*ci.gapX+i*ci.gapX,25+j*ci.gapY,-2*ci.gapZ+k*ci.gapZ);
|
||||
b3Vector3 position(-(ci.arraySizeX/2)*CONCAVE_GAPX+i*CONCAVE_GAPX,3+j*CONCAVE_GAPY,-(ci.arraySizeZ/2)*CONCAVE_GAPZ+k*CONCAVE_GAPZ);
|
||||
b3Vector3 position=b3MakeVector3(-(ci.arraySizeX/2)*CONCAVE_GAPX+i*CONCAVE_GAPX,3+j*CONCAVE_GAPY,-(ci.arraySizeZ/2)*CONCAVE_GAPZ+k*CONCAVE_GAPZ);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
@@ -380,8 +380,8 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
//char* fileName = "cube_offset.obj";
|
||||
|
||||
|
||||
b3Vector3 shift(0,0,0);//0,230,80);//150,-100,-120);
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
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/"};
|
||||
int prefixIndex=-1;
|
||||
|
||||
@@ -455,7 +455,7 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
//for now, only support polyhedral child shapes
|
||||
b3GpuChildShape child;
|
||||
|
||||
b3Vector3 pos(0,0,0);
|
||||
b3Vector3 pos=b3MakeVector3(0,0,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
for (int v=0;v<4;v++)
|
||||
{
|
||||
@@ -479,11 +479,11 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
|
||||
}
|
||||
|
||||
b3Vector3 center(0,0,0);
|
||||
b3Vector3 center=b3MakeVector3(0,0,0);
|
||||
|
||||
b3AlignedObjectArray<GLInstanceVertex> tmpVertices;
|
||||
//add transformed graphics vertices and indices
|
||||
b3Vector3 myScaling(50,50,50);//300,300,300);
|
||||
b3Vector3 myScaling=b3MakeVector3(50,50,50);//300,300,300);
|
||||
for (int v=0;v<numVertices;v++)
|
||||
{
|
||||
GLInstanceVertex vert;
|
||||
@@ -547,10 +547,10 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,0,1,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,0,1,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
@@ -564,15 +564,15 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
float mass = 1;//j==0? 0.f : 1.f;
|
||||
|
||||
//b3Vector3 position(i*10*ci.gapX,j*ci.gapY,k*10*ci.gapZ);
|
||||
b3Vector3 position(i*10*ci.gapX,10+j*10*ci.gapY,k*10*ci.gapZ);
|
||||
b3Vector3 position=b3MakeVector3(i*10*ci.gapX,10+j*10*ci.gapY,k*10*ci.gapZ);
|
||||
|
||||
// b3Quaternion orn(0,0,0,1);
|
||||
b3Quaternion orn(b3Vector3(0,0,1),1.8);
|
||||
b3Quaternion orn(b3MakeVector3(0,0,1),1.8);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
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);
|
||||
|
||||
@@ -612,9 +612,9 @@ void ConcaveCompoundScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
|
||||
|
||||
b3Vector3 childPositions[3] = {
|
||||
b3Vector3(0,-2,0),
|
||||
b3Vector3(0,0,0),
|
||||
b3Vector3(0,0,2)
|
||||
b3MakeVector3(0,-2,0),
|
||||
b3MakeVector3(0,0,0),
|
||||
b3MakeVector3(0,0,2)
|
||||
};
|
||||
|
||||
b3AlignedObjectArray<b3GpuChildShape> childShapes;
|
||||
@@ -645,7 +645,7 @@ b3Vector3 childPositions[3] = {
|
||||
for (int v=0;v<numVertices;v++)
|
||||
{
|
||||
GLInstanceVertex vert = cubeVerts[v];
|
||||
b3Vector3 vertPos(vert.xyzw[0],vert.xyzw[1],vert.xyzw[2]);
|
||||
b3Vector3 vertPos=b3MakeVector3(vert.xyzw[0],vert.xyzw[1],vert.xyzw[2]);
|
||||
b3Vector3 newPos = tr*vertPos;
|
||||
vert.xyzw[0] = newPos[0];
|
||||
vert.xyzw[1] = newPos[1];
|
||||
@@ -664,10 +664,10 @@ b3Vector3 childPositions[3] = {
|
||||
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,0,1,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,0,1,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
@@ -680,14 +680,14 @@ b3Vector3 childPositions[3] = {
|
||||
{
|
||||
float mass = 1;//j==0? 0.f : 1.f;
|
||||
|
||||
b3Vector3 position((-ci.arraySizeX/2+i)*ci.gapX,50+j*ci.gapY,(-ci.arraySizeZ/2+k)*ci.gapZ);
|
||||
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(b3Vector3(1,0,0),0.7);
|
||||
b3Quaternion orn(b3MakeVector3(1,0,0),0.7);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
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);
|
||||
|
||||
@@ -715,10 +715,10 @@ void ConcaveSphereScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
{
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
b3MakeVector4(1,1,0,1),
|
||||
};
|
||||
|
||||
int index=0;
|
||||
@@ -737,7 +737,7 @@ void ConcaveSphereScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
float mass = 1.f;
|
||||
|
||||
|
||||
b3Vector3 position(-(ci.arraySizeX/2)*8+i*8,50+j*8,-(ci.arraySizeZ/2)*8+k*8);
|
||||
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);
|
||||
|
||||
@@ -746,7 +746,7 @@ void ConcaveSphereScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling(radius,radius,radius,1);
|
||||
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);
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
|
||||
#include "OpenGLWindow/GLInstanceGraphicsShape.h"
|
||||
|
||||
#define NUM_COMPOUND_CHILDREN_X 4
|
||||
#define NUM_COMPOUND_CHILDREN_Y 4
|
||||
#define NUM_COMPOUND_CHILDREN_Z 4
|
||||
|
||||
|
||||
|
||||
void GpuCompoundScene::setupScene(const ConstructionInfo& ci)
|
||||
@@ -42,21 +46,33 @@ void GpuCompoundScene::setupScene(const ConstructionInfo& ci)
|
||||
int childColIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
|
||||
|
||||
b3Vector3 childPositions[3] = {
|
||||
/* b3Vector3 childPositions[3] = {
|
||||
b3Vector3(0,-2,0),
|
||||
b3Vector3(0,0,0),
|
||||
b3Vector3(0,0,2)
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
b3AlignedObjectArray<b3GpuChildShape> childShapes;
|
||||
int numChildShapes = 3;
|
||||
for (int i=0;i<numChildShapes;i++)
|
||||
|
||||
for (int x=0;x<NUM_COMPOUND_CHILDREN_X;x++)
|
||||
for (int y=0;y<NUM_COMPOUND_CHILDREN_Y;y++)
|
||||
for (int z=0;z<NUM_COMPOUND_CHILDREN_Z;z++)
|
||||
{
|
||||
int blax = x!=0 ?1 : 0;
|
||||
int blay = y!=0 ?1 : 0;
|
||||
int blaz = z!=0 ?1 : 0;
|
||||
int bla=blax+blay+blaz;
|
||||
if (bla!=1)
|
||||
continue;
|
||||
|
||||
|
||||
|
||||
//for now, only support polyhedral child shapes
|
||||
b3GpuChildShape child;
|
||||
child.m_shapeIndex = childColIndex;
|
||||
b3Vector3 pos = childPositions[i];
|
||||
b3Vector3 pos=b3MakeVector3((x-NUM_COMPOUND_CHILDREN_X/2.f)*2,(y-NUM_COMPOUND_CHILDREN_X/2.f)*2,(z-NUM_COMPOUND_CHILDREN_X/2.f)*2);//childPositions[i];
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
for (int v=0;v<4;v++)
|
||||
{
|
||||
@@ -77,7 +93,7 @@ void GpuCompoundScene::setupScene(const ConstructionInfo& ci)
|
||||
for (int v=0;v<numVertices;v++)
|
||||
{
|
||||
GLInstanceVertex vert = cubeVerts[v];
|
||||
b3Vector3 vertPos(vert.xyzw[0],vert.xyzw[1],vert.xyzw[2]);
|
||||
b3Vector3 vertPos=b3MakeVector3(vert.xyzw[0],vert.xyzw[1],vert.xyzw[2]);
|
||||
b3Vector3 newPos = tr*vertPos;
|
||||
vert.xyzw[0] = newPos[0];
|
||||
vert.xyzw[1] = newPos[1];
|
||||
@@ -97,10 +113,10 @@ void GpuCompoundScene::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,0,1,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,0,1,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
@@ -112,14 +128,14 @@ void GpuCompoundScene::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
float mass = 1;//j==0? 0.f : 1.f;
|
||||
|
||||
b3Vector3 position(i*ci.gapX,10+j*ci.gapY,k*ci.gapZ);
|
||||
b3Vector3 position=b3MakeVector3((i-ci.arraySizeX/2.)*ci.gapX,35+j*3*ci.gapY,(k-ci.arraySizeZ/2.f)*ci.gapZ);
|
||||
//b3Quaternion orn(0,0,0,1);
|
||||
b3Quaternion orn(b3Vector3(1,0,0),0.7);
|
||||
b3Quaternion orn(b3MakeVector3(1,0,0),0.7);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
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);
|
||||
|
||||
@@ -134,7 +150,7 @@ void GpuCompoundScene::setupScene(const ConstructionInfo& ci)
|
||||
float camPos[4]={0,0,0};//65.5,4.5,65.5,0};
|
||||
//float camPos[4]={1,12.5,1.5,0};
|
||||
m_instancingRenderer->setCameraTargetPosition(camPos);
|
||||
m_instancingRenderer->setCameraDistance(20);
|
||||
m_instancingRenderer->setCameraDistance(320);
|
||||
|
||||
}
|
||||
|
||||
@@ -198,10 +214,10 @@ void GpuCompoundScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
}
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
b3MakeVector4(1,1,0,1),
|
||||
};
|
||||
|
||||
int curColor = 1;
|
||||
@@ -211,7 +227,7 @@ void GpuCompoundScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
float mass = 0.f;
|
||||
|
||||
//b3Vector3 position((j&1)+i*2.2,1+j*2.,(j&1)+k*2.2);
|
||||
b3Vector3 position(0,-41,0);
|
||||
b3Vector3 position=b3MakeVector3(0,-41,0);
|
||||
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
@@ -219,7 +235,7 @@ void GpuCompoundScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling(radius,radius,radius,1);
|
||||
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);
|
||||
|
||||
@@ -234,17 +250,21 @@ void GpuCompoundPlaneScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
{
|
||||
|
||||
int index=0;
|
||||
b3Vector3 normal(0,1,0);
|
||||
b3Vector3 normal=b3MakeVector3(0,1,0);
|
||||
float constant=0.f;
|
||||
int colIndex = m_data->m_np->registerPlaneShape(normal,constant);//>registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position(0,0,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
// b3Quaternion orn(b3Vector3(1,0,0),0.3);
|
||||
b3Vector4 color(0,0,1,1);
|
||||
b3Vector4 scaling(100,0.01,100,1);
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
|
||||
b3Vector4 scaling=b3MakeVector4(400,1.,400,1);
|
||||
|
||||
//int colIndex = m_data->m_np->registerPlaneShape(normal,constant);//>registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position=b3MakeVector3(0,0,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
// b3Quaternion orn(b3Vector3(1,0,0),0.3);
|
||||
b3Vector4 color=b3MakeVector4(0,0,1,1);
|
||||
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
b3MakeVector4(1,1,0,1),
|
||||
};
|
||||
|
||||
void GpuConvexScene::setupScene(const ConstructionInfo& ci)
|
||||
@@ -49,7 +49,7 @@ void GpuConvexScene::setupScene(const ConstructionInfo& ci)
|
||||
//float camPos[4]={1,12.5,1.5,0};
|
||||
|
||||
m_instancingRenderer->setCameraTargetPosition(camPos);
|
||||
m_instancingRenderer->setCameraDistance(120);
|
||||
m_instancingRenderer->setCameraDistance(114);
|
||||
//m_instancingRenderer->setCameraYaw(85);
|
||||
m_instancingRenderer->setCameraYaw(30);
|
||||
m_instancingRenderer->setCameraPitch(225);
|
||||
@@ -123,7 +123,7 @@ int GpuConvexScene::createDynamicsObjects2(const ConstructionInfo& ci, const flo
|
||||
for (int i=0;i<numVertices;i++)
|
||||
{
|
||||
float* vertex = (float*) &vts[i*strideInBytes];
|
||||
verts.push_back(b3Vector3(vertex[0]*scaling[0],vertex[1]*scaling[1],vertex[2]*scaling[2]));
|
||||
verts.push_back(b3MakeVector3(vertex[0]*scaling[0],vertex[1]*scaling[1],vertex[2]*scaling[2]));
|
||||
}
|
||||
|
||||
bool merge = true;
|
||||
@@ -157,15 +157,15 @@ int GpuConvexScene::createDynamicsObjects2(const ConstructionInfo& ci, const flo
|
||||
{
|
||||
//mass=0.f;
|
||||
}
|
||||
b3Vector3 position(((j+1)&1)+i*2.2,1+j*2.,((j+1)&1)+k*2.2);
|
||||
b3Vector3 position = b3MakeVector3(((j+1)&1)+i*2.2,1+j*2.,((j+1)&1)+k*2.2);
|
||||
//b3Vector3 position(i*2.2,10+j*1.9,k*2.2);
|
||||
|
||||
//b3Vector3 position=b3MakeVector3(1,0.9,1);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
b3Vector4 scalin=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);
|
||||
|
||||
@@ -200,12 +200,12 @@ void GpuConvexScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
|
||||
|
||||
{
|
||||
b3Vector4 scaling(400,400,400,1);
|
||||
b3Vector4 scaling=b3MakeVector4(400,400,400,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position(0,-400,0);
|
||||
b3Vector3 position=b3MakeVector3(0,-400,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color(0,0,1,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);
|
||||
@@ -226,12 +226,12 @@ void GpuConvexPlaneScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
|
||||
|
||||
{
|
||||
b3Vector4 scaling(400,400,400,1);
|
||||
b3Vector4 scaling=b3MakeVector4(400,400,400,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position(0,-400,0);
|
||||
b3Vector3 position=b3MakeVector3(0,-400,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color(0,0,1,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);
|
||||
@@ -281,8 +281,7 @@ static float mytetra_vertices[] =
|
||||
-1.f, 0, -1.f, 0.5f, 0, 1,0, 0,0,
|
||||
-1.f, 0, 1.f, 0.5f, 0, 1,0, 1,0,
|
||||
1.f, 0, 1.f, 0.5f, 0, 1,0, 1,1,
|
||||
1.f, 0, -1.f, 0.5f, 0, 1,0, 0,1,
|
||||
0, -1, 0 , 0.5f, 0, 1,0, 0,1
|
||||
1.f, 0, -1.f, 0.5f, 0, 1,0, 0,1
|
||||
};
|
||||
|
||||
static int mytetra_indices[]=
|
||||
@@ -355,7 +354,7 @@ void GpuTetraScene::createFromTetGenData(const char* ele,
|
||||
sscanf(ele,"%d %d %d %d %d",&index,&ni[0],&ni[1],&ni[2],&ni[3]);
|
||||
ele+=nextLine(ele);
|
||||
|
||||
b3Vector3 average(0,0,0);
|
||||
b3Vector3 average=b3MakeVector3(0,0,0);
|
||||
|
||||
for (int v=0;v<4;v++)
|
||||
{
|
||||
@@ -382,9 +381,9 @@ void GpuTetraScene::createFromTetGenData(const char* ele,
|
||||
|
||||
|
||||
{
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&mytetra_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position(0,150,0);
|
||||
b3Vector3 position=b3MakeVector3(0,150,0);
|
||||
// position+=average;//*1.2;//*2;
|
||||
position+=average*1.2;//*2;
|
||||
//rigidBodyPositions.push_back(position);
|
||||
|
||||
@@ -109,7 +109,7 @@ void GpuRigidBodyDemo::initPhysics(const ConstructionInfo& ci)
|
||||
|
||||
m_data->m_config.m_maxConvexBodies = b3Max(m_data->m_config.m_maxConvexBodies,ci.arraySizeX*ci.arraySizeY*ci.arraySizeZ+10);
|
||||
m_data->m_config.m_maxConvexShapes = m_data->m_config.m_maxConvexBodies;
|
||||
m_data->m_config.m_maxBroadphasePairs = 16*m_data->m_config.m_maxConvexBodies;
|
||||
m_data->m_config.m_maxBroadphasePairs = 32*m_data->m_config.m_maxConvexBodies;
|
||||
m_data->m_config.m_maxContactCapacity = m_data->m_config.m_maxBroadphasePairs;
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ void GpuRigidBodyDemo::clientMoveAndDisplay()
|
||||
b3Vector3 GpuRigidBodyDemo::getRayTo(int x,int y)
|
||||
{
|
||||
if (!m_instancingRenderer)
|
||||
return b3Vector3(0,0,0);
|
||||
return b3MakeVector3(0,0,0);
|
||||
|
||||
float top = 1.f;
|
||||
float bottom = -1.f;
|
||||
@@ -268,7 +268,7 @@ b3Vector3 GpuRigidBodyDemo::getRayTo(int x,int y)
|
||||
rayForward*= farPlane;
|
||||
|
||||
b3Vector3 rightOffset;
|
||||
b3Vector3 m_cameraUp(0,1,0);
|
||||
b3Vector3 m_cameraUp=b3MakeVector3(0,1,0);
|
||||
b3Vector3 vertical = m_cameraUp;
|
||||
|
||||
b3Vector3 hor;
|
||||
@@ -390,7 +390,7 @@ bool GpuRigidBodyDemo::mouseButtonCallback(int button, int state, float x, float
|
||||
b3Vector3 pivotInA = tr.inverse()*pivotInB;
|
||||
if (m_data->m_pickFixedBody<0)
|
||||
{
|
||||
b3Vector3 pos(0,0,0);
|
||||
b3Vector3 pos=b3MakeVector3(0,0,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
int fixedSphere = m_data->m_np->registerConvexHullShape(0,0,0,0);//>registerSphereShape(0.1);
|
||||
m_data->m_pickFixedBody = m_data->m_rigidBodyPipeline->registerPhysicsInstance(0,pos,orn,fixedSphere,0,false);
|
||||
|
||||
@@ -71,10 +71,10 @@ void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
}
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
b3MakeVector4(1,1,0,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
@@ -84,14 +84,14 @@ void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
float mass = 0.f;
|
||||
|
||||
//b3Vector3 position((j&1)+i*2.2,1+j*2.,(j&1)+k*2.2);
|
||||
b3Vector3 position(0,0,0);
|
||||
b3Vector3 position=b3MakeVector3(0,0,0);
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling(radius,radius,radius,1);
|
||||
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, writeInstanceToGpu);
|
||||
|
||||
@@ -110,10 +110,10 @@ void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
b3MakeVector4(1,1,0,1),
|
||||
};
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
int i=0,j=0,k=0;
|
||||
float mass = 0.f;
|
||||
|
||||
b3Vector3 position(0,0,0);
|
||||
b3Vector3 position=b3MakeVector3(0,0,0);
|
||||
//b3Vector3 position((j&1)+i*142.2,-51+j*142.,(j&1)+k*142.2);
|
||||
//b3Vector3 position(0,-41,0);//0,0,0);//i*radius*3,-41+j*radius*3,k*radius*3);
|
||||
|
||||
@@ -148,7 +148,7 @@ void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling(radius,radius,radius,1);
|
||||
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, writeInstanceToGpu);
|
||||
|
||||
@@ -161,9 +161,9 @@ void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
if (1)
|
||||
{
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
b3Vector4 scaling(0.5,0.5,0.5,1);//1,1,1,1);//0.1,0.1,0.1,1);
|
||||
b3Vector4 scaling=b3MakeVector4(0.5,0.5,0.5,1);//1,1,1,1);//0.1,0.1,0.1,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 normal(0,-1,0);
|
||||
b3Vector3 normal=b3MakeVector3(0,-1,0);
|
||||
float constant=2;
|
||||
|
||||
|
||||
@@ -173,11 +173,11 @@ void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
//int i=0;int j=0;
|
||||
{
|
||||
//int colIndex = m_data->m_np->registerPlaneShape(normal,constant);//>registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector4 position(2*i,70+k*2,2*j+8,0);
|
||||
b3Vector4 position=b3MakeVector4(2*i,70+k*2,2*j+8,0);
|
||||
//b3Quaternion orn(0,0,0,1);
|
||||
b3Quaternion orn(b3Vector3(1,0,0),0.3);
|
||||
b3Quaternion orn(b3MakeVector3(1,0,0),0.3);
|
||||
|
||||
b3Vector4 color(0,0,1,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(1.f,position,orn,colIndex,index,false);
|
||||
|
||||
Reference in New Issue
Block a user