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


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

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


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

示例1:

//-----------------------------------------------------------------------------
//  InitScene
//-----------------------------------------------------------------------------
bool    CPhysicScene::InitScene (const TInitInfo& initInfo)
{
    // Create the scene
    m_pScene = CPhysicEngine::Ref().GetNxPhysicsSDK()->createScene (initInfo.nxInfo);
    if ( m_pScene == NULL ) return false;

    // Editar las propiedades del material por defecto
    NxMaterial* defaultMaterial = m_pScene->getMaterialFromIndex(0); 
    defaultMaterial->setRestitution (0.0f);
    defaultMaterial->setStaticFriction (0.5f);
    defaultMaterial->setDynamicFriction (0.4f);

    // CreateBox (NxVec3(0,0,0), NxVec3(10, 10, 10), 1);
    
    // Configuramos callback collisiones
	//!!
    m_pScene->setUserContactReport(this);
	m_pScene->setUserTriggerReport(this);
	m_pCollisionMng = initInfo.pCollisionMng;

    // Inicializar gestor de agua
    CPhysicWaterMgr::TInitInfo  initWaterInfo;
    initWaterInfo.pScene = this;
    initWaterInfo.fWaterLevel = Globals::g_fWaterLevel;
    initWaterInfo.fWaterDensity = 4.f;
    initWaterInfo.fFrictionAngular = 10.f;
    initWaterInfo.fFrictionLinear = 5.f;
    m_WaterMgr.Init( initWaterInfo );

	// Comprobar si debemos activar el gestor de agua
	//!!
	m_bWaterMngEnabled = initInfo.bWaterMngEnabled;

    return true;
}
开发者ID:JOSE89,项目名称:DamnedSunset,代码行数:38,代码来源:PhysicScene.cpp

示例2: LoadScene

//-------------------------------------------------------------------------------------------------
bool sdPhysicsSystem::LoadScene(sdMap* pkMap)
{
	if (!m_bInitialized || !pkMap)
		return false;

	sdTerrain* pkTerrain = pkMap->GetTerrain();
	NIASSERT(pkTerrain);

	// 创建空白NxScene
	CreateEmptyScene(pkTerrain->GetTerrainSize());
	NIASSERT(m_pkScene);

	float fTimeStep = 1.f / 60.f;
	m_pkScene->setTiming(fTimeStep, 6, NX_TIMESTEP_FIXED);
	m_pkScene->setUserTriggerReport(m_pkUserTriggerReport);

	NxMaterial* pkDefaultMaterial = m_pkScene->getMaterialFromIndex(0);
	NIASSERT(pkDefaultMaterial);
	pkDefaultMaterial->setRestitution(0.1f);
	pkDefaultMaterial->setStaticFriction(0.5f);
	pkDefaultMaterial->setDynamicFriction(0.5f);

	// 加载地形数据到NxScene
	CreateTerrain(pkTerrain);

	// 加载预生成的物件数据到NxScene
	

	// 生成地形的边界
	CreateTerrainBound(pkTerrain);

	return true;
}
开发者ID:arundev,项目名称:dev-code,代码行数:34,代码来源:sdPhysicsSystem.cpp

示例3: InitNx

void InitNx()
{
    // Create the physics SDK
    gPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION);
    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_JOINT_LIMITS, 1);
	gPhysicsSDK->setParameter(NX_VISUALIZE_JOINT_LOCAL_AXES, 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;
	}

	// Create the default material
	NxMaterial* defaultMaterial = gScene->getMaterialFromIndex(0); 
	defaultMaterial->setRestitution(0.5);
	defaultMaterial->setStaticFriction(0.5);
	defaultMaterial->setDynamicFriction(0.5);

	// Create the objects in the scene
	CreateGroundPlane();

	capsule1 = CreateCapsule(NxVec3(0,5,0), 1, 0.5, 10);
	capsule1->raiseBodyFlag(NX_BF_KINEMATIC);
	capsule2 = CreateCapsule(NxVec3(0,3,0), 1, 0.5, 10);
