25 using SiliconStudio.Core.Mathematics;
27 namespace SiliconStudio.
Paradox.Graphics
29 public partial class GeometricPrimitive
49 return new GeometricPrimitive(device, New(sizeX, sizeY, tessellation, toLeftHanded, uvFactors));
62 public static GeometricMeshData<VertexPositionNormalTexture>
New(
float sizeX = 1.0f,
float sizeY = 1.0f,
int tessellation = 1,
bool toLeftHanded =
false,
Vector2? uvFactors = null,
bool generateBackFace =
false)
66 throw new ArgumentOutOfRangeException(
"tessellation",
"tessellation must be > 0");
69 var lineWidth = tessellation + 1;
71 var indices =
new int[tessellation * tessellation * 6 * (generateBackFace? 2: 1)];
73 var deltaX = sizeX / tessellation;
74 var deltaY = sizeY / tessellation;
81 var normal = Vector3.UnitZ;
83 var uv = uvFactors.HasValue ? uvFactors.Value :
new Vector2(1, 1);
86 for (
int y = 0;
y < (tessellation + 1);
y++)
88 for (
int x = 0; x < (tessellation + 1); x++)
90 var position =
new Vector3(-sizeX + deltaX * x, sizeY - deltaY *
y, 0);
91 var texCoord =
new Vector2(uv.X * x / tessellation, uv.Y * y / tessellation);
97 for (
int y = 0;
y < tessellation;
y++)
99 for (
int x = 0; x < tessellation; x++)
102 int vbase = lineWidth *
y + x;
103 indices[indexCount++] = (vbase + 1);
104 indices[indexCount++] = (vbase + 1 + lineWidth);
105 indices[indexCount++] = (vbase + lineWidth);
107 indices[indexCount++] = (vbase + 1);
108 indices[indexCount++] = (vbase + lineWidth);
109 indices[indexCount++] = (vbase);
115 for (
int y = 0;
y < tessellation;
y++)
117 for (
int x = 0; x < tessellation; x++)
120 int vbase = lineWidth *
y + x;
121 indices[indexCount++] = (vbase + 1);
122 indices[indexCount++] = (vbase + lineWidth);
123 indices[indexCount++] = (vbase + 1 + lineWidth);
125 indices[indexCount++] = (vbase + 1);
126 indices[indexCount++] = (vbase);
127 indices[indexCount++] = (vbase + lineWidth);
133 return new GeometricMeshData<VertexPositionNormalTexture>(vertices, indices, toLeftHanded) { Name =
"Plane" };
SiliconStudio.Paradox.Games.Mathematics.Vector2 Vector2
Represents a two dimensional mathematical vector.
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t y
static GeometricMeshData< VertexPositionNormalTexture > New(float sizeX=1.0f, float sizeY=1.0f, int tessellation=1, bool toLeftHanded=false, Vector2?uvFactors=null, bool generateBackFace=false)
Creates a Plane primitive on the X/Y plane with a normal equal to -Vector3.UnitZ. ...
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 texture information...
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.
static GeometricPrimitive New(GraphicsDevice device, float sizeX=1.0f, float sizeY=1.0f, int tessellation=1, bool toLeftHanded=false, Vector2?uvFactors=null)
Creates a Plane primitive on the X/Y plane with a normal equal to -Vector3.UnitZ. ...
SiliconStudio.Core.Mathematics.Vector3 Vector3