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


C++ NxMaterial类代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: NxCreatePhysicsSDK

//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
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

示例5: 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

示例6: while

int plSimulationMgr::GetMaterialIdx(NxScene* scene, float friction, float restitution)
{
    if (friction == 0.5f && restitution == 0.5f)
        return 0;

    // Use the nutty PhysX method to search for a matching material
    #define kNumMatsPerCall 32
    NxMaterial* materials[kNumMatsPerCall];
    NxU32 iterator = 0;
    bool getMore = true;
    while (getMore)
    {
        int numMats = scene->getMaterialArray(materials, kNumMatsPerCall, iterator);

        for (int i = 0; i < numMats; i++)
        {
            if (materials[i]->getDynamicFriction() == friction &&
                materials[i]->getRestitution() == restitution)
            {
                return materials[i]->getMaterialIndex();
            }
        }

        getMore = (numMats == kNumMatsPerCall);
    }

    // Couldn't find the material, so create it
    NxMaterialDesc desc;
    desc.restitution = restitution;
    desc.dynamicFriction = friction;
    desc.staticFriction = friction;
    NxMaterial* mat = scene->createMaterial(desc);
    return mat->getMaterialIndex();
}
开发者ID:branan,项目名称:Plasma-nobink,代码行数:34,代码来源:plSimulationMgr.cpp

示例7: NIASSERT

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

示例8:

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

示例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, 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();
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:58,代码来源:Lesson1006.cpp

示例10: 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

示例11: CreateGroundPlane

NxActor* CreateGroundPlane()
{
    // Create a plane with default descriptor
    NxPlaneShapeDesc planeDesc;
    NxActorDesc actorDesc;
	NxMaterial* defaultMaterial = gScene->getMaterialFromIndex(0); 
	planeDesc.materialIndex	= defaultMaterial->getMaterialIndex();
    actorDesc.shapes.pushBack(&planeDesc);
    return gScene->createActor(actorDesc);
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:10,代码来源:Lesson112.cpp

示例12: 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

示例13: 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

示例14: 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

示例15: cfg

Cutter::Cutter(NxVec3 pos, string fname)
{
	m_cutterHeight = 0.0f;
	m_cutterRotateAngle = 0.0f;
	m_cutterON = false;
	m_cutterParams = new CutterParams;
	m_attachedTriPod = NULL;

	CfgLoader cfg(fname, m_cutterParams->getVariableList());

	//D3DXMatrixRotationYawPitchRoll(&dimm->matChassisRotation, rotateChassis.y, rotateChassis.x, rotateChassis.z);

	ObjectParams temp;
	temp.loadFromFile("Objects\\" + m_cutterParams->chassisModel);
	m_objChassis = new Surface(temp.meshName, temp.generateMaterial(), Vec3(0, 0, 0));
	temp.loadFromFile("Objects\\" + m_cutterParams->cutterModel);
	m_objCutter = new Surface(temp.meshName, temp.generateMaterial(), Vec3(0, 0, 0));

	Vec3 min = m_objChassis->boundingBox.Min;
	//min.y -= 1.0f;
	Vec3 max = m_objChassis->boundingBox.Max;
	//max.y += 0.5f;
	m_actionBox = new ActionBox(min, max);

	core.game->getWorld()->addToWorld(m_objChassis, NO_COLLISION, 0, GROUP_NON_COLLIDABLE, NULL, 1);
	core.game->getWorld()->addToWorld(m_objCutter, NO_COLLISION, 0, GROUP_NON_COLLIDABLE, NULL, 1);

	m_cutterParams->dimm = Vec3(m_objChassis->boundingBox.getWidth()/2, m_objChassis->boundingBox.getHeight()/6, m_objChassis->boundingBox.getDepth()/2);

	m_actor = core.dynamics->createBox(pos, NxVec3(m_cutterParams->dimm), m_cutterParams->density);
	SetActorCollisionGroup(m_actor, GROUP_COLLIDABLE_NON_PUSHABLE);
	NxMaterial *anisoMaterial = NULL;
	//if(!anisoMaterial)
	{
		//Create an anisotropic material
		NxMaterialDesc material; 
		//Anisotropic friction material
		material.restitution = 0.01f;
		material.staticFriction = 0.01f;
		material.dynamicFriction = 0.01f;
		material.dynamicFrictionV = 0.1f;
		material.staticFrictionV = 0.1f;
		material.dirOfAnisotropy.set(1,0,0);
		material.flags = NX_MF_ANISOTROPIC;
		anisoMaterial = core.dynamics->getScene()->createMaterial(material);
	}
	m_actor->getShapes()[0]->setMaterial(anisoMaterial->getMaterialIndex());
}
开发者ID:adasm,项目名称:xgine,代码行数:48,代码来源:Cutter.cpp


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