//	capsule2->setLinearDamping(0.1);
    capsule2->raiseBodyFlag(NX_BF_DISABLE_GRAVITY);

	NxVec3 globalAnchor = NxVec3(0,5,0);
	NxVec3 globalAxis = NxVec3(0,1,0);
	d6Joint = CreateD6Joint(capsule1, capsule2, globalAnchor, globalAxis);

	gSelectedActor = capsule2;
	gForceStrength = 50000;
	gCameraSpeed = 10;

	// Initialize HUD
	InitializeHUD();
	InitializeSpecialHUD();

	// Get the current time
	getElapsedTime();

	// Start the first frame of the simulation
	if (gScene)  StartPhysics();
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:60,代码来源:Lesson211.cpp

示例4: PhysStart

void PhysStart ( void )
{
	gAllocator = new UserAllocator;
    gPhysicsSDK = NxCreatePhysicsSDK ( NX_PHYSICS_SDK_VERSION,gAllocator );

    if ( !gPhysicsSDK )
		return;

	gPhysicsSDK->setParameter ( NX_MIN_SEPARATION_FOR_PENALTY, -0.05f );

	gPhysicsSDK->setParameter ( NX_VISUALIZATION_SCALE,        1 );
	gPhysicsSDK->setParameter ( NX_VISUALIZE_COLLISION_SHAPES, 1 );
	gPhysicsSDK->setParameter ( NX_VISUALIZE_ACTOR_AXES,       1 );
	gPhysicsSDK->setParameter(NX_VISUALIZE_COLLISION_FNORMALS, 1);

    NxSceneDesc			sceneDesc;
    sceneDesc.gravity               = gDefaultGravity;
    sceneDesc.broadPhase            = NX_BROADPHASE_COHERENT;
    sceneDesc.collisionDetection    = true;
	sceneDesc.userContactReport		= carContactReport;
    gScene = gPhysicsSDK->createScene ( sceneDesc );

	NxMaterial* defaultMaterial = gScene->getMaterialFromIndex ( 0 );
	defaultMaterial->setRestitution     ( 0.0f );
	defaultMaterial->setStaticFriction  ( 0.5f );
	defaultMaterial->setDynamicFriction ( 0.5f );

	gPhysicsSDK->setActorGroupPairFlags(0, 0, NX_NOTIFY_ON_TOUCH);
}
开发者ID:Fliper12,项目名称:darkbasicpro,代码行数:29,代码来源:PhysXWrapper.cpp

示例5: initNx

bool initNx()
{
	NxSDKCreateError error;
	gPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, NULL, new ErrorStream(), NxPhysicsSDKDesc(), &error);
	if (gPhysicsSDK == NULL) {
		cout << "Physics SDK creation failed: " << PhysXUtils::getErrorString(error) << endl;
		return false;
	}

	gPhysicsSDK->setParameter(NX_SKIN_WIDTH, 0.2f); // 0.2 is the best I've tried

	NxSceneDesc sceneDesc;
	sceneDesc.gravity = NxVec3(0.0f, -9.81f, 0.0f);
	g_NxScene = gPhysicsSDK->createScene(sceneDesc);

	if (g_NxScene == NULL) {
		cout << "ERROR: unable to create PhysX scene" << endl;
		return false;
	}

	NxMaterial* defaultMaterial = g_NxScene->getMaterialFromIndex(0);
	defaultMaterial->setRestitution(0.0f);
	defaultMaterial->setStaticFriction(0.5f);
	defaultMaterial->setDynamicFriction(0.5f);

	NxPlaneShapeDesc planeDesc;
	NxActorDesc actorDesc;
	actorDesc.shapes.pushBack(&planeDesc);
	g_NxScene->createActor(actorDesc);

	return true;
}
开发者ID:piotrekjanisz,项目名称:master_thesis,代码行数:32,代码来源:main.cpp

示例6: exception

