예제 #1
0
        protected override void init()
        {
            GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);

            ball = new Ball();
            ball = new Ball(ballRadius);
            ball.SetLimits(ballLimitLow, ballLimitHigh);
            ballSpeed = new Vector3(
                ballSpeedFactor + ballSpeedFactor * (float)random.NextDouble(),
                ballSpeedFactor + ballSpeedFactor * (float)random.NextDouble(),
                ballSpeedFactor + ballSpeedFactor * (float)random.NextDouble());
            ball.SetSpeed(ballSpeed);
            ball.SetLightPosition(new Vector3(0f, 0f, -1f));

            ball.MoveLimits(new Vector3(0f, 0f, -1f));

            SetupDepthAndCull();
            GL.Disable(EnableCap.CullFace);
            Textures.EnableTextures();
            g_fzNear = 0.1f;
            g_fzFar = 100f;
            reshape();
        }
예제 #2
0
        //Called after the window and OpenGL are initialized. Called exactly once, before the main loop.
        protected override void init()
        {
            g_fzNear = 10.0f;
            g_fzFar = 1000.0f;
            frontWall = new PaintWall();
            backWall = new PaintWall();
            topWall = new PaintWall();
            bottomWall = new PaintWall();
            leftWall = new PaintWall();
            rightWall = new PaintWall();
            InitializeProgram();

            ball = new Ball(ballRadius);
            ball.SetLimits(ballLimitLow, ballLimitHigh);
            ballSpeed = new Vector3(
                ballSpeedFactor + ballSpeedFactor * (float)random.NextDouble(),
                ballSpeedFactor + ballSpeedFactor * (float)random.NextDouble(),
                ballSpeedFactor + ballSpeedFactor * (float)random.NextDouble());
            ball.SetSpeed(ballSpeed);
            //ball.SetProgram(ballProgram);

            try
            {
                g_unitSphereMesh = new Mesh("unitsphere12.xml");

            } catch (Exception ex) {
                throw new Exception("Error " + ex.ToString());
            }

            SetupDepthAndCull();
            Textures.EnableTextures();

            Camera.Move(0f, 0f, 0f);
            Camera.MoveTarget(0f, 0f, 0.0f);
            reshape();
            current_mesh = g_unitSphereMesh;
            frontWall.Move(0f, 0f, 1f);
            frontWall.Scale(50f);

            backWall.Move(0f, 0f, -1f);
            backWall.Scale(50f);

            leftWall.Move(-1f, 0f, 0f);
            leftWall.Scale(50f);
            leftWall.RotateShape(Vector3.UnitY, 90f);
            rightWall.Move(1f, 0f, 0f);
            rightWall.Scale(50f);
            rightWall.RotateShape(Vector3.UnitY, -90f);

            topWall.Move(0f, 1f, 0f);
            topWall.Scale(50f);
            topWall.RotateShape(Vector3.UnitX, 90f);
            bottomWall.Move(0f, -1f, 0f);
            bottomWall.Scale(50f);
            bottomWall.RotateShape(Vector3.UnitX, -90f);
        }
        protected override void init()
        {
            GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);

            boxLimitLow = new Vector3();
            boxLimitLow = ballLimitLow - new Vector3(ballRadius, ballRadius, ballRadius);
            boxLimitHigh = new Vector3();
            boxLimitHigh = ballLimitHigh + new Vector3(ballRadius, ballRadius, ballRadius);

            paintBox = new PaintBox();
            ball = new Ball(ballRadius);
            ball.SetLimits(ballLimitLow, ballLimitHigh);
            ball.SetSocketControl();
            ballSpeed = new Vector3(
                ballSpeedFactor + ballSpeedFactor * (float)random.NextDouble(),
                ballSpeedFactor + ballSpeedFactor * (float)random.NextDouble(),
                ballSpeedFactor + ballSpeedFactor * (float)random.NextDouble());
            ball.SetSpeed(ballSpeed);
            ball.SetLightPosition(new Vector3(0f, 0f, -1f));

            paintBox.SetLimits(boxLimitLow, boxLimitHigh, new Vector3(epsilon, epsilon, epsilon));
            paintBox.Move(new Vector3(0f, 0f, -1f));
            ball.MoveLimits(new Vector3(0f, 0f, -1f));

            SetupDepthAndCull();
            GL.Disable(EnableCap.CullFace);
            Textures.EnableTextures();
            g_fzNear = 0.5f;
            g_fzFar = 100f;
            reshape();
            paddles = new List<Paddle2>();

            AddPaddle(new Vector3(-1f, -1f, -1f), new Vector3(1f, 1f, -1f));
            paddles[0].SetMouseControl();

            AddPaddle(new Vector3(-1f, -1f, -3f), new Vector3(1f, 1f, -3f));
            paddles[BACK_PADDLE].SetNormal(new Vector3(0f, 0f, 1f));
            paddles[BACK_PADDLE].UseBlock(new Vector3(0.3f, 0.3f, 0.05f));

            AddPaddle(new Vector3(-1f, -1f, -3f), new Vector3(-1f, 1f, -1f));
            paddles[LEFT_PADDLE].SetNormal(new Vector3(1f, 0f, 0f));
            paddles[LEFT_PADDLE].UseBlock(new Vector3(0.05f, 0.3f, 0.3f));

            AddPaddle(new Vector3(1f, -1f, -3f), new Vector3(1f, 1f, -1f));
            paddles[RIGHT_PADDLE].SetNormal(new Vector3(-1f, 0f, 0f));
            paddles[RIGHT_PADDLE].UseBlock(new Vector3(0.05f, 0.3f, 0.3f));

            AddPaddle(new Vector3(-1f, 1f, -3f), new Vector3(1f, 1f, -1f));
            paddles[TOP_PADDLE].SetNormal(new Vector3(0f, -1f, 0f));
            paddles[TOP_PADDLE].UseBlock(new Vector3(0.3f, 0.05f, 0.3f));

            AddPaddle(new Vector3(-1f, -1f, -3f), new Vector3(1f, -1f, -1f));
            paddles[BOTTOM_PADDLE].SetNormal(new Vector3(0f, 1f, 0f));
            paddles[BOTTOM_PADDLE].UseBlock(new Vector3(0.3f, 0.05f, 0.3f));

            mousePostion = new TextClass("MousePosition", 0.4f, 0.04f, staticText);
            mousePostion.SetOffset(new Vector3(-0.75f, -0.75f, -0.5f));
            updateProgram();
            scores = new List<TextClass>();
            AddScore(new Vector3(-0.6f, 0.0f, -1f), new Vector3(0f, 1f, 0f), 45f);
            AddScore(new Vector3(0.6f, 0.0f, -1f), new Vector3(0f, 1f, 0f), -45f);

            AddScore(new Vector3(0.0f, -0.45f, -1f), new Vector3(1.0f, -0f, 0f), 0f);
            AddScore(new Vector3(0.0f, 0.45f, -1f), new Vector3(1.0f, -0f, 0f), 0f);

            AddScore(new Vector3(0.0f, 0.25f, -1f), new Vector3(1.0f, -0f, 0f), 0f);
            AddScore(new Vector3(0.0f, -0.85f, -1f), new Vector3(1.0f, -0f, 0f), 0f);
        }
