Пример #1
0
 def on_hide(self, shown):
     #print "on_hide", shown
     self.sels = []
     try:
         self.manipulator.hideManipulator()
     except RuntimeError, e:
         r.logDebug("on_hide: scene not found")
Пример #2
0
    def update(self, time):
        #print "here", time
        if self.windowActive:
            self.time += time
            if self.sels:
                ent = self.active
                #try:
                #    ent.prim
                #except ValueError:
                #that would work also, but perhaps this is nicer:
                s = naali.getDefaultScene()
                if not s.HasEntityId(ent.id):
                    #my active entity was removed from the scene by someone else
                    self.deselect(ent, valid=False)
                    return

                if self.time > self.UPDATE_INTERVAL:
                    try:
                        #sel_pos = self.selection_box.placeable.Position
                        arr_pos = self.manipulator.getManipulatorPosition()
                        ent_pos = ent.placeable.Position
                        #if sel_pos != ent_pos:
                        self.time = 0  #XXX NOTE: is this logic correct?
                        #    self.selection_box.placeable.Position = ent_pos
                        if arr_pos != ent_pos:
                            self.manipulator.moveTo(self.sels)
                    except RuntimeError, e:
                        r.logDebug("update: scene not found")
Пример #3
0
 def on_hide(self, shown):
     #print "on_hide", shown
     self.sels = []
     try:
         self.manipulator.hideManipulator()
     except RuntimeError, e:
         r.logDebug("on_hide: scene not found")
Пример #4
0
 def hideSelector(self):
     try: #XXX! without this try-except, if something is selected, the viewer will crash on exit
         if self.selection_box is not None:
             self.selection_box.placeable.Scale = Vec(0.0, 0.0, 0.0)
             self.selection_box.placeable.Position = Vec(0.0, 0.0, 0.0)
     except RuntimeError, e:
         r.logDebug("hideSelector failed")
Пример #5
0
 def update(self, time):
     #print "here", time
     self.time += time
     if self.sels:
         ent = self.active
         #try:
         #    ent.prim
         #except ValueError:
         #that would work also, but perhaps this is nicer:
         s = naali.getDefaultScene()
         if not s.HasEntityId(ent.id):
             #my active entity was removed from the scene by someone else
             self.deselect(ent, valid=False)
             return
             
         if self.time > self.UPDATE_INTERVAL:
             try:
                 #sel_pos = self.selection_box.placeable.Position
                 arr_pos = self.manipulator.getManipulatorPosition()
                 ent_pos = ent.placeable.position
                 #if sel_pos != ent_pos:
                 self.time = 0 #XXX NOTE: is this logic correct?
                 #    self.selection_box.placeable.Position = ent_pos
                 if arr_pos != ent_pos:
                     self.manipulator.moveTo(self.sels)
             except RuntimeError, e:
                 r.logDebug("update: scene not found")
Пример #6
0
 def on_hide(self, shown):
     self.windowActive = shown
     if self.windowActive:
         self.sels = []
         try:
             self.manipulator.hideManipulator()
             #if self.move_arrows is not None:
             #ent = self.move_arrows.id
             #is called by qt also when viewer is exiting,
             #when the scene (in rexlogic module) is not there anymore.
         except RuntimeError, e:
             r.logDebug("on_hide: scene not found")
         else:
             self.deselect_all()
Пример #7
0
 def on_hide(self, shown):
     self.windowActive = shown
     if self.windowActive:
         self.sels = []
         try:
             self.manipulator.hideManipulator()
             #if self.move_arrows is not None:
                 #ent = self.move_arrows.id 
                 #is called by qt also when viewer is exiting,
                 #when the scene (in rexlogic module) is not there anymore.
         except RuntimeError, e:
             r.logDebug("on_hide: scene not found")
         else:
             self.deselect_all()