//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
PhysicsProcessor::PhysicsProcessor()
{
    NxPhysicsSDKDesc desc;
    NxSDKCreateError errorCode = NXCE_NO_ERROR;

    NxPhysicsSDK* pPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, NULL, NULL, desc, &errorCode);
    if( pPhysicsSDK == NULL )
    {
        throw std::exception("Exception: Cannot create PhysX SDK Pointer.");
    }
    this->m_pPhysicsSDK = pPhysicsSDK;

    this->m_pPhysicsSDK->setParameter(NX_SKIN_WIDTH, 0.025f);

    NxSceneDesc sceneDesc;
    sceneDesc.gravity = NxVec3(0.0f, -9.81f, 0.0f);

    NxScene* pScene = this->m_pPhysicsSDK->createScene(sceneDesc);
    if( pScene == NULL )
    {
        throw std::exception("Exception: Cannot create PhysX Scene Pointer.");
    }
    this->m_pScene = pScene;

    PhysicsActorFactory* pFactory = &PhysicsActorFactory::instance();

    pFactory->setScene(this->m_pScene);

    NxMaterial * defaultMaterial = this->m_pScene->getMaterialFromIndex(0); 
	defaultMaterial->setRestitution(0.0f);
	defaultMaterial->setStaticFriction(0.5f);
	defaultMaterial->setDynamicFriction(0.5f);
}
开发者ID:SgtFlame,项目名称:indiezen,代码行数:34,代码来源:PhysicsProcessor.cpp

示例7: CreateGroundPlane

	/**
	 * CreateGroundPlane(): Create Ground Plane
	 * @return
	 */
void CreateGroundPlane(){
	/*
	 *	Create Ground Plane
	 * Static Actor: has no 'NxBodyDesc'
	 */
	//actor Descriptor with Collection of Shapes.
	NxActorDesc	actorDesc;

	//Plane Shape Descriptor
	NxPlaneShapeDesc	planeDesc;
	//平面方程式: ax + by + cz + d = 0;
	planeDesc.normal = NxVec3(0, 1, 0);		//面の法線はY軸(↑)方向
	planeDesc.d = 0.0f;								//Y = 0.0fに面を作る

	actorDesc.shapes.pushBack( &planeDesc );	//ActorにPlaneを登録
	
	//NxScene Creates Actor and Returns a Pointer.
	NxActor* pActor = pScene->createActor( actorDesc);
	pActor->userData = NULL;		//PhysX上のActorと(ゲームなどの)データ上のActorを結びつける
	
	//Set the parameters for the Default Material
	//Physicsの"Material"とは目に見える表面材質ではなく,物体の物理学的特徴を表す
	NxMaterial* defaultMaterial = pScene->getMaterialFromIndex( 0 );
	defaultMaterial->setRestitution( 0.3f );			//反発係数
	defaultMaterial->setStaticFriction( 0.5f );		//静止摩擦係数
	defaultMaterial->setDynamicFriction( 0.5f );	//動摩擦係数
}
开发者ID:RozKen,项目名称:MicroToMacro,代码行数:31,代码来源:main+(DESK32's+conflicted+copy+2011-04-12).cpp

示例8: InitNx

void InitNx()
{
	// Create a memory allocator
    gAllocator = new UserAllocator;

    // Create the physics SDK
	gPhysicsSDK = CreatePhysics();

    // 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;
	}

	// Create the default material
	NxMaterial* defaultMaterial = gScene->getMaterialFromIndex(0); 
	defaultMaterial->setRestitution(0.5);
	defaultMaterial->setStaticFriction(0.5);
	defaultMaterial->setDynamicFriction(0.5);

    // Set Core Dump directory
	char buff[512];
	FindMediaFile(fnameCD, buff);
#ifdef WIN32
	SetCurrentDirectory(buff);
#elif LINUX
	chdir(buff);
#endif

	// Create the objects in the scene
	NxActor* groundPlane = CreateGroundPlane();

	NxActor* box = CreateBox(NxVec3(5,0,0), NxVec3(0.5,1,0.5), 20);
	NxActor* sphere = CreateSphere(NxVec3(0,0,0), 1, 10);
	NxActor* capsule = CreateCapsule(NxVec3(-5,0,0), 2, 0.5, 10);
//	pyramid = CreatePyramid(NxVec3(0,0,0), NxVec3(1,0.5,1.5), 10);

	AddUserDataToActors(gScene);

	gSelectedActor = capsule;
//	gSelectedActor = pyramid;

	// Initialize HUD
	InitializeHUD();

	// Get the current time
	getElapsedTime();

	// Start the first frame of the simulation
	if (gScene)  StartPhysics();
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:56,代码来源:Lesson503.cpp

示例9: 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, 2);
	gPhysicsSDK->setParameter(NX_VISUALIZE_COLLISION_SHAPES, 1);
	gPhysicsSDK->setParameter(NX_VISUALIZE_ACTOR_AXES, 1);
	gPhysicsSDK->setParameter(NX_VISUALIZE_JOINT_LIMITS, 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;
	}

	// Create the default material
	NxMaterial* defaultMaterial = gScene->getMaterialFromIndex(0); 
	defaultMaterial->setRestitution(0.5);
	defaultMaterial->setStaticFriction(0.5);
	defaultMaterial->setDynamicFriction(0.5);

	// Create the objects in the scene
	CreateGroundPlane();

	mainBox = CreateMainObject();

	gSelectedActor = mainBox;
	gCameraPos = NxVec3(0,15,-50);
	gCameraSpeed = 20;
    gForceStrength = 50000000;

	// Initialize HUD
	InitializeHUD();

	// Get the current time
	getElapsedTime();

	// Start the first frame of the simulation
	if (gScene)  StartPhysics();
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:54,代码来源:Lesson408.cpp

