Jump to content
• Advertisement

Planar reflection with skid factor

This topic is 4156 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. I have a working vector reflection member of my plane class as below. I want to extend it so that it takes a "skid factor" as an optional argument. When the skid is 1, you get a perfect reflection. When it is 0, I want the reflection to be the parallel component of the plane, ie skidding flatly along it. Obviously non-zero values will lerp between the two extremes ? Can anyone show me how to do this, because my math sucks and I've been stuck on this for ages. Many thanks in advance...
tBOOL	CPlane::Reflect (CVector3 Dir,CVector3 &OutDir)
{
tF32		Dot;
CVector3	VPar;

Dot=Dir*Normal;
if (Dot > 0)
return FALSE;

VPar=Normal*(Dot*2);

Dir-=VPar;
OutDir=Dir;

return TRUE;

}



Share this post

Share on other sites
Advertisement
I'm assuming what you want is a function that takes a vector and outputs a vector that has been reflected around the normal of the plane and modified by some skid factor? From what it seems like your "skid factor" is, my equation would look something like this:

OutDir = Dir - (1 + skid_factor)*Normal*DotProduct(Dir, Normal);

Therefore, when skid_factor is 0, you'll get a line perpendicular to the plane normal (and therefore on parallel to the plane), and when skid_factor is 1 you'll get the perfect reflection.

Share this post

Share on other sites
That's the monkey, thanks. I just can't seem to get this in my head at all.

Share this post

Share on other sites

• Advertisement
• Advertisement

• Popular Contributors

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 11
• 11
• 10
• 13
• 20
• Forum Statistics

• Total Topics
632948
• Total Posts
3009401
• Who's Online (See full list)

There are no registered users currently online

×

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!