RTS Mouse issues 3d

ok im working on a simple RTS style game, but whenever I try to get the mouse coodinates either using a plane or by picking it dosnt seem to work right. Ive tried following the chess demo and some code from RDB on for using a plane and i cant get either to give me the right coodinates here is the code im working with right now:

This is just the pandaai static obsticle demo with rdb’s plane code added in. I cannot figure out what i did wrong or if im even using the right thing for what i want to learn. please let me know how i can fix this. thank you in advance!

# Author: Ryan Myers
# Models: Jeff Styers, Reagan Heller


# Last Updated: 6/13/2005
#
# This tutorial provides an example of creating a character
# and having it walk around on uneven terrain, as well
# as implementing a fully rotatable camera.

#for directx window and functions
import direct.directbase.DirectStart
#for most bus3d stuff
from pandac.PandaModules import *
#for directx object support
from direct.showbase.DirectObject import DirectObject
#for intervals
from direct.interval.IntervalGlobal import *
#for FSM
from direct.fsm import FSM
from direct.fsm import State
#for tasks
from direct.task import Task
#for Actors
from direct.actor.Actor import Actor
#for math
import math
#for system commands
import random, sys, os, math
#for directGUI
from direct.gui.DirectGui import *
from direct.gui.OnscreenText import OnscreenText

#for Pandai
from panda3d.ai import *

#************************GLOBAL**********************************************
speed = 0.75

# Figure out what directory this program is in.
MYDIR=os.path.abspath(sys.path[0])
MYDIR=Filename.fromOsSpecific(MYDIR).getFullpath()

font = loader.loadFont("cmss12")

# Function to put instructions on the screen.
def addInstructions(pos, msg):
    return OnscreenText(text=msg, style=1, fg=(1,1,1,1), font = font,
                        pos=(-1.3, pos), align=TextNode.ALeft, scale = .05)

# Function to put title on the screen.
def addTitle(text):
    return OnscreenText(text=text, style=1, fg=(1,1,1,1), font = font,
                        pos=(1.3,-0.95), align=TextNode.ARight, scale = .07)

