Jump to content

  • Log In with Google      Sign In   
  • Create Account


Moving on surface


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
11 replies to this topic

#1 DmitryNik   Members   -  Reputation: 199

Like
0Likes
Like

Posted 23 November 2012 - 06:18 AM

Hello!

I can bet, there are a lot of questions about how to do it. But due to the lack of skills "how to google right" I cannot find anything which could be useful for beginners in games programming. I've created a terrain from the height map and now I would like to create some strange creatures(like me =) ), which are moving around the surface. How can I make them move on surface according to the heights(y -coordinate): if there is a kind of hill, then creature is about to move on that hill smoothly, not just through this hill. At this moment my camera can move easily through the hills and surely surface itself. So surface only looks solid. So, my question is, how can I make the terrain really(as much as it possible in games world) solid that all creatures are able to move along all curves, hills and will not be able to go through those hills? Is there any specific algorithms and theories? Is it only about collision detection with the surface?

Thank you for your answers beforehand.

Edited by DmitryNik, 23 November 2012 - 06:21 AM.


Sponsor:

#2 DmitryNik   Members   -  Reputation: 199

Like
0Likes
Like

Posted 23 November 2012 - 06:22 AM

p.s. in Attachments could be found a figure that demonstrates, what did I mean=) Real surface is a bit more complicated.
justincase.png

#3 Yrjö P.   Crossbones+   -  Reputation: 1412

Like
1Likes
Like

Posted 23 November 2012 - 06:45 AM

If you don't need stuff jumping, flying, falling off cliffs etc., you could move your characters as if they are still moving on flat plane and just draw them to the height of the surface.

#4 DmitryNik   Members   -  Reputation: 199

Like
0Likes
Like

Posted 23 November 2012 - 07:35 AM

If you don't need stuff jumping, flying, falling off cliffs etc., you could move your characters as if they are still moving on flat plane and just draw them to the height of the surface.


Thank you for your answer. So, as I understood, I only have to translate creatures according to y-coordinate, when it's moving? OK, I thought it would be more difficult, but it seems that the easiest way is the right one always. OK.
But what about flying and falling off the cliffs etc.?

#5 Tispe   Members   -  Reputation: 982

Like
0Likes
Like

Posted 23 November 2012 - 07:53 AM

Maybe use D3DXIntersect() to determine the distance between the entity and the ground?

What it does is to take a Mesh and two vectors. It loops through the mesh (terrain) and checks if any of the triangles in the mesh collides with your vector. The results are in the out parameters.

Have your Entity position be the *pRayPos paramter, and the D3DXVECTOR3(0,-1,0) as the direction vector (straight down).

Or if you want to know the distance to translate your entity up and down. Use a distance from a plane much lower then the terrain and you can get the exact height of the terrain based on your entity planar position

Edited by Tispe, 23 November 2012 - 07:59 AM.


#6 Yrjö P.   Crossbones+   -  Reputation: 1412

Like
1Likes
Like

Posted 23 November 2012 - 08:03 AM

But what about flying and falling off the cliffs etc.?

What about them?

