Esempio n. 1
0
        public Player(Scene parent, Vector3 spawnPos, Vector3 viewDir, GameInput gameInput)
        {
            Parent = parent;
            this.gameInput = gameInput;

            //create hud renderer
            hud = new Hud(this);
            parent.guis.Add(hud);

            Position = spawnPos;
            PointingDirection = viewDir;

            upVector = new Vector3(0, 1, 0);
            zNear = 0.1f;
            zFar = 100;

            Shape boxShape = new BoxShape(new JVector(0.5f, 2, 0.5f));

            Body = new RigidBody(boxShape);
            Body.Position = new JVector(Position.X, Position.Y, Position.Z);
            Body.AllowDeactivation = false;

            JMatrix mMatrix = JMatrix.Identity;

            //mBody.SetMassProperties(mMatrix, 2,false);

            Jitter.Dynamics.Constraints.SingleBody.FixedAngle mConstraint = new Jitter.Dynamics.Constraints.SingleBody.FixedAngle(Body);

            parent.world.AddConstraint(mConstraint);
            parent.world.AddBody(Body);

            viewInfo = new ViewInfo(this);
            viewInfo.aspect = (float)gameWindow.Width / (float)gameWindow.Height;
            viewInfo.updateProjectionMatrix();

            tools.Add(new GameMenu(this, gameInput));
            tools.Add(new Spawner(this, gameInput));
            tools.Add(new Grabber(this, gameInput));
            tools.Add(new Remover(this, gameInput));
            tools.Add(new TerrainGun(this, gameInput));

            tool = tools[1];
        }
Esempio n. 2
0
        public Player(Scene parent, Vector3 spawnPos, Vector3 viewDir, GameInput gameInput)
        {
            Parent         = parent;
            this.gameInput = gameInput;

            //create hud renderer
            hud = new Hud(this);
            parent.guis.Add(hud);

            Position          = spawnPos;
            PointingDirection = viewDir;

            upVector = new Vector3(0, 1, 0);

            Shape boxShape = new BoxShape(new JVector(0.5f, 2, 0.5f));

            Body                   = new RigidBody(boxShape);
            Body.Position          = new JVector(Position.X, Position.Y, Position.Z);
            Body.AllowDeactivation = false;

            JMatrix mMatrix = JMatrix.Identity;

            //mBody.SetMassProperties(mMatrix, 2,false);

            Jitter.Dynamics.Constraints.SingleBody.FixedAngle mConstraint = new Jitter.Dynamics.Constraints.SingleBody.FixedAngle(Body);

            parent.world.AddConstraint(mConstraint);
            parent.world.AddBody(Body);

            viewInfo        = new ViewInfo(this);
            viewInfo.aspect = (float)gameWindow.Width / (float)gameWindow.Height;
            viewInfo.updateProjectionMatrix();

            tools.Add(new GameMenu(this, gameInput));
            tools.Add(new Spawner(this, gameInput));
            tools.Add(new TerrainGun(this, gameInput));
            tools.Add(new Grabber(this, gameInput));
            tools.Add(new Remover(this, gameInput));

            tool = tools[1];
        }