6 using SiliconStudio.Core.Mathematics;
8 namespace SiliconStudio.
Paradox.Graphics
10 public partial class GeometricPrimitive
42 public static GeometricMeshData<VertexPositionNormalColor>
New(
Color color,
float radius = 0.5f,
float height = 1.0f,
int tessellation = 32,
bool toLeftHanded =
false)
44 var indices =
new int[6*tessellation];
47 var slopeLength = Math.Sqrt(radius * radius + height * height);
48 var slopeCos = radius / slopeLength;
49 var slopeSin = height / slopeLength;
55 for (
int i = 0; i < tessellation; ++i)
57 var angle = i / (double)tessellation * 2.0 * Math.PI;
58 var angleTop = (i + 0.5) / tessellation * 2.0 * Math.PI;
60 var position =
new Vector3(0.0f, (
float)Math.Cos(angle) * radius, (float)Math.Sin(angle) * radius);
61 var normal =
new Vector3((
float)slopeSin, (
float)(Math.Cos(angle) * slopeCos), (
float)(Math.Sin(angle) * slopeSin));
62 var normalTop =
new Vector3((
float)slopeSin, (
float)(Math.Cos(angleTop) * slopeCos), (
float)(Math.Sin(angleTop) * slopeSin));
67 indices[index++] = i * 2;
68 indices[index++] = (i * 2 + 3) % (tessellation * 2);
69 indices[index++] = i * 2 + 1;
74 for (
int i = 0; i < tessellation; ++i)
76 var angle = i / (double)tessellation * 2 * Math.PI;
77 var position =
new Vector3(0.0f, (
float)Math.Cos(angle) * radius, (
float)Math.Sin(angle) * radius);
80 indices[index++] = tessellation * 2;
81 indices[index++] = tessellation * 2 + 1 + i;
82 indices[index++] = tessellation * 2 + 1 + ((i + 1) % tessellation);
85 return new GeometricMeshData<VertexPositionNormalColor>(vertices, indices, toLeftHanded) { Name =
"Cone"};
A geometric primitive. Use Cube, Cylinder, GeoSphere, Plane, Sphere, Teapot, Torus. See Draw+vertices to learn how to use it.
Describes a custom vertex format structure that contains position, normal and color information...
Represents a three dimensional mathematical vector.
static GeometricPrimitive< VertexPositionNormalColor > New(GraphicsDevice device, Color color, float radius=0.5f, float height=1.0f, int tessellation=32, bool toLeftHanded=false)
Creates a cone a circular base and a rolled face.
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. See The+GraphicsDevice+class to learn more about the class.
Represents a 32-bit color (4 bytes) in the form of RGBA (in byte order: R, G, B, A).
SiliconStudio.Core.Mathematics.Vector3 Vector3
A cone with a circular base and rolled face.
static GeometricMeshData< VertexPositionNormalColor > New(Color color, float radius=0.5f, float height=1.0f, int tessellation=32, bool toLeftHanded=false)
Creates a cone a circular base and a rolled face.