예제 #4
0
        protected override void init()
        {
            stool.Move(new Vector3(0f, -0.03f, -1f));
            ball = new Ball(ballRadius);
            ball.SetLimits(ballLimitLow, ballLimitHigh);
            ballSpeed = new Vector3(0.5f, 0.5f, 0.5f);
            ball.SetSpeed(ballSpeed);
            ball.SetLightPosition(new Vector3(0f, 0f, -1f));
            ball.SetOffset(new Vector3(-0.75f, 0.75f, -1f));
            for (int i = 0; i < 6; i++)
            {
                Can c = new Can();
                c.RotateShape(new Vector3(1f, 0f, 0f), 90f);
                c.SetColor(Colors.BLUE_COLOR);
                switch (i)
                {
                    case 0: c.Move(new Vector3(-xSeparation, 0f, canZ)); break;
                    case 1: c.Move(new Vector3(0f, 0f, canZ)); break;
                    case 2: c.Move(new Vector3(xSeparation, 0f, canZ)); break;
                    case 3: c.Move(new Vector3(-xSeparation/2, ySeparation, canZ)); break;
                    case 4: c.Move(new Vector3(xSeparation/2, ySeparation, canZ)); break;
                    case 5: c.Move(new Vector3(0f, 2*ySeparation, canZ)); break;
                }
                c.SetSpeed(new Vector3(0f, 0f, 0f));
                c.AddPaddle(ball);

                cans.Add(c);
            }
            SetupDepthAndCull();
            updateProgram();
        }
예제 #5
0
        protected override void init()
        {
            GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);

            boxLimitLow = new Vector3();
            boxLimitLow = ballLimitLow - new Vector3(ballRadius, ballRadius, ballRadius);
            boxLimitHigh = new Vector3();
            boxLimitHigh = ballLimitHigh + new Vector3(ballRadius, ballRadius, ballRadius);

            paintBox = new PaintBox();
            ball = new Ball(ballRadius);
            ball.SetLimits(ballLimitLow, ballLimitHigh);
            ballSpeed = new Vector3(0f, 0f, 0f);
            ball.SetSpeed(ballSpeed);
            ball.SetLightPosition(new Vector3(0f, 0f, -1f));

            paintBox.SetLimits(boxLimitLow, boxLimitHigh, new Vector3(epsilon, epsilon, epsilon));
            paintBox.Move(new Vector3(0f, 0f, -1f));
            ball.MoveLimits(new Vector3(0f, 0f, -1f));

            SetupDepthAndCull();
            GL.Disable(EnableCap.CullFace);
            Textures.EnableTextures();
            g_fzNear = 0.5f;
            g_fzFar = 100f;
            reshape();
            paddles = new List<Paddle2>();
            Paddle2 paddle = new Paddle2();
            paddle.SetLimits(new Vector3(-1f, -1f, -0.5f), new Vector3(1f, 1f, -0.5f));
            paddle.SetKeyboardControl();
            paddles.Add(paddle);
            mousePostion = new TextClass("MousePosition", 0.4f, 0.04f, staticText);
            mousePostion.SetOffset(new Vector3(-0.75f, -0.75f, -0.5f));
            updateProgram();
        }