class Renderer:
    def __init__(self, scenegraph, viewing_setup):
        # window
        if sys.platform.startswith('win'):
            self.window = avango.vive.nodes.ViveWindow()
            self.window.Size.value = self.window.Resolution.value
            self.window.EnableVsync.value = False
            self.window.EnableFullscreen.value = False
        else:
            self.window = avango.gua.nodes.GlfwWindow(Title="window")
            self.window.Size.value = WINDOW_RESOLUTION
            self.window.LeftResolution.value = self.window.Size.value

        viewing_setup.register_window(self.window)

        # viewer
        self.viewer = avango.gua.nodes.Viewer()
        self.viewer.SceneGraphs.value = [scenegraph]
        self.viewer.Windows.value = [self.window]
        self.viewer.DesiredFPS.value = 2000.0

        # render pipeline description
        self.pipeline_description = avango.gua.nodes.PipelineDescription(
            Passes=[])
        self.pipeline_description.EnableABuffer.value = False
        self.pipeline_description.Passes.value.append(
            avango.gua.nodes.TriMeshPassDescription())
        self.pipeline_description.Passes.value.append(
            avango.gua.nodes.LightVisibilityPassDescription())

        self.resolve_pass = avango.gua.nodes.ResolvePassDescription()
        self.resolve_pass.EnvironmentLightingColor.value = avango.gua.Color(
            0.2, 0.2, 0.2)
        self.resolve_pass.ToneMappingMode.value = avango.gua.ToneMappingMode.UNCHARTED
        self.resolve_pass.Exposure.value = 1.0
        self.resolve_pass.EnableSSAO.value = True
        self.resolve_pass.SSAOIntensity.value = 2.0
        self.resolve_pass.SSAOFalloff.value = 1.0
        self.resolve_pass.SSAORadius.value = 10.0
        self.resolve_pass.BackgroundMode.value = avango.gua.BackgroundMode.SKYMAP_TEXTURE
        self.resolve_pass.BackgroundTexture.value = "data/textures/water-painted.jpg"

        self.pipeline_description.Passes.value.append(self.resolve_pass)
        self.pipeline_description.Passes.value.append(
            avango.gua.nodes.SSAAPassDescription())
        viewing_setup.register_pipeline_description(self.pipeline_description)

        # interactive shell
        if not sys.platform.startswith('win'):
            from lib.GuaVE import GuaVE
            self.interactive_shell = GuaVE()

    # blocking function: enters the main application loop of avango-guacamole
    def run(self, local_variables, global_variables):
        if not sys.platform.startswith('win'):
            self.interactive_shell.start(local_variables, global_variables)
        self.viewer.run()
Exemple #2
0
class StereoViewingSetup:

    ### constructor
    def __init__(self,
        SCENEGRAPH = None,
        WINDOW_RESOLUTION = avango.gua.Vec2ui(1024, 1024), # in pixel
        SCREEN_DIMENSIONS = avango.gua.Vec2(0.3, 0.3), # in meter        
        LEFT_SCREEN_POSITION = avango.gua.Vec2ui(0, 0), # in pixel
        LEFT_SCREEN_RESOLUTION = avango.gua.Vec2ui(1024, 1024), # in pixel
        RIGHT_SCREEN_POSITION = avango.gua.Vec2ui(0, 0), # in pixel
        RIGHT_SCREEN_RESOLUTION = avango.gua.Vec2ui(1024, 1024), # in pixel   
        SCREEN_MATRIX = avango.gua.make_identity_mat(),
        STEREO_FLAG = False,
        STEREO_MODE = avango.gua.StereoMode.ANAGLYPH_RED_CYAN,
        HEADTRACKING_FLAG = False,
        HEADTRACKING_STATION = None,
        TRACKING_TRANSMITTER_OFFSET = avango.gua.make_identity_mat(),
        ):

        ### resources ###
        
        self.shell = GuaVE()

        ## init window
        self.window = avango.gua.nodes.Window(Title = "window")
        self.window.Size.value = WINDOW_RESOLUTION
        self.window.LeftPosition.value = LEFT_SCREEN_POSITION
        self.window.LeftResolution.value = LEFT_SCREEN_RESOLUTION
        self.window.RightPosition.value = RIGHT_SCREEN_POSITION
        self.window.RightResolution.value = RIGHT_SCREEN_RESOLUTION
        self.window.EnableVsync.value = True
        
        avango.gua.register_window(self.window.Title.value, self.window) 


        ## init viewer
        self.viewer = avango.gua.nodes.Viewer()
        self.viewer.SceneGraphs.value = [SCENEGRAPH]
        self.viewer.Windows.value = [self.window]
        self.viewer.DesiredFPS.value = 60.0 # in Hz


        ## init passes & render pipeline description
        self.resolve_pass = avango.gua.nodes.ResolvePassDescription()
        self.resolve_pass.EnableSSAO.value = False
        self.resolve_pass.SSAOIntensity.value = 4.0
        self.resolve_pass.SSAOFalloff.value = 10.0
        self.resolve_pass.SSAORadius.value = 7.0
        #self.resolve_pass.EnableScreenSpaceShadow.value = True
        self.resolve_pass.EnvironmentLightingColor.value = avango.gua.Color(0.3, 0.3, 0.3)
        self.resolve_pass.ToneMappingMode.value = avango.gua.ToneMappingMode.UNCHARTED
        self.resolve_pass.Exposure.value = 1.0
        self.resolve_pass.EnableFog.value = True
        self.resolve_pass.FogStart.value = 50.0
        self.resolve_pass.FogEnd.value = 100.0

        #self.resolve_pass.BackgroundMode.value = avango.gua.BackgroundMode.COLOR
        #self.resolve_pass.BackgroundColor.value = avango.gua.Color(0.45, 0.5, 0.6)        
        self.resolve_pass.BackgroundMode.value = avango.gua.BackgroundMode.SKYMAP_TEXTURE        
        self.resolve_pass.BackgroundTexture.value = "data/textures/painted_ships.jpg"


        self.pipeline_description = avango.gua.nodes.PipelineDescription(Passes = [])
        self.pipeline_description.EnableABuffer.value = True
        self.pipeline_description.Passes.value.append(avango.gua.nodes.TriMeshPassDescription())
        self.pipeline_description.Passes.value.append(avango.gua.nodes.LightVisibilityPassDescription())
        self.pipeline_description.Passes.value.append(self.resolve_pass)
        #self.pipeline_description.Passes.value.append(avango.gua.nodes.BBoxPassDescription())
        self.pipeline_description.Passes.value.append(avango.gua.nodes.TexturedScreenSpaceQuadPassDescription())        
        self.pipeline_description.Passes.value.append(avango.gua.nodes.SSAAPassDescription())


        ## init navigation node
        self.navigation_node = avango.gua.nodes.TransformNode(Name = "navigation_node")
        SCENEGRAPH.Root.value.Children.value.append(self.navigation_node)
        
        ## init head node
        self.head_node = avango.gua.nodes.TransformNode(Name = "head_node")
        self.head_node.Transform.value = avango.gua.make_trans_mat(0.0, 0.0, 0.6) # default head position
        self.navigation_node.Children.value.append(self.head_node)

        if HEADTRACKING_FLAG == True:
            self.headtracking_sensor = avango.daemon.nodes.DeviceSensor(DeviceService = avango.daemon.DeviceService())
            self.headtracking_sensor.Station.value = HEADTRACKING_STATION
            self.headtracking_sensor.TransmitterOffset.value = TRACKING_TRANSMITTER_OFFSET

            self.head_node.Transform.connect_from(self.headtracking_sensor.Matrix)


        ## init screen node
        self.screen_node = avango.gua.nodes.ScreenNode(Name = "screen_node")
        self.screen_node.Width.value = SCREEN_DIMENSIONS.x
        self.screen_node.Height.value = SCREEN_DIMENSIONS.y
        self.screen_node.Transform.value = SCREEN_MATRIX
        self.navigation_node.Children.value.append(self.screen_node)
        

        ## init camera node
        self.camera_node = avango.gua.nodes.CameraNode(Name = "camera_node")
        self.camera_node.SceneGraph.value = SCENEGRAPH.Name.value
        self.camera_node.LeftScreenPath.value = self.screen_node.Path.value
        self.camera_node.RightScreenPath.value = self.screen_node.Path.value
        self.camera_node.NearClip.value = 0.1 # in meter
        self.camera_node.FarClip.value = 200.0 # in meter
        self.camera_node.Resolution.value = WINDOW_RESOLUTION
        self.camera_node.OutputWindowName.value = self.window.Title.value
        self.camera_node.BlackList.value = ["invisible"]
        self.camera_node.PipelineDescription.value = self.pipeline_description
        self.head_node.Children.value = [self.camera_node]


        if STEREO_FLAG == True:
            self.camera_node.EnableStereo.value = True
            
            self.window.StereoMode.value = STEREO_MODE
           
            self.set_eye_distance(0.064)


    ### functions ###
    def set_eye_distance(self, FLOAT):
        self.camera_node.EyeDistance.value = FLOAT


    def run(self, LOCALS, GLOBALS):
        self.shell.start(LOCALS, GLOBALS)
        self.viewer.run()


    def list_variabels(self):
        self.shell.list_variables()


    def connect_navigation_matrix(self, SF_MATRIX):
        self.navigation_node.Transform.connect_from(SF_MATRIX)


    def get_head_position(self): # get relative head position (towards screen)
        return self.head_node.Transform.value.get_translate()