Пример #8
0
 def hideManipulator(self):
     #r.logInfo("hiding manipulator")
     if self.usesManipulator:
         try: #XXX! without this try-except, if something is selected, the viewer will crash on exit
             #print "Hiding arrows!"
             if self.manipulator is not None:
                 self.manipulator.placeable.Scale = Vec(0.0, 0.0, 0.0) #ugly hack
                 self.manipulator.placeable.Position = Vec(0.0, 0.0, 0.0)#another ugly hack
             
             self.grabbed_axis = None
             self.grabbed = False
             
         except RuntimeError, e:
             r.logDebug("hideManipulator failed")
Пример #9
0
    def on_activate_editing(self, activate):
        r.logDebug("on_active_editing")
        # Restore stored state when exiting build mode
        if activate == False and self.windowActiveStoredState != None:
            self.windowActive = self.windowActiveStoredState
            self.windowActiveStoredState = None
            if self.windowActive == False:
                self.deselect_all()
                for ent in self.sels:
                    self.remove_highlight(ent)

        # Store the state before build scene activated us
        if activate == True and self.windowActiveStoredState == None:
            self.windowActiveStoredState = self.windowActive
            self.windowActive = True
Пример #10
0
    def on_activate_editing(self, activate):
        r.logDebug("on_active_editing")
        # Restore stored state when exiting build mode
        if activate == False and self.windowActiveStoredState != None:
            self.windowActive = self.windowActiveStoredState
            self.windowActiveStoredState = None
            if self.windowActive == False:
                self.deselect_all()
                for ent in self.sels:
                    self.remove_highlight(ent)

        # Store the state before build scene activated us
        if activate == True and self.windowActiveStoredState == None:
            self.windowActiveStoredState = self.windowActive
            self.windowActive = True
Пример #11
0
    def hideManipulator(self):
        #r.logInfo("hiding manipulator")
        if self.usesManipulator:
            try:  #XXX! without this try-except, if something is selected, the viewer will crash on exit
                #print "Hiding arrows!"
                if self.manipulator is not None:
                    self.manipulator.placeable.Scale = Vec(0.0, 0.0,
                                                           0.0)  #ugly hack
                    self.manipulator.placeable.Position = Vec(
                        0.0, 0.0, 0.0)  #another ugly hack

                self.grabbed_axis = None
                self.grabbed = False

            except RuntimeError, e:
                r.logDebug("hideManipulator failed")
Пример #12
0
 def uploadFile(self, filePath, collectionWebDavPath, resourceWebDavName):
     dataFile = None
     rexviewer.logDebug("WebDav Connection Uploading file: %s" % filePath)
     try:
         dataFile = open(filePath, 'rb')
     except IOError:
         dataFile.close()
         return 'False'
     if (self.setCollectionStorerToPath(collectionWebDavPath)):
         try:
             self.resource.addResource(resourceWebDavName, dataFile.read())
             dataFile.close()
             return 'True'
         except WebdavError, IOError:
             dataFile.close()
             return WebdavError.__str__
Пример #13
0
 def uploadFile(self, filePath, collectionWebDavPath, resourceWebDavName):
     dataFile = None
     rexviewer.logDebug("WebDav Connection Uploading file: %s" % filePath)
     try:
         dataFile = open(filePath, 'rb')
     except IOError:
         dataFile.close()
         return 'False'
     if ( self.setCollectionStorerToPath(collectionWebDavPath) ):
         try:
             self.resource.addResource(resourceWebDavName, dataFile.read())
             dataFile.close()
             return 'True'
         except WebdavError, IOError:
             dataFile.close()
             return WebdavError.__str__
Пример #14
0
 def hideManipulator(self):
     #r.logInfo("hiding manipulator")
     if self.usesManipulator:
         try: #XXX! without this try-except, if something is selected, the viewer will crash on exit
             #print "Hiding arrows!"
             if self.manipulator is not None:
                 self.manipulator.placeable.Scale = QVector3D(0.0, 0.0, 0.0) #ugly hack
                 self.manipulator.placeable.Position = QVector3D(0.0, 0.0, 0.0)#another ugly hack
                 self.manipulator.ruler.SetVisible(False)
                 #r.logInfo("hiding ruler hideManipulator")
                 self.manipulator.ruler.UpdateRuler()
             
             self.grabbed_axis = None
             self.grabbed = False
             remove_custom_cursors()
             
         except RuntimeError, e:
             r.logDebug("hideManipulator failed")
