Calculating WorldView

Started by
18 comments, last by MooMansun 18 years, 6 months ago
Hi, I need to calculate the WorldView/World Matrix to output to a HLSL shader. I am using a First person viewmatrix as the camera. Use this as your example equation: effect.SetValue("worldViewProjection", WorldMatrix * viewMatrix * camera.ProjectionMatrix); How is it done?
Advertisement
Will Matrix.Identity return the worldMatrix?
Quote:Original post by MooMansun
Will Matrix.Identity return the worldMatrix?

No. The "Identity Matrix" is a special property of any mathematically defined matrix where row==column=1.0 [smile]

Quote:effect.SetValue("worldViewProjection", WorldMatrix * viewMatrix * camera.ProjectionMatrix);

The above fragment is, as planely read, the world view projection matrix. To be what you describe in your post you'd have to drop the camera.ProjectionMatrix part.

I'm not entirely sure what you're asking though.

You've got a "world view" matrix - that is the World*View matrix? and you want to set this to an HLSL shader? if so, just set the results of World*View to whatever the appropriate constant name is in your HLSL script..??

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

I just want to calculate the 'WorldMatrix' so that I can insert the result into the command.

"effect.SetValue("worldViewProjection", WorldMatrix * viewMatrix * camera.ProjectionMatrix);"

If I have a mesh in memory, how do I calculate its worldMatrix?
OK, I have found that Matrix.Inverse(viewMatrix) will provide the world matrix. I now have the problem were my controls, linked to the viewmatrix, are messed up.

I know that Matrix.Inverse(viewMatrix) is manipulating the matrix directly and causing the problem.

How do I create a matrix that controls the inverse without screwin up the viewMatrix?
Although I haven't really started game development yet, I have some advice for you.

Read up on your linear algebra and specifically mathematics involving matrices and vectors. It will be SO much easier on you, I hear.
There are 10 types of people in the world. Those who understand binary, and those who don't.
I understand the math, that's a pinch. I'm having a problem creating a second matrix to control the World.

The viewMatrices inverse is the world matrix. I need to control both, not one or the other. When I call Matrix.Invert(viewMatrix), it does not return a new Matrix for the worldMatrix, it inverts the viewMatrix.

Now when I try control the viewMatrix, I am controlling what should be the worldMatrix.

I know in other languages I could copy the memory, but I'm using c# at the moment.
If I were to put it C++ terms. The viewMatrix is a pointer to the Matrix held in memory. When I try to create a Matrix which is a pointer to worldMatrix (inverted viewMatrix), I only end up manipulating the viewMatrix.

Do I need to implement a MatrixStack?
Will this allow me to control both the viewMatrix and the worldMatrix?
You've got a few things confused. The inverse of the view matrix is NOT equal to the world matrix. The world matrix is used to position your models throughout the scene. Each object you render will have its own world matrix. The view matrix describes the position and orientation of the camera. This matrix will stay the same for the whole frame.

Again, the world matrix is used to position your models inside the scene. In mathematical terms, the world matrix transforms vertices from model-space to world space. Each object in your scene will have its own world matrix so that you can position it where ever you want when rendering.

neneboricua
It was near 4 or 5am when I wrote that, not thinking straight.

I posted this elsewhere:

Actually, I just need to be able to calculate the inverse of the current viewMatrix.

Btw, device.Transform.World resulted in the same (D3DERR_INVALIDCALL)

Found this at Microsoft -

Computation of Inverse World Matrix
The world matrix could be represented as:

Mw = Mwr * Mwt, where Mwr is the rotation part and Mwtb is the translation part.

http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnardir3d/html/d3dlight3.asp

I think I have seen this formula before...

This topic is closed to new replies.

Advertisement