コード例 #1
0
ファイル: Page.cs プロジェクト: GlennSandoval/JSIL
        static CubeData () {
            // Temporary stream arrays because I'm way too lazy to convert these to individual vertices by hand
            var positions = new [] {
                // Front face
                new Vector3f(-1, -1,  1),
                new Vector3f( 1, -1,  1),
                new Vector3f( 1,  1,  1),
                new Vector3f(-1,  1,  1),

                // Back face
                new Vector3f(-1, -1, -1),
                new Vector3f(-1,  1, -1),
                new Vector3f( 1,  1, -1),
                new Vector3f( 1, -1, -1),

                // Top face
                new Vector3f(-1,  1, -1),
                new Vector3f(-1,  1,  1),
                new Vector3f( 1,  1,  1),
                new Vector3f( 1,  1, -1),

                // Bottom face
                new Vector3f(-1, -1, -1),
                new Vector3f( 1, -1, -1),
                new Vector3f( 1, -1,  1),
                new Vector3f(-1, -1,  1),

                // Right face
                new Vector3f( 1, -1, -1),
                new Vector3f( 1,  1, -1),
                new Vector3f( 1,  1,  1),
                new Vector3f( 1, -1,  1),

                // Left face
                new Vector3f(-1, -1, -1),
                new Vector3f(-1, -1,  1),
                new Vector3f(-1,  1,  1),
                new Vector3f(-1,  1, -1),
            };

            var normals = new [] {
                // Front face
                 new Vector3f(0,  0,  1),
                 new Vector3f(0,  0,  1),
                 new Vector3f(0,  0,  1),
                 new Vector3f(0,  0,  1),

                // Back face
                 new Vector3f(0,  0, -1),
                 new Vector3f(0,  0, -1),
                 new Vector3f(0,  0, -1),
                 new Vector3f(0,  0, -1),

                // Top face
                 new Vector3f(0,  1,  0),
                 new Vector3f(0,  1,  0),
                 new Vector3f(0,  1,  0),
                 new Vector3f(0,  1,  0),

                // Bottom face
                 new Vector3f(0, -1,  0),
                 new Vector3f(0, -1,  0),
                 new Vector3f(0, -1,  0),
                 new Vector3f(0, -1,  0),

                // Right face
                 new Vector3f(1,  0,  0),
                 new Vector3f(1,  0,  0),
                 new Vector3f(1,  0,  0),
                 new Vector3f(1,  0,  0),

                // Left face
                new Vector3f(-1,  0,  0),
                new Vector3f(-1,  0,  0),
                new Vector3f(-1,  0,  0),
                new Vector3f(-1,  0,  0)
            };

            var texCoords = new [] {
                // Front face
                new Vector2f(0, 0),
                new Vector2f(1, 0),
                new Vector2f(1, 1),
                new Vector2f(0, 1),

                // Back face
                new Vector2f(1, 0),
                new Vector2f(1, 1),
                new Vector2f(0, 1),
                new Vector2f(0, 0),

                // Top face
                new Vector2f(0, 1),
                new Vector2f(0, 0),
                new Vector2f(1, 0),
                new Vector2f(1, 1),

                // Bottom face
                new Vector2f(1, 1),
                new Vector2f(0, 1),
                new Vector2f(0, 0),
                new Vector2f(1, 0),

                // Right face
                new Vector2f(1, 0),
                new Vector2f(1, 1),
                new Vector2f(0, 1),
                new Vector2f(0, 0),

                // Left face
                new Vector2f(0, 0),
                new Vector2f(1, 0),
                new Vector2f(1, 1),
                new Vector2f(0, 1)
            };

            Vertices = new CubeVertex[positions.Length];

            for (var i = 0; i < Vertices.Length; i++) {
                Vertices[i] = new CubeVertex(positions[i], normals[i], texCoords[i]);
            }
        }
コード例 #2
0
        static CubeData()
        {
            // Temporary stream arrays because I'm way too lazy to convert these to individual vertices by hand
            var positions = new [] {
                // Front face
                new Vector3f(-1, -1, 1),
                new Vector3f(1, -1, 1),
                new Vector3f(1, 1, 1),
                new Vector3f(-1, 1, 1),

                // Back face
                new Vector3f(-1, -1, -1),
                new Vector3f(-1, 1, -1),
                new Vector3f(1, 1, -1),
                new Vector3f(1, -1, -1),

                // Top face
                new Vector3f(-1, 1, -1),
                new Vector3f(-1, 1, 1),
                new Vector3f(1, 1, 1),
                new Vector3f(1, 1, -1),

                // Bottom face
                new Vector3f(-1, -1, -1),
                new Vector3f(1, -1, -1),
                new Vector3f(1, -1, 1),
                new Vector3f(-1, -1, 1),

                // Right face
                new Vector3f(1, -1, -1),
                new Vector3f(1, 1, -1),
                new Vector3f(1, 1, 1),
                new Vector3f(1, -1, 1),

                // Left face
                new Vector3f(-1, -1, -1),
                new Vector3f(-1, -1, 1),
                new Vector3f(-1, 1, 1),
                new Vector3f(-1, 1, -1),
            };

            var normals = new [] {
                // Front face
                new Vector3f(0, 0, 1),
                new Vector3f(0, 0, 1),
                new Vector3f(0, 0, 1),
                new Vector3f(0, 0, 1),

                // Back face
                new Vector3f(0, 0, -1),
                new Vector3f(0, 0, -1),
                new Vector3f(0, 0, -1),
                new Vector3f(0, 0, -1),

                // Top face
                new Vector3f(0, 1, 0),
                new Vector3f(0, 1, 0),
                new Vector3f(0, 1, 0),
                new Vector3f(0, 1, 0),

                // Bottom face
                new Vector3f(0, -1, 0),
                new Vector3f(0, -1, 0),
                new Vector3f(0, -1, 0),
                new Vector3f(0, -1, 0),

                // Right face
                new Vector3f(1, 0, 0),
                new Vector3f(1, 0, 0),
                new Vector3f(1, 0, 0),
                new Vector3f(1, 0, 0),

                // Left face
                new Vector3f(-1, 0, 0),
                new Vector3f(-1, 0, 0),
                new Vector3f(-1, 0, 0),
                new Vector3f(-1, 0, 0)
            };

            var texCoords = new [] {
                // Front face
                new Vector2f(0, 0),
                new Vector2f(1, 0),
                new Vector2f(1, 1),
                new Vector2f(0, 1),

                // Back face
                new Vector2f(1, 0),
                new Vector2f(1, 1),
                new Vector2f(0, 1),
                new Vector2f(0, 0),

                // Top face
                new Vector2f(0, 1),
                new Vector2f(0, 0),
                new Vector2f(1, 0),
                new Vector2f(1, 1),

                // Bottom face
                new Vector2f(1, 1),
                new Vector2f(0, 1),
                new Vector2f(0, 0),
                new Vector2f(1, 0),

                // Right face
                new Vector2f(1, 0),
                new Vector2f(1, 1),
                new Vector2f(0, 1),
                new Vector2f(0, 0),

                // Left face
                new Vector2f(0, 0),
                new Vector2f(1, 0),
                new Vector2f(1, 1),
                new Vector2f(0, 1)
            };

            Vertices = new CubeVertex[positions.Length];

            for (var i = 0; i < Vertices.Length; i++)
            {
                Vertices[i] = new CubeVertex(positions[i], normals[i], texCoords[i]);
            }
        }