本文整理汇总了C++中NxActor::raiseBodyFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ NxActor::raiseBodyFlag方法的具体用法?C++ NxActor::raiseBodyFlag怎么用?C++ NxActor::raiseBodyFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NxActor
的用法示例。
在下文中一共展示了NxActor::raiseBodyFlag方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateCube
static void CreateCube(const NxVec3& pos, int size=2, const NxVec3* initial_velocity=NULL, bool kinematic = false, bool Static = false)
{
// Create body
NxBodyDesc BodyDesc;
BodyDesc.angularDamping = 0.5f;
// BodyDesc.maxAngularVelocity = 10.0f;
if(initial_velocity) BodyDesc.linearVelocity = *initial_velocity;
NxBoxShapeDesc BoxDesc;
BoxDesc.dimensions = NxVec3(float(size), float(size), float(size));
NxActorDesc ActorDesc;
// ActorDesc.userData = (void*)size;
ActorDesc.shapes.pushBack(&BoxDesc);
if (!Static)
ActorDesc.body = &BodyDesc;
ActorDesc.density = 10.0f;
ActorDesc.globalPose.t = pos;
ActorDesc.userData = (void*)size;
NxActor* actor = gMyPhysX.getScene()->createActor(ActorDesc);
if (kinematic) {
KinematicActor k;
k.actor = actor;
actor->raiseBodyFlag(NX_BF_KINEMATIC);
if (initial_velocity) {
k.vel = *initial_velocity;
} else {
k.vel.set(0,0,0);
}
gKinematicActors.pushBack(k);
}
}
示例2: CreateBoard
NxActor* CreateBoard(const NxVec3& pos)
{
NxActor* actor = CreateBox(pos + NxVec3(0,0.5,0), NxVec3(1,0.25,0.5), 10);
actor->raiseBodyFlag(NX_BF_FROZEN_ROT_X);
actor->setAngularDamping(0.5);
// Left wheel
NxWheelDesc wheelDesc;
//wheelDesc.wheelAxis.set(0,0,1);
//wheelDesc.downAxis.set(0,-1,0);
wheelDesc.wheelApproximation = 10;
wheelDesc.wheelRadius = 0.5;
wheelDesc.wheelWidth = 0.1;
wheelDesc.wheelSuspension = 0.5;
// wheelDesc.wheelSuspension = 1.0;
wheelDesc.springRestitution = 7000;
wheelDesc.springDamping = 0;
wheelDesc.springBias = 0;
// wheelDesc.springRestitution = 20;
// wheelDesc.springDamping = 0.5;
// wheelDesc.springBias = 0;
wheelDesc.maxBrakeForce = 1;
wheelDesc.frictionToFront = 0.1;
wheelDesc.frictionToSide = 0.99;
wheelDesc.position = NxVec3(1.5,0.5,0);
wheelDesc.wheelFlags = NX_WF_USE_WHEELSHAPE | NX_WF_BUILD_LOWER_HALF | NX_WF_ACCELERATED |
NX_WF_AFFECTED_BY_HANDBRAKE | NX_WF_STEERABLE_INPUT;
wheel1 = AddWheelToActor(actor, &wheelDesc);
// Right wheel
NxWheelDesc wheelDesc2;
//wheelDesc2.wheelAxis.set(0,0,1);
//wheelDesc2.downAxis.set(0,-1,0);
wheelDesc2.wheelApproximation = 10;
wheelDesc2.wheelRadius = 0.5;
wheelDesc2.wheelWidth = 0.1;
wheelDesc2.wheelSuspension = 0.5;
// wheelDesc2.wheelSuspension = 1.0;
wheelDesc2.springRestitution = 7000;
wheelDesc2.springDamping = 0;
wheelDesc2.springBias = 0;
// wheelDesc2.springRestitution = 20;
// wheelDesc2.springDamping = 0.5;
// wheelDesc2.springBias = 0;
wheelDesc2.maxBrakeForce = 1;
wheelDesc2.frictionToFront = 0.1;
wheelDesc2.frictionToSide = 0.99;
wheelDesc2.position = NxVec3(-1.5,0.5,0);
wheelDesc2.wheelFlags = NX_WF_USE_WHEELSHAPE | NX_WF_BUILD_LOWER_HALF | NX_WF_ACCELERATED |
NX_WF_AFFECTED_BY_HANDBRAKE | NX_WF_STEERABLE_INPUT;
wheel2 = AddWheelToActor(actor, &wheelDesc2);
return actor;
}
示例3: addParticle
void ParticleEmitter::addParticle()
{
if ((_iTailIndex == _iHeadIndex) && (_iParticleCount != 0)) // FIFO is full
{
removeParticle();
// Now there is a slot free
}
// Add a single-shape actor to the scene
NxActorDesc actorDesc;
NxBodyDesc bodyDesc;
NxSphereShapeDesc sphereDesc;
sphereDesc.radius = 1.0f;
sphereDesc.group = cParticleCollisionGroup; // this group does not collide with itself
actorDesc.shapes.pushBack(&sphereDesc);
actorDesc.body = &bodyDesc;
actorDesc.density = 10.0f;
actorDesc.globalPose.t = _vStartingPos;
NxActor* pNewActor = _pScene->createActor(actorDesc);
// Give it an initial linear velocity, scaled by _fStartingVelScale
NxVec3 vRandVec(NxReal(rand()*_fStartingVelScale), NxReal(rand()*_fStartingVelScale), NxReal(rand()*_fStartingVelScale));
pNewActor->setLinearVelocity(vRandVec);
// Turn off gravity for smoke
pNewActor->raiseBodyFlag(NX_BF_DISABLE_GRAVITY);
_aParticleArray[_iHeadIndex] = new Particle(pNewActor, _vThermoDynamicAcceleration);
_iHeadIndex = (_iHeadIndex+1) % ciMaxParticles;
++_iParticleCount;
}
示例4: updateVisualization
void PhysicsLib::updateVisualization(const VC3 &cameraPosition, float range, bool forceUpdate)
{
bool visualizeCollisionShapes = data->featureMap[PhysicsLib::VISUALIZE_COLLISION_SHAPES];
bool visualizeDynamic = data->featureMap[PhysicsLib::VISUALIZE_DYNAMIC];
bool visualizeStatic = data->featureMap[PhysicsLib::VISUALIZE_STATIC];
bool visualizeCollisionContacts = data->featureMap[PhysicsLib::VISUALIZE_COLLISION_CONTACTS];
bool visualizeFluids = data->featureMap[PhysicsLib::VISUALIZE_FLUIDS];
bool visualizeJoints = data->featureMap[PhysicsLib::VISUALIZE_JOINTS];
bool visualizeCCD = data->featureMap[PhysicsLib::VISUALIZE_CCD];
if (forceUpdate
|| visualizeCollisionShapes
|| visualizeDynamic
|| visualizeStatic
|| visualizeCollisionContacts
|| visualizeFluids
|| visualizeJoints
|| visualizeCCD)
{
// (do the update)
} else {
// do not unnecessarily do this stuff!
return;
}
float rangeSq = range * range;
int actorAmount = data->scene->getNbActors();
NxActor **actorArray = data->scene->getActors();
if(visualizeCollisionShapes || visualizeStatic || visualizeCollisionContacts)
data->sdk->setParameter(NX_VISUALIZE_COLLISION_SHAPES, 1);
else
data->sdk->setParameter(NX_VISUALIZE_COLLISION_SHAPES, 0);
if(visualizeDynamic)
data->sdk->setParameter(NX_VISUALIZE_BODY_MASS_AXES, 1);
else
data->sdk->setParameter(NX_VISUALIZE_BODY_MASS_AXES, 0);
data->sdk->setParameter(NX_VISUALIZE_CONTACT_NORMAL, visualizeCollisionContacts);
data->sdk->setParameter(NX_VISUALIZE_CONTACT_FORCE, visualizeCollisionContacts);
data->sdk->setParameter(NX_VISUALIZE_CONTACT_POINT, visualizeCollisionContacts);
data->sdk->setParameter(NX_VISUALIZE_COLLISION_SKELETONS, visualizeCCD);
for(int i = 0; i < actorAmount; ++i)
{
NxActor *actor = actorArray[i];
if(!actor)
continue;
NxVec3 nxpos = actor->getGlobalPosition();
VC3 pos(nxpos.x, nxpos.y, nxpos.z);
VC3 diff = (pos - cameraPosition);
diff.y = 0; // ignore height
bool inRange = false;
if (diff.GetSquareLength() < rangeSq)
inRange = true;
if(actor->isDynamic())
{
//if(visualizeDynamic && inRange)
if(visualizeDynamic)
actor->raiseBodyFlag(NX_BF_VISUALIZATION);
else
actor->clearBodyFlag(NX_BF_VISUALIZATION);
}
int shapeAmount = actor->getNbShapes();
NxShape *const*shapes = actor->getShapes();
while(shapeAmount--)
{
NxShape *shape = shapes[shapeAmount];
if(actor->isDynamic())
{
//if(visualizeCollisionShapes && inRange)
if(visualizeCollisionShapes)
shape->setFlag(NX_SF_VISUALIZATION, true);
else
shape->setFlag(NX_SF_VISUALIZATION, false);
}
else
{
if(visualizeStatic && !shape->isHeightField() && inRange)
shape->setFlag(NX_SF_VISUALIZATION, true);
else
shape->setFlag(NX_SF_VISUALIZATION, false);
}
}
}
}
示例5: createBody
//.........这里部分代码省略.........
NxMaterialDesc *entMat = createMaterialFromEntity(referenceObject);
material = world->getScene()->createMaterial(entMatNull);
material->loadFromDesc(*entMat);
result->setMaterial(material);
}else{
if (world->getDefaultMaterial())
{
result->setMaterial(world->getDefaultMaterial());
}
}
//////////////////////////////////////////////////////////////////////////
NxBoxShapeDesc boxShape;
if (creationFlags & E_OFC_DIMENSION )
{
boxShape.dimensions = pMath::getFrom(box_s)*0.5f;
}
boxShape.density = descr->density;
boxShape.materialIndex = result->getMaterial()->getMaterialIndex();
if (result->getSkinWidth()!=-1.0f)
boxShape.skinWidth = result->getSkinWidth();
actorDesc.shapes.pushBack(&boxShape);
//////////////////////////////////////////////////////////////////////////
//dynamic object ?
if (result->getFlags() & BF_Moving){
actorDesc.body = &bodyDesc;
}
else
actorDesc.body = NULL;
//////////////////////////////////////////////////////////////////////////
//set transformations
actorDesc.density = descr->density;
if (creationFlags & E_OFC_POSITION)
{
actorDesc.globalPose.t = pos;
}
if (creationFlags & E_OFC_POSITION)
{
actorDesc.globalPose.M = rot;
}
//////////////////////////////////////////////////////////////////////////
//create the actor
int v = actorDesc.isValid();
NxActor *actor = world->getScene()->createActor(actorDesc);
if (!actor)
{
xLogger::xLog(ELOGERROR,E_LI_AGEIA,"Couldn't create actor");
delete result;
return NULL;
}
//////////////////////////////////////////////////////////////////////////
//set additional settings :
result->setActor(actor);
actor->setName(referenceObject->GetName());
actor->userData= result;
if (result->getFlags() & BF_Moving)
{
VxVector massOffsetOut;referenceObject->Transform(&massOffsetOut,&result->getMassOffset());
actor->setCMassOffsetGlobalPosition(pMath::getFrom(massOffsetOut));
}
if (result->getFlags() & BF_Kinematic)
{
actor->raiseBodyFlag(NX_BF_KINEMATIC);
}
result->enableCollision((result->getFlags() & BF_Collision));
if (result->getFlags() & BF_Moving)
{
if (!(result->getFlags() & BF_Gravity))
{
actor->raiseBodyFlag(NX_BF_DISABLE_GRAVITY);
}
}
NxShape *shape = result->getShapeByIndex();
if (shape)
{
pSubMeshInfo *sInfo = new pSubMeshInfo();
sInfo->entID = referenceObject->GetID();
sInfo->refObject = (CKBeObject*)referenceObject;
shape->userData = (void*)sInfo;
result->setMainShape(shape);
shape->setName(referenceObject->GetName());
}
}
return result;
}