class SimpleViewingSetup:

    ### constructor
    def __init__( self
                , SCENEGRAPH = None
                , PARENT_NODE = None
                , STEREO_MODE = "mono"
                , HEADTRACKING_FLAG = False
                ):


        ### parameters ###
        self.window_size = avango.gua.Vec2ui(2560, 1440) # in pixels
        #self.window_size = avango.gua.Vec2ui(1280, 720) # in pixels
        #self.window_size = avango.gua.Vec2ui(1920, 1080) # in pixels
        self.screen_dimensions = avango.gua.Vec2(0.595, 0.335) # in meter
        self.screen_mat = avango.gua.make_trans_mat(0.0, 0.0, 0.0)


        ### resources ###
        
        self.shell = GuaVE()

        ## init window
        self.window = avango.gua.nodes.GlfwWindow(Title = "window")
        #self.window.EnableFullscreen.value = True
        self.window.Size.value = self.window_size
        self.window.LeftResolution.value = self.window_size
        
        avango.gua.register_window(self.window.Title.value, self.window) 


        ## init viewer
        self.viewer = avango.gua.nodes.Viewer()
        self.viewer.SceneGraphs.value = [SCENEGRAPH]
        self.viewer.Windows.value = [self.window]
        self.viewer.DesiredFPS.value = 60.0 # in Hz


        ## init passes & render pipeline description
        self.resolve_pass = avango.gua.nodes.ResolvePassDescription()
        self.resolve_pass.EnableSSAO.value = True
        self.resolve_pass.SSAOIntensity.value = 3.0
        self.resolve_pass.SSAOFalloff.value = 10.0
        self.resolve_pass.SSAORadius.value = 2.0
        #self.resolve_pass.EnableScreenSpaceShadow.value = True
        self.resolve_pass.EnvironmentLightingColor.value = avango.gua.Color(0.2, 0.2, 0.2)
        self.resolve_pass.ToneMappingMode.value = avango.gua.ToneMappingMode.UNCHARTED
        self.resolve_pass.Exposure.value = 1.0

        #self.resolve_pass.BackgroundMode.value = avango.gua.BackgroundMode.COLOR
        #self.resolve_pass.BackgroundColor.value = avango.gua.Color(0.45, 0.5, 0.6)
        self.resolve_pass.BackgroundMode.value = avango.gua.BackgroundMode.SKYMAP_TEXTURE
        self.resolve_pass.BackgroundTexture.value = "/opt/guacamole/resources/skymaps/DH216SN.png"
        #self.resolve_pass.BackgroundTexture.value = "/opt/guacamole/resources/skymaps/warehouse.jpg"

        self.pipeline_description = avango.gua.nodes.PipelineDescription(Passes = [])
        self.pipeline_description.EnableABuffer.value = False
        self.pipeline_description.Passes.value.append(avango.gua.nodes.TriMeshPassDescription())
        #self.pipeline_description.Passes.value.append(avango.gua.nodes.TexturedQuadPassDescription())
        self.pipeline_description.Passes.value.append(avango.gua.nodes.LightVisibilityPassDescription())
        #self.pipeline_description.Passes.value.append(avango.gua.nodes.BBoxPassDescription())
        self.pipeline_description.Passes.value.append(self.resolve_pass)
        self.pipeline_description.Passes.value.append(avango.gua.nodes.TexturedScreenSpaceQuadPassDescription())               
        self.pipeline_description.Passes.value.append(avango.gua.nodes.SSAAPassDescription())


        ## init navigation node
        self.navigation_node = avango.gua.nodes.TransformNode(Name = "navigation_node")
        PARENT_NODE.Children.value.append(self.navigation_node)
        
        ## init head node
        self.head_node = avango.gua.nodes.TransformNode(Name = "head_node")
        self.head_node.Transform.value = avango.gua.make_trans_mat(0.0, 0.0, 0.6)
        self.navigation_node.Children.value.append(self.head_node)

        if HEADTRACKING_FLAG == True:
            self.headtracking_sensor = avango.daemon.nodes.DeviceSensor(DeviceService = avango.daemon.DeviceService())
            self.headtracking_sensor.Station.value = "tracking-lcd-glasses-1"
            self.headtracking_sensor.TransmitterOffset.value = avango.gua.make_identity_mat()
            self.headtracking_sensor.ReceiverOffset.value = avango.gua.make_identity_mat()

            self.head_node.Transform.connect_from(self.headtracking_sensor.Matrix)


        ## init screen node
        self.screen_node = avango.gua.nodes.ScreenNode(Name = "screen_node")
        self.screen_node.Width.value = self.screen_dimensions.x
        self.screen_node.Height.value = self.screen_dimensions.y
        self.screen_node.Transform.value = self.screen_mat
        self.navigation_node.Children.value.append(self.screen_node)
        

        ## init camera node
        self.camera_node = avango.gua.nodes.CameraNode(Name = "camera_node")
        self.camera_node.SceneGraph.value = SCENEGRAPH.Name.value
        self.camera_node.LeftScreenPath.value = self.screen_node.Path.value
        self.camera_node.NearClip.value = 0.1 # in meter
        self.camera_node.FarClip.value = 100.0 # in meter
        self.camera_node.Resolution.value = self.window_size
        self.camera_node.OutputWindowName.value = self.window.Title.value
        self.camera_node.PipelineDescription.value = self.pipeline_description
        self.head_node.Children.value = [self.camera_node]


        if STEREO_MODE == "anaglyph":
            self.camera_node.EnableStereo.value = True
            self.camera_node.RightScreenPath.value = self.screen_node.Path.value

            self.window.StereoMode.value = avango.gua.StereoMode.ANAGLYPH_RED_CYAN
            self.window.RightResolution.value = self.window_size

            self.set_eye_distance(0.064)


        ## intit FPS gui sub-class
        self.fpsGUI = FPSGui( PARENT_NODE = self.screen_node
                            , WINDOW = self.window
                            , VIEWER = self.viewer
                            )


    ### functions ###
    def set_eye_distance(self, FLOAT):
        self.camera_node.EyeDistance.value = FLOAT


    def run(self, LOCALS, GLOBALS):
        self.shell.start(LOCALS, GLOBALS)
        self.viewer.run()


    def list_variabels(self):
        self.shell.list_variables()


    def connect_navigation_matrix(self, SF_MATRIX):
        self.navigation_node.Transform.connect_from(SF_MATRIX)


    def get_head_position(self): # get relative head position (towards screen)
        return self.head_node.Transform.value.get_translate()
