Opentk/Source/Examples/Shapes/Cube.cs

75 lines
2.3 KiB
C#
Raw Normal View History

2007-09-25 21:11:16 +00:00
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
2007-09-25 21:11:16 +00:00
using System.Drawing;
using OpenTK.Math;
using System.Runtime.InteropServices;
namespace Examples.Shapes
{
public class Cube : Shape
{
public Cube()
{
Vertices = new Vector3[]
{
new Vector3(-1.0f, -1.0f, 1.0f),
new Vector3( 1.0f, -1.0f, 1.0f),
new Vector3( 1.0f, 1.0f, 1.0f),
new Vector3(-1.0f, 1.0f, 1.0f),
new Vector3(-1.0f, -1.0f, -1.0f),
new Vector3( 1.0f, -1.0f, -1.0f),
new Vector3( 1.0f, 1.0f, -1.0f),
new Vector3(-1.0f, 1.0f, -1.0f)
};
Indices = new int[]
{
// front face
0, 1, 2, 2, 3, 0,
// top face
3, 2, 6, 6, 7, 3,
// back face
7, 6, 5, 5, 4, 7,
// left face
4, 0, 3, 3, 7, 4,
// bottom face
0, 1, 5, 5, 4, 0,
// right face
1, 5, 6, 6, 2, 1,
};
Normals = new Vector3[]
{
new Vector3(-1.0f, -1.0f, 1.0f),
new Vector3( 1.0f, -1.0f, 1.0f),
new Vector3( 1.0f, 1.0f, 1.0f),
new Vector3(-1.0f, 1.0f, 1.0f),
new Vector3(-1.0f, -1.0f, -1.0f),
new Vector3( 1.0f, -1.0f, -1.0f),
new Vector3( 1.0f, 1.0f, -1.0f),
new Vector3(-1.0f, 1.0f, -1.0f),
};
Colors = new int[]
{
2007-11-10 23:29:45 +00:00
Utilities.ColorToRgba32(Color.DarkRed),
Utilities.ColorToRgba32(Color.DarkRed),
Utilities.ColorToRgba32(Color.Gold),
Utilities.ColorToRgba32(Color.Gold),
Utilities.ColorToRgba32(Color.DarkRed),
Utilities.ColorToRgba32(Color.DarkRed),
Utilities.ColorToRgba32(Color.Gold),
Utilities.ColorToRgba32(Color.Gold),
};
}
}
}