当前位置: 首页>>代码示例>>C++>>正文


C++ NxMaterial::setFrictionCombineMode方法代码示例

本文整理汇总了C++中NxMaterial::setFrictionCombineMode方法的典型用法代码示例。如果您正苦于以下问题:C++ NxMaterial::setFrictionCombineMode方法的具体用法?C++ NxMaterial::setFrictionCombineMode怎么用?C++ NxMaterial::setFrictionCombineMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NxMaterial的用法示例。


在下文中一共展示了NxMaterial::setFrictionCombineMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadScene

void Vehicle::loadScene(const std::string &fileName)
{

	//车的父节点
	mBaseCarNode			= mSceneMgr->getRootSceneNode()->createChildSceneNode(fileName + "BaseCarNode");

	//DotSceneLoader* dsl = new DotSceneLoader();//rel
	//dsl->parseDotScene(fileName + ".scene", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, mSceneMgr, mBaseCarNode);

	mVehicleRenderable = new VehicleRenderable(mSceneMgr, mBaseCarNode);
	mVehicleRenderable->load(fileName + ".vrf");

	//车身节点
	mBodyNode				= static_cast<Ogre::SceneNode*>(mBaseCarNode->getChild(fileName + "Body"));

	//轮子节点
	mWheels[TOP_LEFT].mSceneNode	= static_cast<Ogre::SceneNode*>(mBaseCarNode->getChild(fileName + "LTWheel"));
	mWheels[TOP_LEFT].mName			= fileName + "LTWheel";

	mWheels[TOP_RIGHT].mSceneNode	= static_cast<Ogre::SceneNode*>(mBaseCarNode->getChild(fileName + "RTWheel"));
	mWheels[TOP_RIGHT].mName		= fileName + "RTWheel";

	mWheels[Bottom_LEFT].mSceneNode	= static_cast<Ogre::SceneNode*>(mBaseCarNode->getChild(fileName + "LBWheel"));
	mWheels[Bottom_LEFT].mName		= fileName + "LBWheel";

	mWheels[Bottom_RIGHT].mSceneNode  = static_cast<Ogre::SceneNode*> (mBaseCarNode->getChild(fileName + "RBWheel"));
	mWheels[Bottom_RIGHT].mName		  = fileName + "RBWheel";

	//设置整体参数
	NxBodyDesc bodyDes;
	//bodyDes.wakeUpCounter	= 1E8;
	bodyDes.mass			= 12000;//mVehicleInfo.gMass;
	//bodyDes.massLocalPose.t	= NxVec3(mVehicleInfo.gMassLocalPose.x, mVehicleInfo.gMassLocalPose.y, mVehicleInfo.gMassLocalPose.z);

	bodyDes.angularDamping	= 0.03f;
	bodyDes.linearDamping	= 0.08f;

	//写入车身的shapeDesc
	mBoundingBox		= mBodyNode->getAttachedObject(0)->getBoundingBox();
	NxBoxShapeDesc boxDes;
	NxVec3 dimen		(mBoundingBox.getHalfSize().x, mBoundingBox.getHalfSize().y, mBoundingBox.getHalfSize().z);
	NxVec3 localPos		(mBodyNode->getPosition().x, mBodyNode->getPosition().y, mBodyNode->getPosition().z);

	////车身到轮子的距离
	//NxReal d1 = NxMath::abs(mBodyNode->getPosition().y - mWheels[0].mSceneNode->getPosition().y);
	////包围盒半径之和
	//NxReal d2 = mBoundingBox.getHalfSize().y + mWheels[0].mSceneNode->getAttachedObject(0)->getBoundingBox().getHalfSize().y;
	////判断轮子是否与车身的包围盒重叠
	//if(d1 < d2)
	//{
	//	//设置为最大适合高度
	//	dimen.y = (mBoundingBox.getSize().y - (d2 - d1)) / 2.0f;
	//}
	boxDes.dimensions.set(dimen);
	boxDes.localPose.t	= localPos;

	NxActorDesc actorDesc;
	actorDesc.body			= &bodyDes;
	actorDesc.globalPose.t	= NxVec3(mOriginalPos.x, mOriginalPos.y, mOriginalPos.z);
	NxQuat quat;
	quat.setWXYZ(mOriginalQuat.w, mOriginalQuat.x, mOriginalQuat.y, mOriginalQuat.z);
	actorDesc.globalPose.M.fromQuat(quat);
	actorDesc.shapes.pushBack(&boxDes);
	mActor		= mNxScene->createActor(actorDesc);
	mActor->setCMassOffsetLocalPosition(NxVec3(0, -mBoundingBox.getSize().y, 0));
	mBodyShape  = static_cast<NxBoxShape*>(mActor->getShapes()[0]);

	//写入轮子的shapeDesc

	createWheelShapeDesc(&mWheels[TOP_LEFT], true);
	createWheelShapeDesc(&mWheels[TOP_RIGHT], true);
	createWheelShapeDesc(&mWheels[Bottom_LEFT], false);
	createWheelShapeDesc(&mWheels[Bottom_RIGHT], false);

	//mWheels[TOP_LEFT].mWheelDesc.localPose.t = NxVec3(mBoundingBox.getHalfSize().x, 2, 0);
	//mWheels[TOP_RIGHT].mWheelDesc.localPose.t = NxVec3(-mBoundingBox.getHalfSize().x, 2, 0);
	//mWheels[Bottom_LEFT].mWheelDesc.localPose.t = NxVec3(mBoundingBox.getHalfSize().x, -mBoundingBox.getHalfSize().y, 0);
	//mWheels[Bottom_RIGHT].mWheelDesc.localPose.t = NxVec3(-mBoundingBox.getHalfSize().x, -mBoundingBox.getHalfSize().y, 0);

	//创建轮子
	mWheels[TOP_LEFT].mWheel = static_cast<NxWheelShape*>(mActor->createShape(mWheels[TOP_LEFT].mWheelDesc));
	mWheels[TOP_RIGHT].mWheel = static_cast<NxWheelShape*>(mActor->createShape(mWheels[TOP_RIGHT].mWheelDesc));
	mWheels[Bottom_LEFT].mWheel	= static_cast<NxWheelShape*>(mActor->createShape(mWheels[Bottom_LEFT].mWheelDesc));
	mWheels[Bottom_RIGHT].mWheel = static_cast<NxWheelShape*>(mActor->createShape(mWheels[Bottom_RIGHT].mWheelDesc));

	NxMaterial* mat = mNxScene->getMaterialFromIndex(0);
	mat->setFrictionCombineMode(NX_CM_MULTIPLY);
	mat->setStaticFriction(300.2f);
	mat->setDynamicFriction(100.5f);
}
开发者ID:flair2005,项目名称:Racing-Game,代码行数:90,代码来源:Vehicle.cpp

