本文整理汇总了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();
}
示例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;
}