示例10: CreateScenario

bool CreateScenario()
{
	DestroyScenario();

	// Create the scene
	NxSceneDesc sceneDesc;
	sceneDesc.gravity = gDefaultGravity;
	sceneDesc.simType = bHWScene? NX_SIMULATION_HW : NX_SIMULATION_SW;
	gScene = gPhysicsSDK->createScene(sceneDesc);	
	if(0 == gScene)
	{ 
		bHWScene = !bHWScene;
		sceneDesc.simType = bHWScene? NX_SIMULATION_HW : NX_SIMULATION_SW;
		gScene = gPhysicsSDK->createScene(sceneDesc);  
		if(0 == gScene) return false;
	}

	// Create the default material
	NxMaterial* defaultMaterial = gScene->getMaterialFromIndex(0); 
	defaultMaterial->setRestitution(0.5);
	defaultMaterial->setStaticFriction(0.5);
	defaultMaterial->setDynamicFriction(0.5);

	// Create the plane in primary scene
	groundPlane = CreateGroundPlane();

	// Create compartment(HSM, managed hardware scene) attached to this scene
	NxCompartmentDesc desc;
	desc.type = NX_SCT_RIGIDBODY;
	desc.deviceCode = NxU32(NX_DC_PPU_0);
	gCompartmentHW = gScene->createCompartment(desc);

	desc.deviceCode = NxU32(NX_DC_CPU);
	gCompartmentSW = gScene->createCompartment(desc);

	// Create objects
	boxHW = CreateManagedBox(NxVec3(6, 0, 0), NxVec3(0.5, 1, 0.5), 20, gCompartmentHW);
	boxSW = CreateManagedBox(NxVec3(3, 0, 0), NxVec3(0.5, 1, 0.5), 20, gCompartmentSW);
	sphereHW = CreateManagedSphere(NxVec3(-6,0,0), 1, 10, gCompartmentHW);
	sphereHW = CreateManagedSphere(NxVec3(-3,0,0), 1, 10, gCompartmentSW);
	capsule = CreateManagedCapsule(NxVec3(0,0,0), 2, 1, 5, 0);

	gSelectedActor = boxHW;

	// Initialize HUD
	InitializeHUD();

	// Start the first frame of the simulation
	StartPhysics();
	return true;
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:51,代码来源:Lesson801.cpp

示例11: InitNx

static bool InitNx()
{
	if (!gAllocator)
		gAllocator = new UserAllocator;

	// Initialize PhysicsSDK
	NxPhysicsSDKDesc desc;
	NxSDKCreateError errorCode = NXCE_NO_ERROR;
	gPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, gAllocator, NULL, desc, &errorCode);
	if(gPhysicsSDK == NULL) 
	{
		printf("\nSDK create error (%d - %s).\nUnable to initialize the PhysX SDK, exiting the sample.\n\n", errorCode, getNxSDKCreateError(errorCode));
		return false;
	}
#if SAMPLES_USE_VRD
	// The settings for the VRD host and port are found in SampleCommonCode/SamplesVRDSettings.h
	if (gPhysicsSDK->getFoundationSDK().getRemoteDebugger() && !gPhysicsSDK->getFoundationSDK().getRemoteDebugger()->isConnected())
		gPhysicsSDK->getFoundationSDK().getRemoteDebugger()->connect(SAMPLES_VRD_HOST, SAMPLES_VRD_PORT, SAMPLES_VRD_EVENTMASK);
#endif

	gPhysicsSDK->setParameter(NX_SKIN_WIDTH, 0.025f);

	// Create two scenes
	for(NxU32 i=0;i<2;i++)
	{
		NxSceneDesc sceneDesc;
		sceneDesc.gravity				= gDefaultGravity;

		gScenes[i] = gPhysicsSDK->createScene(sceneDesc);
		if(gScenes[i] == NULL) 
		{
			printf("\nError: Unable to create one of the two PhysX scenes, exiting the sample.\n\n");
			return false;
		}

		// Create ground plane
		NxPlaneShapeDesc PlaneDesc;
		NxActorDesc ActorDesc;
		ActorDesc.shapes.pushBack(&PlaneDesc);
		gScenes[i]->createActor(ActorDesc);

		//materials are no longer shared between scenes so they have to be set up for both:
		NxMaterial * defaultMaterial = gScenes[i]->getMaterialFromIndex(0); 
		defaultMaterial->setRestitution(0.0f);
		defaultMaterial->setStaticFriction(0.5f);
		defaultMaterial->setDynamicFriction(0.5f);
	}
	return true;
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:49,代码来源:NxMultipleScenes.cpp

示例12: createScene

	bool PhysicsManager::createScene() {
		
		if(!mSDK)
			return false;

		// Create a scene
		NxSceneDesc sceneDesc;
		sceneDesc.setToDefault();
		
		//sceneDesc.timeStepMethod = NX_TIMESTEP_VARIABLE;
		sceneDesc.timeStepMethod = NX_TIMESTEP_FIXED;

		sceneDesc.gravity				= NxVec3(0.0f, -14.1f, 0.0f);

		sceneDesc.simType = NX_SIMULATION_SW;

		mScene = mSDK->createScene(sceneDesc);
		if(mScene == NULL) 
		{
			printf("\nError: Unable to create a PhysX scene, exiting the sample.\n\n");
			return false;
		}

		mScene->setActorGroupPairFlags(0,0,NX_NOTIFY_ON_START_TOUCH|NX_NOTIFY_ON_TOUCH|NX_NOTIFY_ON_END_TOUCH);

		// Set default material
		NxMaterial* defaultMaterial = mScene->getMaterialFromIndex(0);
		defaultMaterial->setRestitution(0.0f);
		defaultMaterial->setStaticFriction(0.5f);
		defaultMaterial->setDynamicFriction(0.5f);

		// Create ground plane
		//NxPlaneShapeDesc planeDesc;
		//NxActorDesc actorDesc;
		//actorDesc.shapes.pushBack(&planeDesc);
		//mScene->createActor(actorDesc);


		mScene->setUserTriggerReport(this);
		mScene->setUserContactReport(this);

		mIsSceneCreated = true;
		mIsRunningSim = true;

		mCurrentTime = 0;

		return true;
	}
开发者ID:alexribek,项目名称:apeengine2,代码行数:48,代码来源:PhysicsManager.cpp

示例13: initNx

		//-----------------------------------------------------------------------
		bool PhysXBridge::initNx(Real gravityY)
		{
			if (!mPhysicsSDK)
			{
				// Initialize PhysicsSDK
				NxPhysicsSDKDesc desc;
				NxSDKCreateError errorCode = NXCE_NO_ERROR;
				mPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, 0, new PhysXLogging(), desc, &errorCode);
				if(!mPhysicsSDK) 
				{
					EXCEPT(Exception::ERR_INTERNAL_ERROR, "PU: Cannot initialise the PhysX SDK.", "PhysXBridge::initNx");
				}

				mPhysicsSDK->setParameter(NX_SKIN_WIDTH, 0.05f);
			}

			// Create a scene
			if (!mScene)
			{
				NxSceneDesc sceneDesc;
				sceneDesc.gravity = NxVec3(0.0f, gravityY, 0.0f);
				mScene = mPhysicsSDK->createScene(sceneDesc);
				if(!mScene)
				{
					EXCEPT(Exception::ERR_INTERNAL_ERROR, "PU: Cannot create a PhysX Scene.", "PhysXBridge::initNx");
				}

				// Set the contact report
				mScene->setUserContactReport(&mPhysXContactReport);

				// Set default material
				NxMaterial* defaultMaterial = mScene->getMaterialFromIndex(0);
				defaultMaterial->setRestitution(0.0f);
				defaultMaterial->setStaticFriction(0.5f);
				defaultMaterial->setDynamicFriction(0.5f);

				// Create ground plane
				createPlane();
			}

			// Create a controller
			ControllerManager& controllerManager = ControllerManager::getSingleton(); 
			ControllerValueRealPtr physXBridgeUpdateValue(PU_NEW PhysXBridgeUpdateValue(this));
			mTimeController = controllerManager.createFrameTimePassthroughController(physXBridgeUpdateValue);

			return true;
		}