示例2: GetPMan


//.........这里部分代码省略.........
	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



	//////////////////////////////////////////////////////////////////////////
	//there is no world settings attribute  : 
	/*
	if (!referenceObject->HasAttribute(GetPMan()->att_sleep_settings) )
	{
		referenceObject->SetAttribute(GetPMan()->att_sleep_settings);
		using namespace vtTools;
		AttributeTools::SetAttributeValue<int>(referenceObject,GetPMan()->att_sleep_settings,0,&sSettings->m_SleepSteps);
		AttributeTools::SetAttributeValue<float>(referenceObject,GetPMan()->att_sleep_settings,1,&sSettings->m_AngularThresold);
		AttributeTools::SetAttributeValue<float>(referenceObject,GetPMan()->att_sleep_settings,2,&sSettings->m_LinearThresold);
		AttributeTools::SetAttributeValue<int>(referenceObject,GetPMan()->att_sleep_settings,3,&sSettings->m_AutoSleepFlag);
	}	
	*/
	

	/*
	result->SleepingSettings(sSettings);
	//////////////////////////////////////////////////////////////////////////

	result->Reference(referenceObject);
	
	result->Init();
*/


	result->_checkForDominanceConstraints();
	result->_construct();






	return result;
	

	//return NULL;

}
开发者ID:gbaumgart,项目名称:vt,代码行数:101,代码来源:pFactoryWorld.cpp


注:本文中的NxMaterial::setFrictionCombineMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。