Stereo3D not syncing [Solved[

  1. I know there are many topics on Stereo3D, but none of them really offer any solid answers.
  2. Im using a Christie DLP projecter with active RealD CE4s Glasses.
  3. Output to the projector is handled via a Quadro 5000 Nvidia
  4. Syncing does occur on other programs
  5. I have added the all of the python.exe variants from the panda1.9.0-x64/python directory to the Nvidia control panels list of programs to use 3d.
  6. I am running python 2.7 and panda1.9.0 as its the only 64bit version.
  7. my config.prc file has the stereo frambuffer set to 1
  8. attached is my code. it does not require any special libraries so it should run for you.

What I am seeing is a jitter, as if the render is attempting to switch back and forth between the two stereoscopic cameras.

HOWEVER, the documentation on displayregions is quite confusing, and it seems to say that it should default into stereo and work with the frame buffer. print base.win.isStereo() returns True.

I think it has to be that the system, projector or software or something, isnt being cued to activate.

Ive seen some snippets from OpenGL that you have to call glutEnterGameMode() and i dont think i can create a Panda3d app within an openGL instance.

If i could get some sample code for the stereo activation in panda3d. code that works with other peoples’ active glasses, Id be really happy.

if it sounds like i hardly know what im doing, well, ya.

[b]EDIT: OKay this is ridiculous. But the projector wasnt set to 120hz in the control panel. At least the code works! Stereo3d people. get your settings right

[/b]

import sys,os
##from OWL import *  #PhaseSpace Libraries
from math import pi, sin, cos, acos, atan, tan, sqrt, asin
from random import *
import time
import datetime
from socket import *
from direct.task import Task
from direct.stdpy import thread
from direct.actor.Actor import Actor
from direct.gui.DirectGui import OnscreenText
from direct.showbase.ShowBase import ShowBase
from direct.showbase.DirectObject import DirectObject
from direct.interval.IntervalGlobal import *
from panda3d.core import *
from pandac.PandaModules import *


#-----------------------------------------
os.system('cls')


def genLabelText( text, i):
    return OnscreenText(text = text, pos = (-1.2, .95-.05*i), fg=(1,1,0,1), align = TextNode.ALeft, scale = .05)
#---------------------------
DO=DirectObject()


#_______________________________________
class MyApp(ShowBase):
    def __init__(self):
        global sizeS
        ShowBase.__init__(self)
        print base.win.isStereo()
        
        self.camera.setPos(600,0,500)
        self.camera.lookAt(0,0,0)
        self.dynamicCam=1
        
        self.camOrbitRoot = self.render.attachNewNode('camOrbitRoot')
        self.camOrbitPeriod = self.camOrbitRoot.hprInterval(10,Vec3(360,0,0))
        self.camOrbitPeriod.loop()
        self.camera.reparentTo(self.camOrbitRoot)

        ambientLight = AmbientLight('ambientLight')
        ambientLight.setColor(Vec4(0.2, 0.3, 0.4, 1))
        ambientLightNP = render.attachNewNode(ambientLight)
        render.setLight(ambientLightNP)     

        dlight=Spotlight('dlight')
        dlight.setShadowCaster(True, 512, 512)
        self.lnp=render.attachNewNode(dlight)
        dlight.setColor(VBase4(.6, .6, .6, 1))       
        self.lnp.setPos(500, 500,500)
        self.lnp.lookAt(0,0,0)
        


        render.setLight(self.lnp)
        ## render.setLight(lnp2)
        render.setShaderAuto()
        
## init stuff
        self.lightNum=1
        self.setFrameRateMeter(True)
        self.disableMouse()        
        self.taskMgr.setupTaskChain('defChain', numThreads=None, tickClock=True,frameSync=True,frameBudget=0.05)
        self.updateTrackers=0
        self.sphere={}
        self.cycles=0
        sizeS=80
        
        for i in range(4):
            
            self.createPanel(2000,i+1)
        
        self.escText=genLabelText("Press 'esc' to quit",0)
        self.controlText=genLabelText("q: UNDEFINED, w:Overhead Camera/Marker Selection, e:Dynamic Camera r:Load Spheres, t:Load Center, y:Change Lights",1)
        
        
    def usingMoCap(self, task):
##        if self.updateTrackers:
##                for i in range(numOfMarkersPresent):
##                    if thisMarkerIsGood:
##                        self.sphere[i].setPos(marker(x,y,z))
##                if self.dynamicCam==1:
##                    self.camera.setPos(self.sphere[chosenIndex1].getPos())
##                    self.camera.lookAt(self.sphere[chosenIndex2].getPos())
##                    
        self.cycles+=1
        if self.cycles==1000:
            self.cycles=0
            print "Running!"
            if self.updateTrackers==1:
                print "And trackers are supposed to be updated!"
        return Task.cont
    

    
    def createPanel(self,size,panel):
        cm = CardMaker("ground")

        
        cm.setFrame(-size, size, -size, size)
        self.floor = render.attachNewNode(cm.generate())
        if panel==1:
            self.floor.setPos(0, 0, 0)
            self.floor.lookAt(0, 0, -1)
        elif panel==2:
            self.floor.setPos(0, size, size)
            self.floor.lookAt(0, size+1, size)
        elif panel==3:
            self.floor.setPos(-size, 0, size)
            self.floor.lookAt(-size-1, 0, size)
        elif panel==4:
            self.floor.setPos(size, 0, size)
            self.floor.lookAt(size+1, 0, size)
        
        floor_tex=loader.loadTexture("models/steel_floor.png")
        floor_ts=TextureStage('floor_ts')
        self.floor.setTexture(floor_ts,floor_tex,1)
        floorTexScalar=size/150
        self.floor.setTexScale(floor_ts,floorTexScalar,floorTexScalar,floorTexScalar)
        

app = MyApp()

    
    
        

#________________________________________________________________
def q_Fcn():
    print "You Pressed q. You can only do this once"
DO.acceptOnce("q", q_Fcn)
#________________________________________________________________
def w_Fcn():
    print "You Pressed w. You can do this as many times as you need."
global markerFocusIndex
markerFocusIndex=-1
def markerFocus():
    global sizeS, markerFocusIndex
    for i in range(len(app.sphere)):
        app.sphere[i].setScale(sizeS,sizeS,sizeS)
        app.sphere[i].setColor(Vec4(1,0,0,1))
        
    markerFocusIndex+=1
    if markerFocusIndex>=len(app.sphere):
        markerFocusIndex=0
    print "Current marker ID"
    print markerFocusIndex

        
    if not len(app.sphere):
        print "no spheres. index reset to 0"
    else:
        app.sphere[markerFocusIndex].setScale(2*sizeS,2*sizeS,2*sizeS)
        app.sphere[markerFocusIndex].setColor(Vec4(0,0,1,1))
##        if app.dynamicCam:
##            app.camera.lookAt(app.sphere[markerFocusIndex].getPos())
        
        


DO.accept("w", w_Fcn)
DO.accept("w", markerFocus)
#________________________________________________________________
def e_Fcn():
    print "You Pressed e. You can do this as many times as you need."
def changeCamera():
        if app.dynamicCam:
            app.dynamicCam=0
            app.camera.reparentTo(render)
            app.camera.setPos(0,0,1000)
            app.camera.lookAt(0,0,0)
            print "Dynamic Camera Turned Off"
        else:
            app.dynamicCam=1
            app.camera.setPos(600,0,500)
            app.camera.lookAt(0,0,0)
            app.camera.reparentTo(app.camOrbitRoot)
            print "Dynamic Camera Turned On"



        
        #dynamic camera position is set in usingMoCap function. 
        
DO.accept("e", e_Fcn)
DO.accept("e", changeCamera)
#________________________________________________________________
def r_Fcn():
    print "You Pressed r. You can do this as many times as you need."
def loadingMultipleExample():
    global sizeS
    print "Loading 4 Spheres for Demo"
    sphereModel = loader.loadModel("models/ball.egg.pz")
    
    if not app.sphere=={}:
        for i in range(len(app.sphere)):
            app.sphere[i].removeNode()
    numOfObjectsToBeLoaded=4
    for i in range(numOfObjectsToBeLoaded): #for each marker
        tipN=NodePath('tipN') #create a nodepath
        tipN.reparentTo(app.render) #attach it the the renderscene
        app.sphere[i]=sphereModel.copyTo(tipN) #define within app according to the nodepath
        app.sphere[i].setPos(randrange(-200,200,10),randrange(-200,200,10),randrange(-50,50,10)+100) #set position, this creates them in a simple line
        app.sphere[i].setScale(sizeS,sizeS,sizeS) #sets the size, as defined by sizeS
        app.sphere[i].setColor(Vec4(1,0,0,1)) #sets the color to be red    
DO.accept("r", r_Fcn)
DO.accept("r", loadingMultipleExample)
#________________________________________________________________
def t_Fcn():
    print "You Pressed t. You can only do this once."
def loadingCenter():
    global sizeS
    print "Loading Center Sphere"
    sphereModel = loader.loadModel("models/ball.egg.pz")
    
                                
    tipN=NodePath('tipN') #create a nodepath
    tipN.reparentTo(app.render) #attach it the the renderscene
    app.sphereC=sphereModel.copyTo(tipN) #define within app according to the nodepath
    app.sphereC.setPos(0,0,0) #set position, this creates them in a simple line
    app.sphereC.setScale(2*sizeS,2*sizeS,2*sizeS) #sets the size, as defined by sizeS
    app.sphereC.setColor(Vec4(0,1,0,1)) #sets the color to be red    .
DO.acceptOnce("t", t_Fcn)
DO.acceptOnce("t", loadingCenter)
#________________________________________________________________
def y_Fcn():
    print "You Pressed y. You can do this as many times as you need."
def switchLights():
    if app.lightNum==1:
        app.lightNum=2
        app.lnp.setPos(0, 0,1000)
        app.lnp.lookAt(0,0,0)
        print "light 2 should be on"

    else:
        app.lightNum=1
        app.lnp.setPos(500, 500,500)
        app.lnp.lookAt(0,0,0)
        print "light 1 should be on"

DO.accept("y", y_Fcn)
DO.accept("y", switchLights)
#________________________________________________________________
def startMoCapStream():
    #AppropriateMoCap initialization
    #PS EXAMPLE (opens ps slave server at defined IP): PSSlave("192.168.2.7",30)
    print("stream started")
    app.taskMgr.add(app.usingMoCap,"usingMoCap", taskChain='defChain') #adds defined fcn to the loop of the game
#________________________________________________________________

#________________________________________________________________

def resetServer():
    #PS example
    #owlDone()
    #startstreamPS()
    print "reset"

#________________________________________________________________

def endGame():
    #PS EXAMPLE
    #owlDone()
    print("Ending Game")
    base.closeWindow(base.win)
DO.accept("escape", endGame)



app.run()