Jump to content
  • Advertisement
Sign in to follow this  
jf_wangfeng

How to build a physical system like Mario64?

This topic is 4552 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 am new in developing game.I like Mario64.When i want to produce a game like Mario64, I find it is hard for me to make the character move up to a inclined plane or a pyramid.So i want some math or geometry advice.Thank you.

Share this post


Link to post
Share on other sites
Advertisement
Take a look at this The plane would be your triangle you are checking collision with and the line would be your current position pointed in the direction of your motion.

Share this post


Link to post
Share on other sites
I can not see the page.Did you mean that make a collision detection with the
triangle.But how to determine if the point is inside a triangle?

Share this post


Link to post
Share on other sites
Quote:

But how to determine if the point is inside a triangle?

This function tests whether any point lies within any arbitrary polygon.
It's definitely not the fastest way, but if works for any polygon, convex or not.

/*
(x1, y1) is the segment's start point
(x2, y2) is the segment's end point
(x0, y0) is the test point

Add the values of this function for all the line segments in your polygon (don't forget the one for the last vertex to the first) and it will be:
0, if the test point is outside the polygon
+1, if it is inside and the order of traversal of vertices is CCW
-1, if it is inside and the order of traversal is CW
any integer if your polygon has self-intersections
*/


float WindingNumberOverLineSegment( float& x1, float& y1, float& x2, float& y2, float& x0, float& y0 )
{
float fAtanNominatorAtOne = (x0-x2)*(x1-x2)+(y0-y2)*(y1-y2);
float fAtanNominatorAtZero = (x0-x1)*(x1-x2)+(y0-y1)*(y1-y2);
float fAtanDenominator = x2 *(y1-y0)+x1 *(y0-y2)+x0 *(y2-y1);

return (atan2(fAtanDenominator, fAtanNominatorAtOne) - atan2(fAtanDenominator, fAtanNominatorAtZero))/(2*PI);
}

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.

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

Sign me up!