i have a 3d manipulator object that i use to manipulate translation, rotation, scale of other 3d objects.
I want to place it at a fix position and fix size on my viewport independent from my current view matrix, view projection matrix. Also other object shall not be able to overdraw this object it shall allways be visible.
I suppose i will somehow need the inverse view and projection matrix of my camera but how is this done exactly ?
Both proposals can not solve my problem adequadely.
Rendering to a rendertarget is too complicated for this small matter because i have already a hitchecker rendertarget where the manipulator model has to be rendered to readback mouse position and check for collission with mouse.
I want to solve the problem with the correct reprojection, retransformation of my manipulator object.
But i cant get in my head how this has to be calculated.
I’m glad you found a solution, but I think you’re still overly complicating the matter.
As you discovered, you can change matrices during a render, as they are merely effect parameters; you don’t have to stick with a consistent view or projection matrix throughout.
However, you don’t have to store the initial matrices either; there’s nothing special about the initial values. I imagine they’re just Matrix.Identity.
The way I would suggest accomplishing it would be something like this:
effect.World = Matrix.CreateTranslation(.5f, -.5f); // Halfway to the right and halfway down
effect.View = Matrix.Identity; //Don't adjust for camera movement
effect.Projection = Matrix.Identity; //Use a 1:1 projection
//Or, alternatively, depending on the "depth" of the object you're rendering,
effect.Projection = new Matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); //Discard Z information to "flatten" to the screen
If you haven’t already, it’s probably a good idea to investigate what these matrix transformations actually do, so you can bend them to your will.