本文整理汇总了C++中NxArray::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ NxArray::begin方法的具体用法?C++ NxArray::begin怎么用?C++ NxArray::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NxArray
的用法示例。
在下文中一共展示了NxArray::begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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();
}
示例3: RenderCallback
void RenderCallback()
{
if (gScene && !bPause)
{
StartPhysics();
GetPhysicsResults();
}
// Clear buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ProcessInputs();
ProcessCameraKeys();
SetupCamera();
RenderActors(bShadows);
// Render all the cloths in the scene
for (MyCloth **cloth = gCloths.begin(); cloth != gCloths.end(); cloth++)
{
glColor4f(1.0f, 0.0f, 0.0f,1.0f);
(*cloth)->draw(bShadows);
}
if (bForceMode)
DrawForce(gSelectedActor, gForceVec, NxVec3(1,1,0));
else
DrawForce(gSelectedActor, gForceVec, NxVec3(0,1,1));
gForceVec = NxVec3(0,0,0);
// Render HUD
hud.Render();
glFlush();
glutSwapBuffers();
}
示例4: update
void VertexWelder::update(NxMeshData meshData)
{
assert(mWriteVerticesPtr != NULL);
bool updateVertices = (*(meshData.dirtyBufferFlagsPtr) & (NX_MDF_VERTICES_POS_DIRTY | NX_MDF_VERTICES_NORMAL_DIRTY)) > 0;
bool updateIndices = (*(meshData.dirtyBufferFlagsPtr) & (NX_MDF_INDICES_DIRTY | NX_MDF_PARENT_INDICES_DIRTY)) > 0;
NxU32 numNewVertices = *meshData.numVerticesPtr;
NxU32 numTriangles = *meshData.numIndicesPtr / 3;
NxU32 oldMappingDomain = mMappingDomain;
NxArray<NewVertex> newVertices;
NxArray<DifficultVertex> difficultVertices;
mMappingDomainAddition = 0;
if (updateVertices)
{
if (mMappingDomain < numNewVertices)
{
#ifdef DEBUG_WELDER
printf("------------------------------------\n");
#endif
for (NxU32 i = mMappingDomain; i < numNewVertices; i++)
{
NewVertex v;
v.index = i;
v.parent = *(NxU32*)(((char*)meshData.parentIndicesBegin) + meshData.parentIndicesByteStride * i);
while (v.parent >= (NxI32)mMappingDomain) {
v.parent = *(NxU32*)(((char*)meshData.parentIndicesBegin) + meshData.parentIndicesByteStride * v.parent);
}
#ifdef DEBUG_WELDER
printf("New Vertex: %d %d\n", v.index, v.parent);
#endif
newVertices.push_back(v);
}
std::sort(newVertices.begin(), newVertices.end(), sortParent);
}
for (NxU32 i = 0; i < mMappingSize; i++)
{
NxU32 mappedIndex = getMapping(i);
NewVertex newV;
newV.parent = mappedIndex;
// Find all vertices that are a parent for a newly created vertex
NxArray<NewVertex>::iterator found = std::lower_bound(newVertices.begin(), newVertices.end(), newV, sortParent);
while (found != NULL && found->parent == mappedIndex)
{
found->mappedVertices ++;
if (found->mappedVertices == 1)
{
found->unMapParent = i;
#ifdef DEBUG_WELDER
printf("New Vertex Update, %d %d %d\n", found->index, found->parent, found->unMapParent);
#endif
}
else
{
// several unmapped parents
DifficultVertex v;
v.mappedIndex = found->index;
v.unMappedIndex = i;
difficultVertices.push_back(v);
#ifdef DEBUG_WELDER
printf("Difficult Vertex %d %d\n", v.unMappedIndex, v.mappedIndex);
#endif
if (found->mappedVertices == 2)
{
v.unMappedIndex = found->unMapParent;
difficultVertices.push_back(v);
#ifdef DEBUG_WELDER
printf("Difficult Vertex %d %d\n", v.unMappedIndex, v.mappedIndex);
#endif
}
found->unMapParent = -2;
}
found++;
}
NxVec3& vertex = *(NxVec3*)(((char*)mWriteVerticesPtr) + mWriteVerticesStride * i);
NxVec3& normal = *(NxVec3*)(((char*)mWriteNormalsPtr) + mWriteNormalsStride* i);
//float* texCoord = (float*)(((char*)texCoords) + texStride * i);
const NxVec3& oldVertex = *(NxVec3*)(((char*)meshData.verticesPosBegin) + meshData.verticesPosByteStride * mappedIndex);
const NxVec3& oldNormal = *(NxVec3*)(((char*)meshData.verticesNormalBegin) + meshData.verticesNormalByteStride * mappedIndex);
vertex = oldVertex;
normal = oldNormal;
}
// Adapt the mapping table
std::sort(newVertices.begin(), newVertices.end(), sortIndex);
std::sort(difficultVertices.begin(), difficultVertices.end(), sortDifficultExt);
}
if (updateIndices)
//.........这里部分代码省略.........
示例5: 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();
}