Jump to content
  • Advertisement

Archived

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

Dendei

Movement on a 3D surface

This topic is 5230 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 posted this in the beginners section because I considered myself a beginner, but have gotten no answer....so here''s my rant/question.... Ok, so I''ve kinda gotten into the 3D game programming a little late (2nd year of college). It''s always hard trying to figure out what you need to know in order to do what you want (and also having the funds to do so). I really love it. A couple friends and I have decided to make a game before next years game developer''s conference (or at least a demo). Nothing too fancy, but something to show off to try and sack a coop in the business. At the moment, I''m having trouble figuring out how to calculate a character''s movement along a surface of polygons. The problem I have is that I can''t figure out how to get the character to move across multiple polygons without keeping track of all the vertices. What I was doing was treating the character as a point on the surface...and it''s easy doing just one surface, but the problem is doing many connected surfaces. Any suggestions? Any better way of doing it? Any other help would be great also.

Share this post


Link to post
Share on other sites
Advertisement
Well, the way most games do it is you perform a simple check each frame to determine if you are on ground or not on ground by trying to trace a single unit into the ground. If you are not standing anything, then you apply gravity and have the object fall. Otherwise you trace in the movement direction and move the object (and subsequently next frame the object will check to see if it is on the ground or not).

Share this post


Link to post
Share on other sites
That requires keeping track of all vertices, but is there a way to do it without keeping track of all the vertices all at once....like maybe store a linked list in a vertices that points to all vertices it is connected with?

[edited by - Dendei on February 20, 2004 1:54:56 PM]

Share this post


Link to post
Share on other sites
Well, shit....I think I just figured out how to solve my problem....I''m a moron. I didn''t think about my data structures class when they taught us graphs. That was stupid of me....

Share this post


Link to post
Share on other sites
You need to test all of the verts that you might come in contact with. You cannot know anything about the world around you unless you perform tests, subsequently you cannot know what polygon you are over unless you perform mathematical tests. If you want to do what I think you want to do, which is automatically know what polygon you are on, you would have to first test all of the polygons at startup to know what polygon you are originally on, and then when you move from one polygon to a neighboring polygon, you would again have to perform mathematical tests to see which neighbor you are on. In short, you cannot ever know anything without performing tests.

In reality, computer game worlds are partitioned into pieces, and you typically have a start point and an endpoint, you find which 'pieces' of the world you cross over to get from the start point to the end point, and each of these pieces of the world has a bunch of polygons or other collision detection structures that you must test for collision.

[edited by - Shadow12345 on February 20, 2004 2:32:52 PM]

Share this post


Link to post
Share on other sites
Ok, what I said before you posted was that if I have each vertex keep track of all the other vertices that are connected to it, it will cut down on the amount of testing that needs to be done. Basically, I move towards the edge of a polygon and am about to cross over the line that connects the two points. At this point, I will take the two vertices that make this line and compare their graph data to decide which vertex I will now be taking into account instead of the third vertex of the polygon that I am moving out of. This vertex data could look something like this:

struct vertex
{
int x = 0, y = 0, z = 0;
vertex *linksTo;
}

Share this post


Link to post
Share on other sites
I guess that would work okay. I just don't know how it will perform on sloping inclines, but you might not even want that. You will also need to handle when you cross over multiple triangles, but that shouldn't be too hard to implement. There are better methods of doing collision detection but what you suggest seems like it will work okay, so good luck.

EDIT:
I would change your data structure from vertex to triangle. This will be easier because if you have a triangle, you know that there will always be exactly 3 neighbors, and then each triangle has its own verts.

[edited by - Shadow12345 on February 20, 2004 2:49:54 PM]

Share this post


Link to post
Share on other sites
well, if the angle between the two triangles is less than is what you want to allow, then don''t let them walk any farther. Hmm, the only problem there is if it just keeps curving within the specified limits. Well, I''m pretty sure some of our characters are going to be able to walk on walls and ceilings. What I could do is every time I start to walk up something keep track of the overall angle by adding all the smaller angles between two triangles together. Once the overall angle reaches your stopping angle, then the person will stop.

Share this post


Link to post
Share on other sites
You''re making this too complicated. Start with a flat surface, see if you can even get that working, and I wouldn''t even think about dealing with inclines until you have something robust with the flat surface.

Share this post


Link to post
Share on other sites
You could maybe cast a ray from the character''s location straight down, then check for the point of intersection between that ray and the polys of that surface. By using the point of intersection, you can get the distance from there to the starting point of the ray. Or something like that. I think I just said it all backwards though.

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!