Пример #15
0
 def update(self, time):
     #print "here", time
     if self.windowActive:
         self.time += time
         if self.sels:
             ent = self.active
             if self.time > self.UPDATE_INTERVAL:
                 try:
                     #sel_pos = self.selection_box.placeable.Position
                     arr_pos = self.manipulator.getManipulatorPosition()
                     ent_pos = ent.placeable.Position
                     #if sel_pos != ent_pos:
                     self.time = 0  #XXX NOTE: is this logic correct?
                     #    self.selection_box.placeable.Position = ent_pos
                     if arr_pos != ent_pos:
                         self.manipulator.moveTo(self.sels)
                 except RuntimeError, e:
                     r.logDebug("update: scene not found")
Пример #16
0
 def update(self, time):
     #print "here", time
     if self.windowActive:
         self.time += time
         if self.sels:
             ent = self.active
             if self.time > self.UPDATE_INTERVAL:
                 try:
                     sel_pos = self.selection_box.placeable.Position
                     arr_pos = self.manipulator.getManipulatorPosition()
                     ent_pos = ent.placeable.Position
                     if sel_pos != ent_pos:
                         self.time = 0
                         self.selection_box.placeable.Position = ent_pos
                     if arr_pos != ent_pos:
                         self.manipulator.moveTo(self.sels)
                 except RuntimeError, e:
                     r.logDebug("update: scene not found")
Пример #17
0
    def on_genericmessage(self, name, data):
        #print "MediaURLHandler got Generic Message:", name, data
        if name == "RexMediaUrl":
            #print "MediaURLHandler got data:", data
            textureuuid, urlstring, refreshrate = data
            refreshrate = int(refreshrate)

            if self.texture2mediaurlview.has_key(textureuuid):
                mediaurlview = self.texture2mediaurlview[textureuuid]
                if mediaurlview is not None:
                    if mediaurlview.url().toString() == urlstring:
                        mediaurlview.refreshrate = refreshrate
                        return
                    del self.texture2mediaurlview[textureuuid]
                    mediaurlview.delete_playback_widget()

            #could check whether a webview for this url already existed
            mv = MediaurlView(urlstring, refreshrate)

            #for when get visuals_modified events later,
            #e.g. for newly downloaded objects
            self.texture2mediaurlview[textureuuid] = mv

            # Check if texture is in scene and only if is create playback widget
            if mv.playback_widget == None:
                r.logDebug("MediaUrlHandler: Checking scene for texture " +
                           str(textureuuid))
                if r.checkSceneForTexture(textureuuid):
                    mv.create_playback_widget()

            # If widget was created (texture found in scene), then apply to submeshes
            if mv.playback_widget != None:
                affected_entitys = naali._pythonscriptmodule.ApplyUICanvasToSubmeshesWithTexture(
                    mv.playback_widget, textureuuid, mv.refreshrate)
                # Connect affected entities Toucheble signals to to MediaurlView
                if affected_entitys != None:
                    for entity in affected_entitys:
                        self.connect_touchable(mv, entity)
                mv.load_url()
Пример #18
0
    def on_genericmessage(self, name, data):
        #print "MediaURLHandler got Generic Message:", name, data
        if name == "RexMediaUrl":
            #print "MediaURLHandler got data:", data
            textureuuid, urlstring, refreshrate = data
            refreshrate = int(refreshrate)
            
            if self.texture2mediaurlview.has_key(textureuuid):
                mediaurlview = self.texture2mediaurlview[textureuuid]
                if mediaurlview is not None:
                    if mediaurlview.url().toString() == urlstring:
                        mediaurlview.refreshrate = refreshrate
                        return
                    del self.texture2mediaurlview[textureuuid]
                    mediaurlview.delete_playback_widget()

            #could check whether a webview for this url already existed
            mv = MediaurlView(urlstring, refreshrate)

            #for when get visuals_modified events later, 
            #e.g. for newly downloaded objects
            self.texture2mediaurlview[textureuuid] = mv
            
            # Check if texture is in scene and only if is create playback widget
            if mv.playback_widget == None:
                r.logDebug("MediaUrlHandler: Checking scene for texture " + str(textureuuid))
                if r.checkSceneForTexture(textureuuid):
                    mv.create_playback_widget()
                    
            # If widget was created (texture found in scene), then apply to submeshes
            if mv.playback_widget != None:
                affected_entitys = r.applyUICanvasToSubmeshesWithTexture(mv.playback_widget, textureuuid, mv.refreshrate)
                # Connect affected entities Toucheble signals to to MediaurlView
                if affected_entitys != None:
                    for entity in affected_entitys:
                        self.connect_touchable(mv, entity)
                mv.load_url()
