Using this engine, but how?

Jul 17, 2011 at 11:14 PM

Hi,

I try to use this engine in my game, but it fails on the camera implementation.

I have a camera:

transformMatrix = Matrix.CreateTranslation(-cameraPosition); // cameraPosition is a Vector3 currently 0,0,0

in contentLoad:

 

// Create a new simple point light texture to use for the lights
this.mLightTexture = LightTextureBuilder.CreatePointLight(this.GraphicsDevice, 512);

// Create some lights and hulls
light = new Light2D();
light.Texture = mLightTexture;
light.Range = 10f;
light.Color = Color.White;
light.Intensity = 1f;
light.X = 20;
light.Y = 20;
this.krypton.Lights.Add(light);

hull = ShadowHull.CreateRectangle(Vector2.One);
hull.Position.X = 0;
hull.Position.Y = 0;
hull.Scale.X = 10;
hull.Scale.Y = 10;
this.krypton.Hulls.Add(hull);

That should set a light on the left-top corner of my Game: 20,20
and a shadow hull at 0,0

I set the matrix:
this.krypton.Matrix = transformMatrix;

but nothing is drawn.
Only if I use

            // Create a world view projection matrix to use with krypton
            Matrix world = Matrix.Identity;
            Matrix view = Matrix.CreateTranslation(new Vector3(0, 0, 0) * -1f);
            Matrix projection = Matrix.CreateOrthographic(this.mVerticalUnits * this.GraphicsDevice.Viewport.AspectRatio, this.mVerticalUnits, 0, 1);

            // Assign the matrix and pre-render the lightmap.
            // Make sure not to change the position of any lights or shadow hulls after this call, as it won't take effect till the next frame!
            this.krypton.Matrix = world * view * projection;

it shows my light, but not on 10,10.... why not?

 

 

Coordinator
Aug 4, 2011 at 10:04 PM
Edited Aug 4, 2011 at 10:04 PM

DarkPrisma,

I'm sorry for the late response. Have you tried the following? (note the cameraPosition vs the new Vector3(...)

// Create a world view projection matrix to use with krypton
Matrix world = Matrix.Identity;
Matrix view = Matrix.CreateTranslation(cameraPosition * -1f);
Matrix projection = Matrix.CreateOrthographic(this.mVerticalUnits * this.GraphicsDevice.Viewport.AspectRatio, this.mVerticalUnits, 0, 1);
// Assign the matrix and pre-render the lightmap.
// Make sure not to change the position of any lights or shadow hulls after this call, as it won't take effect till the next frame!
this.krypton.Matrix = world * view * projection;