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


C++ vector::GetInterpolatedNormal方法代码示例

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


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

示例1: SetFace


//.........这里部分代码省略.........
			new_face.RaiseTypeFlag(CMapFace::TYPE_NOCLIP);		// no collision detection against this face
		else
			new_face.ClearTypeFlag(CMapFace::TYPE_NOCLIP);	// usual case

		if( strstr(rSurf.GetName().c_str(),"_Invisible") )	//if the surface name contains "_Invisible"
			new_face.RaiseTypeFlag(CMapFace::TYPE_INVISIBLE);	// this face is not rendered
		else
			new_face.ClearTypeFlag(CMapFace::TYPE_INVISIBLE);	// usual case

		// find the image mapped on this face and get its index
		new_face.m_sTextureID = iSurfaceIndex;

		// The value of TextureID is given as the order of the still image 
		// in vector<m_clipstill> 
		// If a still image is the first element in vector<m_clipstill>, 
		// the TextureID of its owner face is 0

		// The image index of CLIP chunk in LWO2 file starts from 1. Therefore, if a surface doesn't
		// have any image, imagetag of the surface should be 0.  << Is this right?
		// And the 'm_sTextureID' remains -1

		// find the texture uvmap of this face	
		pTexuvmap = lwobject.FindTextureUVMapFromSurface(rSurf, ID_COLR, *thislayer);

		// find the vertex color map applied to this face		
		pVertexColorMap= lwobject.FindVertexColorMapFromSurface(rSurf, *thislayer);

		int iNumPoints = rSrcFace.GetNumPoints();
		for(j=0; j<iNumPoints ;j++)  // the number of points in this face
		{
			memset(&vDest, 0, sizeof(MAPVERTEX));
			vDest.color = 0xFFFFFFFF;	//default vertex color: white and opaque

			pnt_index = rSrcFace.GetVertexIndex()[j];   // the index to a point in the PNTS chunk
			vDest.vPosition = thislayer->GetVertex().at( pnt_index );

			// set texture-uv to the vertex
			// search uv map (VMAP chunk) until the corresponding uv-point is found
			if( pTexuvmap )  // if (pTexuvmap == NULL), we have no uv points for this face
			{
				if( !thislayer->GetUV( vDest.vTex0.u, vDest.vTex0.v, pnt_index, pTexuvmap ) )
				{
					vDest.vTex0.u = 32767;
					vDest.vTex0.v = 32767;
				}
			}

			new_face.m_sLightMapID = -1;
/*			if( pLightmapTextureUVMap )
			{
				if( !thislayer->GetUV( vDest.vTex1.u, vDest.vTex1.v, pnt_index, pLightmapTextureUVMap ) )
				{
					vDest.vTex1.u = -1;
					vDest.vTex1.v = -1;
				}
				else
					new_face.m_sLightMapID = 0;	// TODO: support for multiple lightmap textures
			}*/

			if( pVertexColorMap )
				SetVertexColor( vDest, pnt_index, (DWORD)i, pVertexColorMap );

			if( rSurf.GetMaxSmoothingAngle() < 3.141592f / 2.0f * 89.9f / 90.0f )
				vDest.vNormal = thislayer->GetInterpolatedNormal( rSrcFace, pnt_index );	// smooth shadeing
			else
				vDest.vNormal = rSrcFace.GetFaceNormal();	// flat shading

		//========== normal direction check (visual debugging) =============================================
//			vDest.color = D3DCOLOR_XRGB( abs((int)(vDest.vNormal.x * 250.0f)),
//				                         abs((int)(vDest.vNormal.y * 250.0f)),
//										 abs((int)(vDest.vNormal.z * 250.0f)) );
		//========== normal direction check (visual debugging) =============================================


			new_face.AddMAPVERTEX(vDest);
		}

		new_face.m_sNode = 0;
		new_face.m_bFlag = false;

		if( strstr(rSurf.GetName().c_str(),"_LightSource") )
		{	// mark as a light source
			new_face.RaiseTypeFlag( CMapFace::TYPE_LIGHTSOURCE );
			new_face.RaiseTypeFlag( CMapFace::TYPE_NOCLIP );		// light source faces are not used for collision detection - actually, this is not a good solution
		}


		//========== normal direction check =============================================
//		for(j=0; j<new_face.GetNumVertices()-1; j++)
//		{
//			if( 0.001f < D3DXVec3LengthSq( &(new_face.GetMapVertex(j).vNormal - new_face.GetMapVertex(j+1).vNormal) ) )
//				int iSmoothShadingPolygon = 1;
//		}
		//========== normal direction check =============================================


		pvecFace->push_back( new_face );

	}
}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:101,代码来源:BSPMapData_LW.cpp


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