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


C++ MeshPtr::Get方法代码示例

本文整理汇总了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;
}
开发者ID:dgi09,项目名称:D3D,代码行数:48,代码来源:AssetLoader.cpp

示例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);

}
开发者ID:dgi09,项目名称:D3D,代码行数:45,代码来源:AssetLoader.cpp

示例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();
	}

}
开发者ID:dgi09,项目名称:3DRenderingEngine,代码行数:22,代码来源:AnimatedEntity.cpp


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