Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            try
            {
                ActiveMesh = Mesh.LoadMeshFromFile(@"Resources\Meshes\link.obj");
            }
            catch (Exception e)
            {
                Console.WriteLine($"Failed to load mesh: {e.Message}");
                Console.Read();
                return;
            }

            //BrightnessInit.go();
            //BrightnessInit.sortstuff();
            GameInit(RENDER_WIDTH, RENDER_HEIGHT, "render");
            ActiveMesh.Translate(new Vector3(-800, -300, -8));
            //someShape.rotate((float)0.25);

            FrameBuffer.DrawFrame(Rasterizer.RenderSolid(ActiveMesh));
            //Console.ReadLine();
            //someShape.rotate((float)(3.1415));

            // render loop
            while (true)
            {
                //light1.intensity = (int)((double)800 * Math.Sin(4*i));
                //someShape.rotate(0.005, 0);
                //someShape.rotate(0.005, 1);
                //someShape.rotate(0.005, 2);
                //someShape.translate(new Mesh.point3((float)Math.Sin(i), 0, 0));
                //  buffer.drawFrame(drawLine(new byte[RENDER_HEIGHT * RENDER_WIDTH], a1, a2));
                if (renderState.x == 0)
                {
                    FrameBuffer.DrawFrame(Rasterizer.RenderSolid(ActiveMesh));
                }
                else if (renderState.x == 1)
                {
                    FrameBuffer.DrawFrame(Rasterizer.RenderVertices(ActiveMesh));
                }
                else if (renderState.x == 2)
                {
                    FrameBuffer.DrawFrame(Rasterizer.RenderWire(ActiveMesh));
                }

                //light1.coords.x = 1000 * (float)Math.Sin(i);
                // light1.coords.y = 1000 * (float)Math.Sin(i);
                //light1.coords.z = 100 * (float)Math.Sin(i);
                //someShape.rotate((float)0.005, 0);
                //someShape.rotate((float)0.005, 1);
            }
        }
Ejemplo n.º 2
0
        private static void MainGetInput()
        {
            //Console.TreatControlCAsInput = true;

            while (true)
            {
                ConsoleKeyInfo keyInfo = Console.ReadKey();
                if (keyInfo.Key == ConsoleKey.Escape)
                {
                    Environment.Exit(0);
                    return;
                }

                switch (keyInfo.Key)
                {
                case ConsoleKey.Spacebar:
                    renderState.changeState();
                    break;

                case ConsoleKey.W:
                    ActiveMesh.Translate(0, 0, 0.1f);
                    break;

                case ConsoleKey.A:
                    ActiveMesh.Translate(-10.0f, 0, 0);
                    break;

                case ConsoleKey.S:
                    ActiveMesh.Translate(0, 0, -0.1f);
                    break;

                case ConsoleKey.D:
                    ActiveMesh.Translate(10.0f, 0, 0);
                    break;

                case ConsoleKey.R:
                    ActiveMesh.Rotate(0.01, 0);
                    break;

                case ConsoleKey.T:
                    ActiveMesh.Rotate(0.01, 1);
                    break;

                case ConsoleKey.Y:
                    ActiveMesh.Rotate(0.01, 2);
                    break;

                case ConsoleKey.Q:
                    ActiveMesh.Translate(0, -10.0f, 0);
                    break;

                case ConsoleKey.E:
                    ActiveMesh.Translate(0, 10.0f, 0);
                    break;
                }
            }
        }
Ejemplo n.º 3
0
 public void applyVelocity()
 {
     if (Math.Abs(MassCenter.X + Math.Sign(velocity.X) * radius) >= floor)
     {
         velocity.X        *= -1;
         angularVelocity.X += velocity.X / 100;
     }
     if (Math.Abs(MassCenter.Y + Math.Sign(velocity.Y) * radius) >= floor)
     {
         velocity.Y        *= -1;
         angularVelocity.Y += velocity.Y / 100;
     }
     if (Math.Abs(MassCenter.Z + Math.Sign(velocity.Z) * radius) + 600.0f >= floor)
     {
         velocity.Z        *= -1;
         angularVelocity.Z += velocity.Z / 100;
     }
     mesh.Translate(velocity);
     mesh.Rotate(angularVelocity);
 }