PandaSteer 2

Thanks for PandaSteer2, chombee.
Your code is clean, well commented and you make it look simple. Those are hallmarks of a good programmer. I am new to Python & learnt a few tricks from you.

Happened to glance at your module, thought it would be handy for positioning and suchlike, but could not resist tweaking.

Fixed a couple of trivial bugs :-

def drawAxes(..):
        self.drawLine(Vec3(0,0,0), Vec3(0,size[1],0), color, thickness,np)
        self.drawLine(Vec3(0,0,0), Vec3(0,0,size[2[]), color, thickness,np)

    class World(DirectObject):
        """The test environment."""
       import direct.directbase.DirectStart	# to get global "base"

The “thickness” parameters are no good, because of the way setThickness() works. The last call before create() sets the thickness of ALL lines. You may as well use setThickness() directly.

d = Draw()
d.setThickness(3)     # set thickness of ALL lines
node = d.create() # A special GeomNode that draws the shapes.

Implemented your idea for drawing relative to a given nodepath by using its transform matrix. But I suspect the drawing stays fixed if the nodepath moves. Proper way is probably to attach your Draw() object to the nodepath and let Panda take care of moving it.

    def drawLine(self,startPoint,endPoint,color=defaultHue,thickness=None,np=None):
        """Draw a line from startPoint to endPoint using the given color.
        color: 3-tuple of floats between 0 and 1: r,g,b	(alpha is unused?)
        thickness: float
        np:	nodepath to use for coordinate frame. Line will be draw relative to
            this node. Default (None) uses render's global coords
        if np:
            # change start & end points as if they were relative to np

##        self.setThickness(thickness)	# wrong! LAST call sets thickness for ALL lines

(Naturally all other methods need to pass np to drawLine().)

Wrote a new method drawLattice().
Later realised that it could replace all of drawRectangle(), drawXYGrid() & drawCuboid(). Did not bother to change them, but added examples to your demo.

    def drawLattice(self,xRange,yRange,zRange,color=(1,1,1),np=None):
        '''draw 3 dimensional grid of lines
        XRange,yRange,zRange are each a TUPLE of floats :
            (10,17,22)		draws grid lines at the three given coordinates
            range(-10,11,5) draws regular grid lines at -10,-5,0,5,10
            (0,)			draws a flat grid, collapsing one dimension
                            Note the comma - tuple with 1 item only
            First & last elements define endpoints of lines. 
            Interesting effects if points are out of order.
        for x in xRange:
            for y in yRange:	# draw lines in Z direction
                              Vec3(x,y,zRange[len(zRange)-1]), color, 1,np)
            for z in zRange:	# draw lines in Y direction
                              Vec3(x,yRange[len(yRange)-1],z), color, 1,np)
        for z in zRange:
            for y in yRange:	# draw lines in X direction
                              Vec3(xRange[len(xRange)-1],y,z), color, 1,np)

    class World(DirectObject):
        """The test environment."""
        import direct.directbase.DirectStart		# to get global "base"
        def __init__(self):
            # Draw some lattices .............................................
            # 3x3x3 cube at (0,-50,0)
            # single flat YZ grid at x=-50 with uneven Y lines
            # box - same as drawCuboid()
            # set of disconnected XY grids
                          zRange=(0,10,20,30,0),	# repeat first number at end to suppress Z lines

            # rotated & positioned as if under a nodepath
            rot.setPosHpr(-10,-20,5,  120,0,45)

A hack for drawSphere() might be to draw a circle and attach it to a nodepath with setBillboardPointEye().
But I have not tried it – gotta start using PandaSteer2 !

Hey, thanks for this :slight_smile: Looks like good stuff. I’ll be taking a peek when I get back to programming with pandasteer, whenever that may be (but sometime).

Hope you enjoy the rest of it!

You need these changes if you want to use it with Panda 1.5.4:

---	mar feb  3 13:01:31 2009
+++	dom feb  1 23:19:02 2009
@@ -221,7 +221,7 @@
         vec*=newDist#set length to clamped value
         camera.setFluidPos(vec)#move the camera to new distance
         #Move the segment end but keep it a little behind and below the camera.
-        self.segment.node().getSolid(0).setPointB(
+        self.segment.node().modifySolid(0).setPointB(
   , P.Point3(0,-2,-1)))
 #end EdgeScreenTracker

---	mar feb  3 13:03:52 2009
+++	dom feb  1 23:18:24 2009
@@ -698,7 +698,7 @@
         # Update the Vehicles's CollisionTube, varying the length of the tube
         # according to the Vehicle's speed.
-        tube=self.tubenp.node().getSolid(0)
+        tube=self.tubenp.node().modifySolid(0)

---	mar feb  3 13:04:58 2009
+++	dom feb  1 23:23:37 2009
@@ -166,7 +166,7 @@
         # Makes the ray's origin the camera and make the ray point to mpos
-        self.picker.node().getSolid(0).setFromLens(
+        self.picker.node().modifySolid(0).setFromLens(
         # We don't want to traverse now, so wait for panda to do it then move.

---	mar feb  3 13:06:12 2009
+++	dom feb  1 23:18:24 2009
@@ -698,7 +698,7 @@
         # Update the Vehicles's CollisionTube, varying the length of the tube
         # according to the Vehicle's speed.
-        tube=self.tubenp.node().getSolid(0)
+        tube=self.tubenp.node().modifySolid(0)

Bye! :wink:


Hi chombee! Thanks for your work.

These changes are required to use vehicle and character classes into an external Panda3D application:


---	mar feb  3 18:44:18 2009
+++	mar feb  3 17:56:42 2009
@@ -26,7 +26,6 @@
 # Character, and set the variable names accordingly.
 # Panda3D imports
-import direct.directbase.DirectStart
 from pandac import PandaModules as P
 from direct.fsm import FSM
 from import Actor


---	mar feb  3 18:45:27 2009
+++	mar feb  3 17:58:48 2009
@@ -38,7 +38,7 @@
 def traverse(task):
     return Task.cont
-collisionTraverse=taskMgr.add(traverse,"collisionTraverse task of")
 # CollisionHandler used for Vehicles avoiding static obstacles
 obstacleHandler = CollisionHandlerQueue()
 # CollisionHandler used to detect Vehicles colliding with eachother
@@ -193,6 +193,8 @@
+        collisionTraverse=taskMgr.add(traverse,"collisionTraverse task of")

Now you can import character module without a double Panda window.

To ease the seek&find to other people hitting this thread, I packed all the latest files (till today) of this really amazing demo in a convenient zipped file with the addition of the zuck fixes above and uploaded into my website. You may download the package here: (9.9 MB)

PS: chombee, it would be nice, if you can, to put this package on the top of this thread and mark it as last version, just to avoid confusion.

How is this code doing? What would you like to add? What is on your todo list? I have been thinking a lot about making a python lib for doing Prolog stuff. I have also thought about doing a path finder using Monte-Carlo methods. … lo_methods
I am using most of my free time now making my mmORPG but it might be fun to help here and help my program at the same time.

Hey wow, thanks for doing that astelix. I’ve been away from Panda for a long time, but I just tried your pandasteer download with the latest release of panda on the latest version of ubuntu, and it works. For some reason I was getting only 6 FPS and I remember the demo being much faster, but that is probably due to the graphics configuration of my current machine.

I’ve uploaded the latest code, from the download you put together, to my github account. I think this should be a good place for permanent storage:

PandaSteer was developed in a svn repository not a git one, so to get the history on github would take some work that I don’t have time for, but I think it’s worthwhile just to host the latest code without history somewhere more permanent.

Douglas, I haven’t worked on this code for a long time but IIRC as an implementation of steering behaviours it was more or less done. (The terrain-based demos I had begun to add into it were less complete.) Astelix’s download is the latest one.

heya chombee nice to see you around here again - I can’t recall very well but as I wrote in the previous post I just stuck into the fixes I found here without much else so can’t say if I broken something to make it slower than before but could be. Feel free to add my mirror 'cos is a stable account since is my personal website