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


C++ Mesh::CalculateAABB方法代码示例

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


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

示例1: Sphere

	inline Mesh* Mesh::Sphere(std::string name, float32 radius, uint32 segs, uint32 rgs) {
		Mesh* mesh = new Mesh(name);
		
		uint32 segments = Mathf.Max(segs, 3) + 1,
			   rings = Mathf.Max(rgs, 3) + 2;
		
		float32 PI = Mathf.PI,
				TWO_PI = PI * 2.0f,
				HALF_PI = PI * 0.5f,
				R = 1.0f / (rings - 1),
				S = 1.0f / (segments - 1),
				x, y, z;

		uint32 r, s,
			   a, b, c, d;

		Array<Vec3f*>& vertices = mesh->vertices;
		Array<Vec3f*>& normals = mesh->normals;
		Array<Vec2f*>& uv = mesh->uv;
		Array<Colorf*>& colors = mesh->colors;
		Array<uint32>& indices = mesh->indices;
		
		for (r = 0; r < rings; r++) {
			for (s = 0; s < segments; s++) {
				x = Mathf.Cos(TWO_PI * s * S) * Mathf.Sin(PI * r * R);
				y = Mathf.Sin(TWO_PI * s * S) * Mathf.Sin(PI * r * R);
				z = Mathf.Sin(-HALF_PI + PI * r * R);

				vertices.Push(new Vec3f(x * radius, y * radius, z * radius));
				normals.Push(new Vec3f(x, y, z));
				uv.Push(new Vec2f(s * S, r * R));
				colors.Push(new Colorf(s * S, r * R, 0.0f));
			}
		}

		for (r = 0; r < rings - 1; r++) {
			for (s = 0; s < segments - 1; s++) {
				a = r * segments + s;
				b = r * segments + (s + 1);
				c = (r + 1) * segments + (s + 1);
				d = (r + 1) * segments + s;
				
				indices.Push(a);
				indices.Push(b);
				indices.Push(c);
				indices.Push(a);
				indices.Push(c);
				indices.Push(d);
			}
		}
		
		mesh->CalculateTangents();
		mesh->CalculateAABB();
		
		return mesh;
	}
开发者ID:nathanfaucett,项目名称:Odin.cpp,代码行数:56,代码来源:mesh.cpp

示例2: Plane

	inline Mesh* Mesh::Plane(std::string name, float32 width, float32 height, int32 widthSegments, int32 heightSegments) {
		
        Mesh* mesh = new Mesh(name);
		Mesh::m_BuildPlane(mesh, 0, 1, 1, 1, width, widthSegments, height, heightSegments, 0, 0);
		
		mesh->CalculateTangents();
		mesh->CalculateAABB();
		
		return mesh;
	}
开发者ID:nathanfaucett,项目名称:Odin.cpp,代码行数:10,代码来源:mesh.cpp

示例3: Cube

	inline Mesh* Mesh::Cube(std::string name, float32 width, float32 height, float32 depth, int32 widthSegments, int32 heightSegments, int32 depthSegments) {
		float32 hw = width * 0.5,
                hh = height * 0.5,
                hd = depth * 0.5;
		
        Mesh* mesh = new Mesh(name);
		Mesh::m_BuildPlane(mesh, 2, 1, -1, 1, depth, depthSegments, height, heightSegments, hw, widthSegments);
		Mesh::m_BuildPlane(mesh, 2, 1, 1, 1, depth, depthSegments, height, heightSegments, -hw, widthSegments);
		Mesh::m_BuildPlane(mesh, 0, 2, 1, -1, width, widthSegments, depth, depthSegments, hh, heightSegments);
		Mesh::m_BuildPlane(mesh, 0, 2, 1, 1, width, widthSegments, depth, depthSegments, -hh, heightSegments);
		Mesh::m_BuildPlane(mesh, 0, 1, 1, 1, width, widthSegments, height, heightSegments, hd, depthSegments);
		Mesh::m_BuildPlane(mesh, 0, 1, -1, 1, width, widthSegments, height, heightSegments, -hd, depthSegments);
		
		mesh->CalculateTangents();
		mesh->CalculateAABB();
		
		return mesh;
	}
开发者ID:nathanfaucett,项目名称:Odin.cpp,代码行数:18,代码来源:mesh.cpp


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