class World(DirectObject):

    def __init__(self):
        
        self.keyMap = {"left":0, "right":0, "up":0, "down":0, "Leftclick":0}
        
        self.title = addTitle("Pandai Tutorial: Adding Dynamic Obstacles")
        self.inst1 = addInstructions(0.95, "[ESC]: Quit")
        self.inst2 = addInstructions(0.90, "[Enter]: Start Pathfinding")
        self.inst21 = addInstructions(0.85, "[Arrow Keys]: Move Arrow")
        self.inst3 = addInstructions(0.80, "[1]: Small box")
        self.inst4 = addInstructions(0.75, "[2]: Big box")
        self.inst5 = addInstructions(0.70, "[Space]: Place box")
        
        #base.disableMouse()
        base.cam.setPosHpr(0,-210,135,0,327,0)
        self.box = 0
        self.pointer_move = False
        z = 0 
        self.pos3d = Point3()

        self.loadModels()
        self.setAI()
        # Create a plane to allow for mouse position
        self.plane = Plane(Vec3(0, 0, 1), Point3(0, 0, z))

    def loadModels(self):

        self.environ1 = loader.loadModel("models/skydome")      
        self.environ1.reparentTo(render)
        self.environ1.setPos(0,0,0)
        self.environ1.setScale(1)
        
        self.environ2 = loader.loadModel("models/skydome")      
        self.environ2.reparentTo(render)
        self.environ2.setP(180)
        self.environ2.setH(270)
        self.environ2.setScale(1)

        self.environ = loader.loadModel("models/groundPlane")      
        self.environ.reparentTo(render)
        self.environ.setPos(0,0,0)
               
        # Create the main character, Ralph

        #ralphStartPos = self.environ.find("**/start_point").getPos()
        ralphStartPos = Vec3(-51,-64,0)
        self.ralph = Actor("models/ralph",
                                 {"run":"models/ralph-run",
                                  "walk":"models/ralph-walk"})
        self.ralph.reparentTo(render)
        self.ralph.setScale(2)
        self.ralph.setPos(ralphStartPos)
        
        self.pointer = loader.loadModel("models/arrow")
        self.pointer.setColor(1,0,0)
        self.pointer.setPos(0,0,0)
        self.pointer.setScale(3)
        self.pointer.reparentTo(render)
      
    def setAI(self):
        #Creating AI World
        self.AIworld = AIWorld(render)
        
        self.accept("enter", self.setMove)
        self.accept("1", self.addBlock)
        self.accept("2", self.addBigBlock)
        self.accept("space", self.addStaticObstacle)
        
        #movement
        self.accept("arrow_left", self.setKey, ["left",1])
        self.accept("arrow_right", self.setKey, ["right",1])
        self.accept("arrow_up", self.setKey, ["up",1])
        self.accept("arrow_down", self.setKey, ["down",1])
        self.accept("arrow_left-up", self.setKey, ["left",0])
        self.accept("arrow_right-up", self.setKey, ["right",0])
        self.accept("arrow_up-up", self.setKey, ["up",0])
        self.accept("arrow_down-up", self.setKey, ["down",0])
        self.accept("escape", sys.exit)
        self.accept("mouse1", self.setKey, ["Leftclick",1])
        self.accept("mouse1-up", self.setKey, ["Leftclick",0])

        self.AIchar = AICharacter("ralph",self.ralph, 60, 0.05, 15)
        self.AIworld.addAiChar(self.AIchar)
        self.AIbehaviors = self.AIchar.getAiBehaviors()
        
        self.AIbehaviors.initPathFind("models/navmesh.csv")
        
        #AI World update        
        taskMgr.add(self.AIUpdate,"AIUpdate")
        
        #movement task
        taskMgr.add(self.Mover,"Mover")
        taskMgr.add(self.mouseTask, 'mouseTask')
        
        self.dirnlight1 = DirectionalLight("dirn_light1")
        self.dirnlight1.setColor(Vec4(1.0,1.0,1.0,1.0))
        self.dirnlightnode1 = render.attachNewNode(self.dirnlight1)
        self.dirnlightnode1.setHpr(0,317,0)
        render.setLight(self.dirnlightnode1)
        
    def setMove(self):
        self.AIbehaviors.pathFindTo(self.pointer)
        self.ralph.loop("run")
    
    def addBlock(self):
        self.pointer_move = True
        self.box = loader.loadModel("models/box")
        self.box.setPos(0,-60,0)
        self.box.setScale(1)
        self.box.reparentTo(render)
        
    def addBigBlock(self):
        self.pointer_move = True
        self.box = loader.loadModel("models/box")
        self.box.setPos(0,-60,0)
        self.box.setScale(2)
        self.box.setColor(1,1,0)
        self.box.reparentTo(render)
    
    def addStaticObstacle(self):
        if(self.box!=0):
            self.AIbehaviors.addStaticObstacle(self.box)
            self.box = 0
            self.pointer_move = False
            
    #to update the AIWorld    
    def AIUpdate(self,task):
        self.AIworld.update()
        #if(self.AIbehaviors.behaviorStatus("pathfollow") == "done"):
            #self.ralph.stop("run")
            #self.ralph.pose("walk", 0)
            
        return Task.cont
    
    def setKey(self, key, value):
        self.keyMap[key] = value
        
    def Mover(self,task):
        startPos = self.pointer.getPos()
        if (self.keyMap["left"]!=0):
            self.pointer.setPos(startPos + Point3(-speed,0,0))
        if (self.keyMap["right"]!=0):
            self.pointer.setPos(startPos + Point3(speed,0,0))
        if (self.keyMap["up"]!=0):
            self.pointer.setPos(startPos + Point3(0,speed,0))
        if (self.keyMap["down"]!=0):
            self.pointer.setPos(startPos + Point3(0,-speed,0))
            
        if(self.pointer_move == True and self.box != 0):
            self.box.setPos(self.pointer.getPos())
                
        return Task.cont

    def mouseTask(self, task):
        if base.mouseWatcherNode.hasMouse():
            mpos = base.mouseWatcherNode.getMouse()
            pos3d = Point3()
            nearPoint = Point3()
            farPoint = Point3()
            base.camLens.extrude(mpos, nearPoint, farPoint)
        if (self.keyMap["Leftclick"]!=0):
            if self.plane.intersectsLine(pos3d,render.getRelativePoint(camera, nearPoint), render.getRelativePoint(camera,farPoint)):
                self.pointer.setPos(render, pos3d)
                self.pointer.setZ(0)
                print pos3d
        return Task.cont

