本文整理汇总了C++中NxMaterial::loadFromDesc方法的典型用法代码示例。如果您正苦于以下问题:C++ NxMaterial::loadFromDesc方法的具体用法?C++ NxMaterial::loadFromDesc怎么用?C++ NxMaterial::loadFromDesc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NxMaterial
的用法示例。
在下文中一共展示了NxMaterial::loadFromDesc方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitNx
void InitNx()
{
// Create a memory allocator
gAllocator = new UserAllocator;
// Create the physics SDK
gPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, gAllocator);
if (!gPhysicsSDK) return;
// Set the physics parameters
gPhysicsSDK->setParameter(NX_SKIN_WIDTH, 0.01);
// Set the debug visualization parameters
gPhysicsSDK->setParameter(NX_VISUALIZATION_SCALE, 1);
gPhysicsSDK->setParameter(NX_VISUALIZE_COLLISION_SHAPES, 1);
gPhysicsSDK->setParameter(NX_VISUALIZE_ACTOR_AXES, 1);
//gPhysicsSDK->setParameter(NX_VISUALIZE_CLOTH_COLLISIONS, 1);
gPhysicsSDK->setParameter(NX_VISUALIZE_CLOTH_SLEEP, 1);
// Check available hardware
NxHWVersion hwCheck = gPhysicsSDK->getHWVersion();
if (hwCheck == NX_HW_VERSION_NONE)
{
gHardwareCloth = false;
}
else
gHardwareCloth = true;
// Create the scenes
NxSceneDesc sceneDesc;
sceneDesc.gravity = gDefaultGravity;
sceneDesc.simType = NX_SIMULATION_HW;
gScene = gPhysicsSDK->createScene(sceneDesc);
if(!gScene){
sceneDesc.simType = NX_SIMULATION_SW;
gScene = gPhysicsSDK->createScene(sceneDesc);
if(!gScene) return;
}
// Create the default material
NxMaterialDesc m;
m.restitution = 0.5;
m.staticFriction = 0.2;
m.dynamicFriction = 0.2;
NxMaterial* mat = gScene->getMaterialFromIndex(0);
mat->loadFromDesc(m);
SetupTearingScene();
if (gScene->getNbActors() > 0)
gSelectedActor = *gScene->getActors();
else
gSelectedActor = NULL;
// Initialize HUD
InitializeHUD();
InitializeSpecialHUD();
}
示例2: InitNx
void InitNx()
{
// Create the physics SDK
gPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, NULL, &gErrorStream);
if (!gPhysicsSDK) return;
// Set the physics parameters
gPhysicsSDK->setParameter(NX_SKIN_WIDTH, 0.05);
// Set the debug visualization parameters
gPhysicsSDK->setParameter(NX_VISUALIZATION_SCALE, 1);
gPhysicsSDK->setParameter(NX_VISUALIZE_ACTOR_AXES, 1);
gPhysicsSDK->setParameter(NX_VISUALIZE_COLLISION_SHAPES, 1);
// gPhysicsSDK->setParameter(NX_VISUALIZE_COLLISION_AXES, 1);
// gPhysicsSDK->setParameter(NX_VISUALIZE_COLLISION_FNORMALS, 1);
gPhysicsSDK->setParameter(NX_VISUALIZE_CONTACT_POINT, 1);
gPhysicsSDK->setParameter(NX_VISUALIZE_CONTACT_NORMAL, 1);
// Create the scene
NxSceneDesc sceneDesc;
sceneDesc.gravity = gDefaultGravity;
sceneDesc.simType = NX_SIMULATION_HW;
gScene = gPhysicsSDK->createScene(sceneDesc);
if(!gScene){
sceneDesc.simType = NX_SIMULATION_SW;
gScene = gPhysicsSDK->createScene(sceneDesc);
if(!gScene) return;
}
NxU32 set = 0;
#ifdef WIN32
set = SetCurrentDirectory(&fname[0]);
if (!set) set = SetCurrentDirectory(&fname1[0]);
if (!set)
{
char basePath[256];
GetModuleFileName(NULL, basePath, 256);
char* pTmp = strrchr(basePath, '\\');
basePath[pTmp-basePath+1] = 0;
SetCurrentDirectory(basePath);//for running from start menu
set = SetCurrentDirectory(&fname2[0]);
}
if (!set) set = SetCurrentDirectory(&fname3[0]);
#elif LINUX
set = chdir(&fname[0]);
if (set != 0) set = chdir(&fname2[0]);
if (set != 0) set = chdir(&fname3[0]);
#endif
// Create the default material
NxMaterialDesc defaultMaterial;
defaultMaterial.restitution = 0;
defaultMaterial.staticFriction = 0.5;
defaultMaterial.dynamicFriction = 0.5;
NxMaterial* m = gScene->getMaterialFromIndex(0);
m->loadFromDesc(defaultMaterial);
char buffer[512];
FindMediaFile("Course.pml", buffer);
nxmlLoadScene(buffer, gPhysicsSDK, gScene);
// Switch from Max Coordinate System to
// Training Program Coordinate System
NxMat34 mat;
NxMat33 orient;
orient.setColumn(0, NxVec3(-1,0,0));
orient.setColumn(1, NxVec3(0,0,1));
orient.setColumn(2, NxVec3(0,1,0));
mat.M = orient;
SwitchCoordinateSystem(gScene, mat);
// Reset wheel material
wsm = NULL;
// Create the trike actor
trike = CreateTrike(NxVec3(0,3,0));
trike->wakeUp(1e30);
AddUserDataToActors(gScene);
gSelectedActor = trike;
// Initialize HUD
InitializeHUD();
InitializeSpecialHUD();
// Get the current time
getElapsedTime();
// Start the first frame of the simulation
if (gScene) StartPhysics();
}
示例3: createBody
pRigidBody*pFactory::createBox(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject,pObjectDescr*descr,int creationFlags)
{
pWorld *world=getManager()->getWorld(worldReferenceObject,referenceObject);
pRigidBody*result = world->getBody(referenceObject);
if(result)
{
result->destroy();
delete result;
result = NULL;
}
// we create our final body in the given world :
result = createBody(referenceObject,worldReferenceObject);
if (result)
{
result->setWorld(world);
using namespace vtTools::AttributeTools;
result->setFlags(descr->flags);
result->setHullType(descr->hullType);
result->setDataFlags(0x000);
result->checkDataFlags();
if (result->getSkinWidth()==-1.0f)
{
result->setSkinWidth(0.01f);
}
VxMatrix v_matrix ;
VxVector position,scale;
VxQuaternion quat;
v_matrix = referenceObject->GetWorldMatrix();
Vx3DDecomposeMatrix(v_matrix,quat,position,scale);
VxVector box_s= BoxGetZero(referenceObject);
NxVec3 pos = pMath::getFrom(position);
NxQuat rot = pMath::getFrom(quat);
float density = result->getDensity();
float radius = referenceObject->GetRadius();
if (referenceObject->GetRadius() < 0.001f )
{
radius = 1.0f;
}
//////////////////////////////////////////////////////////////////////////
//create actors description
NxActorDesc actorDesc;actorDesc.setToDefault();
NxBodyDesc bodyDesc;bodyDesc.setToDefault();
//////////////////////////////////////////////////////////////////////////
NxMaterialDesc *materialDescr = NULL;
NxMaterial *material = NULL;
if (isFlagOn(result->getDataFlags(),EDF_MATERIAL_PARAMETER))
{
NxMaterialDesc entMatNull;entMatNull.setToDefault();
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;
}
//.........这里部分代码省略.........
示例4: GetPMan
//.........这里部分代码省略.........
return NULL;
}
}
result->setScene(scene);
scene->setUserContactReport(result->contactReport);
scene->setUserTriggerReport(result->triggerReport);
NxMaterialDesc *materialDescr = NULL;
NxMaterial *material = NULL;
if (referenceObject->HasAttribute(surfaceAttribute))
{
materialDescr = createMaterialFromEntity(referenceObject);
material = result->getScene()->createMaterial(*materialDescr);
material->userData = (void*)GetValueFromParameterStruct<int>(referenceObject->GetAttributeParameter(surfaceAttribute) ,E_MS_XML_TYPE);
}else{
if (getDefaultDocument())
{
materialDescr = createMaterialFromXML("Default",getDefaultDocument());
}
if (materialDescr)
{
material = result->getScene()->createMaterial(*materialDescr);
}
if (!material)
{
materialDescr = new NxMaterialDesc();
materialDescr->setToDefault();
material = result->getScene()->getMaterialFromIndex(0);
material->loadFromDesc(*materialDescr);
}
}
int z = (int)material->userData;
NxMaterial *zeroMaterial = result->getScene()->getMaterialFromIndex(0);
zeroMaterial->setDirOfAnisotropy(material->getDirOfAnisotropy());
zeroMaterial->setStaticFriction(material->getStaticFriction());
zeroMaterial->setDynamicFriction(material->getDynamicFriction());
zeroMaterial->setStaticFrictionV(material->getStaticFrictionV());
zeroMaterial->setDynamicFrictionV(material->getDynamicFrictionV());
zeroMaterial->setFrictionCombineMode(material->getFrictionCombineMode());
zeroMaterial->setRestitutionCombineMode(material->getRestitutionCombineMode());
zeroMaterial->setFlags(material->getFlags());
zeroMaterial->userData = material->userData;
if (!material)
{
xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,"Couldn't create default material!");
}
result->setDefaultMaterial(material);
scene->userData = result;
//NxConstraintDominance testDom(1.0, 1.0f);
//result->getScene()->setDominanceGroupPair(1, 2,testDom ); //board - debris