本文整理汇总了C++中NxMaterial::getRestitution方法的典型用法代码示例。如果您正苦于以下问题:C++ NxMaterial::getRestitution方法的具体用法?C++ NxMaterial::getRestitution怎么用?C++ NxMaterial::getRestitution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NxMaterial
的用法示例。
在下文中一共展示了NxMaterial::getRestitution方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetScene
NxScene* plSimulationMgr::GetScene(plKey world)
{
if (!world)
world = GetKey();
NxScene* scene = fScenes[world];
if (!scene)
{
NxSceneDesc sceneDesc;
sceneDesc.gravity.set(0, 0, -32.174049f);
sceneDesc.userTriggerReport = &gSensorReport;
sceneDesc.userContactReport = &gContactReport;
scene = fSDK->createScene(sceneDesc);
// See "Advancing The Simulation State" in the PhysX SDK Documentation
// This will cause PhysX to only update for our step size. If we call simulate
// faster than that, PhysX will return immediately. If we call it slower than that,
// PhysX will do some extra steps for us (isn't that nice?).
// Anyway, this should be a good way to make us independent of the framerate.
// If not, I blame the usual suspects (Tye, eap, etc...)
scene->setTiming(kDefaultStepSize);
// Most physicals use the default friction and restitution values, so we
// make them the default.
NxMaterial* mat = scene->getMaterialFromIndex(0);
float rest = mat->getRestitution();
float sfriction = mat->getStaticFriction();
float dfriction = mat->getDynamicFriction();
mat->setRestitution(0.5);
mat->setStaticFriction(0.5);
mat->setDynamicFriction(0.5);
// By default we just leave all the collision groups enabled, since
// PhysX already makes sure that things like statics and statics don't
// collide. However, we do make it so the avatar and dynamic blockers
// only block avatars and dynamics.
for (int i = 0; i < plSimDefs::kGroupMax; i++)
{
scene->setGroupCollisionFlag(i, plSimDefs::kGroupAvatarBlocker, false);
scene->setGroupCollisionFlag(i, plSimDefs::kGroupDynamicBlocker, false);
scene->setGroupCollisionFlag(i, plSimDefs::kGroupLOSOnly, false);
scene->setGroupCollisionFlag(plSimDefs::kGroupLOSOnly, i, false);
}
scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupAvatar, false);
scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupAvatarBlocker, true);
scene->setGroupCollisionFlag(plSimDefs::kGroupDynamic, plSimDefs::kGroupDynamicBlocker, true);
scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupStatic, true);
scene->setGroupCollisionFlag( plSimDefs::kGroupStatic, plSimDefs::kGroupAvatar, true);
scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupDynamic, true);
// The dynamics are in actor group 1, everything else is in 0. Request
// a callback for whenever a dynamic touches something.
scene->setActorGroupPairFlags(0, 1, NX_NOTIFY_ON_TOUCH);
scene->setActorGroupPairFlags(1, 1, NX_NOTIFY_ON_TOUCH);
fScenes[world] = scene;
}
return scene;
}
示例2: PMaterialIterator
int PMaterialIterator(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
if (beh->IsInputActive(0))
{
beh->ActivateInput(0,FALSE);
//////////////////////////////////////////////////////////////////////////
//we reset our session counter
int sessionIndex=-1;
beh->SetOutputParameterValue(0,&sessionIndex);
LMaterials*sResults = NULL;
beh->GetLocalParameterValue(0,&sResults);
if (!sResults)
{
sResults = new LMaterials();
}else
sResults->clear();
NxScene * scene = GetPMan()->getDefaultWorld()->getScene();
for(int i = 0 ; i < GetPMan()->getDefaultWorld()->getScene()->getNbMaterials() ; i ++)
{
NxMaterial *currentMaterial = scene->getMaterialFromIndex(i);
sResults->push_back(currentMaterial);
}
beh->SetLocalParameterValue(0,&sResults);
if (sResults->size())
{
beh->ActivateInput(1);
}else
{
beh->ActivateOutput(0);
return 0;
}
}
if( beh->IsInputActive(1) )
{
beh->ActivateInput(1,FALSE);
int currentIndex=0; CKParameterOut *pout = beh->GetOutputParameter(0); pout->GetValue(¤tIndex);
currentIndex++;
LMaterials *sResults = NULL; beh->GetLocalParameterValue(0,&sResults);
if (!sResults) { beh->ActivateOutput(0); return 0; }
if (currentIndex>=sResults->size())
{
sResults->clear();
beh->ActivateOutput(0);
return 0;
}
NxMaterial * material = sResults->at(currentIndex);
if (material!=NULL)
{
int sIndex = currentIndex+1;
beh->SetOutputParameterValue(0,&sIndex);
//SetOutputParameterValue<int>(beh,O_XML,material->xmlLinkID);
SetOutputParameterValue<float>(beh,O_DFRICTION,material->getDynamicFriction());
SetOutputParameterValue<float>(beh,O_SFRICTION,material->getStaticFriction());
SetOutputParameterValue<float>(beh,O_RES,material->getRestitution());
SetOutputParameterValue<float>(beh,O_DFRICTIONV,material->getDynamicFrictionV());
SetOutputParameterValue<float>(beh,O_SFRICTIONV,material->getStaticFrictionV());
SetOutputParameterValue<VxVector>(beh,O_ANIS,getFrom(material->getDirOfAnisotropy()));
SetOutputParameterValue<int>(beh,O_FCMODE,material->getFrictionCombineMode());
SetOutputParameterValue<int>(beh,O_RCMODE,material->getFrictionCombineMode());
SetOutputParameterValue<int>(beh,O_FLAGS,material->getFlags());
}
//.........这里部分代码省略.........
示例3: Write
void plPXPhysical::Write(hsStream* stream, hsResMgr* mgr)
{
plPhysical::Write(stream, mgr);
hsAssert(fActor, "nil actor");
hsAssert(fActor->getNbShapes() == 1, "Can only write actors with one shape. Writing first only.");
NxShape* shape = fActor->getShapes()[0];
NxMaterialIndex matIdx = shape->getMaterial();
NxScene* scene = plSimulationMgr::GetInstance()->GetScene(fWorldKey);
NxMaterial* mat = scene->getMaterialFromIndex(matIdx);
float friction = mat->getStaticFriction();
float restitution = mat->getRestitution();
stream->WriteLEScalar(fActor->getMass());
stream->WriteLEScalar(friction);
stream->WriteLEScalar(restitution);
stream->WriteByte(fBoundsType);
stream->WriteByte(fGroup);
stream->WriteLE32(fReportsOn);
stream->WriteLE16(fLOSDBs);
mgr->WriteKey(stream, fObjectKey);
mgr->WriteKey(stream, fSceneNode);
mgr->WriteKey(stream, fWorldKey);
mgr->WriteKey(stream, fSndGroup);
hsPoint3 pos;
hsQuat rot;
IGetPositionSim(pos);
IGetRotationSim(rot);
pos.Write(stream);
rot.Write(stream);
fProps.Write(stream);
if (fBoundsType == plSimDefs::kSphereBounds)
{
const NxSphereShape* sphereShape = shape->isSphere();
stream->WriteLEScalar(sphereShape->getRadius());
hsPoint3 localPos = plPXConvert::Point(sphereShape->getLocalPosition());
localPos.Write(stream);
}
else if (fBoundsType == plSimDefs::kBoxBounds)
{
const NxBoxShape* boxShape = shape->isBox();
hsPoint3 dim = plPXConvert::Point(boxShape->getDimensions());
dim.Write(stream);
hsPoint3 localPos = plPXConvert::Point(boxShape->getLocalPosition());
localPos.Write(stream);
}
else
{
if (fBoundsType == plSimDefs::kHullBounds)
hsAssert(shape->isConvexMesh(), "Hull shape isn't a convex mesh");
else
hsAssert(shape->isTriangleMesh(), "Exact shape isn't a trimesh");
// We hide the stream we used to create this mesh away in the shape user data.
// Pull it out and write it to disk.
hsVectorStream* vecStream = (hsVectorStream*)shape->userData;
stream->Write(vecStream->GetEOF(), vecStream->GetData());
delete vecStream;
}
}
示例4: GetRestitution
/// Retrieves the coefficient of restitution.
virtual Scalar GetRestitution () const { return m_pNxMaterial->getRestitution(); }