class ViewingSetup:

    ### constructor
    def __init__( self
                , SCENEGRAPH = None
                , SCREEN_RESOLUTION = avango.gua.Vec2ui(1024, 1024) # in pixels
                , SCREEN_DIMENSIONS = avango.gua.Vec2(0.3, 0.3) # in meter
                , SCREEN_MATRIX = avango.gua.make_identity_mat()
                , STEREO_FLAG = False
                , STEREO_MODE = avango.gua.StereoMode.ANAGLYPH_RED_CYAN
                , HEADTRACKING_FLAG = False
                , HEADTRACKING_STATION = None
                , TRACKING_TRANSMITTER_OFFSET = avango.gua.make_identity_mat()
                ):

        ### resources ###
        
        self.shell = GuaVE()

        ## init window
        self.window = avango.gua.nodes.GlfwWindow(Title = "window")
        self.window.Size.value = SCREEN_RESOLUTION
        self.window.LeftResolution.value = SCREEN_RESOLUTION
        self.window.RightResolution.value = SCREEN_RESOLUTION        
        self.window.EnableVsync.value = False
        
        avango.gua.register_window(self.window.Title.value, self.window) 


        ## init viewer
        self.viewer = avango.gua.nodes.Viewer()
        self.viewer.SceneGraphs.value = [SCENEGRAPH]
        self.viewer.Windows.value = [self.window]
        self.viewer.DesiredFPS.value = 200.0 # in Hz


        ## init passes & render pipeline description
        self.resolve_pass = avango.gua.nodes.ResolvePassDescription()
        self.resolve_pass.EnableSSAO.value = True
        self.resolve_pass.SSAOIntensity.value = 2.0
        #self.resolve_pass.SSAOFalloff.value = 10.0
        self.resolve_pass.SSAORadius.value = 4.0
        #self.resolve_pass.EnableScreenSpaceShadow.value = True
        self.resolve_pass.EnvironmentLightingColor.value = avango.gua.Color(0.2, 0.2, 0.2)
        self.resolve_pass.ToneMappingMode.value = avango.gua.ToneMappingMode.UNCHARTED
        self.resolve_pass.Exposure.value = 1.0


        self.resolve_pass.BackgroundMode.value = avango.gua.BackgroundMode.COLOR
        self.resolve_pass.BackgroundColor.value = avango.gua.Color(0.45, 0.5, 0.6)  

        #self.resolve_pass.BackgroundMode.value = avango.gua.BackgroundMode.SKYMAP_TEXTURE
        #self.resolve_pass.BackgroundTexture.value = "/opt/guacamole/resources/skymaps/stars.jpg"
        #self.resolve_pass.BackgroundTexture.value = "/opt/guacamole/resources/skymaps/bath.jpg"


        self.pipeline_description = avango.gua.nodes.PipelineDescription(Passes = [])
        self.pipeline_description.EnableABuffer.value = True
        self.pipeline_description.Passes.value.append(avango.gua.nodes.TriMeshPassDescription())
        self.pipeline_description.Passes.value.append(avango.gua.nodes.LightVisibilityPassDescription())
        self.pipeline_description.Passes.value.append(self.resolve_pass)
        self.pipeline_description.Passes.value.append(avango.gua.nodes.TexturedScreenSpaceQuadPassDescription())        
        self.pipeline_description.Passes.value.append(avango.gua.nodes.SSAAPassDescription())


        ## init navigation node
        self.navigation_node = avango.gua.nodes.TransformNode(Name = "navigation_node")
        SCENEGRAPH.Root.value.Children.value.append(self.navigation_node)
        
        ## init head node
        self.head_node = avango.gua.nodes.TransformNode(Name = "head_node")
        self.navigation_node.Children.value.append(self.head_node)

        if HEADTRACKING_FLAG == True:
            self.headtracking_sensor = avango.daemon.nodes.DeviceSensor(DeviceService = avango.daemon.DeviceService())
            self.headtracking_sensor.Station.value = HEADTRACKING_STATION
            self.headtracking_sensor.TransmitterOffset.value = TRACKING_TRANSMITTER_OFFSET
            self.headtracking_sensor.ReceiverOffset.value = avango.gua.make_identity_mat()

            self.head_node.Transform.connect_from(self.headtracking_sensor.Matrix)

        else:
            self.head_node.Transform.value = avango.gua.make_trans_mat(0.0, 0.0, 0.6) # default head position


        ## init screen node
        self.screen_node = avango.gua.nodes.ScreenNode(Name = "screen_node")
        self.screen_node.Width.value = SCREEN_DIMENSIONS.x
        self.screen_node.Height.value = SCREEN_DIMENSIONS.y
        self.screen_node.Transform.value = SCREEN_MATRIX
        self.navigation_node.Children.value.append(self.screen_node)
        

        ## init camera node
        self.camera_node = avango.gua.nodes.CameraNode(Name = "camera_node")
        self.camera_node.SceneGraph.value = SCENEGRAPH.Name.value
        self.camera_node.LeftScreenPath.value = self.screen_node.Path.value
        self.camera_node.RightScreenPath.value = self.screen_node.Path.value
        self.camera_node.NearClip.value = 0.1 # in meter
        self.camera_node.FarClip.value = 150.0 # in meter
        self.camera_node.Resolution.value = SCREEN_RESOLUTION
        self.camera_node.OutputWindowName.value = self.window.Title.value
        self.camera_node.PipelineDescription.value = self.pipeline_description
        self.head_node.Children.value = [self.camera_node]
        self.camera_node.EnableStereo.value = STEREO_FLAG
        self.camera_node.BlackList.value = ["invisible"]


        if STEREO_FLAG == True:
            self.window.StereoMode.value = STEREO_MODE
           
            self.set_eye_distance(0.064)


        ## init FPS gui sub-class
        self.fpsGUI = FPSGui( PARENT_NODE = self.screen_node
                            , WINDOW = self.window
                            , VIEWER = self.viewer
                            )



    ### functions ###
    def set_eye_distance(self, FLOAT):
        self.camera_node.EyeDistance.value = FLOAT


    def run(self, LOCALS, GLOBALS):
        self.shell.start(LOCALS, GLOBALS)
        self.viewer.run()


    def list_variabels(self):
        self.shell.list_variables()


    def connect_navigation_matrix(self, SF_MATRIX):
        self.navigation_node.Transform.connect_from(SF_MATRIX)


    def get_head_position(self): # get relative head position (towards screen)
        return self.head_node.Transform.value.get_translate()


    def get_navigation_node(self):
        return self.navigation_node