w = World()
run()

Ok so i figured out my mistake! it was fairly simple. The camera I was using was Base.cam but my mouse event called camera, which is not the same so it was creating a second camera so once i named them all the same it worked great now I can put this in my game woot!!! some minor touch ups to the code for anyone looking for the working code

# Author: Ryan Myers
# Models: Jeff Styers, Reagan Heller


# Last Updated: 6/13/2005
#
# This tutorial provides an example of creating a character
# and having it walk around on uneven terrain, as well
# as implementing a fully rotatable camera.

#for directx window and functions
import direct.directbase.DirectStart
#for most bus3d stuff
from pandac.PandaModules import *
#for directx object support
from direct.showbase.DirectObject import DirectObject
#for intervals
from direct.interval.IntervalGlobal import *
#for FSM
from direct.fsm import FSM
from direct.fsm import State
#for tasks
from direct.task import Task
#for Actors
from direct.actor.Actor import Actor
#for math
import math
#for system commands
import random, sys, os, math
#for directGUI
from direct.gui.DirectGui import *
from direct.gui.OnscreenText import OnscreenText

#for Pandai
from panda3d.ai import *

#************************GLOBAL**********************************************
speed = 0.75

# Figure out what directory this program is in.
MYDIR=os.path.abspath(sys.path[0])
MYDIR=Filename.fromOsSpecific(MYDIR).getFullpath()

font = loader.loadFont("cmss12")

# Function to put instructions on the screen.
def addInstructions(pos, msg):
    return OnscreenText(text=msg, style=1, fg=(1,1,1,1), font = font,
                        pos=(-1.3, pos), align=TextNode.ALeft, scale = .05)

# Function to put title on the screen.
def addTitle(text):
    return OnscreenText(text=text, style=1, fg=(1,1,1,1), font = font,
                        pos=(1.3,-0.95), align=TextNode.ARight, scale = .07)

