squared collision sollids

hey all, i have a problem again with collision. in my game, i´m trying to build a tower with bricks. now the problem: how can I create squared collision solids for squared objects? in the introductory tutorial, it´s writen that I can create a collision plane… i don´t understand it. anybody can help me please??

Hey Kutz. I assume your objects are stored as egg files? In that case you’ll see a line with the following:

<Group> Box {
     <VertexPool> Box.verts {

Where Box is the name of the object that was made in a modelling program. After this line, you can put a tag to place collision solids around objects. For example

<Group> Box {
     <Collide>  box {Polyset keep descend}
     <VertexPool> Box.verts {

lets panda know that there is a collision solid of some sort
to be generated for this object. The name ‘box’ can be anything, I believe.

for the options in the curly brackets:

Polyset->take all polygons in this scope and make them collision solids
keep->leave the original geometry there too (otherwise it becomes collision solids, which are invisible)
descend->traverse the heirarchy below this point. This allows you to get any sub objects tagged for collision

There are a bunch of other options listed in the panda source under
Panda/src/docs/egg-syntax.txt

The end result is a set of collision polygons for your mesh. Now, if your mesh is high poly, this will have an effect on your running speed. In that case, make a low poly approximation object around the original, find it in the egg file, and do the following:

<Group> BoxApproximation {
     <Collide>  box {Polyset descend}
     <VertexPool> Box.verts {

This makes the BoxApproximation an invisible collision object. If the boxApproximation is parented to the Box, then they will move together.

Warning: Polyset or one of the other geometric flags for the must be specified first.

If it worked, you should see a CollisionNode on the model with the same name as the Group

hey man, thanks for the help. but it has two weeks that i´m trying to put this collision tag in the egg file. but, when i use the command in py file

find("**/collision tag name")

, the prompt return an error message saying that the node is empty!!! what is this? do you want take a look in my model? i can send the egg files to your email.

First of all, try doing this on the model:


results=myModel.findAllMatches("**/+CollisionNode")
result.ls()

if the model is small, you also just do a myModel.ls() and look at the heirarchy. IS there any CollisionNodes at all?

It would probably be best if you flag your model geometry. You can do this with egg-optchar. use ‘egg-optchar -h’ in the command line to view how to use it

yar, is your egg file an actor?

zpavlov: my egg file is just a model, made in 3ds max. i used the command myModel.ls() and don´t appears a CollisionNode, only GeomNode. when i used the command findAllMatches, nothing happends.

russ: I´ll try to do this, if I understand.

tell me, i have a big problem, isn´t?

Otherwise, you can make the collisionSolids directly in the .py file.

If you wanna make a square, you can simply use CollisionPolygon.
Specify the 4 corner points in counter-clockwise order, and render it to your model.

If you want a square where the side is, say, 14 units, then

yourSquare = CollisionPolygon(Point3(7,0,-7), Point3(7,0,7), Point3(-7,0,7), Point3(-7,0,-7))

will give you a square standing in front of you, centeret in (0,0,0) relative to your model.

If you want a box, you can make it from 6 quads.

Let me know if you need further help with the coordinates.

yeah, i need help to find the coordinates. there´s a easier way to find it? or i have to try and try? the collision polygon works well for the “from object”?
:unamused:

russ, i can´t made the command egg-optchar. i don´t understood the syntax. can you show me an example please?

No, collision polygons are not good as from objects. They are some of the most expensive shapes to calculate, and I don’t even think they can be used as from-objects.

You really should consider using spheres, if that is anywhere near good enough in your game.

Math combined with some trial-and-error is usually the way I do it.
Perhaps you will also find the SceneEditor useful: panda3d.org/manual/index.php/Panda_Tools

Could you post the beginning of your egg file (first 60 lines or so) as well as the spot where you added the tag? Keep an eye out for a “dart <1>” line, as that will force it to compress out stuff.

first, re-export your egg with -a model to make it a character. egg-optchar only works on character models. then in the command line:

egg-optchar -d myDirectory -flag geom1 -flag geom2 myModel.egg

I should say that Rainbow Brite is right, you should consider making collision spheres. They are the least expensive of the collision solids, which would make your game runa lot more smoothly.

hey zpavlov, this is my code:

<CoordinateSystem> { Z-Up }

<Comment> {
  "MaxEggPlugin nul.max -a model 'C:\Panda3D-1.0.5\models\lego1x1.egg'"
}
<Group> {
  <Dart> { 1 }
  <Group> "Scene Root" {
    <Group> "Ego 05" {
      <Collide> ego {Polyset keep }
      <VertexPool> "Ego 05.verts" {
        <Vertex> 1 {
          2.96797 2.96797 0
          <UV> { 1 0 }
          <Normal> { 0 0 -0.296797 }
        }
        <Vertex> 2 {
          2.96797 0 0
          <UV> { 1 1 }
          <Normal> { 0 0 -0.296797 }
        }
        <Vertex> 3 {
          0 0 0
          <UV> { 0 1 }
          <Normal> { 0 0 -0.296797 }
        }
        <Vertex> 4 {
          0 2.96797 0
          <UV> { 0 0 }
          <Normal> { 0 0 -0.296797 }
        }
        <Vertex> 5 {
          0 0 0
          <UV> { 0 0 }
          <Normal> { 0 -0.296797 0 }
        }
        <Vertex> 6 {
          2.96797 0 2.96797
          <UV> { 1 1 }
          <Normal> { 0 -0.296797 0 }
        }
        <Vertex> 7 {
          0 0 2.96797
          <UV> { 0 1 }
          <Normal> { 0 -0.296797 0 }
        }
        <Vertex> 8 {
          2.96797 0 0
          <UV> { 1 0 }
          <Normal> { 0 -0.296797 0 }
        }
        <Vertex> 9 {
          2.96797 0 0
          <UV> { 0 0 }
          <Normal> { 0.296797 0 0 }
        }
        <Vertex> 10 {
          2.96797 2.96797 2.96797
          <UV> { 1 1 }
          <Normal> { 0.209867 0.209867 0 }
        }
        <Vertex> 11 {
          2.96797 0 2.96797
          <UV> { 0 1 }
          <Normal> { 0.296797 0 0 }
        }
        <Vertex> 12 {
          2.96797 2.96797 0
          <UV> { 1 0 }
          <Normal> { 0.209867 0.209867 0 }
---SNIP---

i´ve tried to put the tag before the group “Ego 05”, and using {polyset descend}, but doesn´t work too. take a look. i thing i did something wrong.
and collision spheres are a good idea, but it will not work well in compressed puzzle pieces, that is what i´m trying to do.