Note that there are some explanatory texts on larger screens.

plurals
  1. POFarseer/XNA Assertion Failed, Vector2 position for body modified by camera matrix
    primarykey
    data
    text
    <p>I created a camera with a matrix and used it to move the view point in 2D. Basically I started from this template: <a href="http://torshall.se/?p=272" rel="nofollow">http://torshall.se/?p=272</a></p> <p>I also had in one of my class, a simple code to spawn boxs with the mouse:</p> <pre><code>public void CreateBodies() { mouse = Mouse.GetState(); if (mouse.RightButton == ButtonState.Pressed) { Bodies += 1; if (Bodies &gt;= MaxBodies) Bodies = 0; rectBody[Bodies] = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(rectangle.Width), ConvertUnits.ToSimUnits(rectangle.Height), 1); rectBody[Bodies].Position = ConvertUnits.ToSimUnits(mouse.X, mouse.Y); rectBody[Bodies].BodyType = BodyType.Dynamic; } } </code></pre> <p>This Worked perfectly fine but when I moved the ''camera'' the mouse didn't change in the right location, Si I did this little modification in game1.cs and in my method to have the world coord. of my mouse:</p> <pre><code>mouse = Mouse.GetState(); Matrix inverse = Matrix.Invert(camera.transform); Vector2 mousePos = Vector2.Transform(new Vector2(mouse.X, mouse.Y), inverse); TE.CreateBodies(mousePos); public void CreateBodies(Vector2 mousePosition) { mouse = Mouse.GetState(); MousePosition = mousePosition; if (mouse.RightButton == ButtonState.Pressed) { Bodies += 1; if (Bodies &gt;= MaxBodies) { Bodies = 0; } rectBody[Bodies] = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(rectangle.Width), ConvertUnits.ToSimUnits(rectangle.Height), 1); rectBody[Bodies].BodyType = BodyType.Dynamic; rectBody[Bodies].Position = ConvertUnits.ToSimUnits(MousePosition); } } </code></pre> <p>Now this is supposed to give me the world coords. of my mouse, but I have a problem, when I run the program and click somewhere on the screen to create a box I get this error:</p> <p><a href="http://img68.xooimage.com/files/6/a/4/bob-2c526f4.png" rel="nofollow">http://img68.xooimage.com/files/6/a/4/bob-2c526f4.png</a></p> <p>What's going on? :/</p> <p>Edit:</p> <p>This is at the line 439 of body.cs:</p> <pre><code>Debug.Assert(!float.IsNaN(value.X) &amp;&amp; !float.IsNaN(value.Y)); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload