本文整理汇总了C++中NxShape::setMaterial方法的典型用法代码示例。如果您正苦于以下问题:C++ NxShape::setMaterial方法的具体用法?C++ NxShape::setMaterial怎么用?C++ NxShape::setMaterial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NxShape
的用法示例。
在下文中一共展示了NxShape::setMaterial方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
}
//----------------------------------------------------------------
//
// Collision
//
if ((oDescr.mask & OD_Collision))
result->updateCollisionSettings(oDescr.collision,referenceObject);
else if(pFactory::Instance()->findSettings(oDescr.collision,referenceObject))
result->updateCollisionSettings(oDescr.collision,referenceObject);
//----------------------------------------------------------------
//
// Material
//
NxMaterialDesc *materialDescr = NULL;
NxMaterial *material = NULL;
pMaterial &bMaterial = oDescr.material;
if (oDescr.mask & OD_Material)
{
result->updateMaterialSettings(bMaterial,referenceObject);
}else
{
bool hasMaterial = pFactory::Instance()->findSettings(bMaterial,referenceObject);
if (!hasMaterial)
{
if (world->getDefaultMaterial())
{
int z = (int)world->getDefaultMaterial()->userData;
shape->setMaterial(world->getDefaultMaterial()->getMaterialIndex());
}
}else{
iAssertW( bMaterial.isValid(),bMaterial.setToDefault(),
"Material settings were still invalid : ");
NxMaterialDesc nxMatDescr;
pFactory::Instance()->copyTo(nxMatDescr,bMaterial);
NxMaterial *nxMaterial = world->getScene()->createMaterial(nxMatDescr);
if (nxMaterial)
{
shape->setMaterial(nxMaterial->getMaterialIndex());
}
}
}
xLogger::xLog(ELOGINFO,E_LI_MANAGER,"Rigid body creation successful : %s",referenceObject->GetName());
result->setInitialDescription(&oDescr);
//----------------------------------------------------------------
//
// Hierarchy mode fix :
//
if ( (oDescr.flags & BF_Hierarchy) )
oDescr.hirarchy = true;
if ( oDescr.hirarchy )
oDescr.flags << BF_Hierarchy;
示例2: Init
//.........这里部分代码省略.........
if (fGroup == plSimDefs::kGroupDynamic)
{
// handle the animated physicals.... make kinematic for now.
fNumberAnimatedPhysicals++;
bodyDesc.flags |= NX_BF_KINEMATIC;
startAsleep = true;
}
else
{
// handle the animated activators....
fNumberAnimatedActivators++;
bodyDesc.flags |= NX_BF_KINEMATIC;
startAsleep = true;
}
}
}
else
{
if ( GetProperty(plSimulationInterface::kPhysAnim) )
SimLog("An animated physical that has no mass: %s", GetKeyName().c_str());
}
actorDesc.userData = this;
actorDesc.name = GetKeyName().c_str();
// Put the dynamics into actor group 1. The actor groups are only used for
// deciding who we get contact reports for.
if (fGroup == plSimDefs::kGroupDynamic)
actorDesc.group = 1;
NxScene* scene = plSimulationMgr::GetInstance()->GetScene(fWorldKey);
try
{
fActor = scene->createActor(actorDesc);
} catch (...)
{
hsAssert(false, "Actor creation crashed");
return false;
}
hsAssert(fActor, "Actor creation failed");
if (!fActor)
return false;
NxShape* shape = fActor->getShapes()[0];
shape->setMaterial(plSimulationMgr::GetInstance()->GetMaterialIdx(scene, recipe.friction, recipe.restitution));
// Turn on the trigger flags for any detectors.
//
// Normally, we'd set these flags on the shape before it's created. However,
// in the case where the detector is going to be animated, it'll have a rigid
// body too, and that will cause problems at creation. According to Ageia,
// a detector shape doesn't actually count as a shape, so the SDK will have
// problems trying to calculate an intertial tensor. By letting it be
// created as a normal dynamic first, then setting the flags, we work around
// that problem.
if (fGroup == plSimDefs::kGroupDetector)
{
shape->setFlag(NX_TRIGGER_ON_ENTER, true);
shape->setFlag(NX_TRIGGER_ON_LEAVE, true);
}
if (GetProperty(plSimulationInterface::kStartInactive) || startAsleep)
{
if (!fActor->isSleeping())
{
if (plSimulationMgr::fExtraProfile)
SimLog("Deactivating %s in SetPositionAndRotationSim", GetKeyName().c_str());
fActor->putToSleep();
}
}
if (GetProperty(plSimulationInterface::kDisable))
IEnable(false);
if (GetProperty(plSimulationInterface::kSuppressed_DEAD))
IEnable(false);
plNodeRefMsg* refMsg = new plNodeRefMsg(fSceneNode, plRefMsg::kOnCreate, -1, plNodeRefMsg::kPhysical);
hsgResMgr::ResMgr()->AddViaNotify(GetKey(), refMsg, plRefFlags::kActiveRef);
if (fWorldKey)
{
plGenRefMsg* ref = new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, 0, kPhysRefWorld);
hsgResMgr::ResMgr()->AddViaNotify(fWorldKey, ref, plRefFlags::kActiveRef);
}
// only dynamic physicals without noSync need SDLs
if ( fGroup == plSimDefs::kGroupDynamic && !fProps.IsBitSet(plSimulationInterface::kNoSynchronize) )
{
// add SDL modifier
plSceneObject* sceneObj = plSceneObject::ConvertNoRef(fObjectKey->ObjectIsLoaded());
hsAssert(sceneObj, "nil sceneObject, failed to create and attach SDL modifier");
delete fSDLMod;
fSDLMod = new plPhysicalSDLModifier;
sceneObj->AddModifier(fSDLMod);
}
return true;
}
示例3: createBody
//.........这里部分代码省略.........
//----------------------------------------------------------------
//
// Special Parameters
//
//- look for optimization attribute :
result->checkForOptimization();
//----------------------------------------------------------------
//
// store mesh meta info in the first main mesh
//
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());
pMaterial bMaterial;
bool hasMaterial = pFactory::Instance()->findSettings(bMaterial,referenceObject);
if (!hasMaterial)
{
if (world->getDefaultMaterial())
{
int z = (int)world->getDefaultMaterial()->userData;
shape->setMaterial(world->getDefaultMaterial()->getMaterialIndex());
//pFactory::Instance()->copyTo(bMaterial,world->getDefaultMaterial());
}
}else{
NxMaterialDesc nxMatDescr;
pFactory::Instance()->copyTo(nxMatDescr,bMaterial);
NxMaterial *nxMaterial = world->getScene()->createMaterial(nxMatDescr);
if (nxMaterial)
{
shape->setMaterial(nxMaterial->getMaterialIndex());
}
}
}
result->enableCollision( (result->getFlags() & BF_Collision), referenceObject );
//- handle collisions setup
if (oDescr->version == pObjectDescr::E_OD_VERSION::OD_DECR_V1)
result->updateCollisionSettings(*oDescr,referenceObject);
xLogger::xLog(ELOGINFO,E_LI_MANAGER,"Rigid body creation successful : %s",referenceObject->GetName());
//----------------------------------------------------------------
//
// Parse hierarchy
//
if (!oDescr->hirarchy)