Problems aligning with camera matrix.

Jul 3, 2012 at 1:29 PM
Edited Jul 3, 2012 at 1:32 PM

I cannot seem to get the ParticleEffect to align with my camera matrix properly.

 

Camera Class is as follows:

 

public

public class Camera2d
    {
        protected float _zoom;
        public Matrix _transform;
        public Matrix _inverseTransform;
        public Vector2 _pos;
        protected float _rotation;
        public BoundingFrustum boundingFrustum;

        public Camera2d()
        {
            _zoom = 1.0f;
            _rotation = 0.0f;
            _pos = Vector2.Zero;
            boundingFrustum = new BoundingFrustum(_transform);
        }

        public float Zoom
        {
            get { return _zoom; }
            set { _zoom = value; if (_zoom < 0.1f) _zoom = 0.1f; }
        }

        public float Rotation
        {
            get { return _rotation; }
            set { _rotation = value; }
        }

        public void Move(Vector2 amount)
        { _pos += amount; }

        public Vector2 Pos
        {
            get { return _pos; }
            set { _pos = value; }
        }

        public Matrix get_transformation(GraphicsDeviceManager graphicsDevice)
        {
            _transform =
                          Matrix.CreateTranslation(new Vector3(-_pos.X, -_pos.Y, 0)) *
                                                  Matrix.CreateRotationZ(Rotation) *
                                                   Matrix.CreateScale(new Vector3(Zoom, Zoom, 1)) *
                                                 Matrix.CreateTranslation(new Vector3(graphicsDevice.GraphicsDevice.Viewport.Width * 0.5f, graphicsDevice.GraphicsDevice.Viewport.Height * 0.5f, 0));

            _inverseTransform = Matrix.Invert(_transform);

            return _transform;
        }
    }

 

Using that, I have attempted to draw the ParticleEffect as follows:

 

//using a spriteBatchRenderer

ParticleRenderer.Render(CurrentEffect, ref PlayerCam._transform);

 

The Effect itself Triggers at the players position. This does not align properly with the camera - I can only see the effect if I am stood near 0,0.

I have tried the latest download and the latest source code, of which the latter seems to have several other issues.

 

Any help would be greatly appreciated :)