Просмотр исходного кода

Added TYPE_UNCAPPED_CYLINDER scene mesh type

Ivan Safrin 13 лет назад
Родитель
Сommit
526fafcdc8

+ 2 - 1
Core/Contents/Include/PolyMesh.h

@@ -221,8 +221,9 @@ namespace Polycode {
 			* @param height Height of the cylinder.
 			* @param radius Radius of the cylinder.
 			* @param numSegments Number of segments.
+			* @param capped Create the end caps.
 			*/ 								
-			void createCylinder(Number height, Number radius, int numSegments);
+			void createCylinder(Number height, Number radius, int numSegments, bool capped=true);
 
 			/**
 			* Creates a cone mesh.

+ 11 - 1
Core/Contents/Include/PolyScenePrimitive.h

@@ -98,7 +98,17 @@ namespace Polycode {
 			* v3 - Number of ring segments.			
 			* v4- Number of pipe segments.
 			*/			
-			static const int TYPE_TORUS = 6;			
+			static const int TYPE_TORUS = 6;	
+			
+
+			/**
+			* A cylinder.
+			* v1 - Cylinder length			
+			* v2 - Cylinder radius
+			* v3 - Number of segments.
+			*/			
+			static const int TYPE_UNCAPPED_CYLINDER = 7;
+							
 
 		
 		protected:

+ 3 - 2
Core/Contents/Source/PolyMesh.cpp

@@ -526,7 +526,7 @@ namespace Polycode {
 		arrayDirtyMap[RenderDataArray::TANGENT_DATA_ARRAY] = true;				
 	}
 
-	void Mesh::createCylinder(Number height, Number radius, int numSegments) {
+	void Mesh::createCylinder(Number height, Number radius, int numSegments, bool capped) {
 	
 		setMeshType(Mesh::TRI_MESH);
 		Number lastx = 0;
@@ -551,6 +551,7 @@ namespace Polycode {
 				polygon->addVertex(lastx,0,lastz,lastv,0);												
 				addPolygon(polygon);	
 				
+				if(capped) {
 				polygon = new Polygon();	
 				polygon->addVertex(lastx,height,lastz, 0.5+(lastz/radius*0.5), 0.5+(lastx/radius*0.5));			
 				polygon->addVertex(x,height,z, 0.5+(z/radius*0.5), 0.5+(x/radius*0.5));														
@@ -562,7 +563,7 @@ namespace Polycode {
 				polygon->addVertex(0,0,0,0.5,0.5);																																					
 				polygon->addVertex(x,0,z, 0.5+(z/radius*0.5), 0.5+(x/radius*0.5));								
 				addPolygon(polygon);			
-
+				}
 								
 			}
 			lastx = x;

+ 7 - 1
Core/Contents/Source/PolyScenePrimitive.cpp

@@ -57,7 +57,13 @@ ScenePrimitive::ScenePrimitive(int type, Number v1, Number v2, Number v3,Number
 			bBox.x = v2*2;
 			bBox.y = v1;
 			bBox.z = v2*2;						
-		break;		
+		break;
+		case TYPE_UNCAPPED_CYLINDER:
+			mesh->createCylinder(v1,v2,v3, false);
+			bBox.x = v2*2;
+			bBox.y = v1;
+			bBox.z = v2*2;						
+		break;						
 		case TYPE_CONE:
 			mesh->createCone(v1,v2,v3);
 			bBox.x = v2*2;