Collisions in Roaming Ralph: where are the ground collisions

So I’ve been analyzing the code from Roaming Ralph to try to get a feel for “ground detection”, and the one thing I can’t find is where the collision with the ground is defined.
It says here:

        # This environment model contains collision meshes.  If you look
        # in the egg file, you will see the following:
        #
        #    <Collide> { Polyset keep descend }
        #
        # This tag causes the following mesh to be converted to a collision
        # mesh -- a mesh which is optimized for collision, not rendering.
        # It also keeps the original mesh, so there are now two copies ---
        # one optimized for rendering, one for collisions.  

I have no idea how to look in the egg file, nor how to optimize something for collision. Is that where the collision data from the “world” model is stored? How would I duplicate that?

First of all you have to know the difference between CollisionNode and GeomNode…look at this thread to see the problem faced me before

[Solved - Slowing down when to use mouse on 3d object)

In Roaming-Ralph example, the programmer used the CollisionNode method

To see if the used is CollisionNode or GeomNode you can write the code:

print Nodepath.ls()

then all the nodes will be displayed

About the collision with the terrain, you have to notice that the file world.egg.pz has lots of nodes and one of it is called “terrain” and the code you will find is:

if (len(entries)>0) and (entries[0].getIntoNode().getName() == "terrain"):
            self.ralph.setZ(entries[0].getSurfacePoint(render).getZ())

and there two examples to differentiate between the two ways of collisions to be more clear

4shared.com/file/GterwbXn/GeomNode.html

4shared.com/file/h8HuV4be/CollisionNode.html

Note: in those two examples I forgot to remove this useless code

if self.myHandler.getEntry(0).getIntoNode().getName()=="sphereNode":
     self.gx+=1

in the last lines…so don’t be conflicted

I have no idea what that means, nor what to do with it. Does the Geomnode interact with the collision ray or something?

All I need to do is find a way for a very irregular and pretty large polygon to interact with a figure; like if the figure hits the polygon, something happens. I just have no idea how to begin doing this.

Please help? I really have to figure this out…

Basically, what I need is a way to figure out collisions with uneven ground over a very large area. I simply have no idea how to do this. Collision Geometry is out of the question-this model is very large and has a hell of a lot of polygons in it, and every method within panda seems highly questionable… How can I do this?

There are three methods for collision:

1- By calculating the distance between the objects…and this used in asteroid tutorial

2- The second is what I mentioned and the (from) object must have a collision solid to interact with (into) object
(like for example a car hitted a man then the car is a (from) object and must have a collision solid such as sphere or ray and the man hitted (into) could be CollisionNode or GeomNode)
and I discussed about the ability of making the collision solid to be the character itself (e.g making a Ralph shape as a collision solid when use Ralph as a (from) object)…but this was unavailable

3- The third one is to use physics but I didn’t use it before.
may this link helps you:
http://opende.sourceforge.net/wiki/index.php/Manual_(Collision_Detection)

Note: In the second method you may use sphere solid as collision node and scale it by using setScale to fit the polygon you are using…You may also put several sphere solids to one character (like putting a sphere solid to Ralph’s head and another one for his body and a third for his feet where each one has its suitable scale) but separate between them and dont make them in contact

I’m assuming this works by checking the position relative to the center of the object… Is there a way to check position relative to the nearest vertex point/line/polygon?

Exactly. I need a good way to create an into object that fits a very complex, large world platform. Collision Geometry is WAY too slow, and individual polygons… well, the world is just too damn big. I made it by fractal splitting a plane 10x in Blender, then smoothing it out with Subsurf. In short: it’s a really complex object.

It HAS to be possible to create collisions for something like that… Or at least something which is more simple, but not too much simpler. :frowning: How did RR do it? I still don’t get it.