本文整理汇总了C++中NxArray::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ NxArray::clear方法的具体用法?C++ NxArray::clear怎么用?C++ NxArray::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NxArray
的用法示例。
在下文中一共展示了NxArray::clear方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: query
// ----------------------------------------------------------------------------------------------------------
void MeshHash::query(const NxBounds3 &bounds, NxArray<int> &itemIndices, int maxIndices)
{
int x1,y1,z1;
int x2,y2,z2;
int x,y,z;
cellCoordOf(bounds.min, x1,y1,z1);
cellCoordOf(bounds.max, x2,y2,z2);
itemIndices.clear();
for (x = x1; x <= x2; x++)
{
for (y = y1; y <= y2; y++)
{
for (z = z1; z <= z2; z++)
{
int h = hashFunction(x,y,z);
MeshHashRoot &r = mHashIndex[h];
if (r.timeStamp != mTime) continue;
int i = r.first;
while (i >= 0)
{
MeshHashEntry &entry = mEntries[i];
itemIndices.push_back(entry.itemIndex);
if (maxIndices >= 0 && (int)itemIndices.size() >= maxIndices) return;
i = entry.next;
}
}
}
}
}
示例2: ReleaseNx
void ReleaseNx()
{
if (gScene)
{
for (MyCloth** cloth = gCloths.begin(); cloth != gCloths.end(); cloth++)
delete *cloth;
gCloths.clear();
gPhysicsSDK->releaseScene(*gScene);
}
if (gPhysicsSDK) NxReleasePhysicsSDK(gPhysicsSDK);
NX_DELETE_SINGLE(gAllocator);
}
示例3: TickCar
void TickCar()
{
NxReal steeringAngle = gSteeringValue * gMaxSteeringAngle;
NxArray<CarWheelContact>::iterator i = wheelContactPoints.begin();
while(i != wheelContactPoints.end())
{
CarWheelContact& cwc = *i;
WheelShapeUserData* wheelData = (WheelShapeUserData *)(cwc.wheel->userData);
//apply to powered wheels only.
if (wheelData->frontWheel)
{
//steering:
NxMat33 wheelOrientation = cwc.wheel->getLocalOrientation();
wheelOrientation.setColumn(0, NxVec3(NxMath::cos(steeringAngle), 0, NxMath::sin(steeringAngle) ));
wheelOrientation.setColumn(2, NxVec3(NxMath::sin(steeringAngle), 0, -NxMath::cos(steeringAngle) ));
cwc.wheel->setLocalOrientation(wheelOrientation);
if (frontWheelIsPowered)
{
//get the world space orientation:
wheelOrientation = cwc.wheel->getGlobalOrientation();
NxVec3 steeringDirection;
wheelOrientation.getColumn(0, steeringDirection);
//the power direction of the front wheel is the wheel's axis as it is steered.
if (gMotorForce)
{
cwc.car->addForceAtPos(steeringDirection * gMotorForce,cwc.contactPoint);
}
}
}
if (!wheelData->frontWheel && rearWheelIsPowered)
{
//get the orientation of this car:
NxMat33 m = cwc.car->getGlobalOrientation();
NxVec3 carForwardAxis;
m.getColumn(0, carForwardAxis);
//the power direction of the rear wheel is always the car's length axis.
cwc.car->addForceAtPos(carForwardAxis * gMotorForce,cwc.contactPoint);
}
i++;
}
wheelContactPoints.clear();
}
示例4: render
void render()
{
static Timer t;
if(gScene && !gPauseSimulation) //start the simulation
{
gTouchedTris.clear();
gScene->simulate(t.elapsed_time());
//printf("%f\n",t.elapsed_time());
t.reset();
gScene->flushStream();
/*ASYNC: in here we can do computations which depend only on the old
state of the scene "actors". Writing to the scene is not allowed.
Write calls in here are skipped.
*/
gScene->fetchResults(NX_RIGID_BODY_FINISHED,true);
}
// Clear buffers
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor4f(0.0,1.0,1.0,1.0);
DrawSkyBox(5000.0f);
//drawPlane(2000.0);
//Render all actors
int nbActors = gScene->getNbActors();
NxActor** actors = gScene->getActors();
while(nbActors--)
{
NxActor* actor = *actors++;
if(!actor->userData) continue;
// Render actor
glPushMatrix();
float glMat[16];
actor->getGlobalPose().getColumnMajor44(glMat);
glMultMatrixf(glMat);
NxVec3 color = static_cast<UserData*>(actor->userData)->color;
glColor4f(color.x,color.y,color.z,1.0f);
glutSolidCube((static_cast<UserData*>(actor->userData)->size)*2.0f);
glPopMatrix();
}
RenderTerrain();
}
示例5: initialize
// -----------------------------------------------------------------------
void VertexWelder::initialize(const NxClothMeshDesc& unweldedMesh)
{
NxArray<NxU32> mapping;
NxReal squaredEpsilon = mEpsilon * mEpsilon;
for (NxU32 i = 0; i < unweldedMesh.numVertices; i++)
{
const NxVec3& curVec = *(const NxVec3*)(((const char*)unweldedMesh.points) + (i * unweldedMesh.pointStrideBytes));
// Find Vertex in newVertices
NxU32 newIndex = 0;
for (newIndex = 0; newIndex < mNewVertices.size(); newIndex++)
{
NxVec3& newVec = mNewVertices[newIndex];
if ((mEpsilon == 0 && newVec == curVec) || (newVec.distanceSquared(curVec) < squaredEpsilon))
//if (newVec == curVec)
{
break;
}
}
if (newIndex == mNewVertices.size())
{
// Not found in previous list
mNewVertices.push_back(curVec);
}
mapping.push_back(newIndex);
}
// Store mapping
mMappingSize = mapping.size();
mMappingSpace = unweldedMesh.numTriangles * 3;
mMappingDomain = mNewVertices.size();
mMapping = (NxU32*)malloc(sizeof(NxU32) * mMappingSpace);
memcpy(mMapping, &mapping[0], sizeof(NxU32) * mMappingSize);
memset(((NxU32*)mMapping) + mMappingSize, 0, sizeof(NxU32) * (mMappingSpace - mMappingSize));
mapping.clear();
if (mNewVertices.size() < unweldedMesh.numVertices)
{
mUsed = true;
}
else
{
return;
}
if (unweldedMesh.flags & NX_MF_16_BIT_INDICES)
{
mNewFaces16 = (NxU16*)malloc(sizeof(NxU16) * unweldedMesh.numTriangles * 3);
}
else
{
mNewFaces32 = (NxU32*)malloc(sizeof(NxU32) * unweldedMesh.numTriangles * 3);
}
for (NxU32 i = 0; i < unweldedMesh.numTriangles; i++)
{
NxU32 triangles[3];
const char* triangleChar = ((const char*)unweldedMesh.triangles) + (unweldedMesh.triangleStrideBytes * i);
if (mNewFaces16)
{
const NxU16* tris = (const NxU16*)triangleChar;
triangles[0] = tris[0];
triangles[1] = tris[1];
triangles[2] = tris[2];
}
else
{
assert(mNewFaces32 != NULL);
const NxU32* tris = (const NxU32*)triangleChar;
triangles[0] = tris[0];
triangles[1] = tris[1];
triangles[2] = tris[2];
}
for (NxU32 j = 0; j < 3; j++)
{
triangles[j] = getMapping(triangles[j]);
}
if (mNewFaces16)
{
for (NxU32 j = 0; j < 3; j++)
{
mNewFaces16[3*i+j] = (NxU16)(triangles[j] & 0xffff);
}
}
else
{
for (NxU32 j = 0; j < 3; j++)
{
mNewFaces32[3*i+j] = triangles[j];
}
}
}
}
示例6: TickCar
void TickCar ( void )
{
g_iValue = 10;
NxReal steeringAngle = gSteeringValue * gMaxSteeringAngle;
NxArray<CarWheelContact>::iterator i = wheelContactPoints.begin();
while(i != wheelContactPoints.end())
{
CarWheelContact& cwc = *i;
WheelShapeUserData* wheelData = (WheelShapeUserData *)(cwc.wheel->userData);
/*
struct CarWheelContact
{
NxActor* car;
NxShape* wheel;
NxVec3 contactPoint;
NxVec3 contactNormalForce;
NxVec3 contactFrictionForce;
};
*/
{
NxMat34 pose = cwc.wheel->getGlobalPose ( );
NxMat33 orient = pose.M;
NxVec3 pos = pose.t;
float glmat[16];
orient.getColumnMajorStride4(&(glmat[0]));
pos.get(&(glmat[12]));
glmat[3] = glmat[7] = glmat[11] = 0.0f;
glmat[15] = 1.0f;
SetWorldMatrix ( g_iValue, ( D3DXMATRIX* ) &glmat );
sObject* pObject = dbGetObject ( g_iValue );
pObject->position.vecPosition = D3DXVECTOR3 ( glmat [ 12 ], glmat [ 13 ], glmat [ 14 ] );
//dbPositionObject ( g_iValue, glmat [ 12 ], glmat [ 13 ], glmat [ 14 ] );
g_iValue++;
}
//apply to powered wheels only.
if (wheelData->frontWheel)
{
//steering:
NxMat33 wheelOrientation = cwc.wheel->getLocalOrientation();
wheelOrientation.setColumn(0, NxVec3(NxMath::cos(steeringAngle), 0, NxMath::sin(steeringAngle) ));
wheelOrientation.setColumn(2, NxVec3(NxMath::sin(steeringAngle), 0, -NxMath::cos(steeringAngle) ));
cwc.wheel->setLocalOrientation(wheelOrientation);
if (frontWheelIsPowered)
{
//get the world space orientation:
wheelOrientation = cwc.wheel->getGlobalOrientation();
NxVec3 steeringDirection;
wheelOrientation.getColumn(0, steeringDirection);
//the power direction of the front wheel is the wheel's axis as it is steered.
if (gMotorForce)
{
cwc.car->addForceAtPos(steeringDirection * gMotorForce,cwc.contactPoint);
}
}
}
if (!wheelData->frontWheel && rearWheelIsPowered)
{
//get the orientation of this car:
NxMat33 m = cwc.car->getGlobalOrientation();
NxVec3 carForwardAxis;
m.getColumn(0, carForwardAxis);
//the power direction of the rear wheel is always the car's length axis.
cwc.car->addForceAtPos(carForwardAxis * gMotorForce,cwc.contactPoint);
}
i++;
}
wheelContactPoints.clear();
}