예제 #1
0
        public static void Pyramid(int it, float x, float y, float z, float size, float rotAngle, OpenTK.Vector3 rotAxis, Texture tRef, Scheme Tint, Transparency transparancy)
        {//Creates Pyramid Object
            //Adjusts object position for centering
            x += size / 2;
            x *= -1;
            y += size / 2;
            z += size / 2;

            rotAngle *= it;//sets rotation angle

            GL.PushMatrix();
            GL.Translate(x, y, z);                                                                           //Moves object

            GL.Rotate(-rotAngle, rotAxis.X, rotAxis.Y, rotAxis.Z);                                           //Rotates object
            //Bottom
            GL.BindTexture(TextureTarget.Texture2D, tRef.getBottom());                                       //Get texture
            GL.Begin(PrimitiveType.Quads);
            GL.Color4(Tint.getBottom().R, Tint.getBottom().G, Tint.getBottom().B, transparancy.getBottom()); //Set color and transparancy
            GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(-size / 2, -size / 2, size / 2);                            //Create Plane
            GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(-size / 2, -size / 2, -size / 2);
            GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(size / 2, -size / 2, -size / 2);
            GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(size / 2, -size / 2, size / 2);
            GL.End();

            //Front
            GL.BindTexture(TextureTarget.Texture2D, tRef.getFront());
            GL.Begin(PrimitiveType.Triangles);
            GL.Color4(Tint.getFront().R, Tint.getFront().G, Tint.getFront().B, transparancy.getFront());
            GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(-size / 2, -size / 2, size / 2);
            GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(size / 2, -size / 2, size / 2);
            GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(0, size / 2, 0);
            GL.End();

            //Back
            GL.BindTexture(TextureTarget.Texture2D, tRef.getBack());
            GL.Begin(PrimitiveType.Triangles);
            GL.Color4(Tint.getBack().R, Tint.getBack().G, Tint.getBack().B, transparancy.getBack());
            GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(size / 2, -size / 2, -size / 2);
            GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(-size / 2, -size / 2, -size / 2);
            GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(0, size / 2, 0);
            GL.End();

            //Left
            GL.BindTexture(TextureTarget.Texture2D, tRef.getLeft());
            GL.Begin(PrimitiveType.Triangles);
            GL.Color4(Tint.getLeft().R, Tint.getLeft().G, Tint.getLeft().B, transparancy.getLeft());
            GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(-size / 2, -size / 2, -size / 2);
            GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(-size / 2, -size / 2, size / 2);
            GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(0, size / 2, 0);
            GL.End();

            //Right
            GL.BindTexture(TextureTarget.Texture2D, tRef.getRight());
            GL.Begin(PrimitiveType.Triangles);
            GL.Color4(Tint.getRight().R, Tint.getRight().G, Tint.getRight().B, transparancy.getRight());
            GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(size / 2, -size / 2, size / 2);
            GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(size / 2, -size / 2, -size / 2);
            GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(0, size / 2, 0);
            GL.End();



            GL.PopMatrix();
        }
