First off I want to say hello (my first post). I just bought Pro the other day and have been playing around and having fun! ;D
So onward to my question...
I am trying to toss a sphere from the screen based on the mouse position. I opened up the starter template and changed really nothing except the locking mouse to center, I showed the mouse, and I turned off the camera from rotating on the mouse move.
I added some other stuff to create the model which doesn't really matter because you can see the results of the unproject in the debug line.
So if you move your mouse from one side to the other you get about a 0.5f difference in x, y or z. But if you move your camera an inch over to be centered on the spot that your mouse was just at then you get somewhere between a 5.3f- 6.0f difference.
So when I click to shoot the sphere it does not move at all (though the direction that I pass it to apply force to seems to work with the dir because its just normalized)
I have tried a few different things and this is the one that seems to come the closest.
Note: I have used unproject in XNA before successfully but it just doesn't want to work here...
Main Code:--------------------------------------------------Vector3 mouse = new Vector3(Mouse.GetState().X, Mouse.GetState().Y, 0);Vector3 pos1 = SunBurnCoreSystem.Instance.GraphicsDeviceManager.GraphicsDevice.Viewport.Unproject(mouse, sceneState.Projection, sceneState.View, Matrix.Identity);Vector3 pos2 = SunBurnCoreSystem.Instance.GraphicsDeviceManager.GraphicsDevice.Viewport.Unproject(mouse + new Vector3(0, 0, 1), sceneState.Projection, sceneState.View, Matrix.Identity);Vector3 dir = Vector3.Normalize(pos2 - pos1);Debug.WriteLine(pos1 + " | " + sceneState.ViewToWorld.Translation);--------------------------------------------------
Oh my goodness! >.>
Such a noob mistake!
I forgot to freeze my transformations of the models...
Okay works now :]
Welcome to the club :)
THANKS! Glad to be a part :)