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


C++ Model::GetIndexBuffer方法代码示例

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


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

示例1: Init_Buffer

void GenerateLOD::Init_Buffer(fbxsdk::FbxMesh *pMesh, Model &model)
{
	model.SetVertexCount(static_cast<int>(ControlP->size()));
	model.SetPolygonCount(static_cast<int>(Triangles->size()));

	// Create the VertexBuffer
	model.CreateVertextBuffer();

	IDirect3DVertexBuffer9 *g_pVB = model.GetVertexBuffer();

	CUSTOMVERTEX *pVertices;
	g_pVB->Lock(0, 0, (void **)&pVertices, 0);
	FbxLayerElementArrayTemplate<FbxVector2> *pUVarray = NULL;
	bool hasUV = pMesh->GetTextureUV(&pUVarray);
	if (!hasUV) {
		printf("Has No Textures!\n");
	}

	WORD count = 0;
	std::unordered_map<int, WORD> RemainPoints;
	FbxVector4 *pControlPoints = pMesh->GetControlPoints();
	for (std::unordered_map<int, Point>::iterator it = (*ControlP).begin(); it != (*ControlP).end(); ++it) {
		const FbxVector4 &P = pControlPoints[it->first];
		pVertices[count].x = static_cast<FLOAT>(P[0]);
		pVertices[count].y = static_cast<FLOAT>(P[1]);
		pVertices[count].z = static_cast<FLOAT>(P[2]);

		// uv coordinate
		pVertices[count].tu = static_cast<FLOAT>((pUVarray->GetAt(*it->second.uvSet.begin()))[0]);
		pVertices[count].tv = static_cast<FLOAT>((pUVarray->GetAt(*it->second.uvSet.begin()))[1]);

		RemainPoints[it->first] = count;
		++count;
	}
	g_pVB->Unlock();

	
	// Create the IndexBuffer
	model.CreateIndexBuffer();

	IDirect3DIndexBuffer9 *g_pIB = model.GetIndexBuffer();

	WORD *index;
	int cnt = 0;
	g_pIB->Lock(0, 0, (void **)&index, 0);
	for (std::unordered_map<int, Face>::iterator it = (*Triangles).begin(); it != (*Triangles).end(); ++it) {
		index[cnt++] = RemainPoints[it->second.points[0]];
		index[cnt++] = RemainPoints[it->second.points[1]];
		index[cnt++] = RemainPoints[it->second.points[2]];
	}
	g_pIB->Unlock();
}
开发者ID:oyjb,项目名称:Mesh_Simplification,代码行数:52,代码来源:GenerateLOD.cpp

示例2: CreateModelFromObjFile

	Model * CreateModelFromObjFile( const std::string & filename ) {
		File *file = FileOpenForRead( filename );
		ParseState ps;
		while ( file->AtEnd() == false && ps.mode != Mode_Failed ) {
			string line = file->ReadLine();
			vector< Token > tokens = TokenizeString( line.c_str() );
			ps.ProcessLine( tokens );
		}
		delete file;
		if ( ps.mode == Mode_Failed ) {
			return NULL;
		}
		Model *m = new Model( filename );
		m->SetPrimitive( Primitive_Triangles );
		VertexBuffer & vb = m->GetVertexBuffer();
		vb.SetVarying( ps.varying );
		//Output( "model %s varying = %d", filename.c_str(), ps.varying );
		vb.SetData( (int)ps.vbdata.size() * sizeof( float ), &ps.vbdata[0] );
		m->GetIndexBuffer().SetData( (int)ps.ibdata.size() * sizeof( ushort ), &ps.ibdata[0] );
		return m;
	}
开发者ID:bcrowell,项目名称:planetfinder_ios,代码行数:21,代码来源:modelobj.cpp


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