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


C++ BMP::GetWidth方法代码示例

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


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

示例1: BMP

liStaticMesh *lrmResourceManager::LoadHeightmap(const std::string &filename)
{
	auto I = LoadedStaticMeshes.find(filename);

	if(I != LoadedStaticMeshes.end())
	{
		return LoadedStaticMeshes[filename];
	}

	BMP *bmp = new BMP(HeightmapPath + filename);

	if(bmp->GetError() != BMP::ERR_OK)
	{
		std::cerr << "Couldn't open file " << filename << std::endl;
		delete bmp;

		return nullptr;
	}

	bmp->Print(cout);

	lrmStaticMesh *StaticMeshSrc = new lrmStaticMesh();

	LoadHeightmapVertices(bmp,StaticMeshSrc->Vertices);

	StaticMeshSrc->Normals.resize(bmp->GetHeight() * bmp->GetWidth());
	StaticMeshSrc->Tangents.resize(bmp->GetHeight() * bmp->GetWidth());
	StaticMeshSrc->Bitangents.resize(bmp->GetHeight() * bmp->GetWidth());

	StaticMeshSrc->TexCoords.resize(bmp->GetHeight() * bmp->GetWidth());

	lrmStaticMesh::lrmMtlGroup *MtlGroup = new lrmStaticMesh::lrmMtlGroup();
	MtlGroup->Material = "Material";

	StaticMeshSrc->MatGroups.push_back(MtlGroup);

	bool Puszcsy = true;
	bool Szercsy = true;

	for(int i=0;i < bmp->GetHeight()-1;i++)
	{
		for(int j=0;j < bmp->GetWidth()-1;j++)
		{
			const lmVector3D &V1 = StaticMeshSrc->Vertices[i	 * bmp->GetWidth()	+ j    ];
			const lmVector3D &V2 = StaticMeshSrc->Vertices[i	 * bmp->GetWidth()	+ (j+1)];
			const lmVector3D &V3 = StaticMeshSrc->Vertices[(i+1) * bmp->GetWidth()	+ j    ];
			const lmVector3D &V4 = StaticMeshSrc->Vertices[(i+1) * bmp->GetWidth()	+ (j+1)];

			lmVector3D Normal1 = lmCross(V2-V1,V4-V1);
			Normal1.Normalize();

			lmVector3D Normal2 = lmCross(V4-V1,V3-V1);
			Normal2.Normalize();

			LoadHeightmapTriangles_SM(bmp,i,j,Normal1,Normal2,StaticMeshSrc->Normals,StaticMeshSrc->MatGroups[0]->IndexBuffer);

			if(Puszcsy)
			{
				StaticMeshSrc->TexCoords[i * bmp->GetWidth() + (j+1)][0] = 1.0;
			}

			Puszcsy = !Puszcsy;

			if(Szercsy)
			{
				StaticMeshSrc->TexCoords[(i+1) * bmp->GetWidth() +  j   ][1] = 1.0;
				StaticMeshSrc->TexCoords[(i+1) * bmp->GetWidth() + (j+1)][1] = 1.0;
			}
		}

		Szercsy = !Szercsy;
	}

	delete bmp;

	for(lmVector3D &Normal : StaticMeshSrc->Normals)
	{
		Normal.Normalize();
	}

	for(int i=0;i < StaticMeshSrc->Normals.size();i++)
	{
		//lmVector3D Tangent = lmCross(lmCross(StaticMeshSrc->Normals[i],(-1.0)*StaticMeshSrc->Vertices[i]),StaticMeshSrc->Normals[i]);
		lmVector3D Tangent = lmCross(lmCross(StaticMeshSrc->Normals[i],{1.0,0.0,0.0}),StaticMeshSrc->Normals[i]);
        Tangent.Normalize();

        StaticMeshSrc->Tangents[i] = Tangent;

        lmVector3D Bitangent = lmCross(Tangent,StaticMeshSrc->Normals[i]);
        Bitangent.Normalize();

        StaticMeshSrc->Bitangents[i] = Bitangent;
	}

	liStaticMesh *StaticMesh;
	GPUFactory->UploadStaticMesh(StaticMesh,StaticMeshSrc);

	delete StaticMeshSrc;

	LoadedStaticMeshes[filename] = StaticMesh;
//.........这里部分代码省略.........
开发者ID:sereslorant,项目名称:logan_engine,代码行数:101,代码来源:lrmResourceManager.cpp


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