Exemple #5
0
class SimpleViewingSetup:

    ### constructor
    def __init__(self,
                 SCENEGRAPH=None,
                 PARENT_NODE=None,
                 STEREO_MODE="mono",
                 HEADTRACKING_FLAG=False):

        ### parameters ###
        #self.window_size = avango.gua.Vec2ui(2560, 1440) # in pixels
        self.window_size = avango.gua.Vec2ui(1920, 1200)  # in pixels
        #self.window_size = avango.gua.Vec2ui(1280, 720) # in pixels
        self.screen_dimensions = avango.gua.Vec2(0.595, 0.335)  # in meter
        self.screen_mat = avango.gua.make_trans_mat(0.0, 0.0, 0.0)

        ### resources ###

        self.shell = GuaVE()

        ## init window
        self.window = avango.gua.nodes.GlfwWindow(Title="window")
        self.window.EnableFullscreen.value = True
        self.window.Size.value = self.window_size
        self.window.LeftResolution.value = self.window_size

        avango.gua.register_window(self.window.Title.value, self.window)

        ## init viewer
        self.viewer = avango.gua.nodes.Viewer()
        self.viewer.SceneGraphs.value = [SCENEGRAPH]
        self.viewer.Windows.value = [self.window]
        self.viewer.DesiredFPS.value = 60.0  # in Hz

        ## init passes & render pipeline description
        self.resolve_pass = avango.gua.nodes.ResolvePassDescription()
        self.resolve_pass.EnableSSAO.value = True
        self.resolve_pass.SSAOIntensity.value = 3.0
        self.resolve_pass.SSAOFalloff.value = 10.0
        self.resolve_pass.SSAORadius.value = 2.0
        #self.resolve_pass.EnableScreenSpaceShadow.value = True
        self.resolve_pass.EnvironmentLightingColor.value = avango.gua.Color(
            0.2, 0.2, 0.2)
        self.resolve_pass.ToneMappingMode.value = avango.gua.ToneMappingMode.UNCHARTED
        self.resolve_pass.Exposure.value = 1.0

        #self.resolve_pass.BackgroundMode.value = avango.gua.BackgroundMode.COLOR
        #self.resolve_pass.BackgroundColor.value = avango.gua.Color(0.45, 0.5, 0.6)
        self.resolve_pass.BackgroundMode.value = avango.gua.BackgroundMode.SKYMAP_TEXTURE
        self.resolve_pass.BackgroundTexture.value = "/opt/guacamole/resources/skymaps/DH216SN.png"
        #self.resolve_pass.BackgroundTexture.value = "/opt/guacamole/resources/skymaps/warehouse.jpg"

        self.pipeline_description = avango.gua.nodes.PipelineDescription(
            Passes=[])
        self.pipeline_description.EnableABuffer.value = False
        self.pipeline_description.Passes.value.append(
            avango.gua.nodes.TriMeshPassDescription())
        #self.pipeline_description.Passes.value.append(avango.gua.nodes.TexturedQuadPassDescription())
        self.pipeline_description.Passes.value.append(
            avango.gua.nodes.LightVisibilityPassDescription())
        #self.pipeline_description.Passes.value.append(avango.gua.nodes.BBoxPassDescription())
        self.pipeline_description.Passes.value.append(self.resolve_pass)
        self.pipeline_description.Passes.value.append(
            avango.gua.nodes.TexturedScreenSpaceQuadPassDescription())
        self.pipeline_description.Passes.value.append(
            avango.gua.nodes.SSAAPassDescription())

        ## init navigation node
        self.navigation_node = avango.gua.nodes.TransformNode(
            Name="navigation_node")
        PARENT_NODE.Children.value.append(self.navigation_node)

        ## init head node
        self.head_node = avango.gua.nodes.TransformNode(Name="head_node")
        self.head_node.Transform.value = avango.gua.make_trans_mat(
            0.0, 0.0, 0.6)
        self.navigation_node.Children.value.append(self.head_node)

        if HEADTRACKING_FLAG == True:
            self.headtracking_sensor = avango.daemon.nodes.DeviceSensor(
                DeviceService=avango.daemon.DeviceService())
            self.headtracking_sensor.Station.value = "tracking-lcd-glasses-1"
            self.headtracking_sensor.TransmitterOffset.value = avango.gua.make_identity_mat(
            )
            self.headtracking_sensor.ReceiverOffset.value = avango.gua.make_identity_mat(
            )

            self.head_node.Transform.connect_from(
                self.headtracking_sensor.Matrix)

        ## init screen node
        self.screen_node = avango.gua.nodes.ScreenNode(Name="screen_node")
        self.screen_node.Width.value = self.screen_dimensions.x
        self.screen_node.Height.value = self.screen_dimensions.y
        self.screen_node.Transform.value = self.screen_mat
        self.navigation_node.Children.value.append(self.screen_node)

        ## init camera node
        self.camera_node = avango.gua.nodes.CameraNode(Name="camera_node")
        self.camera_node.SceneGraph.value = SCENEGRAPH.Name.value
        self.camera_node.LeftScreenPath.value = self.screen_node.Path.value
        self.camera_node.NearClip.value = 0.1  # in meter
        self.camera_node.FarClip.value = 100.0  # in meter
        self.camera_node.Resolution.value = self.window_size
        self.camera_node.OutputWindowName.value = self.window.Title.value
        self.camera_node.PipelineDescription.value = self.pipeline_description
        self.head_node.Children.value = [self.camera_node]

        if STEREO_MODE == "anaglyph":
            self.camera_node.EnableStereo.value = True
            self.camera_node.RightScreenPath.value = self.screen_node.Path.value

            self.window.StereoMode.value = avango.gua.StereoMode.ANAGLYPH_RED_CYAN
            self.window.RightResolution.value = self.window_size

            self.set_eye_distance(0.064)

        ## intit FPS gui sub-class
        self.fpsGUI = FPSGui(PARENT_NODE=self.screen_node,
                             WINDOW=self.window,
                             VIEWER=self.viewer)

    ### functions ###
    def set_eye_distance(self, FLOAT):
        self.camera_node.EyeDistance.value = FLOAT

    def run(self, LOCALS, GLOBALS):
        self.shell.start(LOCALS, GLOBALS)
        self.viewer.run()

    def list_variabels(self):
        self.shell.list_variables()

    def connect_navigation_matrix(self, SF_MATRIX):
        self.navigation_node.Transform.connect_from(SF_MATRIX)

    def get_head_position(self):  # get relative head position (towards screen)
        return self.head_node.Transform.value.get_translate()
