Well okay, I guess, I am not that into it.
I'll post my code, so you can see if it has the necessary information.
protected override void Initialize()
{
// TODO: Add your initialization logic here
basicEffect = new BasicEffect(GraphicsDevice);
List<VertexPositionColor> vertices = new List<VertexPositionColor>();
float t = (float)(1.0 + Math.Sqrt(5.0f)) / 2.0f;
vertices = AddNormalizedVertex(vertices, new Vector3(-1, 0, t), Color.Gray);
vertices = AddNormalizedVertex(vertices, new Vector3(1, 0, t), Color.Gray);
vertices = AddNormalizedVertex(vertices, new Vector3(-1, 0, -t), Color.Gray);
vertices = AddNormalizedVertex(vertices, new Vector3(1, 0, -t), Color.Gray);
vertices = AddNormalizedVertex(vertices, new Vector3(0, t, 1), Color.Gray);
vertices = AddNormalizedVertex(vertices, new Vector3(0, t, -1), Color.Gray);
vertices = AddNormalizedVertex(vertices, new Vector3(0, -t, 1), Color.Gray);
vertices = AddNormalizedVertex(vertices, new Vector3(0, -t, -1), Color.Gray);
vertices = AddNormalizedVertex(vertices, new Vector3(t, 1, 0), Color.Gray);
vertices = AddNormalizedVertex(vertices, new Vector3(-t, 1, 0), Color.Gray);
vertices = AddNormalizedVertex(vertices, new Vector3(t, -1, 0), Color.Gray);
vertices = AddNormalizedVertex(vertices, new Vector3(-t, -1, 0), Color.Gray);
List<int> indices = new List<int>();
indices.Add(0); indices.Add(6); indices.Add(1);
indices.Add(0); indices.Add(11); indices.Add(6);
indices.Add(1); indices.Add(4); indices.Add(0);
indices.Add(1); indices.Add(8); indices.Add(4);
indices.Add(1); indices.Add(10); indices.Add(8);
indices.Add(2); indices.Add(5); indices.Add(3);
indices.Add(2); indices.Add(9); indices.Add(5);
indices.Add(2); indices.Add(11); indices.Add(9);
indices.Add(3); indices.Add(7); indices.Add(2);
indices.Add(3); indices.Add(10); indices.Add(7);
indices.Add(4); indices.Add(8); indices.Add(5);
indices.Add(4); indices.Add(9); indices.Add(0);
indices.Add(5); indices.Add(8); indices.Add(3);
indices.Add(5); indices.Add(9); indices.Add(4);
indices.Add(6); indices.Add(10); indices.Add(1);
indices.Add(6); indices.Add(11); indices.Add(7);
indices.Add(7); indices.Add(10); indices.Add(6);
indices.Add(7); indices.Add(11); indices.Add(2);
indices.Add(8); indices.Add(10); indices.Add(3);
indices.Add(9); indices.Add(11); indices.Add(0);
List<int> indices2 = new List<int>();
for (int j = 0; j <4 ; j++)
{
for (int i = 0; i < indices.Count; i++)
{
Vector3 p1 = vertices[indices[i]].Position;
int p1I = (int)i++;
Vector3 p2 = vertices[indices[i]].Position;
int p2I = (int)i++;
Vector3 p3 = vertices[indices[i]].Position;
int p3I = (int)i;
int a = (int)vertices.Count;
vertices = AddNormalizedVertex(vertices, new Vector3(((p1.X + p2.X) / 2), (p1.Y + p2.Y) / 2, (p1.Z + p2.Z) / 2), Color.Green);
int b = (int)vertices.Count;
vertices = AddNormalizedVertex(vertices, new Vector3((p2.X + p3.X) / 2, (p2.Y + p3.Y) / 2, (p2.Z + p3.Z) / 2), Color.Yellow);
int c = (int)vertices.Count;
vertices = AddNormalizedVertex(vertices, new Vector3((p3.X + p1.X) / 2, (p3.Y + p1.Y) / 2, (p3.Z + p1.Z) / 2), Color.Red);
indices2.Add(indices[p1I]); indices2.Add(c); indices2.Add(a);
indices2.Add(indices[p2I]); indices2.Add(a); indices2.Add(b);
indices2.Add(indices[p3I]); indices2.Add(b); indices2.Add(c);
indices2.Add(b); indices2.Add(a); indices2.Add(c);
}
indices.Clear();
foreach (int index in indices2)
{
indices.Add(index);
}
}
vertexList = new VertexPositionColor[vertices.Count];
for (int i = 0; i < vertices.Count; i++)
{
vertexList[i] = vertices[i];
}
indexList = new int[indices.Count];
for (int i = 0; i < indices.Count; i++)
{
indexList[i] = indices[i];
}
vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColor), vertexList.Length, BufferUsage.WriteOnly);
vertexBuffer.SetData<VertexPositionColor>(vertexList);
indexBuffer = new IndexBuffer(graphics.GraphicsDevice, typeof(int), indexList.Length, BufferUsage.WriteOnly);
indexBuffer.SetData(indexList);
base.Initialize();
}
Thats the Code for the Icosphere (building a Icosahedron and sudivide the vertices).
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.DarkSlateBlue);
DrawPrimitive(vertexList);
base.Draw(gameTime);
}
protected void DrawPrimitive(VertexPositionColor[] vertices)
{
basicEffect.VertexColorEnabled = true;
basicEffect.World = world;
basicEffect.View = view;
basicEffect.Projection = projection;
GraphicsDevice.SetVertexBuffer(vertexBuffer);
GraphicsDevice.Indices = indexBuffer;
RasterizerState rasterizerState = new RasterizerState();
rasterizerState.CullMode = CullMode.None;
GraphicsDevice.RasterizerState = rasterizerState;
foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
{
pass.Apply();
GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertexList.Length, 0, indexList.Length / 3);
}
}
And thats the draw Methodes. if I type in basicEffect.EnableLighting = true; It will crash.
Another thing just came to my mind, if I Enable Culling, there are some weird effects in the icosphere as some triangles won't be drawn correctly.
But either way, even with only 0 iteration (pure Icosahedron without subdividing) there is this crash :/
The error it gives me is this:
"SharpDX.SharpDXException" in SharpDX.dll
HRESULT: [0x80070057], Modules: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: Invalide Parameter.