本文整理汇总了C++中NxActor::setLinearVelocity方法的典型用法代码示例。如果您正苦于以下问题:C++ NxActor::setLinearVelocity方法的具体用法?C++ NxActor::setLinearVelocity怎么用?C++ NxActor::setLinearVelocity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NxActor
的用法示例。
在下文中一共展示了NxActor::setLinearVelocity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KeyboardUpCallback
void KeyboardUpCallback(unsigned char key, int x, int y)
{
gKeys[key] = false;
switch (key)
{
case 'p': { bPause = !bPause;
if (bPause)
hud.SetDisplayString(2, "Paused - Hit \"p\" to Unpause", 0.3f, 0.55f);
else
hud.SetDisplayString(2, "", 0.0f, 0.0f);
break; }
case 'x': { bShadows = !bShadows; break; }
case 'b': { bDebugWireframeMode = !bDebugWireframeMode; break; }
case 'f': { bForceMode = !bForceMode; break; }
case 'o':
{
NxCloth** cloths = gScene->getCloths();
for (NxU32 i = 0; i < gScene->getNbCloths(); i++)
{
cloths[i]->setFlags(cloths[i]->getFlags() ^ NX_CLF_BENDING_ORTHO);
}
break;
}
case 'g':
{
NxCloth** cloths = gScene->getCloths();
for (NxU32 i = 0; i < gScene->getNbCloths(); i++)
{
cloths[i]->setFlags(cloths[i]->getFlags() ^ NX_CLF_GRAVITY);
}
break;
}
case 'y':
{
NxCloth** cloths = gScene->getCloths();
for (NxU32 i = 0; i < gScene->getNbCloths(); i++)
{
cloths[i]->setFlags(cloths[i]->getFlags() ^ NX_CLF_BENDING);
}
break;
}
case ' ':
{
NxActor* sphere = CreateSphere(gCameraPos, 1, 1);
sphere->setLinearVelocity(gCameraForward * 20);
break;
}
case 27 : { exit(0); break; }
default : { break; }
}
}
示例2: 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;
}
示例3: GetPMan
pRigidBody*pFactory::cloneRigidBody(CK3dEntity *src,CK3dEntity *dst,CKDependencies *deps,int copyFlags,int bodyFlags/* =0 */)
{
//src->Rest
pRigidBody *result = GetPMan()->getBody(dst);
pRigidBody *srcBody = GetPMan()->getBody(src);
CK3dEntity *referenceObject = dst;
XString errMsg;
pObjectDescr oDescr;
//----------------------------------------------------------------
//
// sanity checks
//
#ifdef _DEBUG
assert(src);
assert(dst);
#endif // _DEBUG
if (!(copyFlags & PB_CF_PHYSICS))
{
errMsg.Format("Nothing to copy, aborting");
xLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,errMsg.Str());
return NULL;
}
//iAssertW(!result,"","Object :%s already physicalized");
//----------------------------------------------------------------
//
// fill object description
//
if (!result && IParameter::Instance()->copyTo(oDescr,src,copyFlags))
{
pWorld *world = GetPMan()->getWorld(oDescr.worlReference) ? GetPMan()->getWorld(oDescr.worlReference) : GetPMan()->getDefaultWorld();
if(world)
{
if ( (copyFlags && PB_CF_OVRRIDE_BODY_FLAGS) )
oDescr.flags = (BodyFlags)bodyFlags;
//now create the final rigid body :
result = pFactory::Instance()->createRigidBody(dst,oDescr);
}
}
if (!result){
xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,"cloning failed");
return NULL;
}
//----------------------------------------------------------------
//
// clone joints
//
if ( (copyFlags & PB_CF_JOINTS) )
{
pFactory::cloneJoints(src,dst,copyFlags);
}
//----------------------------------------------------------------
//
// copy velocities
//
if ( (copyFlags & PB_CF_VELOCITIES) )
{
NxActor *actorSrc = srcBody->getActor();
NxActor *actorDst = result->getActor();
actorDst->setLinearVelocity( actorSrc->getLinearVelocity() );
actorDst->setAngularVelocity( actorSrc->getAngularVelocity() );
}
//----------------------------------------------------------------
//
// copy forces
//
if ( (copyFlags & PB_CF_FORCE) )
{
NxActor *actorSrc = srcBody->getActor();
NxActor *actorDst = result->getActor();
actorDst->setLinearMomentum( actorSrc->getLinearMomentum() );
actorDst->setAngularMomentum( actorSrc->getAngularMomentum() );
}
//----------------------------------------------------------------
//
// copy sub shapes if :
//
// "Copy Children In Dependencies" &&
// ( copyFlags::OverrideBodyFlags & hierarchy && newBodyFlags & hierarchy ) ||
// ( oldBodyFlags & hierarchy )
if ( ((*deps->At(CKCID_3DENTITY)) & CK_DEPENDENCIES_COPY_3DENTITY_CHILDREN) &&
( (( copyFlags & PB_CF_OVRRIDE_BODY_FLAGS ) && (bodyFlags & BF_Hierarchy)) ||
( oDescr.flags & BF_Hierarchy) )
)
{
int dCount = dst->GetChildrenCount();
CK3dEntity* subEntity = NULL;
//.........这里部分代码省略.........