Collisions from Maya to Panda3d

Hello everybody.

I’m new to Panda3D and the forum, so I’d like to ask for help in a program that i’m building to learn a little about Panda3D.

I’m trying to understand how collision works. So I constructed in Maya2008 a cube and flagged the cube with melScript. In the egg file, it appears "ObjectType "

Here is the start of the egg file:
{ Y-Up }

{
“maya2egg2008 -a model -o colTeste.egg cube.mb”
}
phong3SG {
teste1.jpg
format { rgb }
wrapu { repeat }
wrapv { repeat }
minfilter { linear_mipmap_linear }
magfilter { linear }
}
cube {
{ 1 }
groundPlane_transform {
}
pSphere1 {
{ barrier }
pSphereShape1.verts {
0 {
-0.92871 -1.60775 -1.70911
{ 0 0.05 }
{ 0.148755 -0.987692 -0.0483336 }
{ 1 1 1 1 }
}

Then I imported a ball (constructed in Maya too) without any kind of collision flagged. Using panda3D, I created a collision sphere to be around that ball.

Then, I instanciated a CollisionHandlerPusher and added the node attached to the CollisionSphere.

Finally, to test it, I implemented a method in which the ball moves toward the cube everytime a key is pressed. The problem is that the ball goes through the cube, ignoring completely the fact that should be a collision.

It should be a small beginner mistake, but I searched a lot in the forum and didn’t find the answer.

Thank’s just for reading all ths text =)

The “-a model” means that you have converted the file as an animated model. This is probably a mistake: you don’t actually have any joints or animation in your model, so there’s no reason to convert it this way; “-a none” would be a better choice, which is the way to convert a file as a static model.

As it happens, Panda doesn’t support loading a collision solid from an animated model, so in order to load your egg file properly, you will have to convert it with “-a none”.

If you are using the egg melScript plugin to do the conversion, there is probably some GUI option to select this option. I’m not very familiar with the GUI tool, though.

David

David,

Thanks a lot for helping. Tomorrow morning (It’s 2am here in Brazil) I’ll try this, then I tell you if it worked!

David, I just did what you said… this is my new egg file:

{ Y-Up }

{
“maya2egg2008 -a none -o colTeste.egg bolinha.mb”
}
phong3SG {
teste1.jpg
format { rgb }
wrapu { repeat }
wrapv { repeat }
minfilter { linear_mipmap_linear }
magfilter { linear }
}
groundPlane_transform {
}
pSphere1 {
{ barrier }

Now, the barrier was invisible (what is good, because if I understood it right, barriers are not visible). To show it, I used

render.findAllMatches(’**/+CollisionNode’).show()

And the barrier appeared.

But the problem remains. The ball is just ignoring the barrier. Should I somehow add this barrier to the collisionHandlerPusher? Because I added just the ball that is moving towards the barrier, not the barrier.

Tks again!

No, no need to add the barrier to your collision system. Whatever problem remains is probably not a problem with your model; it must be a problem with your code that moves the ball. Are you sure you wrote that code to respect the result of a collision detection?

David

I really don’t know if the method that moves the ball respects collision. Eeverytime I “move” that ball I just set it’s new position. Doesn’t seem right, but I don’t know other way to simulate the movement. Does another way exist?

Tks!

There are lots of ways to move an object. Some of them respect collisions automatically (e.g. using physics), some of them never respect collisions (e.g. using an interval), and some of them may or may not respect collisions (e.g. setting a new position each frame in a task).

The CollisionHandlerPusher works by “pushing” back on the node that you indicate when a collision is detected. (Usually that node is the collision node itself, or the visible geometry that is the parent of the collision node, which you want to be affected by the collisions.)

When the pusher “pushes” a node, it just updates its position to keep it out of the wall. But if you have a running task that just immediately updates the node’s position to the next position in sequence, it will undo the effect of the pusher.

One option is to design your task to take into account the node’s current position whenever it sets the new position. That is, always set the node to a new position relative to its current position, instead of relative to its starting position. That way, you will take into account the effect of the pusher, which can update the node’s position midstream.

I’m pretty sure there are examples of this sort of thing in the manual or in the sample programs.

David

I’ll take a look in the manual and the program samples and the I’ll come back to tell you the result. Tks a lot!!

David,

It worked. I just solved that problem with the new position. Tks a lot for your help. It would be hard to discover all that stuff for myself.