Exemple #6
0
class SimpleViewingSetup:

    ### constructor
    def __init__(self, SCENEGRAPH, STEREO_MODE):

        ### external references ###
        self.SCENEGRAPH = SCENEGRAPH

        ### parameters ###
        self.window_size = avango.gua.Vec2ui(2560, 1440)  # in pixels
        self.screen_dimensions = avango.gua.Vec2(0.595, 0.335)  # in meter
        self.screen_mat = avango.gua.make_trans_mat(0.0, 0.0, 0.0)

        ### resources ###
        self.shell = GuaVE()

        ## init window
        self.window = avango.gua.nodes.GlfwWindow(Title="window")
        self.window.Size.value = self.window_size
        self.window.LeftResolution.value = self.window_size

        avango.gua.register_window(self.window.Title.value, self.window)

        ## init viewer
        self.viewer = avango.gua.nodes.Viewer()
        self.viewer.SceneGraphs.value = [self.SCENEGRAPH]
        self.viewer.Windows.value = [self.window]
        self.viewer.DesiredFPS.value = 60.0  # in Hz

        ## init passes & render pipeline description
        self.resolve_pass = avango.gua.nodes.ResolvePassDescription()
        self.resolve_pass.EnableSSAO.value = False
        self.resolve_pass.SSAOIntensity.value = 4.0
        self.resolve_pass.SSAOFalloff.value = 10.0
        self.resolve_pass.SSAORadius.value = 7.0
        self.resolve_pass.EnvironmentLightingColor.value = avango.gua.Color(
            0.1, 0.1, 0.1)
        self.resolve_pass.ToneMappingMode.value = avango.gua.ToneMappingMode.UNCHARTED
        self.resolve_pass.Exposure.value = 1.0

        self.resolve_pass.BackgroundMode.value = avango.gua.BackgroundMode.SKYMAP_TEXTURE
        self.resolve_pass.BackgroundTexture.value = "/opt/guacamole/resources/skymaps/stars.jpg"

        self.pipeline_description = avango.gua.nodes.PipelineDescription(
            Passes=[])
        self.pipeline_description.EnableABuffer.value = True
        self.pipeline_description.Passes.value.append(
            avango.gua.nodes.TriMeshPassDescription())
        self.pipeline_description.Passes.value.append(
            avango.gua.nodes.LineStripPassDescription())
        self.pipeline_description.Passes.value.append(
            avango.gua.nodes.LightVisibilityPassDescription())
        self.pipeline_description.Passes.value.append(self.resolve_pass)
        self.pipeline_description.Passes.value.append(
            avango.gua.nodes.SSAAPassDescription())

        ## init navigation node
        self.navigation_node = avango.gua.nodes.TransformNode(
            Name="navigation_node")
        self.SCENEGRAPH.Root.value.Children.value.append(self.navigation_node)

        ## init head node
        self.head_node = avango.gua.nodes.TransformNode(Name="head_node")
        self.head_node.Transform.value = avango.gua.make_trans_mat(
            0.0, 0.0, 0.6)  # move head node 60cm in front of screen
        self.navigation_node.Children.value.append(self.head_node)

        ## init screen node
        self.screen_node = avango.gua.nodes.ScreenNode(Name="screen_node")
        self.screen_node.Width.value = self.screen_dimensions.x
        self.screen_node.Height.value = self.screen_dimensions.y
        self.screen_node.Transform.value = self.screen_mat
        self.navigation_node.Children.value.append(self.screen_node)

        ## init camera node
        self.camera_node = avango.gua.nodes.CameraNode(Name="camera_node")
        self.camera_node.SceneGraph.value = self.SCENEGRAPH.Name.value
        self.camera_node.LeftScreenPath.value = self.screen_node.Path.value
        self.camera_node.NearClip.value = 0.1  # in meter
        self.camera_node.FarClip.value = 100.0  # in meter
        self.camera_node.Resolution.value = self.window_size
        self.camera_node.OutputWindowName.value = self.window.Title.value
        self.camera_node.PipelineDescription.value = self.pipeline_description
        self.head_node.Children.value = [self.camera_node]

    ### functions ###
    def run(self, LOCALS, GLOBALS):
        self.shell.start(LOCALS, GLOBALS)
        self.viewer.run()

    def list_variabels(self):
        self.shell.list_variables()

    def connect_navigation_matrix(self, SF_MATRIX):
        self.navigation_node.Transform.connect_from(SF_MATRIX)

    def get_head_position(self):  # get relative head position (towards screen)
        return self.head_node.Transform.value.get_translate()
