4

3D Equalizer Engine

I'm surprised no one has asked for this before. But 3D Equalizer seems to support Python as of release 3DE4 R3b4. It's very popular as a high end tracking solution and personally I work with a matchmover who uses it. And I'd like to integrate his workflow, just like the rest of the packages. I know it runs as an X11 application, so I can image that that might pose some problems, or not. It would be great if you could look into this.

19 comments

  • Avatar
    Rob Blau Official comment

    Jonathan, that's awesome. Is that repo yours (I'm not sure who splidje is on github)? If so, mind if we link to it from our list of shared integrations?

  • 0
    Avatar
    Ryan Mayeda

    Hi Marijn.

    Great to hear 3D Equalizer has Python support.  I noticed you also posted in the other forums for camera tracking tools.  I'm curious to know which one you think would be best to do first out of all of them?

    Ryan.

  • 0
    Avatar
    Marijn Eken

    I think 3D Equalizer would be the one highest on my (and other's) lists. It's the most professional and most used in bigger studios. That said, I'm also the least sure that it's possible to make it work for this software. Personally I could use a 3D Equalizer Engine right now for a project. ;)

  • 0
    Avatar
    Marijn Eken

    I did some research into creating an engine for 3DEqualizer Release 4 and this is what I found out:

    • It's possible to make 3DE run a script on startup. If you place a Python script in the "sys_data/py_scripts" folder and put these two lines at the top of the file, it will be executed on startup:
      # 3DE4.script.startup: true
      # 3DE4.script.hide: true
      It's not clear when exactly the script runs, but we might assume it is when the application has fully initialized.
    • I tested this on OS X only, but it seems that 3DEqualizer will use the Python version installed at /usr/bin/python. Regardless of path settings, it seems to always look at this location. On my system it's running the default Python, which is version 2.6.x. I'm not sure if 3DE would work fine with version 2.7, but I guess it would. I'm just not sure how to make 3DE use a different version without changing what /usr/bin/python is pointing to.
    • You can set the environment variable PYTHON_CUSTOM_SCRIPTS_3DE4 to point to an additional location where 3DE will look for Python scripts.
    • Menu creation in 3DE happens on startup and is based on the Python scripts it finds, which define the menu items through comments in the file (not through API calls). There is a menu option to do a 'Rescan Python Directories', which will pick up new or changed files, which could potentially be used to update the Shotgun menu. But, this function is not exposed in the 3DE Python API. This rescan function is however tied to a keyboard shortcut (Shift+S), so maybe it's possible to send that key command to 3DE to trigger a rescan?
    • I've done a basic test to see if PySide/Qt would run from the Python console in 3DE. And that actually worked. I didn't go as far as setting up a message loop, as I figured I would be able to 'steal' all of that from the tk-framework-softimageqt package. I just wanted to know that 3DE wouldn't crash hard upon opening a Qt window, which it didn't.

    I have a couple of questions:

    1. Is developing a 3DEqualizer Engine anywhere on the roadmap for you guys at Shotgun?
    2. If I decide to continue development on an engine, can you guys provide support? I'm not very experienced in Qt at all. Also, 3DE is a X11/XQuartz application, which is also something I'm not that familiar with. I would concentrate on OS X development, since that is our main platform.
    3. Do you happen to know if anyone else is working on this? If so, I would like to get in contact with them.
    4. Is tk-framework-softimageqt the best example to 'steal' code from, as Houdini has a similar setup, but not a split out framework?

    Thanks,
    Marijn

  • 0
    Avatar
    Marijn Eken

    Update:

    3DE r4b8: added a new python command for re-building all python GUI menus and buttons

    I haven't tried or tested it, but I think it's the 

    rescanPythonDirs()

    command they're talking about. This is at least a step in the right direction for Shotgun support in terms of changing menu items. Although it still means that files have to be written to disk with the new menu structure, before this command is called.

    The one thing that's still missing (as far as I can see) is a message loop tie-in for the Qt processes.

  • 0
    Avatar
    rolf schneider

    Hi Marijn,

    3DE provides a timer infrastructure for mixing its GUI with pyQT:

     

    tde4.setTimerCallbackFunction(<function name>, <timeout_in_ms>) will start a Timer which calls function "function name" on a regular basis. Simply call pyQT.processEvents() from that function, let's say 10 times per second. 

    Example:

    def _timer():
        pyQT.processEvents()
       

    tde4.setTimerCallbackFunction("_timer",100)


    Cheers!

     

  • 0
    Avatar
    Marijn Eken

    Hi Rolf,

    Thanks a lot for your suggestion. I hadn't noticed that function or thought that would be an option, so thanks for pointing that out. That should go a long way towards making an Engine.

    While the new rescanPythonDirs() function is great, are there any plans to supply an API for creating/destroying menu items on the fly? It would just make it a bit easier to create an Engine and support all the functions it needs, that's all.

    And just one last question. It is correct that 3DE is hardcoded to always run Python from /usr/bin/python? I would like it to use my 'own' version that is not the system installed version. Specifically, I want to point it to the Python install that comes with Shotgun Desktop, which has PySide/PyQT included. Is there a possibility to do that?

  • 0
    Avatar
    rolf schneider

    Hi Marijn,

    there are no plans to provide a python API for creating/deleting (menu)-buttons for 3DE's regular user interface. Each (orange) menu/button is intended to represent a python script found in the system - we think this is a good approach since an ever changing GUI is confusing for the user. If you'd like to provide a self-modifying interface to Shotgun, then pl. create a non-modal custom window (postCustomRequesterAndContinue()) and you're totally free to create/destory/enable/disable all kinds of widgets on the fly...

     

    In order to use a different version of Python in connection with 3DE, you have to define a few environment variables before starting 3DE (from a shell):

    - LD_LIBRARY_PATH: add the path to the "lib/" dir of your python

    - PYTHONHOME: set the path to the installation root dir of your python

    - PATH: add the path to the "bin/" dir of your python

     

    Best, Rolf

     

  • 0
    Avatar
    Elisa Prana

    Hi Marijn,

    How far did you go with your implementation ? 
    I'm also interested in a 3D Equalizer Engine.

    Cheers

  • 1
    Avatar
    Marijn Eken

    Hi Elisa,

    I did try the suggestions Rolf made about setting the Python paths. Unfortunately that didn't work straight away for me. It's been a while, so I'm not 100% sure anymore on what exactly happened, but I believe it was still loading the system Python, rather than the one I was pointing to with the environment variables. And I remember that at some point I was left with a non-responsive 3DE.

    In either case, my priorities have changed since then and I haven't been able to get back to this. I'm unsure if and when it would come back on my agenda to be honest. I'm suspecting it won't be any time soon. Sorry about that.


    Cheers,
    Marijn

  • 0
    Avatar
    rolf schneider

    Hi Elisa,

    I don't know why Marijn wasn't able to use a different Python version with 3DE. There is actually a little startup script (which is shipped with 3DE) - it is called "3DE4" and can be found in "<3de install dir>/bin/". This script defines the above mentioned env. variables. It is a common technique to use a different version of Python with 3DE4 - many people modify this little script according to their needs...

    Best, Rolf

     

  • 0
    Avatar
    Marijn Eken

    Hi,

    I also don't know why it didn't work, but at that point I didn't have time to investigate it any deeper. I didn't know about the startup script you just mentioned. I now looked in that folder, but I could only see a 17MB file called '3DE4' that looked like a binary executable to me. This is on OS X. Is it different on other OSes maybe?

    Cheers,
    Marijn

  • 0
    Avatar
    rolf schneider

    Hi Marijn,

    the startup script applies to Linux only. Under OSX, 3DE uses the python installation which comes with the OS. I checked the code and there is no reason why setting these env. variables under OSX shouldn't work, too! So, I have no idea why this hasn't worked on your side...

    This startup script is pretty simple, and does no magic things - pl. see below...

    Best, Rolf

     

    #!/bin/sh

    #
    # 3DE4 startup script, modify it to your own needs!
    #


    # find out 3DE4's install dir
    if [ -n "${TDE4_ROOT:+1}" ]
    then
              ROOT=$TDE4_ROOT
    else
              ROOT=`readlink -f $0`
              ROOT=`dirname $ROOT`
              ROOT=`dirname $ROOT`
    fi


    # set LD_LIBRARY_PATH so that 3DE4 can find its python.so lib
    export LD_LIBRARY_PATH=$ROOT/sys_data/py26_inst/lib:$LD_LIBRARY_PATH

    # set PYTHONHOME
    export PYTHONHOME=$ROOT/sys_data/py26_inst

    # add 3DE's python "bin/" dir to PATH
    export PATH=$ROOT/sys_data/py26_inst/bin:$PATH


    # run 3DE4
    $ROOT/bin/3DE4.bin "$@"

     

  • 0
    Avatar
    Jonathan Hearn

    Hello all,

    This has all been very useful, so thank you very much. Managed to get this working, if you'd like to try it:

    https://github.com/splidje/tk-3de4

  • 0
    Avatar
    Marijn Eken

    Hey Jonathan,

    That's really nice. I've since moved on to other things, but great to find out that my initial struggles have helped someone. Just for the fun of it I'd like to try it out. I should be able to get my hands on a 3DE license.

    I did notice you're calling the Qt processing 100 times per second. Did you find out it didn't work so well with less calls per second? Cheers.

  • 0
    Avatar
    Jonathan Hearn

    I had it at 100ms, wondered whether the ui was being a bit unresponsive, set it to 10ms, saw no real difference, but then left it in. 100's probably better.

  • 0
    Avatar
    rolf schneider

    Hi Jonathan,

    thanks for providing a 3DE4 shotgun engine! Do you mind if we'd add it to the "tech docs" section of our website?!

    As a side note: you shouldn't call Qt's event loop 100 times per second since it will certainly make 3DE's interface quite sluggish - calling it 15-20 times per sec should work fine!

    Best, R.

     

  • 0
    Avatar
    Jonathan Hearn

    Hello Rolf,

    Yes, that's fine. And I've just updated the code to have a 50ms interval.

  • 0
    Avatar
    rolf schneider

    Awesome - thanks a lot for your support! R. :)

     

Please sign in to leave a comment.