Пример #19
0
        print "- initial import."
        exec("import %s" % modulename)
    else:
        print "- reload."
        exec("%s = reload(%s)" % (modulename, modulename))
    return sys.modules[modulename]
"""

modules = []

try:
    apitest.circuits_testmodule
except: #first run
    import apitest.circuits_testmodule
else:
    r.logDebug("   reloading apitest.circuits_testmodule")
    apitest.circuits_testmodule = reload(apitest.circuits_testmodule)

try:
    usr.chathandler
except: #first run
    import usr.chathandler
else:
    r.logDebug("   reloading usr.chathandler")
    usr.chathandler = reload(usr.chathandler)

try:
    usr.keycommands
except: #first run
    import usr.keycommands
else:
Пример #20
0
        print "created a new Highlight component"

    h = e.highlight
    print type(h), h

    h.Show()
    #h.Hide()

    vis = h.IsVisible()
    if vis:
        print "vis"
    else:
        print "not"

if 0:  #log level visibility
    r.logDebug("Debug")
    #r.logWarning("Warning") #not implement now, should add i guess
    r.logInfo("Info")

if 0:  #local object creation, testing if local previews of .scenes would work
    from PythonQt.QtGui import QVector3D as Vec3
    from PythonQt.QtGui import QQuaternion as Quat

    print "hep"
    e = r.createEntity("Jack.mesh", 1515)
    print e
    e.placeable.Position = Vec3(128, 128, 60)
    e.placeable.Scale = Vec3(5, 5, 5)
    e.placeable.Orientation = Quat(0, 0, 0, 1)

if 0:  #running localscene dotscene loader
Пример #21
0
    def __init__(self):
        self.sels = []  
        Component.__init__(self)
        self.window = window.ObjectEditWindow(self)
        self.resetValues()
        self.worldstream = r.getServerConnection()
        self.usingManipulator = False
        self.useLocalTransform = False
        self.cpp_python_handler = None
        self.left_button_down = False
        self.keypressed = False

        self.shortcuts = {
            (Qt.Key_Z, Qt.ControlModifier) : self.undo,
            (Qt.Key_Delete, Qt.NoModifier) : self.deleteObject,
            (Qt.Key_L, Qt.AltModifier) : self.linkObjects,
            (Qt.Key_L, Qt.ControlModifier|Qt.ShiftModifier) : self.unlinkObjects,
        }

        # Connect to key pressed signal from input context
        self.edit_inputcontext = naali.createInputContext("object-edit", 100)
        self.edit_inputcontext.SetTakeMouseEventsOverQt(True)
        self.edit_inputcontext.connect('KeyPressed(KeyEvent*)', self.on_keypressed)

        # Connect to mouse events
        self.edit_inputcontext.connect('MouseScroll(MouseEvent*)', self.on_mousescroll)
        self.edit_inputcontext.connect('MouseLeftPressed(MouseEvent*)', self.on_mouseleftpressed)
        self.edit_inputcontext.connect('MouseLeftReleased(MouseEvent*)', self.on_mouseleftreleased)
        self.edit_inputcontext.connect('MouseMove(MouseEvent*)', self.on_mousemove)
        
        self.resetManipulators()
        
        loader = QUiLoader()
        selectionfile = QFile(self.SELECTIONRECT)
        self.selection_rect = loader.load(selectionfile)
        #rectprops = r.createUiWidgetProperty(2)
        #~ print type(rectprops), dir(rectprops)
        #print rectprops.WidgetType
        #uiprops.widget_name_ = "Selection Rect"
        
        #uiprops.my_size_ = QSize(width, height) #not needed anymore, uimodule reads it
        proxy = r.createUiProxyWidget(self.selection_rect)
        uism = r.getUiSceneManager()
        uism.AddWidgetToScene(proxy)
        proxy.setWindowFlags(0) #changing it to Qt::Widget
        
        self.selection_rect.setGeometry(0,0,0,0)
        self.selection_rect_startpos = None
        
        r.c = self #this is for using objectedit from command.py
        
        # Get world building modules python handler
        self.cpp_python_handler = r.getQWorldBuildingHandler()
        if self.cpp_python_handler == None:
            r.logDebug("Could not aqquire world building service to object edit")
        else:
            # Connect signals
            self.cpp_python_handler.connect('ActivateEditing(bool)', self.on_activate_editing)
            self.cpp_python_handler.connect('ManipulationMode(int)', self.on_manupulation_mode_change)
            self.cpp_python_handler.connect('RemoveHightlight()', self.deselect_all)
            self.cpp_python_handler.connect('RotateValuesToNetwork(int, int, int)', self.changerot_cpp)
            self.cpp_python_handler.connect('ScaleValuesToNetwork(double, double, double)', self.changescale_cpp)
            self.cpp_python_handler.connect('PosValuesToNetwork(double, double, double)', self.changepos_cpp)
            self.cpp_python_handler.connect('CreateObject()', self.createObject)
            self.cpp_python_handler.connect('DuplicateObject()', self.duplicate)
            self.cpp_python_handler.connect('DeleteObject()', self.deleteObject)
            # Pass widgets
            self.cpp_python_handler.PassWidget("Mesh", self.window.mesh_widget)
            self.cpp_python_handler.PassWidget("Animation", self.window.animation_widget)
            self.cpp_python_handler.PassWidget("Sound", self.window.sound_widget)
            self.cpp_python_handler.PassWidget("Materials", self.window.materialTabFormWidget)
            # Check if build mode is active, required on python restarts
            self.on_activate_editing(self.cpp_python_handler.IsBuildingActive())
Пример #22
0
        print "- initial import."
        exec("import %s" % modulename)
    else:
        print "- reload."
        exec("%s = reload(%s)" % (modulename, modulename))
    return sys.modules[modulename]
"""

