Axes Indicator


I need to create an axis-indicator for a scene being rendered, i.e. a 3d model with 3 mutually orthogonal lines that always point to the three coordinate axes in the world (by rotating about the point of concurrence of these lines) while itself remaining fixed in a corner of the rendered window.

The way I am trying to do this is to create a 3d model for the 3 line using blender and loading the model into the scene.

But I am unable to get the model to remain fixed in a particular corner of the rendered window.

Any ideas?


You could parent the axis object to the camera. Then whenever you move the camera the object will automatically move along with the camera. The problem with that approach though is that the axis object will intersect with nearby objects in the scene. That may not be a problem for your specific scene of course, but many graphics engines support different drawing layers to make sure 3D objects that are part of the UI (most commonly the player’s gun in an FPS) and Panda may too, I’m not sure.

ADDITION: On this page the undocumented DepthOffsetAttrib may do what I’m describing - … documented

deleted useless content

dang! looks like today I find hard to understand english - after a while I realized I missed again what you said but this time I feel I get it 100%

take this code and launch it and let me know if is was what you asked for:

from pandac.PandaModules import *
from direct.showbase.DirectObject import DirectObject
from direct.task import Task
import direct.directbase.DirectStart
import random

class World(DirectObject):
  def __init__(self):
    # in pod
    #these are just to make a little fuss
    for i in range(10):
      ball = loader.loadModel("smiley")
      ball.setPos(random.randint(-4,4), random.randint(0,10), random.randint(-4,4))
    # pod
    base.camLens.setNearFar(0.1, 1000)
    dlight = DirectionalLight('dlight')
    dlight.setColor(VBase4(0.9, 0.9, 0.9, 1))
    dlnp = render.attachNewNode(dlight)
    dlnp.setHpr(0, -60, 0)
    self.mouseTask=taskMgr.add(self.mouseTask, 'mouseTask')
    self.accept("c", self.centercam)
  def centercam(self):
    base.mouseInterfaceNode.setPos(0, 30, -4.2)
  def mouseTask(self, task):
    return Task.cont

use the center mouse button to roll the perspective - as you see the axis follows the dolly movements

Thanks a ton astelix!

This is exactly what I needed.


you’re welcome - by the way I see this is precisely what jhocking have addressed above

Oops!! :laughing:

Sorry jhocking, your advice was equally important, forgot to thank you!