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


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

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


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

示例1: GetMaterialIdx

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

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

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

示例4: run

int DXApp::run(HINSTANCE hInst, HWND hWnd)
{
    MSG msg;
    HACCEL hAccelTable;
    hAccelTable = LoadAccelerators(hInst, (LPCTSTR)IDC_TESTDXPROJ);
    QueryPerformanceFrequency((LARGE_INTEGER*)&Frequency);


    if(!_p_physdk) return -1;

    NxSceneDesc sceneDesc;
    sceneDesc.gravity.set(0, -9800.f, 0);
    sceneDesc.collisionDetection = true;
    sceneDesc.groundPlane = true;
    _p_scene = _p_physdk->createScene(sceneDesc);
    if(!_p_scene) return -2;

    _time_step = 1.0f/400.0f;
    _p_scene->setTiming(_time_step);

    NxMaterialDesc ParticleMaterialDesc;
    ParticleMaterialDesc.restitution = 0.80f;
    //ParticleMaterialDesc.spinFriction = 0.2f;
    ParticleMaterialDesc.staticFriction = 0.8f;
    ParticleMaterialDesc.dynamicFriction = 0.5f;
    NxMaterial* ParticleMaterial = _p_scene->createMaterial(ParticleMaterialDesc);
    _particle_material = ParticleMaterial->getMaterialIndex();


    D3DPRESENT_PARAMETERS D3DParams;
    D3DParams.Windowed = true;
    D3DParams.BackBufferWidth = width;
    D3DParams.BackBufferHeight = height;
    D3DParams.MultiSampleType = D3DMULTISAMPLE_NONE;
    D3DParams.MultiSampleQuality = 0;
    D3DParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
    D3DParams.Flags = 0;
    D3DParams.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
    D3DParams.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
    D3DParams.BackBufferFormat = D3DFMT_UNKNOWN;
    D3DParams.BackBufferCount = 3;
    D3DParams.hDeviceWindow = hWnd;
    D3DParams.EnableAutoDepthStencil = true;
    D3DParams.AutoDepthStencilFormat = D3DFMT_D16;

    if(FAILED(_p_D3D->CreateDevice( D3DADAPTER_DEFAULT,
                                    D3DDEVTYPE_HAL,
                                    hWnd,
                                    D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                    &D3DParams,
                                    &_p_device)))
    {
        return -3;
    }

    D3DXCreateFont(_p_device, 12, 0, FW_NORMAL, 1, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Arial", &FPSFont);

    _p_device->SetFVF(particle_fvf);
    if(FAILED(D3DXCompileShaderFromFile(
                  strPixelShader,
                  NULL,
                  NULL,
                  "ps_main",
                  "ps_2_0",
                  0,
                  &_p_code,
                  NULL,
                  &_p_constant_able )))
    {
        MessageBox(hWnd, "Error compiling Script", "Pixel Shader Compile Error", MB_ICONERROR);
        return 1;
    }

    _p_device->CreatePixelShader((DWORD*)_p_code->GetBufferPointer(), &_p_shader);
    _p_code->Release();
    _p_code = NULL;

    //SHADOW Buffer Pixel Shaders
    if(FAILED(D3DXCompileShaderFromFile(
                  strShadowPS,
                  NULL,
                  NULL,
                  "ps_main",
                  "ps_2_0",
                  0,
                  &_p_code,
                  NULL,
                  &_p_SB_constant_able )))
    {
        MessageBox(hWnd, "Error compiling Script", "Pixel Shader Compile Error", MB_ICONERROR);
        return 1;
    }

    _p_device->CreatePixelShader((DWORD*)_p_code->GetBufferPointer(), &_p_SB_shader);
    _p_code->Release();
    _p_code = NULL;

    //SHADOW Buffer Vertex Shaders
    if(FAILED(D3DXCompileShaderFromFile(
                  strShadowVS,
//.........这里部分代码省略.........
开发者ID:Arelius,项目名称:TestMotionBlur,代码行数:101,代码来源:DXApp.cpp

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

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

示例6: 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)
开发者ID:gbaumgart,项目名称:vt,代码行数:67,代码来源:pFactoryBody.cpp

示例7: GetMaterialID

	/// materials ids are set to shape descs
	virtual int GetMaterialID() { return (int)m_pNxMaterial->getMaterialIndex(); }
开发者ID:HermanHGF,项目名称:amorphous,代码行数:2,代码来源:NxPhysMaterial.hpp


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