Jump to content
  • Advertisement
Sign in to follow this  
MooMansun

Calculating WorldView

This topic is 4758 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!