开发者ID:Ketzer2002,项目名称:meridian59-engine,代码行数:48,代码来源:ParticleUniversePhysXBridge.cpp

示例14: 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_COLLISION_FNORMALS, 1);

	// Create the scene
	NxSceneDesc sceneDesc;
	sceneDesc.simType				= NX_SIMULATION_SW;
	sceneDesc.gravity               = gDefaultGravity;
	gScene = gPhysicsSDK->createScene(sceneDesc);	

	// Create the default material
	NxMaterial* defaultMaterial = gScene->getMaterialFromIndex(0); 
	defaultMaterial->setRestitution(0.5);
	defaultMaterial->setStaticFriction(0.5);
	defaultMaterial->setDynamicFriction(0.5);

	groundPlane	= CreateGroundPlane();
	//groundPlane->getShapes()[0]->setFlag(NX_SF_FLUID_DRAIN,true);

	// Create drain actors
	CreateDrainActors();

	fluidEmitter = CreateFluidEmitter(0.35, 0.35);

	// Initialize HUD
	InitializeHUD();

	// Get the current time
	getElapsedTime();

	// Start the first frame of the simulation
	if (gScene)  StartPhysics();
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:47,代码来源:Lesson904.cpp

示例15: InitNx

bool InitNx()
{
	// Initialize PhysicsSDK
	NxPhysicsSDKDesc desc;
	gMyPhysX.initPhysX(desc);

	if(isPhysXHardwarePresent())
		printf("PhysX Hardware is available in your system!\n");
	// Create a scene
	NxSceneDesc sceneDesc;
	sceneDesc.gravity				= gDefaultGravity;

	gMyPhysX.createDefaultScene(sceneDesc);

	// Create ground plane
	NxPlaneShapeDesc PlaneDesc;
	PlaneDesc.group = 2;
	NxActorDesc ActorDesc;
	ActorDesc.shapes.pushBack(&PlaneDesc);
	gMyPhysX.getScene()->createActor(ActorDesc);

	NxMaterial * defaultMaterial = gMyPhysX.getScene()->getMaterialFromIndex(0); 
	defaultMaterial->setRestitution(0.0f);
	defaultMaterial->setStaticFriction(0.5f);
	defaultMaterial->setDynamicFriction(0.5f);

	// Create trigger

	NxVec3 zeroV(0,0,0);

	CreateTrigger(NxVec3(0,10,0), 10);
	CreateTrigger(NxVec3(-40,10,0), 10, &zeroV, false);
	CreateCube(NxVec3(-40,10,40), 10, NULL, false, true);
	CreateCube(NxVec3(-40,10,80), 10, NULL, true, false);

	//This creates a kinematic actor with a trigger, note that kinematic
	//triggers get interactions with static objects, thus this trigger
	//(which is placed directly above the ground) will directly get an
	//enter event for the ground plane (and change it's color). 
	CreateTrigger(NxVec3(40,10,0), 10, NULL, true);
	//You can try to move it up just a little bit, and you will see 
	//that it will no longer intersect the ground plane.
	//CreateTrigger(NxVec3(40,11,0), 10, NULL, true);

	return true;
}
开发者ID:flair2005,项目名称:Physx,代码行数:46,代码来源:SampleTrigger.cpp


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