If you need stuff like that, some of it can be "faked" in simple ways (that are competely legit to use as long as their limitations aren't critical for your game). For instance, you could have a helicopter always fly at a certain height above the terrain, in which case it would be no harder to do technically than other characters; many AAA RTS games do just that. Similar technique would handle characters jumping, and it would look OK as long as the terrain doesn't have steep slopes. The more sophisticated behaviors you need, the more stuff you have to implement.

One easy thing you might want to do with the terrain is to scale characters' movement speed according to whether they are going uphill; without that, their movement will seem very unnatural near steeper slopes. If you detected a very steep slope, you could also put the character in a "falling" state and handle that differently than normal movement. But if you increase complexity with special cases like that, at some point it'll becomes too much to hold together and you start needing actual collision detection and/or physics engines.

#7 DmitryNik   Members   -  Reputation: 199

Like
0Likes
Like

Posted 23 November 2012 - 11:36 AM

Maybe use D3DXIntersect() to determine the distance between the entity and the ground?

What it does is to take a Mesh and two vectors. It loops through the mesh (terrain) and checks if any of the triangles in the mesh collides with your vector. The results are in the out parameters.

Have your Entity position be the *pRayPos paramter, and the D3DXVECTOR3(0,-1,0) as the direction vector (straight down).

Or if you want to know the distance to translate your entity up and down. Use a distance from a plane much lower then the terrain and you can get the exact height of the terrain based on your entity planar position


Will it a bit slow? For instance, if I take a simple height map 128x128, then in this case there are about 16384 vertices and let's say 5461 triangles. it will definitely take too much time for checking. Is there another way? Will be position tracking for each character a good idea? How it was done earlier?

Edited by DmitryNik, 23 November 2012 - 11:37 AM.


#8 DmitryNik   Members   -  Reputation: 199

Like
0Likes
Like

Posted 23 November 2012 - 11:45 AM


But what about flying and falling off the cliffs etc.?

What about them?

If you need stuff like that, some of it can be "faked" in simple ways (that are competely legit to use as long as their limitations aren't critical for your game). For instance, you could have a helicopter always fly at a certain height above the terrain, in which case it would be no harder to do technically than other characters; many AAA RTS games do just that. Similar technique would handle characters jumping, and it would look OK as long as the terrain doesn't have steep slopes. The more sophisticated behaviors you need, the more stuff you have to implement.

One easy thing you might want to do with the terrain is to scale characters' movement speed according to whether they are going uphill; without that, their movement will seem very unnatural near steeper slopes. If you detected a very steep slope, you could also put the character in a "falling" state and handle that differently than normal movement. But if you increase complexity with special cases like that, at some point it'll becomes too much to hold together and you start needing actual collision detection and/or physics engines.


That one is a good answer.Yeah, I thought of using collision detection. That's actually nice, if I have to implement my own physics engine. Only in this case I can learn at least something.

#9 shadowisadog   Crossbones+   -  Reputation: 2378

Like
1Likes
Like

Posted 23 November 2012 - 01:25 PM

Something like doing a swept ellipsoid collision detection/response might work:

http://www.peroxide....0/pxdtut10.html
http://www.three14.demon.nl/sweptellipsoid/SweptEllipsoid.pdf

Although an easier way would be to use an existing physics engine such as ODE, Bullet, or PhysX.

Edited by shadowisadog, 23 November 2012 - 01:28 PM.


#10 DmitryNik   Members   -  Reputation: 199

Like
0Likes
Like

Posted 23 November 2012 - 03:38 PM

Something like doing a swept ellipsoid collision detection/response might work:

http://www.peroxide....0/pxdtut10.html
http://www.three14.d...ptEllipsoid.pdf

Although an easier way would be to use an existing physics engine such as ODE, Bullet, or PhysX.


Thank you for the links. Ready engines, in my opinion(I could be wrong), are not a good starting point, if I'd like to learn something. By making my own(buggyPosted Image ) engine, I'll learn things faster =)

#11 shadowisadog   Crossbones+   -  Reputation: 2378

Like
0Likes
Like

Posted 23 November 2012 - 03:59 PM

I view existing engines as an excellent starting point.

Technology progresses when we build off of the work of others. Constantly reinventing wheels can teach a lot, but in the terms of actually accomplishing greater things, what does it really do?

In a number of cases these engines are the products of years or even decades of work...

In the end the question must be what do you hope to accomplish? If it is to learn how to do collision detection and response then by all means implement it yourself, but if you wish to make games then using existing technology is a fantastic idea.

If nothing else in several years or with time why not contribute to an open source existing physics engine? That way you could advance the technology and not start from scratch.

Just my two cents.

Edited by shadowisadog, 23 November 2012 - 04:01 PM.


#12 DmitryNik   Members   -  Reputation: 199

Like
0Likes
Like

Posted 24 November 2012 - 05:14 AM

I view existing engines as an excellent starting point.

Technology progresses when we build off of the work of others. Constantly reinventing wheels can teach a lot, but in the terms of actually accomplishing greater things, what does it really do?

In a number of cases these engines are the products of years or even decades of work...

In the end the question must be what do you hope to accomplish? If it is to learn how to do collision detection and response then by all means implement it yourself, but if you wish to make games then using existing technology is a fantastic idea.

If nothing else in several years or with time why not contribute to an open source existing physics engine? That way you could advance the technology and not start from scratch.

Just my two cents.


That is true too.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS