Jump to content
  • Advertisement


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


moving camera parallel to walls

This topic is 5894 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

I've written a damn simple collision detection function to work with quads. At the moment if the user tries to move the camera in a direction which will result in the camera being "too close" to a polygon in the level, then the move is disallowed. However what I want to do is to allow the user to move in this case, parallel to the offending polygon. The amount that they move parallel to the polygon will be scaled by the angle between the way they want to go and the vector parallel to the polygon. OK so assuming that I can find the vector parallel to the polygon I would use
newVectorForward = dot(OriginalVectorForward,ParallelVector)*ParallelVector
To find this vector, will it work to use the cross product of the Y-axis vector and the normal of the plane of the polygon? If anyone has done this, some advice would be really appreciated. Thanks Toby Gobsmacked - by Toby Murray [edited by - tobymurray on April 29, 2002 10:55:21 PM]

Share this post

Link to post
Share on other sites
What you want to do is this:

newVector = scaleFactor * ( moveVector - quadnormal*( dot(quadnormal, moveVector) ) )

From the basics:
dot(quadnormal, movevector) = "length" of projection of moveVector onto quadnormal (assuming unit-length qn)

We subtract out the perpendicular part of mV, which is the part we just projected onto qn, to get newVector in the plane of the quad, and multiply by a scale factor dependent on how we want to relate the initial and final vectors. In the simplest case,
scaleFactor is equal to length of moveVector divided by length of newVector.


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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!