<Collide> { Polyset keep descend } failing

Return to Pipeline

<Collide> { Polyset keep descend } failing

Postby Craig » Sun Oct 16, 2011 10:43 pm

I'm used to putting "<Collide> { Polyset keep descend }" inside my groups in egg files manually to make them use collision (until I have proper collision geom). I tried this in a nice 38mb egg today, and only some of it worked. It looked like all the transformed subobjects' collision was not properly transformed.

This code generates correct collision data:


Code: Select all
from panda3d.core import NodePath,CollisionPolygon,CollisionNode,GeomVertexReader,BitMask32

groundMask=BitMask32(0b1)


# from FenrirWolf via http://www.panda3d.org/forums/viewtopic.php?p=43705&sid=d5588e66bcedd9f7c7f51a3226ad890c
# modified by Craig Macomber
def rebuildGeomNodesToColPolys (incomingNode,relativeTo=None):
    '''
    Converts GeomNodes into CollisionPolys in a straight 1-to-1 conversion

    Returns a new NodePath containing the CollisionNodes
    '''
   
    parent = NodePath('cGeomConversionParent')
    for c in incomingNode.findAllMatches('**/+GeomNode'):
        if relativeTo:
            xform=c.getMat(relativeTo).xformPoint
        else:
            xform=c.getMat().xformPoint
        gni = 0
        geomNode = c.node()
        for g in range(geomNode.getNumGeoms()):
            geom = geomNode.getGeom(g).decompose()
            vdata = geom.getVertexData()
            vreader = GeomVertexReader(vdata, 'vertex')
            cChild = CollisionNode('cGeom-%s-gni%i' % (c.getName(), gni))
           
            gni += 1
            for p in range(geom.getNumPrimitives()):
                prim = geom.getPrimitive(p)
                for p2 in range(prim.getNumPrimitives()):
                    s = prim.getPrimitiveStart(p2)
                    e = prim.getPrimitiveEnd(p2)
                    v = []
                    for vi in range (s, e):
                        vreader.setRow(prim.getVertex(vi))
                        v.append (xform(vreader.getData3f()))
                    colPoly = CollisionPolygon(*v)
                    cChild.addSolid(colPoly)

            n=parent.attachNewNode (cChild)
            #n.show()
           
    return parent



I would expect the loader to do something like this for <Collide> { Polyset keep descend }, but apparently its not. Is this a bug, or intended for some reason? Perhaps there is something odd about my egg file? Visible geom works fine though.

Incase its relevant, this egg was made with Google-ScketchUp->dae->blender->chicken->egg
Craig
 
Posts: 326
Joined: Thu Jul 02, 2009 8:55 pm

Postby drwr » Mon Oct 17, 2011 1:19 pm

Hmm, you mean you put the <Collide> tag at the top of the egg file, and it doesn't handle the transforms below it? It's true, I don't think we've ever considered that case.

The thing is that the <Collide> tag is meant to be placed at the point in the scene graph where you expect the collision objects to be generated. Everything below that is just vertices that define the shape of the collision object. Individual collision objects are not supposed to be very complex, so it never occurred to us that you might want to have an individual collision object that includes several nested transforms internally, and the egg loader doesn't support this.

If what you want is to create many individual collision objects, each one under a different transform, then you're supposed to repeat the <Collide> tag under each individual transform.

I agree for the purposes of conveniently tagging an entire file to be used with collisions, this is not very convenient, and it wouldn't be hard to make it support this form. We just never thought of it. You could add it as a feature request to launchpad. Still, you do want to be careful that you don't create too much complexity in a single collision object, if performance matters at all to you.

David
drwr
 
Posts: 11253
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

collisions with geomip

Postby lord gengoro kitsune » Mon Nov 14, 2011 10:38 pm

Would this piece of code enable me to create collision geometry for a tiled terrain engine using either the geomip or heightfield tesselator tiles. This right now is a big need for me as I want to be able to collide the terrain and be able to pick points on it for terrain editing functions similar to the "god mode" terrain editor in Sim City 4. As Panda exists right now there is no way to create collideable geomip tiles or even mark an existing tile as an "into" object.

I just keep putting one hind paw in front of the other, hopefully one day they'll quit falling thru the ground.
User avatar
lord gengoro kitsune
 
