예제 #1
0
        //Draw Object, Set Objects Powerup to the objects current position.
        public void Draw(clsCamera Cam,GraphicsDevice gd, SpriteBatch spriteBatch, SpriteFont font)
        {
            if(Visible)
            {
                boundingBox.Min = Position; boundingBox.Max = Position + Size;

                foreach (ModelMesh mesh in fbxModel[Frame].Meshes)
                {
                    foreach (BasicEffect effect in mesh.Effects)
                    {
                        effect.EnableDefaultLighting();
                        effect.World = worldMatrix *
                                Matrix.CreateRotationX(MathHelper.ToRadians(Rotation.X)) *
                                Matrix.CreateRotationY(MathHelper.ToRadians(Rotation.Y)) *
                                Matrix.CreateRotationZ(MathHelper.ToRadians(Rotation.Z)) *
                                Matrix.CreateTranslation(Position);
                        effect.View = Cam.viewMatrix;
                        effect.Projection = Cam.projectionMatrix;
                    }
                    mesh.Draw();
                }
                screenCoords_position = TransformPosition(Cam, gd, Position);
                screenCoords_size = TransformPosition(Cam, gd, Position + Size);
                screenCoords_size -= screenCoords_position;
                if (!PowerUp.isVisible())
                {
                    PowerUp.SetPosition(screenCoords_position + screenCoords_size / 2);
                }
               }
        }
예제 #2
0
 //Render a new bounding box
 public void BoundingRender(clsCamera Cam)
 {
     boundingBoxViewer.Render(boundingBox, Cam.viewMatrix, Cam.projectionMatrix, Color.Red);
 }
예제 #3
0
 //Convert current 3D position into screen coordinates
 public Vector2 TransformPosition(clsCamera Cam, GraphicsDevice gd, Vector3 _in)
 {
     Vector4 oTransformedPosition = Vector4.Transform(_in, Cam.viewMatrix * Cam.projectionMatrix);
     if (oTransformedPosition.W != 0)
     {
         oTransformedPosition.X /= oTransformedPosition.W;
         oTransformedPosition.Y /= oTransformedPosition.W;
         oTransformedPosition.Z /= oTransformedPosition.W;
     }
     return new Vector2(
       oTransformedPosition.X * gd.PresentationParameters.BackBufferWidth / 2 + gd.PresentationParameters.BackBufferWidth / 2,
       -oTransformedPosition.Y * gd.PresentationParameters.BackBufferHeight / 2 + gd.PresentationParameters.BackBufferHeight / 2);
 }
예제 #4
0
 //Instantiate a power up object
 public void AddPowerUP(int _ID, Texture2D _texture, clsCamera Cam, Vector2 _position, Vector2 _size, GraphicsDevice GD, byte _framesinAnim)
 {
     PowerUp = new clsDrops(_ID, _texture, _position, _size, new Vector2(0, 1), _framesinAnim);
 }
예제 #5
0
 //Draw the object in a certain position
 public void Draw(clsCamera Cam, Vector3 _position)
 {
     Position = _position;
     if (Visible)
     {
         foreach (ModelMesh mesh in fbxModel[Frame].Meshes)
         {
             foreach (BasicEffect effect in mesh.Effects)
             {
                 effect.EnableDefaultLighting();
                 effect.World = worldMatrix * Matrix.CreateScale(Scale) *
                         Matrix.CreateRotationX(MathHelper.ToRadians(Rotation.X)) *
                         Matrix.CreateRotationY(MathHelper.ToRadians(Rotation.Y)) *
                         Matrix.CreateRotationZ(MathHelper.ToRadians(Rotation.Z)) *
                         Matrix.CreateTranslation(Position);
                 effect.View = Cam.viewMatrix;
                 effect.Projection = Cam.projectionMatrix;
             }
             mesh.Draw();
         }
     }
 }