Exemple #7
0
class MultiUserViewingSetup:

    ### constructor
    def __init__(
            self,
            SCENEGRAPH=None,
            WINDOW_RESOLUTION=avango.gua.Vec2ui(
                1400, 1050),  # default resolution in pixel
            SCREEN_DIMENSIONS=avango.gua.Vec2(
                1.135, 0.85),  # default screen size in meter
            SCREEN_MATRIX=avango.gua.make_identity_mat(),
            TRACKING_TRANSMITTER_OFFSET=avango.gua.make_identity_mat(),
            LEFT_POSITION=avango.gua.Vec2ui(0, 0),
            LEFT_RESOLUTION=avango.gua.Vec2ui(1400, 1050),
            RIGHT_POSITION=avango.gua.Vec2ui(1400, 0),
            RIGHT_RESOLUTION=avango.gua.Vec2ui(1400, 1050),
            DISPLAY_STRING_LIST=[":0.0"],
            WARP_MATRIX_RED_RIGHT="",
            WARP_MATRIX_GREEN_RIGHT="",
            WARP_MATRIX_BLUE_RIGHT="",
            WARP_MATRIX_RED_LEFT="",
            WARP_MATRIX_GREEN_LEFT="",
            WARP_MATRIX_BLUE_LEFT="",
            BLACK_LIST=[]):

        ## parameter quards
        if SCENEGRAPH is None:
            print("ERROR: scengraph instance missing")
            quit()

        ### external references ###
        self.SCENEGRAPH = SCENEGRAPH

        ### parameters ###
        self.window_resolution = WINDOW_RESOLUTION
        self.screen_dimensions = SCREEN_DIMENSIONS
        self.screen_mat = SCREEN_MATRIX
        self.left_resolution = LEFT_RESOLUTION
        self.right_resolution = RIGHT_RESOLUTION
        self.left_position = LEFT_POSITION
        self.right_position = RIGHT_POSITION

        self.tracking_transmitter_offset = TRACKING_TRANSMITTER_OFFSET

        self.display_string_list = DISPLAY_STRING_LIST

        self.warp_matrix_red_right = WARP_MATRIX_RED_RIGHT
        self.warp_matrix_green_right = WARP_MATRIX_GREEN_RIGHT
        self.warp_matrix_blue_right = WARP_MATRIX_BLUE_RIGHT
        self.warp_matrix_red_left = WARP_MATRIX_RED_LEFT
        self.warp_matrix_green_left = WARP_MATRIX_GREEN_LEFT
        self.warp_matrix_blue_left = WARP_MATRIX_BLUE_LEFT

        self.black_list = BLACK_LIST

        ### variables ###
        self.user_list = []

        ### resources ###

        self.shell = GuaVE()

        ## init viewer
        self.viewer = avango.gua.nodes.Viewer()
        self.viewer.SceneGraphs.value = [self.SCENEGRAPH]
        #self.viewer.Windows.value = [self.window]
        self.viewer.DesiredFPS.value = 200.0  # in Hz

        ## init navigation node
        self.navigation_node = avango.gua.nodes.TransformNode(
            Name="navigation_node")
        self.SCENEGRAPH.Root.value.Children.value.append(self.navigation_node)

        ## init screen node
        self.screen_node = avango.gua.nodes.ScreenNode(Name="screen_node")
        self.screen_node.Width.value = self.screen_dimensions.x
        self.screen_node.Height.value = self.screen_dimensions.y
        self.screen_node.Transform.value = self.screen_mat
        self.navigation_node.Children.value.append(self.screen_node)

    def init_user(
        self,
        HEADTRACKING_SENSOR_STATION="",
    ):

        # print(type(self.display_string_list[0][0]))
        _display_string = self.display_string_list[len(self.user_list)][0]

        _user = User(
            SCENEGRAPH=self.SCENEGRAPH,
            NAVIGATION_NODE=self.navigation_node,
            SCREEN_NODE=self.screen_node,
            DISPLAY_STRING=_display_string,
            WINDOW_RESOLUTION=self.window_resolution,
            SCREEN_DIMENSIONS=self.screen_dimensions,
            SCREEN_MATRIX=self.screen_mat,
            HEADTRACKING_SENSOR_STATION=HEADTRACKING_SENSOR_STATION,
            TRACKING_TRANSMITTER_OFFSET=self.tracking_transmitter_offset,
            LEFT_POSITION=self.left_position,
            LEFT_RESOLUTION=self.left_resolution,
            RIGHT_POSITION=self.right_position,
            RIGHT_RESOLUTION=self.right_resolution,
            WARP_MATRIX_RED_RIGHT=self.warp_matrix_red_right,
            WARP_MATRIX_GREEN_RIGHT=self.warp_matrix_green_right,
            WARP_MATRIX_BLUE_RIGHT=self.warp_matrix_blue_right,
            WARP_MATRIX_RED_LEFT=self.warp_matrix_red_left,
            WARP_MATRIX_GREEN_LEFT=self.warp_matrix_green_left,
            WARP_MATRIX_BLUE_LEFT=self.warp_matrix_blue_left,
            BLACK_LIST=self.black_list,
        )

        self.user_list.append(_user)

        self.viewer.Windows.value.append(_user.window)

    def run(self, LOCALS, GLOBALS):
        self.shell.start(LOCALS, GLOBALS)
        self.viewer.run()

    def list_variabels(self):
        self.shell.list_variables()

    def connect_navigation_matrix(self, SF_MATRIX):
        self.navigation_node.Transform.connect_from(SF_MATRIX)
