Hi everyone, I just completed Joe Strout's article on making
a first person shooter with realbasic (I think it was in RBD #3?) and
I have been trying to expand it so that it supports more 3D terrain
like hills, stairs, and balconies, but I've found this to be _much_
more difficult than I expected, and I am starting to wonder if I am
on the wrong track.
To calculate a character's y axis so that he stays on the
triangular plane defined by the triangle mesh he is standing on, I
wrote a complex, confusing function called "ConstrainToSlope. This
function basically takes a given point (the character's position),
determines how far it must be moved up or down in order for it to be
on the plane defined by the triangle the character is currently in,
and returns that distance as a double. Then I move the character up
or down that distance.
After debugging the code as well as I could and slightly
changing the floor mesh so that it contained a sloped triangle in one
room to test my code with, I ran the application, and it worked-- up
until the point when the character ran into the corner of the room
with the slope in it. Then the camera stopped responding to the
direction keys (it froze in place), and the display I added to the
main screen to show the character's position said that his Y position
was NAN(000), (whatever that means), but as I moved the arrow keys,
the x and z positions changed, as if he was still running around the
room like normal (except that, judging by his position, he appeared
to be running freely through walls).
Does anyone have an idea of what went wrong? I'd really
appreciate any help or suggestions for better ways to do this.
thanks a lot,
Joe Raffanti
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|