Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Thomas Obermaier

directional projection onto an arbitrary plane

This topic is 5215 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 guys! How would you create a matrix that can handle directional projection onto a plane? i''m currently playing around with that, but there''s no suitable solution at the moment for me. has someone an idea how to do that? thx in advance, thomas

Share this post


Link to post
Share on other sites
Advertisement
Given a point and a direction, you have the equation for a line. Simply find the intersection of that line with the plane. Your plane equation looks like:


ax + by + cz + k = 0


where (a, b, c) is the normal and k is an offset from the origin.

That's one equation.

Your line can be written in parametric form as 3 equations:


x = d.x * t + x0
y = d.y * t + y0
z = d.z * t + z0


You can find (x0, y0, z0) by plugging in (p.x, p.y, p.z) for (x, y, z) and the known values of d. Therefore, the only remaining unknown is t. Once you known (x0, y0, z0), plug those 3 equations in for x, y, and z in the plane equation above. You will now have one equation and one unknown, the infamous t. Solve that 1 equation algebraically for t, then plug into the 3 x, y, z equations to get your intersection point!

Take care to handle the special cases when d.x, d.y, and/or d.z are zero. And when a, b, and/or c are zero. In the former cases, note that x, y, and/or z will be a constant value independent of t and so you just plug the constant value into the plane equation. In the latter case one or more of the terms of the plane equation will drop out.

Graham Rhodes
Principal Scientist
Applied Research Associates, Inc.

[edited by - grhodes_at_work on June 7, 2004 1:46:29 PM]

Share this post


Link to post
Share on other sites
Hum... Okay. I know this will be a solution... But how can i create this so it fits into a matrix M?

I''d like to multiplicate this matrix with every vertex, to get the directional projected vertex. like with planar projection shadows, so i can do this calculation on the GPU side.

Algorithm:

Create directional projection matrix: Mprojection
Multiply the current modelview matrix with this special projection matrix

Vprojected = M * Vorigin

Is it even possible?

-Thomas

Share this post


Link to post
Share on other sites
I don''t know the answer to this question, but I seem to remember that the book ''3D Math Primer'' includes code to create a matrix that projects onto an arbitrary plane. So you might look into that.

Share this post


Link to post
Share on other sites
You may want to take a look at Mark Kilgards ''stencil reflections and shadows'' (or something like that) on the NVidia website. I seem to remember it building up a matrix that did what you say.

Hope you find it.

Share this post


Link to post
Share on other sites

  • 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!