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


C++ MeshEntity::GetPrimaryTechniqueHandle方法代码示例

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


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

示例1: ToString

std::string CMeshPhysicsObject::ToString(DWORD nMethod)
{
#ifndef MAX_LINE
#define MAX_LINE	500
#endif
	/** -- sample script generated:
	asset = ParaAsset.LoadStaticMesh("", "sample/trees/tree1.x");
	player = ParaScene.CreateMeshPhysicsObject("", asset, 1,1,1, true, "0.193295,0,0,0,0.187032,-0.0488078,0,0.0488078,0.187032,0,0,0");
	player:SetPosition(148,120.156,95);player:SetFacing(0);sceneLoader:AddChild(player);
	*/
	string sScript;
	char line[MAX_LINE+1];
	MeshEntity * pModel = (m_pMeshObject)?m_pMeshObject->m_ppMesh.get():NULL;
	
	if(pModel)
	{
		Matrix4 mat;
		float fOBB_X, fOBB_Y, fOBB_Z, fFacing;
		m_pMeshObject->GetLocalTransform(&mat);
		
		// tricky: when saving mesh object, we will use the bounding box of its view clipping object if any. 
		if(pModel->GetPrimaryTechniqueHandle() > 0)
		{
			// the view clipping object is usually a sphere that best contains the transformed mesh object's obb. 
			GetViewClippingObject()->GetBoundingBox(&fOBB_X, &fOBB_Y, &fOBB_Z, &fFacing);
		}
		else
		{
			m_pMeshObject->GetBoundingBox(&fOBB_X, &fOBB_Y, &fOBB_Z, &fFacing);
		}
		fFacing = GetFacing();

		//////////////////////////////////////////////////////////////////////////
		// write creator
		if( (nMethod&CBaseObject::NPL_DONOT_OUTPUT_ASSET) ==0)
		{
			My_snprinf(line, MAX_LINE, "asset=ParaAsset.LoadStaticMesh(\"\",[[%s]]);\n", 
				pModel->GetKey().c_str());
			sScript.append(line);
		}
		
		bool bSaveName = false;

		/// currently I only save name if it begins with "g_".
		const string& sName = GetIdentifier();
		if(sName.size()>2 && sName[1] == '_' && sName[0] == 'g')
			bSaveName = true;

		if(bSaveName)
		{
			My_snprinf(line, MAX_LINE, "player=cpmesh(\"%s\",asset,",sName.c_str());
			sScript.append(line);
		}
		else
		{
			sScript.append("player=cpmesh(\"\", asset, ");
		}

		My_snprinf(line, MAX_LINE, "%f,%f,%f, %s, \
\"%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f\");\n", fOBB_X, fOBB_Y, fOBB_Z, ((g_bForceExportMeshPhysics || IsPhysicsEnabled()) ? "true":"false"),
			mat._11, mat._12, mat._13, mat._21, mat._22, mat._23,mat._31, mat._32, mat._33,mat._41, mat._42, mat._43);
		sScript.append(line);
		//////////////////////////////////////////////////////////////////////////
		// write replaceable textures
		int nNumReplaceableTextures = GetNumReplaceableTextures();
		if(nNumReplaceableTextures>0)
		{
			for(int i=0;i<nNumReplaceableTextures;++i)
			{
				TextureEntity* pTex1 =  GetReplaceableTexture(i);
				if( pTex1)
				{
					TextureEntity* pTex2 =  GetDefaultReplaceableTexture(i);
					if(pTex2 && pTex2->IsValid() && pTex2!=pTex1)
					{
						// set the replaceable texture if it is different from the default one. 
						string sFileName = pTex1->GetKey();
						if(CGlobals::GetGlobalTerrain()->GetEnablePathEncoding())
						{
							CPathReplaceables::GetSingleton().EncodePath(sFileName, sFileName, "WORLD");
						}
						My_snprinf(line, MAX_LINE, "player:SetReplaceableTexture(%d,ParaAsset.LoadTexture(\"\",\"%s\",1));\n", i, sFileName.c_str());
						sScript.append(line);
					}
				}
			}
		}
		// write if it is a big mesh
		if(CheckAttribute(OBJ_BIG_STATIC_OBJECT))
		{
			My_snprinf(line, MAX_LINE, "player:SetAttribute(8192, true);\n");
			sScript.append(line);
		}
		

		const char* sHomeZoneName = GetHomeZoneName();
		if(sHomeZoneName && sHomeZoneName[0]!= '\0')
		{
			My_snprinf(line, MAX_LINE, "player:SetHomeZone(\"%s\");\n", sHomeZoneName);
			sScript.append(line);
//.........这里部分代码省略.........
开发者ID:imfoollink,项目名称:NPLRuntime,代码行数:101,代码来源:MeshPhysicsObject.cpp


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