Skip to main content
GameDev.net gamedev.net
🔒 Locked

Crawling Across an Arbitrary Surface

Started by SFA Jun 17, 2004 at 6:36 AM 10 replies 2.1k views
Original Post
SFA
SFA
Hi. I'm researching for my Ph.D at the moment and I'm contemplating extending my current Real-Time Spider API so that it can climb across arbitary surfaces. At the moment, the spiders walk around a flat plane. See the screenshot here : Evil I've developed a bone/joint/limb system using Inverse Kinematics to model the way they walk. The blue targets near each leg tip on the spider represents the target point where the tip of the leg should try and touch. These move ahead of the spider in phase at all times. Now what I want to do is have these spiders walk across ANY surface. At first, this would be something like un-even terrain. But eventually, I'd like them to walk up walls and across ceilings (an example would be a spider walking around a cube). I'd like to ask two questions in this thread. The first is : 1. Is anyone aware if this has been done before using a similar method? I'm refering to published papers here. I've done a lot of searching, but perhaps I haven't been using the correct keywords! I'm aware that spider walking has been done before, but I didn't see any research into getting them to walk around objects in a realistic manner. And the second, which is the main purpose of this thread : 2. How could I concievably go about doing this? Forget about the spider's leg targets for now. Imagine the spiders are just ground-hugging craft. What I want them to do is stay stuck to a surface or object at all times. I'm using Euler Intergration to move the agents around, so movement is based around changing direction continuously and *smoothly. *So, for example, if an agent is heading towards a target and then suddenly decides to approach a target behind it, it will not 'flip' around, but turn in an arc. I've managed to avoid the problem of orientation and position in 3D up to now because I've kept the Y plane constant - so the agents never take it into consideration when moving. Its 2.5D if you like. The agent's orientation is set to be the same as the NORMAL of the Y plane. I can grasp the idea of how I'd get an agent to 'skim' across an uneven surface (terrain if you will). Its position would be equal to the polygon height? at that point and its orientation would be equal to the polygon's normal...but what would happen if I stuck the surface hugging agents on a cube, where the surface changes at angles of 90 degrees? Can anyone point me in the right direction / give me some feedback / comment? I'm pretty certain I know what I want to do, but I have no idea what keywords I could use to search for info (papers, dissertations, articles etc). Thanks for reading. Any help would be great! Cheers, SFA.
http://www.voodoo-magic.co.uk
Kuladus
Kuladus
Sorry I can't help you, but I just want to say that that is an awesome thesis, and I can't wait until you have a working demo. [smile]
onebeer
onebeer
On a related note, there is an interesting article in the latest Game Developer magazine about using feedback loops. One of the uses was for placing model's feet on uneven terrain.
onebeer
Kylotan
Kylotan
Can't you use the average of the 8 normals under each blue target? Crossing a 90 degree cube edge would therefore have the spider at about 45 degrees when half-way across, which seems reasonable (at least mathematically).
SFA
SFA
Quote:
Original post by Kylotan

Can't you use the average of the 8 normals under each blue target? Crossing a 90 degree cube edge would therefore have the spider at about 45 degrees when half-way across, which seems reasonable (at least mathematically).


The problem with that is that the targets are aligned with the position and orientation of the spider - perfectly fine for a 2.5D approach, but extending it so that the spiders can walk along uneven/arbitary surfaces poses the same problem as the body itself.

Just to explain one thing - the spider's position and orientation isn't linked directly to the legs. The spider's 'soul' (i.e its AI) dictates where its going, and Euler Integration calculates its position in the next frame by taking into consideration stuff like current velocity and target position. The legs move with the spider, and keep up with the body. As opposed to the body actually being propelled by the legs.

I'm not even concerned with orientation at the minute - as you pointed out, the orientation could be calculated as the average of the leg target normals. You could even split the calculation in two, so that you could calculate the orientation of the front of the spider using the front 4 targets, and the orientation of the thorax using the back 4.

