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


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

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


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

示例1: Load

void* ModelLoader::Load(const void* data, int32_t size)
{
	Model* model = new Model((uint8_t*)data, size);

	model->ModelCount = Effekseer::Min(Effekseer::Max(model->GetModelCount(), 1), 40);

	model->InternalModels = new Model::InternalModel[model->GetFrameCount()];

	for (int32_t f = 0; f < model->GetFrameCount(); f++)
	{
		model->InternalModels[f].VertexCount = model->GetVertexCount(f);

		{
			std::vector<Effekseer::Model::VertexWithIndex> vs;
			for (int32_t m = 0; m < model->ModelCount; m++)
			{
				for (int32_t i = 0; i < model->GetVertexCount(f); i++)
				{
					Effekseer::Model::VertexWithIndex v;
					v.Position = model->GetVertexes(f)[i].Position;
					v.Normal = model->GetVertexes(f)[i].Normal;
					v.Binormal = model->GetVertexes(f)[i].Binormal;
					v.Tangent = model->GetVertexes(f)[i].Tangent;
					v.UV = model->GetVertexes(f)[i].UV;
					v.VColor = model->GetVertexes(f)[i].VColor;
					v.Index[0] = m;

					vs.push_back(v);
				}
			}

			ID3D11Buffer* vb = NULL;

			D3D11_BUFFER_DESC hBufferDesc;
			hBufferDesc.ByteWidth = sizeof(Effekseer::Model::VertexWithIndex) * model->GetVertexCount(f) * model->ModelCount;
			hBufferDesc.Usage = D3D11_USAGE_DEFAULT;
			hBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
			hBufferDesc.CPUAccessFlags = 0;
			hBufferDesc.MiscFlags = 0;
			hBufferDesc.StructureByteStride = sizeof(float);

			D3D11_SUBRESOURCE_DATA hSubResourceData;
			hSubResourceData.pSysMem = &(vs[0]);
			hSubResourceData.SysMemPitch = 0;
			hSubResourceData.SysMemSlicePitch = 0;

			if (FAILED(device->CreateBuffer(&hBufferDesc, &hSubResourceData, &vb)))
			{
				return NULL;
			}

			model->InternalModels[f].VertexBuffer = vb;
		}

		model->InternalModels[f].FaceCount = model->GetFaceCount(f);
		model->InternalModels[f].IndexCount = model->InternalModels[f].FaceCount * 3;

		{
			std::vector<Effekseer::Model::Face> fs;
			for (int32_t m = 0; m < model->ModelCount; m++)
			{
				for (int32_t i = 0; i < model->InternalModels[f].FaceCount; i++)
				{
					Effekseer::Model::Face face;
					face.Indexes[0] = model->GetFaces(f)[i].Indexes[0] + model->GetVertexCount(f) * m;
					face.Indexes[1] = model->GetFaces(f)[i].Indexes[1] + model->GetVertexCount(f) * m;
					face.Indexes[2] = model->GetFaces(f)[i].Indexes[2] + model->GetVertexCount(f) * m;
					fs.push_back(face);
				}
			}

			ID3D11Buffer* ib = NULL;
			D3D11_BUFFER_DESC hBufferDesc;
			hBufferDesc.Usage = D3D11_USAGE_DEFAULT;
			hBufferDesc.ByteWidth = sizeof(int32_t) * 3 * model->InternalModels[f].FaceCount * model->ModelCount;
			hBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
			hBufferDesc.CPUAccessFlags = 0;
			hBufferDesc.MiscFlags = 0;
			hBufferDesc.StructureByteStride = sizeof(int32_t);

			D3D11_SUBRESOURCE_DATA hSubResourceData;
			hSubResourceData.pSysMem = &(fs[0]);
			hSubResourceData.SysMemPitch = 0;
			hSubResourceData.SysMemSlicePitch = 0;

			if (FAILED(device->CreateBuffer(&hBufferDesc, &hSubResourceData, &ib)))
			{
				ES_SAFE_DELETE(model);
				return nullptr;
			}

			model->InternalModels[f].IndexBuffer = ib;
		}
	}

	return model;
}
开发者ID:effekseer,项目名称:Effekseer,代码行数:97,代码来源:EffekseerRendererDX11.ModelLoader.cpp


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