本文整理汇总了C++中MeshPtr::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshPtr::Get方法的具体用法?C++ MeshPtr::Get怎么用?C++ MeshPtr::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshPtr
的用法示例。
在下文中一共展示了MeshPtr::Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadAnimatedModel
ModelPtr AssetLoader::LoadAnimatedModel(std::string fileName)
{
FILE * f = nullptr;
fopen_s(&f,fileName.c_str(),"rb");
if(f != nullptr)
{
unsigned int number;
fread_s(&number,4,4,1,f);
if(number != 50)
{
fclose(f);
return ModelPtr(true);
}
unsigned int meshesCount;
fread_s(&meshesCount,4,4,1,f);
ModelPtr ptr(Heap::GetPtr()->Models.New());
Model * model = ptr.Get();
for(unsigned int iMesh = 0; iMesh < meshesCount; iMesh++)
{
fread_s(&animatedMeshData.numOfVerts,4,4,1,f);
fread_s(animatedMeshData.verts,sizeof(AnimatedVert) * animatedMeshData.numOfVerts,sizeof(AnimatedVert),animatedMeshData.numOfVerts,f);
fread_s(&animatedMeshData.numOfIndecies,4,4,1,f);
fread_s(animatedMeshData.indecies,sizeof(unsigned int) * animatedMeshData.numOfIndecies, 4 ,animatedMeshData.numOfIndecies,f);
MeshPtr meshPtr = factory->CreateMesh();
Mesh * mesh = meshPtr.Get();
mesh->Init();
mesh->SetDrawMethod(DM_DRAW_INDEXED);
mesh->InitVertexBuffer(animatedMeshData.numOfVerts * sizeof(AnimatedVert),sizeof(AnimatedVert),animatedMeshData.verts);
mesh->InitIndexBuffer(animatedMeshData.numOfIndecies,animatedMeshData.indecies);
model->AddMesh(meshPtr);
}
fclose(f);
return ptr;
}
else return nullptr;
}
示例2: LoadStaticModel
ModelPtr AssetLoader::LoadStaticModel(std::string fileName)
{
std::ifstream file(fileName.c_str(),std::ios::binary);
if(file.is_open())
{
unsigned int number;
file.read((char*)&number,sizeof(unsigned int));
if(number != 0)
return ModelPtr(true);
unsigned int numberOfMeshes;
file.read((char*)&numberOfMeshes,4);
ModelPtr ptr(Heap::GetPtr()->Models.New());
Model * model = ptr.Get();
for(unsigned int iMesh = 0; iMesh < numberOfMeshes; iMesh++)
{
file.read((char*)&staticMeshData.numberOfVerts,sizeof(unsigned int));
file.read((char*)staticMeshData.vertecies,sizeof(StaticVert) * staticMeshData.numberOfVerts);
file.read((char*)&staticMeshData.numberOfIndecies,sizeof(unsigned int));
file.read((char*)staticMeshData.indecies,sizeof(unsigned int) * staticMeshData.numberOfIndecies);
MeshPtr meshPtr = factory->CreateMesh();
Mesh * mesh = meshPtr.Get();
mesh->Init();
mesh->SetDrawMethod(DM_DRAW_INDEXED);
mesh->InitVertexBuffer(staticMeshData.numberOfVerts * sizeof(StaticVert),sizeof(StaticVert),staticMeshData.vertecies);
mesh->InitIndexBuffer(staticMeshData.numberOfIndecies,staticMeshData.indecies);
model->AddMesh(meshPtr);
}
file.close();
return ptr;
}
else return ModelPtr(true);
}
示例3: Draw
void AnimatedEntity::Draw(EffectBinder * binder)
{
SetUpShaderData();
BindAnimationData(binder);
BindEntityData(binder);
Model * model = modelHandler.Get().Get();
for(unsigned int i = 0;i < model->GetNumberOfMeshes();i++)
{
Material mat = materials[i];
BindMaterialData(binder,mat);
binder->BindAllSections();
MeshPtr ptr = model->GetMeshAt(i);
Mesh * mesh = ptr.Get();
mesh->DrawIndexed();
}
}