modules = []

try:
    apitest.circuits_testmodule
except: #first run
    import apitest.circuits_testmodule
else:
    r.logDebug("   reloading apitest.circuits_testmodule")
    apitest.circuits_testmodule = reload(apitest.circuits_testmodule)

try:
    usr.chathandler
except: #first run
    import usr.chathandler
else:
    r.logDebug("   reloading usr.chathandler")
    usr.chathandler = reload(usr.chathandler)

try:
    usr.keycommands
except: #first run
    import usr.keycommands
else:
Пример #23
0
    def __init__(self):
        self.sels = []
        Component.__init__(self)
        self.window = window.ObjectEditWindow(self)
        self.resetValues()
        self.worldstream = r.getServerConnection()
        self.usingManipulator = False
        self.useLocalTransform = False
        self.cpp_python_handler = None
        self.left_button_down = False
        self.keypressed = False

        self.shortcuts = {
            (Qt.Key_Z, Qt.ControlModifier): self.undo,
            (Qt.Key_Delete, Qt.NoModifier): self.deleteObject,
            (Qt.Key_L, Qt.AltModifier): self.linkObjects,
            (Qt.Key_L, Qt.ControlModifier | Qt.ShiftModifier):
            self.unlinkObjects,
        }

        # Connect to key pressed signal from input context
        self.edit_inputcontext = naali.createInputContext("object-edit", 100)
        self.edit_inputcontext.SetTakeMouseEventsOverQt(True)
        self.edit_inputcontext.connect('KeyPressed(KeyEvent*)',
                                       self.on_keypressed)

        # Connect to mouse events
        self.edit_inputcontext.connect('MouseScroll(MouseEvent*)',
                                       self.on_mousescroll)
        self.edit_inputcontext.connect('MouseLeftPressed(MouseEvent*)',
                                       self.on_mouseleftpressed)
        self.edit_inputcontext.connect('MouseLeftReleased(MouseEvent*)',
                                       self.on_mouseleftreleased)
        self.edit_inputcontext.connect('MouseMove(MouseEvent*)',
                                       self.on_mousemove)

        self.resetManipulators()

        loader = QUiLoader()
        selectionfile = QFile(self.SELECTIONRECT)
        self.selection_rect = loader.load(selectionfile)
        #rectprops = r.createUiWidgetProperty(2)
        #~ print type(rectprops), dir(rectprops)
        #print rectprops.WidgetType
        #uiprops.widget_name_ = "Selection Rect"

        #uiprops.my_size_ = QSize(width, height) #not needed anymore, uimodule reads it
        proxy = r.createUiProxyWidget(self.selection_rect)
        uism = naali.ui
        uism.AddWidgetToScene(proxy)
        proxy.setWindowFlags(0)  #changing it to Qt::Widget

        self.selection_rect.setGeometry(0, 0, 0, 0)
        self.selection_rect_startpos = None

        r.c = self  #this is for using objectedit from command.py

        # Get world building modules python handler
        self.cpp_python_handler = r.getQWorldBuildingHandler()
        if self.cpp_python_handler == None:
            r.logDebug(
                "Could not aqquire world building service to object edit")
        else:
            # Connect signals
            self.cpp_python_handler.connect('ActivateEditing(bool)',
                                            self.on_activate_editing)
            self.cpp_python_handler.connect('ManipulationMode(int)',
                                            self.on_manupulation_mode_change)
            self.cpp_python_handler.connect('RemoveHightlight()',
                                            self.deselect_all)
            self.cpp_python_handler.connect(
                'RotateValuesToNetwork(int, int, int)', self.changerot_cpp)
            self.cpp_python_handler.connect(
                'ScaleValuesToNetwork(double, double, double)',
                self.changescale_cpp)
            self.cpp_python_handler.connect(
                'PosValuesToNetwork(double, double, double)',
                self.changepos_cpp)
            self.cpp_python_handler.connect('CreateObject()',
                                            self.createObject)
            self.cpp_python_handler.connect('DuplicateObject()',
                                            self.duplicate)
            self.cpp_python_handler.connect('DeleteObject()',
                                            self.deleteObject)
            # Pass widgets
            self.cpp_python_handler.PassWidget("Mesh", self.window.mesh_widget)
            self.cpp_python_handler.PassWidget("Animation",
                                               self.window.animation_widget)
            self.cpp_python_handler.PassWidget("Sound",
                                               self.window.sound_widget)
            self.cpp_python_handler.PassWidget(
                "Materials", self.window.materialTabFormWidget)
            # Check if build mode is active, required on python restarts
            self.on_activate_editing(
                self.cpp_python_handler.IsBuildingActive())
Пример #24
0
    #animname = "Fly"
    animname = "Walk"
    a.EnableAnimation(animname)
    #print a.SetAnimationTimePosition("Walk", 0.2)

    #step with consequent calls
    try:
        r.t
    except: #first run
        r.t = 0
    r.t += 0.1
    print a.SetAnimationTimePosition(animname, r.t % 1)
    
        
if 0: #log level visibility
    r.logDebug("Debug")
    #r.logWarning("Warning") #not implement now, should add i guess
    r.logInfo("Info")

if 0: #local object creation, testing if local previews of .scenes would work
    from PythonQt.QtGui import QVector3D as Vec3
    from PythonQt.QtGui import QQuaternion as Quat

    print "hep"
    e = r.createEntity("Jack.mesh", 1515)
    print e
    e.placeable.Position = Vec3(128, 128, 60)
    e.placeable.Scale = Vec3(5, 5, 5)
    e.placeable.Orientation = Quat(0, 0, 0, 1)

if 0: #createentity directly from the c++ scenemanager where it's a qt slot now