The first step would be to revert back to representing the agent as a sphere (where orientation doesn't matter), and have it moving around an uneven surface/cube correctly. Any ideas?
http://www.voodoo-magic.co.uk
Fingers_
Fingers_
Do what the real spider does... If the leg doesn't find a surface it'll probe around until it does. In the case of going over an edge, the spider would bend the leg around the edge until it touches the other surface. If it can't find a foothold then it'll give up, back off the edge and go somewhere else.

Programmatically, I suppose you'd start with the target position, do a raycast "down" and see if it finds a walkable surface nearby. If not, cast a ray down and back towards the body of the spider. Iterate with a decreasing angle between the ray and the target->body vector, and pick the first walkable spot you can reach (ie. furthest down the other surface).
lonesock
lonesock
Hi.

What I do is each leg tip (OK, foot) has a current position, a final position (where the foot will rest when this step is done), and a target, all of them 3D position vectors. For the 1st half of a step I set:

target = final + Gnd_Normal * 2.0 * Height;

then I use a simple Euler update to move current towards target. Then the foot is above Height, then I switch to phase 2 of the step, where

target = final - Gnd_Normal * 0.5 * Height;

when the foot actually goes below the terrain I clamp it and kill all velocity until that leg is triggered again.

there is a screen of it on my extremely outdated website:
http://webpages.charter.net/lonesock/images/screen.jpg

however the demo zip is missing: sorry. When I get www.lonesock.net up it should have the newest stuff.

To adapt it to any orientation, you would just need to update your normal vector, and your ground intersection routines.

Note that the 2.0 and 0.5 are approximate: I just played with numbers that seemed to work well with all my models.
rick_appleton
rick_appleton
Using a point object for now, what I would do is the following. I'm assuming that the target the spider wants to get to is known, and that it knows which way to walk on the current surface, and the surface it is crossing onto (having a destination exactly at the edge of the surface, if the surface does not contain the target, or having a final target somewhere on the surface if it does would be the best I think).

Using simple euler-integration I would continue walking on this surface until my next step passes the edge of the surface. Then determine how much time I need in the last step to get exactly to the edge, and then use the remainder of the timestep to continue to the new target (which is located on the new surface, or at another edge of the new surface if the final target is not on this surface).

This will of course not lead to smooth movement across the edge, but it's a starting place I think.

This sounds like a fun project, keep us posted if you will.
SFA
SFA
Thanks for all the replies guys. Interesting stuff!

The spider's legs at the moment move quite similar to the way you describe lonesock.

Each leg has a target point, which the spider tries to touch with the tip of its leg each frame (using Inverse Kinematics). So left to its own devices, the leg would stretch and try to touch the target.

Each leg has 6 joints in it, which all have constraints (maximum and minimum rotating angle). Which gives the spider its natural leg shape.

The target is always STEP_DISTANCE along its forward orientation vector. Which means that whatever direction the spider is pointing in, its legs will always take step forwards along that orientation.

I use simple sin/cos wave functions to calculate the x (forward) and y (up) position of the target each frame. Its set up in such a way that in one leg cycle, the target will move forward in an arc (describing the optimal spider leg position at each frame). The spider's legs follow closely behind. Its like a manual animation basically, the only difference being that the animation 's inital and final position is set by the leg targets.

You can download a simple demo I managed to find HERE (2mb)

The demo spider is best viewed side on! The compiler is giving me problems on this machine, so I can't make a more up to date and 'tweaked' release. But it does give you some idea of what its like in motion. I've also included a 'debug' version, which shows how the target points update and propel the spiders. Ignore the warning about a missing sphere.3ds - I think they look better without the rubbish body model! :)
http://www.voodoo-magic.co.uk
Lokken
Lokken
VERY cool demos
________what we do in life, echoes in eternity
SFA
SFA
Quote:
Original post by fup

They look really cool.

Have you looked at steering behaviors?

http://www.red3d.com/cwr/steer/


That's what's powering them. Their 'soul' so to speak is based on Craig Raynold's Steering Behaviour paper! :)
http://www.voodoo-magic.co.uk

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.