Using Directtools

I’ve been trying my hand at some sort of scene editor, and after getting some nice results with a maya style camera was slightly dismayed to find that it looks like there is something similar already in the directtools library.

On a closer look at Gyedo’s level editor it seems like he leverages a lot of stuff from this module as well - bounding boxes, selection, etc. Would there be any drawback from using this library? Is it here to stay? Is it intended to be purposed like this or is it tailored to the direct toolset? I don’t see any point in reinventing the wheel and I already use the Direct Grid for all my editor stuff, so I guess it makes sense to reuse what is already available.

Which brings me to my next problem. If I want a bounding box it seems like I should do this:

from direct.directtools.DirectSelection import DirectBoundingBox

However I get the following error:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import direct.directtools.DirectSelection
  File "C:\Panda3D-1.7.0\direct\directtools\DirectSelection.py", line 421, in <module>
    class SelectionQueue(CollisionHandlerQueue):
  File "C:\Panda3D-1.7.0\direct\directtools\DirectSelection.py", line 422, in SelectionQueue
    def __init__(self, parentNP = render):
NameError: name 'render' is not defined

Which seems odd because

from direct.directtools.DirectGrid import DirectGrid

works fine.

Am I missing something? Or am I better off copying the bounding box code into my own module and going from there?

Hi,

somewhere before line 1 in test.py you need to import DirectStart, aka:

from direct.directbase import DirectStart
import direct.directtools.DirectSelection

Dunno what to say about your other questions, someone else will have to answer that. I only know why it’s complaining that ‘render’ is non existent.

~powerpup118

Thanks for the quick reply, Powerpup. I was able to import the module properly now. Shame you have to import DirectStart in order to do this :frowning:

Could you explain more why that’s a shame? What where you hoping for? No window? if so:

from pandac.PandaModules import loadPrcFileData 
loadPrcFileData("", "window-type none") 
from direct.directbase import DirectStart
import direct.directtools.DirectSelection

and it will open a “blank” (no) window
is this what you want?

~powerpup118