예제 #2
0
        public static void BoxScene(int it, OpenTK.Vector3 coor1, OpenTK.Vector3 coor2, int scheme)
        {                       //Draws Frame and Floor for a specified area
            float rotSpeed = 0; //sets the angle of Rotation

            OpenTK.Vector3 rotAxis = Main.rotAxis;
            float[]        TP      = new float[6] {
                1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f
            };
            Texture texture = new Texture("Wood");
            Scheme  Basic   = Main.Colors[scheme];

            OpenTK.Vector3 distance = coor1.distanceTo(coor2);
            int            xcount;
            int            ycount;
            int            zcount;

            if (distance.X == 0)
            {
                xcount = 1;
            }
            else
            {
                xcount = (int)(distance.X / Math.Abs(distance.X));
            }

            if (distance.Y == 0)
            {
                ycount = 1;
            }
            else
            {
                ycount = (int)(distance.Y / Math.Abs(distance.Y));
            }

            if (distance.Z == 0)
            {
                zcount = 1;
            }
            else
            {
                zcount = (int)(distance.Z / Math.Abs(distance.Z));
            }



            //Base
            DrawRect(it,
                     -(coor1.X - .6f * xcount), (coor1.Y - .6f * ycount), (coor1.Z - .6f * zcount),
                     -distance.X - xcount * 1.2f, 0.1f, 0.1f,
                     rotSpeed, rotAxis,
                     texture, Basic, TP);
            DrawRect(it,
                     -(coor1.X - .6f * xcount), (coor1.Y - .6f * ycount), (coor1.Z - .6f * zcount),
                     0.1f, 0.1f, distance.Z + zcount * 1.2f,
                     rotSpeed, rotAxis,
                     texture, Basic, TP);
            DrawRect(it,
                     -(coor1.X + distance.X + .6f * xcount), (coor1.Y - .6f * ycount), (coor1.Z + distance.Z + .6f * zcount),
                     distance.X + xcount * 1.2f, 0.1f, 0.1f,
                     rotSpeed, rotAxis,
                     texture, Basic, TP);
            DrawRect(it,
                     -(coor1.X + distance.X + .6f * xcount), (coor1.Y - .6f * ycount), (coor1.Z + distance.Z + .6f * zcount),
                     0.1f, 0.1f, -distance.Z - zcount * 1.2f,
                     rotSpeed, rotAxis,
                     texture, Basic, TP);

            //Walls
            DrawRect(it,
                     -(coor1.X - .6f * xcount), (coor1.Y + distance.Y + .6f * ycount), (coor1.Z - .6f * zcount),
                     0.1f, -(distance.Y + ycount * 1.2f), 0.1f,
                     rotSpeed, rotAxis,
                     texture, Basic, TP);
            DrawRect(it,
                     -(coor1.X + distance.X + .6f * xcount), (coor1.Y + distance.Y + .6f * ycount), (coor1.Z + distance.Z + .6f * zcount),
                     0.1f, -(distance.Y + ycount * 1.2f), 0.1f,
                     rotSpeed, rotAxis,
                     texture, Basic, TP);
            DrawRect(it,
                     -(coor1.X - .6f * xcount), (coor1.Y + distance.Y + .6f * ycount), (coor1.Z + distance.Z + .6f * zcount),
                     0.1f, -(distance.Y + ycount * 1.2f), 0.1f,
                     rotSpeed, rotAxis,
                     texture, Basic, TP);
            DrawRect(it,
                     -(coor1.X + distance.X + .6f * xcount), (coor1.Y + distance.Y + .6f * ycount), (coor1.Z - .6f * zcount),
                     0.1f, -(distance.Y + ycount * 1.2f), 0.1f,
                     rotSpeed, rotAxis,
                     texture, Basic, TP);
            //Top
            DrawRect(it,
                     -(coor1.X - .6f * xcount), (coor1.Y + distance.Y + .6f * ycount), (coor1.Z - .6f * zcount),
                     -distance.X - xcount * 1.2f, 0.1f, 0.1f,
                     rotSpeed, rotAxis,
                     texture, Basic, TP);
            DrawRect(it,
                     -(coor1.X - .6f * xcount), (coor1.Y + distance.Y + .6f * ycount), (coor1.Z - .6f * zcount),
                     0.1f, 0.1f, distance.Z + zcount * 1.2f,
                     rotSpeed, rotAxis,
                     texture, Basic, TP);
            DrawRect(it,
                     -(coor1.X + distance.X + .6f * xcount), (coor1.Y + distance.Y + .6f * ycount), (coor1.Z + distance.Z + .6f * zcount),
                     distance.X + xcount * 1.2f, 0.1f, 0.1f,
                     rotSpeed, rotAxis,
                     texture, Basic, TP);
            DrawRect(it,
                     -(coor1.X + distance.X + .6f * xcount), (coor1.Y + distance.Y + .6f * ycount), (coor1.Z + distance.Z + .6f * zcount),
                     0.1f, 0.1f, -distance.Z - zcount * 1.2f,
                     rotSpeed, rotAxis,
                     texture, Basic, TP);

            //BasePlane
            //DrawRect(it, 0, 0, 0, coor.X, 0, coor.Z, rotSpeed, rotAxis, floor, Basic, TP);
        }