Posts: 67
Joined: Sun Aug 15, 2010 11:53 pm
Location: cleveland OH

Re: collisions with geomip

Postby Craig » Tue Nov 15, 2011 2:44 am

lord gengoro kitsune wrote:Would this piece of code enable me to create collision geometry for a tiled terrain engine using either the geomip or heightfield tesselator tiles.


If you look here: https://github.com/Craig-Macomber/Panda ... ry.py#L156 you will see that this very code was used by my tiled terrain engine to generate collision from a geomip terrain. I don't recommend using it with non brute forced geomip since it changes over time.

That was the first use of this code, though now I use it with this code: https://github.com/Craig-Macomber/Panda ... til.py#L62 to build optimized oct-trees of collision data from visible geometry. This code is tuned for good performance with both large polygons, and high counts of smaller ones. It should work well with no adjustments for scale since it scales based on the over all bounds, and builds the tree to an appropriate depth. I threw a 100K poly map or so at it and it worked well.
Craig
 
Posts: 326
Joined: Thu Jul 02, 2009 8:55 pm

wow it is sooo cool

Postby lord gengoro kitsune » Tue Nov 15, 2011 10:16 am

Just tried out your new code, now I need to integrate it with my engine... fortunately this should be as easy as replacing one module. And I've tried it with the new multithreading config option and that now works as well. This should be good for solving my terrain collision issues. Of course the last and probably worst thing will be integrating Animate Dream's multilevel and slope based texturing renderers into this, then I will have the terrain engine I need and will be able to finally move on to adding my DBPERSIST database scheme and P2P networking.

Is there any particular advantage to GitHub over say Google Code? I'm still looking for somewhere to put my version so you all can see it.

I'm tired of living in a hole in the ground.
User avatar
lord gengoro kitsune
 
Posts: 67
Joined: Sun Aug 15, 2010 11:53 pm
Location: cleveland OH

Re: wow it is sooo cool

Postby AnimateDream » Wed Nov 16, 2011 11:36 pm

lord gengoro kitsune wrote:Is there any particular advantage to GitHub over say Google Code? I'm still looking for somewhere to put my version so you all can see it.


The more relevant question is which version control system you prefer using. I don't have experience with all of them, but I like svn for its simplicity, and git for its features and speed. The panda repository uses cvs, but in my honest opinion it was rendered obsolete by svn a decade ago. Some people like bazaar or mercurial. Assuming you prefer git as do Craig and I, you may also find github's interface a bit friendlier. Feel free to email or PM me. I don't want to side track this thread further.
AnimateDream
 
Posts: 89
Joined: Tue Feb 16, 2010 2:36 am

Postby silveralex » Tue Jan 24, 2012 6:20 pm

I think I may be running into this on a city scene I'd like collisions enabled on.

Did this feature ever get requested officially?

I will try to use the code above for now as well.
User avatar
silveralex
 
Posts: 235
Joined: Tue Apr 21, 2009 1:48 pm
Location: New York, NY

Postby Craig » Tue Jan 24, 2012 6:45 pm

silveralex wrote:I think I may be running into this on a city scene I'd like collisions enabled on.

Did this feature ever get requested officially?

I will try to use the code above for now as well.


You might want to nab the code from here: https://github.com/Craig-Macomber/Panda3D-Terrain-System/blob/master/collisionUtil.py

That may be newer, and also has a handy function for taking the resulting nodePath and making an octTree out of it. I use them together to generate collision for my entire map (100+K triangles or so), and it works great.

I didn't request the feature/change, so I don't think anyone did.
Craig
 
Posts: 326
Joined: Thu Jul 02, 2009 8:55 pm

Postby silveralex » Tue Jan 24, 2012 6:51 pm

Thx!

I'd just send my model to the rebuild func and get back a Collission solid?
User avatar
silveralex
 
Posts: 235
Joined: Tue Apr 21, 2009 1:48 pm
Location: New York, NY

Postby Craig » Tue Jan 24, 2012 7:41 pm

silveralex wrote:Thx!

I'd just send my model to the rebuild func and get back a Collission solid?


That returns a nodepath containing the collision solids, which you can then optionally run through colTree which returns an optimized version.
Craig
 
Posts: 326
Joined: Thu Jul 02, 2009 8:55 pm


Return to Pipeline

Who is online

Users browsing this forum: No registered users and 0 guests