class World(DirectObject):

    def __init__(self):
        base.disableMouse()
        self.keyMap = {"left":0, "right":0, "up":0, "down":0, "Leftclick":0}
        
        self.title = addTitle("Pandai Tutorial: Adding Dynamic Obstacles")
        self.inst1 = addInstructions(0.95, "[ESC]: Quit")
        self.inst2 = addInstructions(0.90, "[Enter]: Start Pathfinding")
        self.inst21 = addInstructions(0.85, "[Arrow Keys]: Move Arrow")
        self.inst3 = addInstructions(0.80, "[1]: Small box")
        self.inst4 = addInstructions(0.75, "[2]: Big box")
        self.inst5 = addInstructions(0.70, "[Space]: Place box")
        
        #base.disableMouse()
        base.camera.setPosHpr(0,-210,135,0,327,0)
        self.box = 0
        self.pointer_move = False
        z = 0 
        self.plane = Plane(Vec3(0, 0, 1), Point3(0, 0, z)) 

        self.loadModels()
        self.setAI()
        taskMgr.add(self.mouseTask, 'mouseTask')
       
    def loadModels(self):

        self.environ1 = loader.loadModel("models/skydome")      
        self.environ1.reparentTo(render)
        self.environ1.setPos(0,0,0)
        self.environ1.setScale(1)
        
        self.environ2 = loader.loadModel("models/skydome")      
        self.environ2.reparentTo(render)
        self.environ2.setP(180)
        self.environ2.setH(270)
        self.environ2.setScale(1)

        self.environ = loader.loadModel("models/groundPlane")      
        self.environ.reparentTo(render)
        self.environ.setPos(0,0,0)
               
        # Create the main character, Ralph

        #ralphStartPos = self.environ.find("**/start_point").getPos()
        ralphStartPos = Vec3(-51,-64,0)
        self.ralph = Actor("models/ralph",
                                 {"run":"models/ralph-run",
                                  "walk":"models/ralph-walk"})
        self.ralph.reparentTo(render)
        self.ralph.setScale(2)
        self.ralph.setPos(ralphStartPos)
        
        self.pointer = loader.loadModel("models/arrow")
        self.pointer.setColor(1,0,0)
        self.pointer.setPos(60,-60,0)
        self.pointer.setScale(3)
        self.pointer.reparentTo(render)
      
    def setAI(self):
        #Creating AI World
        self.AIworld = AIWorld(render)
        
        self.accept("enter", self.setMove)
        self.accept("1", self.addBlock)
        self.accept("2", self.addBigBlock)
        self.accept("space", self.addStaticObstacle)
        
        #movement
        self.accept("arrow_left", self.setKey, ["left",1])
        self.accept("arrow_right", self.setKey, ["right",1])
        self.accept("arrow_up", self.setKey, ["up",1])
        self.accept("arrow_down", self.setKey, ["down",1])
        self.accept("arrow_left-up", self.setKey, ["left",0])
        self.accept("arrow_right-up", self.setKey, ["right",0])
        self.accept("arrow_up-up", self.setKey, ["up",0])
        self.accept("arrow_down-up", self.setKey, ["down",0])
        self.accept("mouse1", self.setKey, ["Leftclick",1])
        self.accept("mouse1-up", self.setKey, ["Leftclick",0])
           
        self.AIchar = AICharacter("ralph",self.ralph, 60, 0.05, 15)
        self.AIworld.addAiChar(self.AIchar)
        self.AIbehaviors = self.AIchar.getAiBehaviors()
        
        self.AIbehaviors.initPathFind("models/navmesh.csv")
        
        #AI World update        
        taskMgr.add(self.AIUpdate,"AIUpdate")
        
        #movement task
        taskMgr.add(self.Mover,"Mover")
                
        self.dirnlight1 = DirectionalLight("dirn_light1")
        self.dirnlight1.setColor(Vec4(1.0,1.0,1.0,1.0))
        self.dirnlightnode1 = render.attachNewNode(self.dirnlight1)
        self.dirnlightnode1.setHpr(0,317,0)
        render.setLight(self.dirnlightnode1)
        
    def setMove(self):
        self.AIbehaviors.pathFindTo(self.pointer)
        self.ralph.loop("run")
    
    def addBlock(self):
        self.pointer_move = True
        self.box = loader.loadModel("models/box")
        self.box.setPos(0,-60,0)
        self.box.setScale(1)
        self.box.reparentTo(render)
        
    def addBigBlock(self):
        self.pointer_move = True
        self.box = loader.loadModel("models/box")
        self.box.setPos(0,-60,0)
        self.box.setScale(2)
        self.box.setColor(1,1,0)
        self.box.reparentTo(render)
    
    def addStaticObstacle(self):
        if(self.box!=0):
            self.AIbehaviors.addStaticObstacle(self.box)
            self.box = 0
            self.pointer_move = False
            
    #to update the AIWorld    
    def AIUpdate(self,task):
        self.AIworld.update()
        #if(self.AIbehaviors.behaviorStatus("pathfollow") == "done"):
            #self.ralph.stop("run")
            #self.ralph.pose("walk", 0)
            
        return Task.cont
    
    def setKey(self, key, value):
        self.keyMap[key] = value
        
    def Mover(self,task):
        startPos = self.pointer.getPos()
        if (self.keyMap["left"]!=0):
            self.pointer.setPos(startPos + Point3(-speed,0,0))
        if (self.keyMap["right"]!=0):
            self.pointer.setPos(startPos + Point3(speed,0,0))
        if (self.keyMap["up"]!=0):
            self.pointer.setPos(startPos + Point3(0,speed,0))
        if (self.keyMap["down"]!=0):
            self.pointer.setPos(startPos + Point3(0,-speed,0))
            
        if(self.pointer_move == True and self.box != 0):
            self.box.setPos(self.pointer.getPos())
                
        return Task.cont

    def mouseTask(self, task):
        if base.mouseWatcherNode.hasMouse(): 
            mpos = base.mouseWatcherNode.getMouse() 
            pos3d = Point3() 
            nearPoint = Point3() 
            farPoint = Point3() 
            base.camLens.extrude(mpos, nearPoint, farPoint) 
        if (self.keyMap["Leftclick"]!=0):
            if self.plane.intersectsLine(pos3d, render.getRelativePoint(base.camera, nearPoint), render.getRelativePoint(base.camera, farPoint)):
                self.pointer.setPos(render, pos3d)
