Coordinates in 3D

I have imported some images and I’d like to plot points on these images (the images are maps) to draw a path. Is there a way to get coordinates on these images so that I can easily place points on the maps?

You do not know the size of maps?

No, the images have a track on them, I need to place points or objects on these points. I can guess at each of the different coordinates but that would take a long time. Ideally I’d like the program to tell me the coordinates of any area when I mouse over it, similar to the capabilities of matplotlib when graphing 3D

Give an example of a code download maps, and then to determine how it can be done.

If the map is on a flat plane you can use this snippet to find where the mouse ray and plane intersect:

If the map is on a 2d gui element (or something alike) you just need the mouse pointer position in the window and where the frame showing the map is.

If the map is some sort of 3D object then you can either do typical collision detection or some sort of magic with a pixel sized buffer under the cursor.

This is what I’m working with, I need to get the coordinates of specific points on these maps. I’ve tried a few different things but the coordinates seem to be dependent on how close you are to the images. I need the exact coordinates. Any suggestions on what would work best?

How do you upload them? To answer you need to know on the mesh you upload them, or ???

I made a sketch of the code :arrow_right:

import direct.directbase.DirectStart

from panda3d.core import (CollisionTraverser,CollisionNode, 
                          BitMask32, Vec4, WindowProperties)
from direct.gui.DirectGui import DirectEntry

from direct.directtools.DirectGeometry import LineNodePath

from camera import CamFree
camera_level = CamFree()

cursor = LineNodePath(render, 'up', 4, colorVec = Vec4(0, 1, 0, 1)) 
cursor.drawLines([((0, 0, 0), (0, 0, 1500))])      

x = DirectEntry(pos = (-base.getAspectRatio()+0.05, 0, 0.9), width = 10, scale=.05, numLines = 1, focus = 0, initialText = "X")
y = DirectEntry(pos = (-base.getAspectRatio()+0.05, 0, 0.8), width = 10, scale=.05, numLines = 1, focus = 0, initialText = "Y")
z = DirectEntry(pos = (-base.getAspectRatio()+0.05, 0, 0.7), width = 10, scale=.05, numLines = 1, focus = 0, initialText = "Z")
def scan(task):
    if camera_level.keyMap['Mouse3'] == 0:
        if base.mouseWatcherNode.hasMouse():
            mpos = base.mouseWatcherNode.getMouse() 
            pickerRay.setFromLens(base.camNode, mpos.getX(), mpos.getY())   
            for i in xrange(pickerQ.getNumEntries()): 
                entry = pickerQ.getEntry(i)   
                xyz = entry.getSurfacePoint(render)
                if camera_level.keyMap['Mouse1'] == 1:
    return task.cont
taskMgr.add(scan, 'scan')

# Image size
height = 707
width = 999
tex = loader.loadTexture('auto.png')
map = loader.loadModel("map.egg")
map.setTexture(tex, 0)
map.reparentTo(render), 0, 0)

picker = CollisionTraverser()
pickerQ = CollisionHandlerQueue()  
pickerCollN = CollisionNode('mouseRay')  
pickerCamN =      
pickerRay = CollisionRay()     
picker.addCollider(pickerCamN, pickerQ)

You need the image set size. :bulb:


GetCoord.7z (163 KB)

Hold down the right mouse button. Mouse1 - pick.
Move buttons : W - forward , S - backward , A - left , D - right , Q - up , E - down , Shift - Accelerate ,
mouse wheel - speed.

I hope you will be able to move forward. :stuck_out_tongue:

Sorry I’m fairly new to python and panda3d, when I try to implement that into my own code or running your example my python cannot find a camera module. I’ve tried using pip but that isn’t working for me and I’ve been searching for a zip file for it with no luck. Any information on how to get this module would be much appreciated.


Is there a way to have my maps stacked like the previous picture I posted? I’ve tried stacking them by using setPos but just one layer appears.

They need to ask different setZ()

I have set my Z positions to be different (12, 10, 8, etc.) but it seems as if it produces only one of the maps and every other level disappears. Do I have to change alpha to see the other levels?

You probably downloaded without individual object reference loadModel.


map1 = loader.loadModel(“map1.egg”)

map2 = loader.loadModel(“map2.egg”)

map3 = loader.loadModel(“map3.egg”)

The following code is what I’m working with:

HELItex = loader.loadTexture(“out1.png”)
HELImap = loader.loadModel(“map.egg”)
HELImap.setTexture(HELItex, 0)

NAVtex = loader.loadTexture(“out2.png”)
NAVmap = loader.loadModel(“map2.egg”)
NAVmap.setTexture(NAVtex, 0)
NAVmap.reparentTo(render), 0, 0)

m = loader.loadModel(“point.egg”)
m.setPos(517, 79, 13)
m.setScale(50, 50, 50)

Too small interval, set 12, 120, 220

Thanks so much, didn’t even think to try different spacing!