class SimpleViewingSetup:

    ### constructor
    def __init__( self
                , SCENEGRAPH = None
                , RESOLUTION = avango.gua.Vec2ui(1920, 1080) # in pixels
                , STEREO_MODE = "mono"
                , SCREEN_DIMENSIONS = avango.gua.Vec2(1.0, 1.0) # in meter
                , SCREEN_MAT = avango.gua.make_identity_mat()
                , HEADTRACKING_FLAG = False
                , TRACKING_STATION = ""
                , TRANSMITTER_OFFSET_MAT = avango.gua.make_identity_mat()
                , NAVIGATION_START_MAT = avango.gua.make_identity_mat()
                , HOSTNAME = ""
                , CLIENT_FLAG = False
                , BLACK_LIST = []
                ):
                                

        ### external references ###
        self.SCENEGRAPH = SCENEGRAPH
                                  
        ### parameters ###
        self.hostname = HOSTNAME

        self.mono_height_threshold = 0.4
        self.head_pos = avango.gua.make_trans_mat(0.0, 0.573, 1.0)
        if self.hostname == "athena":
            #teaching
            self.mono_height_threshold = 0.25
            self.head_pos = avango.gua.make_trans_mat(0.0, 0.6, 0.0)
            # sitting
            #self.mono_height_threshold = 0.15
            #self.head_pos = avango.gua.make_trans_mat(0.0, 0.6, 0.0)
        
        
        ### resources ###
        
        self.shell = GuaVE()

        ## init window
        self.window = avango.gua.nodes.GlfwWindow(Title = "window")
        #self.window.EnableFullscreen.value = True
        self.window.Size.value = RESOLUTION
        self.window.LeftResolution.value = RESOLUTION
        
        avango.gua.register_window(self.window.Title.value, self.window) 


        ## init viewer
        self.viewer = avango.gua.nodes.Viewer()
        self.viewer.SceneGraphs.value = [SCENEGRAPH]
        self.viewer.Windows.value = [self.window]
        #self.viewer.DesiredFPS.value = 60.0 # in Hz


        ## init passes & render pipeline description
        self.resolve_pass = avango.gua.nodes.ResolvePassDescription()
        self.resolve_pass.EnableSSAO.value = False
        self.resolve_pass.SSAOIntensity.value = 3.0
        self.resolve_pass.SSAOFalloff.value = 10.0
        self.resolve_pass.SSAORadius.value = 2.0
        #self.resolve_pass.EnableScreenSpaceShadow.value = True
        self.resolve_pass.EnvironmentLightingColor.value = avango.gua.Color(0.2, 0.2, 0.2)
        self.resolve_pass.ToneMappingMode.value = avango.gua.ToneMappingMode.UNCHARTED
        self.resolve_pass.Exposure.value = 1.0

        #self.resolve_pass.BackgroundMode.value = avango.gua.BackgroundMode.COLOR
        #self.resolve_pass.BackgroundColor.value = avango.gua.Color(0.45, 0.5, 0.6)
        self.resolve_pass.BackgroundMode.value = avango.gua.BackgroundMode.SKYMAP_TEXTURE
        #self.resolve_pass.BackgroundTexture.value = "/opt/guacamole/resources/skymaps/DH216SN.png"
        #self.resolve_pass.BackgroundTexture.value = "/opt/guacamole/resources/skymaps/warehouse.jpg"
        #self.resolve_pass.BackgroundTexture.value = "/opt/guacamole/resources/skymaps/bath.jpg"
        self.resolve_pass.BackgroundTexture.value = "/opt/kinect-resources/calib_3dvc/skype_3D/textures/skymap.png"        
        

        self.pipeline_description = avango.gua.nodes.PipelineDescription(Passes = [])
        self.pipeline_description.EnableABuffer.value = False
        self.pipeline_description.Passes.value.append(avango.gua.nodes.TriMeshPassDescription())
        self.pipeline_description.Passes.value.append(avango.gua.nodes.Video3DPassDescription())
        #self.pipeline_description.Passes.value.append(avango.gua.nodes.TexturedQuadPassDescription())
        self.pipeline_description.Passes.value.append(avango.gua.nodes.LightVisibilityPassDescription())
        #self.pipeline_description.Passes.value.append(avango.gua.nodes.BBoxPassDescription())
        self.pipeline_description.Passes.value.append(self.resolve_pass)
        self.pipeline_description.Passes.value.append(avango.gua.nodes.TexturedScreenSpaceQuadPassDescription())               
        self.pipeline_description.Passes.value.append(avango.gua.nodes.SSAAPassDescription())


        self.navigation_node = avango.gua.nodes.TransformNode(Name = "{0}_navigation_node".format(self.hostname))
        SCENEGRAPH.Root.value.Children.value.append(self.navigation_node)
        self.navigation_node.Transform.value = NAVIGATION_START_MAT

        '''
        ## init navigation geometry
        _trimesh_loader = avango.gua.nodes.TriMeshLoader() # get trimesh loader to load external tri-meshes            

        self.navigation_geometry = _trimesh_loader.create_geometry_from_file("{0}_navigation_geometry".format(self.hostname), "data/objects/plane.obj", avango.gua.LoaderFlags.DEFAULTS)
        self.navigation_geometry.Transform.value = avango.gua.make_scale_mat(1.0)
        self.navigation_node.Children.value.append(self.navigation_geometry)
        '''
        
        ## init head node
        self.head_node = avango.gua.nodes.TransformNode(Name = "head_node")
        self.head_node.Transform.value = avango.gua.make_trans_mat(0.0, 0.0, 0.6)
        self.navigation_node.Children.value.append(self.head_node)

        if HEADTRACKING_FLAG == True:
            self.headtracking_sensor = avango.daemon.nodes.DeviceSensor(DeviceService = avango.daemon.DeviceService())
            self.headtracking_sensor.Station.value = TRACKING_STATION
            self.headtracking_sensor.TransmitterOffset.value = TRANSMITTER_OFFSET_MAT
            self.headtracking_sensor.ReceiverOffset.value = avango.gua.make_identity_mat()

            self.head_node.Transform.connect_from(self.headtracking_sensor.Matrix)
            #print(self.headtracking_sensor.Matrix)


        ## init screen node
        self.screen_node = avango.gua.nodes.ScreenNode(Name = "screen_node")
        self.screen_node.Width.value = SCREEN_DIMENSIONS.x
        self.screen_node.Height.value = SCREEN_DIMENSIONS.y
        self.screen_node.Transform.value = SCREEN_MAT
        self.navigation_node.Children.value.append(self.screen_node)
        

        ## init camera node
        self.camera_node = avango.gua.nodes.CameraNode(Name = "camera_node")
        self.camera_node.SceneGraph.value = SCENEGRAPH.Name.value
        self.camera_node.LeftScreenPath.value = self.screen_node.Path.value
        self.camera_node.RightScreenPath.value = self.screen_node.Path.value
        self.camera_node.NearClip.value = 0.1 # in meter
        self.camera_node.FarClip.value = 100.0 # in meter
        self.camera_node.Resolution.value = RESOLUTION
        self.camera_node.OutputWindowName.value = self.window.Title.value
        self.camera_node.PipelineDescription.value = self.pipeline_description
        self.camera_node.BlackList.value = BLACK_LIST
        
        self.head_node.Children.value = [self.camera_node]

        #print("stereo mode", STEREO_MODE)
        if STEREO_MODE == "anaglyph":
            self.camera_node.EnableStereo.value = True

            self.window.StereoMode.value = avango.gua.StereoMode.ANAGLYPH_RED_CYAN
            self.window.RightResolution.value = RESOLUTION

            self.set_eye_distance(0.064)

        elif STEREO_MODE == "checkerboard":
            self.camera_node.EnableStereo.value = True

            self.window.StereoMode.value = avango.gua.StereoMode.CHECKERBOARD
            self.window.RightResolution.value = RESOLUTION

            self.set_eye_distance(0.064)

        elif STEREO_MODE == "SIDE_BY_SIDE":
            self.camera_node.EnableStereo.value = True
            
            self.window.StereoMode.value = avango.gua.StereoMode.SIDE_BY_SIDE

            self.window.Size.value = avango.gua.Vec2ui(1920*2, 1200)

            #print("offsetMat", TRANSMITTER_OFFSET_MAT)

            #self.head_node.Transform.value.get_translate()[1] = self.head_node.Transform.value.get_translate()[1] + 20

            self.window.LeftResolution.value = avango.gua.Vec2ui(1780, 1185)
            self.window.LeftPosition.value = avango.gua.Vec2ui(140, 0)
            self.window.RightResolution.value = avango.gua.Vec2ui(1780, 1185)
            self.window.RightPosition.value = avango.gua.Vec2ui(1920, 0)

            self.set_eye_distance(0.064)

        ## intit FPS gui sub-class
        self.fpsGUI = FPSGui( PARENT_NODE = self.screen_node
                            , WINDOW = self.window
                            , VIEWER = self.viewer
                            )

        self.script = SimpleViewingSetupScript()
        self.script.my_constructor(CLASS = self)


        ### trigger callbacks ###

        ## @var frame_trigger
        # Triggers framewise evaluation of respective callback method
        self.frame_trigger = avango.script.nodes.Update(Callback = self.frame_callback, Active = False)

        if CLIENT_FLAG == True:
            self.frame_trigger.Active.value = True # enable frame trigger to search for distributed scenegraph
        


    ### callback functions ###
    def frame_callback(self):
        _nettrans = self.SCENEGRAPH.Root.value.Children.value[0]

        for _node in _nettrans.Children.value:               
            if _node.Name.value.count(self.hostname) > 0:
                self.navigation_node.Transform.connect_from(_node.Transform)

                self.frame_trigger.Active.value = False # disable frame callback
                
                break


        '''
        for _node in _nettrans.Children.value:               
            if _node.Name.value.count(self.hostname) > 0:
                self.SCENEGRAPH.Root.value.Children.value.remove(self.navigation_node)
                _node.Children.value.append(self.navigation_node)

                ## update node paths
                self.camera_node.LeftScreenPath.value = self.screen_node.Path.value
                self.camera_node.RightScreenPath.value = self.screen_node.Path.value
                
                self.frame_trigger.Active.value = False # disable frame callback
        '''

    ### functions ###
    def set_eye_distance(self, FLOAT):
        self.camera_node.EyeDistance.value = FLOAT


    def run(self, LOCALS, GLOBALS):
        self.shell.start(LOCALS, GLOBALS)
        self.viewer.run()


    def list_variabels(self):
        self.shell.list_variables()


    def connect_navigation_matrix(self, SF_MATRIX):
        self.navigation_node.Transform.connect_from(SF_MATRIX)


    def get_head_position(self): # get relative head position (towards screen)
        return self.head_node.Transform.value.get_translate()