#                print pos3d
        return task.again

w = World()
run()

New problem, this code now works but i am trying to figure out how you can use this code when the ground is not level. If i have a hill I can set the Z based off the X and Y that we find, but this throws the mouse off and dosnt actually appear where I click on the terrain. as the ray dosnt hit the terrain it hits a plane at Z “0” (Which only works right if you look straight down and not at an angle) is there a way to get the ray to work with my terrain instead (or geomip terrain) or any way i can produce the results I want. I am building a 3d game which makes this tougher to do and im unsure on the best way to go about this as my land dosnt currently have anything for collisions (and i want to avoid adding it if possible). Thanks for you help!

You’ll have to perform an intersection test with the actual terrain, using the collision system, instead of simply asking for the mathematical intersection with a plane. The Chessboard sample demonstrates doing this.

David

Ok so then i need to make my terrain collidable, I think Im doing it wrong because if i try to follow the chessboard demo i should do the code below to my terrain, but i get an error of:

Assertion failed: !is_empty() at line 270 of c:\panda3d-1.7.0\panda\src\pgraph\nodePath.I
Traceback (most recent call last):
File “Main.py”, line 78, in
w=World()
File “Main.py”, line 28, in init
self.terrainLoad = TerrainClass()
File “C:\Panda3D-1.7.0\mygames\Terrain.py”, line 35, in init
root.find("**/polygon").node().setIntoCollideMask(
AssertionError: !is_empty() at line 270 of c:\panda3d-1.7.0\panda\src\pgraph\nodePath.I

What can I do to fix this?

(This is just the terrain code)

from pandac.PandaModules import * #Texture, GeoMipTerrain, VBase4
from direct.task import Task
from panda3d.core import BitMask32
from direct.showbase.DirectObject import DirectObject
from pandac.PandaModules import Filename, TextureStage

class TerrainClass(DirectObject):
    def __init__(self):
        
        #Load the first environment model
        self.terrain = GeoMipTerrain("ground")
        self.terrain.setHeightfield(Filename("Terrain/terraintest.bmp")) #Terrain/game heightmap.bmp
        
        # Set terrain properties
        self.terrain.setBlockSize(32)
        self.terrain.getRoot().reparentTo(render)
#        self.terrain.setBruteforce(True)
        self.terrain_tex = loader.loadTexture('Terrain/ground.jpg')
        self.terrain_tex.setMagfilter (Texture.FTLinear) 
        self.terrain_tex.setMinfilter(Texture.FTLinearMipmapLinear)
        
        # Store root NodePath for convenience then set root settings for the terrain
        root = self.terrain.getRoot()
        root.reparentTo(render)
        ts = TextureStage('ts')
        root.setPos(0,0,0)
        root.setSz(50)
        root.setTexScale(ts.getDefault(),15,15)
        root.setTexture(self.terrain_tex,1)
        root.setTwoSided(True)
        
        #Set the model itself to be collideable with the ray. If this model was
        #any more complex than a single polygon, you should set up a collision
        #sphere around it instead. But for single polygons this works fine.
        root.find("**/polygon").node().setIntoCollideMask(
        BitMask32.bit(1))
        #Set a tag on the square's node so we can look up what square this is
        #later during the collision pass
        root.find("**/polygon").node().setTag('Terrain')
        #set global variable
            #there are currently no global variables

        #Updates the taskMgr
        taskMgr.add(self.updateTask, "update")

        #this updates the terrain when needed
    def updateTask(self, task): 
        self.terrain.update() 
        return task.cont 

The error message means you don’t have a sub-node called “polygon”.

I think you were following the chessboard example a little too literally; in the chessboard model, each of its pieces have a sub-node called “polygon”. Your model is different. You need to find the name of the geometry within your terrain model. Or you can just use the root of the terrain if you want to make the whole thing collidable.

David

Yaah im getting closer, I figured that out just before you said it drwr, thanks for all your help. Now im not getting an error but the if statement is failing in the code This is my mouse task running in my main file it calls info from mouseload.py (Where i setup the picker and calls info from terrainload.py to actualy do the collision but the if statement comes up 0 “if self.Mouseload.pq.getNumEntries() > 0:”
so something isnt working… if you need more code let me know!

    def mouseTask(self, task):
        #Check to see if we can access the mouse. We need it to do anything else
        if base.mouseWatcherNode.hasMouse():
            #get the mouse position
            mpos = base.mouseWatcherNode.getMouse()
      
            #Set the position of the ray based on the mouse position
            self.Mouseload.pickerRay.setFromLens(base.camNode, mpos.getX(), mpos.getY())

        #Do the actual collision pass (Do it only on the terrain for efficiency purposes)
        self.Mouseload.picker.traverse(self.terrainLoad.terrain.getRoot())
        if self.Mouseload.pq.getNumEntries() > 0:
            #if we have hit something, sort the hits so that the closest is first, and highlight that node
            self.Mouseload.pq.sortEntries()
            i = int(self.Mouseload.pq.getEntry(0).getIntoNode().getTag('Terrain'))
            #Set the highlight on the picked square
            self.Mouseload.hiSq = i
            print "Hit"
        return Task.cont

That just means your ray didn’t intersect the terrain. There are any number of things that might have gone wrong, which I can’t tell from looking at your pick loop. For instance, the collide bits might not have been correctly applied to your terrain; or the pickerRay might not be correctly parented to the camera; or the collision traverser might not have the pickerRay added to it; or any number of other problems.

David

well that would be alot of code to paste in here so my collision mask appears to be working but i need to find my problem now so once i have a problem i can find ill let you know!

Ok so Ive tried going back through my code and solving the issue but im still getting the issue of no entries so im gonna pos all relavent code to this to see if anyone can find my problem cause I cannot:

Things to assume:

  1. anything you dont see (imports etc) is actually there i just left it out as i didnt think it was needed.
  2. There is no error it runs fine I just dont get a return from the ray.
  3. If you need more code just ask I need to find myself a private pastebin (need a pass to see) I can use to host the code to make it easier to look at

Terrainload.py:

        self.terrain = GeoMipTerrain("ground")
        self.terrain.setHeightfield(Filename("Terrain/terraintest.bmp")) #Terrain/game heightmap.bmp
        

        self.terrain.setBlockSize(32)
        self.terrain.getRoot().reparentTo(render)
        self.terrain_tex = loader.loadTexture('Terrain/ground.jpg')
        self.terrain_tex.setMagfilter (Texture.FTLinear) 
        self.terrain_tex.setMinfilter(Texture.FTLinearMipmapLinear)
        
        root = self.terrain.getRoot()
        root.reparentTo(render)
        ts = TextureStage('ts')
        root.setPos(0,0,0)
        root.setSz(50)
        root.setTexScale(ts.getDefault(),15,15)
        root.setTexture(self.terrain_tex,1)
        root.setTwoSided(True)
        #Set the terrain itself to be collideable.
        root.setCollideMask(BitMask32.bit(1))

Mouseload.py

        #Since we are using collision detection to do picking, we set it up like any other collision detection system with a traverser and a handler
        self.picker = CollisionTraverser()            #Make a traverser
        self.pq     = CollisionHandlerQueue()         #Make a handler
        #Make a collision node for our picker ray
        self.pickerNode = CollisionNode('mouseRay')
        #Attach that node to the camera since the ray will need to be positioned relative to it
        self.pickerNP = camera.attachNewNode(self.pickerNode)
        #Everything to be picked will use bit 1. This way if we were doing other collision we could seperate it
        self.pickerNode.setFromCollideMask(BitMask32.bit(1))
        self.pickerRay = CollisionRay()               #Make our ray
        self.pickerNode.addSolid(self.pickerRay)      #Add it to the collision node
        #Register the ray as something that can cause collisions
        self.picker.addCollider(self.pickerNP, self.pq)
        self.picker.showCollisions(render)

Min.py

    def mouseTask(self, task):
        #Check to see if we can access the mouse. We need it to do anything else
        if base.mouseWatcherNode.hasMouse():
            #get the mouse position
            mpos = base.mouseWatcherNode.getMouse()
      
            #Set the position of the ray based on the mouse position
            self.Mouseload.pickerRay.setFromLens(base.camNode, mpos.getX(), mpos.getY())
            
            #Do the actual collision pass (Do it only on the terrain for efficiency purposes)
            self.Mouseload.picker.traverse(self.terrainLoad.terrain.getRoot())
#            print self.Mouseload.pq.getEntry(0)
#            print self.Mouseload.pq.getNumEntries()
            if self.Mouseload.pq.getNumEntries() > 0:
                #if we have hit something, sort the hits so that the closest is first, and highlight that node
                self.Mouseload.pq.sortEntries()
                print "Hit"
        return Task.cont

Ok I almost have it I got my traverser working on my actors but it wont work on my geomip terrain which is odd since they are all using the same code of

root.setCollideMask(BitMask32.bit(0))
ive also tried:
root.node().setIntoCollideMask(BitMask32.bit(0))

Neither of these worked

So i need to know why this dosnt work for geomip terrain although I was told it should.

How i found it:
when I sent my traverser to render and have all my actors using that basic code as well the picker hits them but not the terrain and i dont know why this would happen.

Hmm, the GeoMipTerrain regenerates its geometry periodically, for instance when you call update() or generate(). When it regenerates, it will change the collide mask back to the default.

Make sure you have called update() or generate() for the first time before you call root.setCollideMask(), and if you call generate() again, or if you call update() and it returns true, then you should call root.setCollideMask() again.

David

Sweet now its working! Down Side is though that my frame rate just went Flop lol im getting 30fps on my machine which Is prettymuch top of the line radeon 5870 vid card core17-860 proc 4gig 16000mhz ram so I dont see this working unless i can simplify this alot. But now that it works I am happy as I canplay with it.

Edit:
I get 120fps (with lmits removed) when i turn off the code: self.picker.showCollisions(render) as this takes alot of memory! But now its working great!

Hm, it’s supposed to preserve the collision mask. We ran into this issue before, and I believe I checked in a change to fix it.

(If you fix it that would be great as re-adding every frame is an extra task I did not need) and its definitely not working in my envirment shown below:
Core I7 860
4 gig ram
radeon 5870
2tb hdd using raid 0
windows 7 64bit
Panda 1.7.0

Now for my question I got it working but something seems odd… when i run this code:

self.pq.getEntry(0).getIntoNodePath().getPos()

It always comes up with a 0 height (PosZ) now I could figure out the height myself but you would figure this system would know (cause if I run “Print self.pq.getEntry(0)” it shows the PosZ) instead it always has a height of 0. What could be wrong there from what i can see this should be working perfecty.

When you call entry.getIntoNodePath().getPos(), you are asking for the position of the object that you collided with, relative to that object’s parent. It’s not surprising that that position is 0; most objects are at a position of 0 relative to their parent.

What did you mean to ask for? The point of the intersection? That would be entry.getSurfacePoint(context), where context is the NodePath in which you intend to use that point (for instance, render to get the point as global coordinates, or self.model to get the point in your own model’s coordinates, assuming you have a self.model).

David

Chia-Pet could you please attach your code in a zip file or sth so we can test it directly without having to put it together and apply the changes?

Thanks a bunch
Adam