howto place a 3d object in the lower right corner of the viewport

hello,

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 ?

Many thanks for every hint

Greetings from betty in Germany

-render that object to rendertarget and draw rendertarget at any position on screen using spritebatch(?)…

-render to another viewport(overlap your current viewport at desired position)

hello PumpkinPudding,

thanks for your answer.

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.

betty

you mean Viewport.Unproject(Vector3 source, Matrix projection, Matrix view, Matrix world) ?

vector3 source: (x,y,z)
xy is mouseposition(or position on screen)
z is… how far from the camera (0-1 near and far clip plane)

now, by try and error i could solve my problem.

When initializing the game a camera is initialized.

This initial viewmatrix of the camera has to be stored.

When rendering the manipulator object you have to create the world view projection matrix with the initial viewmatrix

wvp_matrix_to_shader = world (of manipulator object) * initialviewmatrix * projectionmatrix (of camera)

thats it

best regards from betty

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.