sceneeditor: clean up scene editor code, removing deprecated calls

Closes #373
This commit is contained in:
John Cote 2018-08-10 23:10:22 +02:00 committed by rdb
parent be19411cf8
commit e99f8a7bcc
19 changed files with 66 additions and 74 deletions

View File

@ -11,7 +11,7 @@ from direct.tkwidgets import Floater
from direct.tkwidgets import Slider from direct.tkwidgets import Slider
from Tkinter import * from Tkinter import *
import string, math, types import string, math, types
from pandac.PandaModules import * from panda3d.core import *
class collisionWindow(AppShell): class collisionWindow(AppShell):

View File

@ -9,7 +9,7 @@ from direct.tkwidgets.VectorWidgets import Vector3Entry
from direct.tkwidgets.Slider import Slider from direct.tkwidgets.Slider import Slider
from Tkinter import Frame, Button, Menubutton, Menu from Tkinter import Frame, Button, Menubutton, Menu
import string, math, types, Pmw, Tkinter import string, math, types, Pmw, Tkinter
from pandac.PandaModules import * from panda3d.core import *
class lightingPanel(AppShell): class lightingPanel(AppShell):
################################################################# #################################################################

View File

@ -11,7 +11,7 @@ from direct.tkwidgets import Floater
from direct.tkwidgets import Dial from direct.tkwidgets import Dial
from direct.tkwidgets import Slider from direct.tkwidgets import Slider
from direct.tkwidgets import VectorWidgets from direct.tkwidgets import VectorWidgets
from pandac.PandaModules import * from panda3d.core import *
from Tkinter import * from Tkinter import *
import Pmw import Pmw

View File

@ -9,10 +9,8 @@
from direct.showbase.ShowBaseGlobal import * from direct.showbase.ShowBaseGlobal import *
from direct.interval.IntervalGlobal import * from direct.interval.IntervalGlobal import *
from direct.showbase.DirectObject import DirectObject from direct.showbase.DirectObject import DirectObject
from pandac.PandaModules import * from panda3d.core import *
import math import math
#Manakel 2/12/2005: replace from pandac import by from pandac.PandaModules import
from pandac.PandaModules import MouseWatcher
class ViewPort: class ViewPort:

View File

@ -3,8 +3,10 @@ import sys
try: import _tkinter try: import _tkinter
except: sys.exit("Please install python module 'Tkinter'") except: sys.exit("Please install python module 'Tkinter'")
import direct from direct.showbase.ShowBase import ShowBase
from direct.directbase.DirectStart import*
ShowBase()
from direct.showbase.TkGlobal import spawnTkLoop from direct.showbase.TkGlobal import spawnTkLoop
from Tkinter import * from Tkinter import *
from tkFileDialog import * from tkFileDialog import *
@ -251,7 +253,10 @@ class myLevelEditor(AppShell):
for event in self.actionEvents: for event in self.actionEvents:
self.accept(event[0], event[1], extraArgs = event[2:]) self.accept(event[0], event[1], extraArgs = event[2:])
camera.toggleVis() if camera.is_hidden():
camera.show()
else:
camera.hide()
self.selectNode(base.camera) ## Initially, we select camera as the first node... self.selectNode(base.camera) ## Initially, we select camera as the first node...
def appInit(self): def appInit(self):
@ -1705,4 +1710,4 @@ class myLevelEditor(AppShell):
editor = myLevelEditor(parent = base.tkRoot) editor = myLevelEditor(parent = base.tkRoot)
run() base.run()

View File

@ -392,8 +392,7 @@ class DirectCameraControl(DirectObject):
sf = 0.1 sf = 0.1
self.coaMarker.setScale(sf) self.coaMarker.setScale(sf)
# Lerp color to fade out # Lerp color to fade out
self.coaMarker.lerpColor(VBase4(1,0,0,1), VBase4(1,0,0,0), 3.0, self.coaMarker.colorInterval(3.0, VBase4(1, 0, 0, 0), name='fadeAway').start()
task = 'fadeAway')
def homeCam(self): def homeCam(self):
# Record undo point # Record undo point

View File

@ -3,7 +3,7 @@
# This code saves the scene out as python code... the scene is stored in the various dictionaries in "dataHolder.py" ...the class "AllScene" # This code saves the scene out as python code... the scene is stored in the various dictionaries in "dataHolder.py" ...the class "AllScene"
# #
#################################################################################################################################################### ####################################################################################################################################################
from pandac.PandaModules import * from panda3d.core import *
from direct.showbase.ShowBaseGlobal import * from direct.showbase.ShowBaseGlobal import *
import os import os

View File

@ -1,8 +1,6 @@
from pandac.PandaModules import * from panda3d.core import *
from direct.showbase.DirectObject import DirectObject from direct.showbase.DirectObject import DirectObject
from direct.showbase.PhysicsManagerGlobal import * from direct.showbase.PhysicsManagerGlobal import *
#Manakel 2/12/2005: replace from pandac import by from pandac.PandaModules import
from pandac.PandaModules import ForceNode
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
import sys import sys

View File

@ -12,7 +12,7 @@
# #
################################################################# #################################################################
from pandac.PandaModules import * from panda3d.core import *
from direct.directtools.DirectGlobals import * from direct.directtools.DirectGlobals import *
from direct.directtools.DirectUtil import * from direct.directtools.DirectUtil import *
import math import math

View File

@ -5,7 +5,7 @@
from direct.showbase.DirectObject import * from direct.showbase.DirectObject import *
from string import lower from string import lower
from direct.directtools import DirectUtil from direct.directtools import DirectUtil
from pandac.PandaModules import * from panda3d.core import *
import string import string

View File

@ -520,7 +520,7 @@ class ObjectHandles(NodePath,DirectObject):
# To avoid recreating a vec every frame # To avoid recreating a vec every frame
self.hitPt = Vec3(0) self.hitPt = Vec3(0)
# Get a handle on the components # Get a handle on the components
self.xHandles = self.find('**/X') self.xHandles = self.find('**/ohScalingNode')
self.xPostGroup = self.xHandles.find('**/x-post-group') self.xPostGroup = self.xHandles.find('**/x-post-group')
self.xPostCollision = self.xHandles.find('**/x-post') self.xPostCollision = self.xHandles.find('**/x-post')
self.xRingGroup = self.xHandles.find('**/x-ring-group') self.xRingGroup = self.xHandles.find('**/x-ring-group')

View File

@ -682,16 +682,16 @@ class MopathRecorder(AppShell, DirectObject):
marker if subnode selected marker if subnode selected
""" """
taskMgr.remove(self.name + '-curveEditTask') taskMgr.remove(self.name + '-curveEditTask')
print nodePath.id() print nodePath.get_key()
if nodePath.id() in self.playbackMarkerIds: if nodePath.get_key() in self.playbackMarkerIds:
SEditor.select(self.playbackMarker) SEditor.select(self.playbackMarker)
elif nodePath.id() in self.tangentMarkerIds: elif nodePath.get_key() in self.tangentMarkerIds:
SEditor.select(self.tangentMarker) SEditor.select(self.tangentMarker)
elif nodePath.id() == self.playbackMarker.id(): elif nodePath.get_key() == self.playbackMarker.get_key():
self.tangentGroup.show() self.tangentGroup.show()
taskMgr.add(self.curveEditTask, taskMgr.add(self.curveEditTask,
self.name + '-curveEditTask') self.name + '-curveEditTask')
elif nodePath.id() == self.tangentMarker.id(): elif nodePath.get_key() == self.tangentMarker.get_key():
self.tangentGroup.show() self.tangentGroup.show()
taskMgr.add(self.curveEditTask, taskMgr.add(self.curveEditTask,
self.name + '-curveEditTask') self.name + '-curveEditTask')
@ -699,7 +699,7 @@ class MopathRecorder(AppShell, DirectObject):
self.tangentGroup.hide() self.tangentGroup.hide()
def getChildIds(self, nodePath): def getChildIds(self, nodePath):
ids = [nodePath.id()] ids = [nodePath.get_key()]
kids = nodePath.getChildren() kids = nodePath.getChildren()
for kid in kids: for kid in kids:
ids += self.getChildIds(kid) ids += self.getChildIds(kid)
@ -710,14 +710,14 @@ class MopathRecorder(AppShell, DirectObject):
Hook called upon deselection of a node path used to select playback Hook called upon deselection of a node path used to select playback
marker if subnode selected marker if subnode selected
""" """
if ((nodePath.id() == self.playbackMarker.id()) or if ((nodePath.get_key() == self.playbackMarker.get_key()) or
(nodePath.id() == self.tangentMarker.id())): (nodePath.get_key() == self.tangentMarker.get_key())):
self.tangentGroup.hide() self.tangentGroup.hide()
def curveEditTask(self,state): def curveEditTask(self,state):
if self.curveCollection != None: if self.curveCollection != None:
# Update curve position # Update curve position
if self.manipulandumId == self.playbackMarker.id(): if self.manipulandumId == self.playbackMarker.get_key():
# Show playback marker # Show playback marker
self.playbackMarker.getChild(0).show() self.playbackMarker.getChild(0).show()
pos = Point3(0) pos = Point3(0)
@ -731,7 +731,7 @@ class MopathRecorder(AppShell, DirectObject):
# Note: this calls recompute on the curves # Note: this calls recompute on the curves
self.nurbsCurveDrawer.draw() self.nurbsCurveDrawer.draw()
# Update tangent # Update tangent
if self.manipulandumId == self.tangentMarker.id(): if self.manipulandumId == self.tangentMarker.get_key():
# If manipulating marker, update tangent # If manipulating marker, update tangent
# Hide playback marker # Hide playback marker
self.playbackMarker.getChild(0).hide() self.playbackMarker.getChild(0).hide()
@ -766,10 +766,10 @@ class MopathRecorder(AppShell, DirectObject):
def manipulateObjectStartHook(self): def manipulateObjectStartHook(self):
self.manipulandumId = None self.manipulandumId = None
if SEditor.selected.last: if SEditor.selected.last:
if SEditor.selected.last.id() == self.playbackMarker.id(): if SEditor.selected.last.get_key() == self.playbackMarker.get_key():
self.manipulandumId = self.playbackMarker.id() self.manipulandumId = self.playbackMarker.get_key()
elif SEditor.selected.last.id() == self.tangentMarker.id(): elif SEditor.selected.last.get_key() == self.tangentMarker.get_key():
self.manipulandumId = self.tangentMarker.id() self.manipulandumId = self.tangentMarker.get_key()
def manipulateObjectCleanupHook(self): def manipulateObjectCleanupHook(self):
# Clear flag # Clear flag
@ -1282,7 +1282,7 @@ class MopathRecorder(AppShell, DirectObject):
dictName = name dictName = name
else: else:
# Generate a unique name for the dict # Generate a unique name for the dict
dictName = name # + '-' + `nodePath.id()` dictName = name # + '-' + `nodePath.get_key()`
if not dict.has_key(dictName): if not dict.has_key(dictName):
# Update combo box to include new item # Update combo box to include new item
names.append(dictName) names.append(dictName)

View File

@ -1,4 +1,4 @@
from pandac.PandaModules import * from panda3d.core import *
import seParticles import seParticles
import seForceGroup import seForceGroup
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal

View File

@ -1,28 +1,8 @@
from pandac.PandaModules import * from panda3d.core import *
from panda3d.physics import *
from direct.particles.ParticleManagerGlobal import * from direct.particles.ParticleManagerGlobal import *
from direct.showbase.PhysicsManagerGlobal import * from direct.showbase.PhysicsManagerGlobal import *
#Manakel 2/12/2005: replace from pandac import by from pandac.PandaModules import
from pandac.PandaModules import ParticleSystem
from pandac.PandaModules import BaseParticleFactory
from pandac.PandaModules import PointParticleFactory
from pandac.PandaModules import ZSpinParticleFactory
#import OrientedParticleFactory #import OrientedParticleFactory
from pandac.PandaModules import BaseParticleRenderer
from pandac.PandaModules import PointParticleRenderer
from pandac.PandaModules import LineParticleRenderer
from pandac.PandaModules import GeomParticleRenderer
from pandac.PandaModules import SparkleParticleRenderer
from pandac.PandaModules import SpriteParticleRenderer
from pandac.PandaModules import BaseParticleEmitter
from pandac.PandaModules import BoxEmitter
from pandac.PandaModules import DiscEmitter
from pandac.PandaModules import LineEmitter
from pandac.PandaModules import PointEmitter
from pandac.PandaModules import RectangleEmitter
from pandac.PandaModules import RingEmitter
from pandac.PandaModules import SphereSurfaceEmitter
from pandac.PandaModules import SphereVolumeEmitter
from pandac.PandaModules import TangentRingEmitter
import string import string
import os import os
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal

View File

@ -6,7 +6,7 @@ from direct.tkwidgets.AppShell import AppShell
from direct.tkwidgets.Dial import AngleDial from direct.tkwidgets.Dial import AngleDial
from direct.tkwidgets.Floater import Floater from direct.tkwidgets.Floater import Floater
from Tkinter import Button, Menubutton, Menu, StringVar from Tkinter import Button, Menubutton, Menu, StringVar
from pandac.PandaModules import * from panda3d.core import *
import Tkinter, Pmw import Tkinter, Pmw
""" """
TODO: TODO:
@ -428,7 +428,7 @@ class Placer(AppShell):
background = self.nodePathMenuBG) background = self.nodePathMenuBG)
# Check to see if node path and ref node path are the same # Check to see if node path and ref node path are the same
if ((self.refCS != None) and if ((self.refCS != None) and
(self.refCS.id() == self['nodePath'].id())): (self.refCS.get_key() == self['nodePath'].get_key())):
# Yes they are, use temp CS as ref # Yes they are, use temp CS as ref
# This calls updatePlacer # This calls updatePlacer
self.setReferenceNodePath(self.tempCS) self.setReferenceNodePath(self.tempCS)
@ -473,7 +473,7 @@ class Placer(AppShell):
listbox = self.refNodePathMenu.component('scrolledlist') listbox = self.refNodePathMenu.component('scrolledlist')
listbox.setlist(self.refNodePathNames) listbox.setlist(self.refNodePathNames)
# Check to see if node path and ref node path are the same # Check to see if node path and ref node path are the same
if (nodePath != None) and (nodePath.id() == self['nodePath'].id()): if (nodePath != None) and (nodePath.get_key() == self['nodePath'].get_key()):
# Yes they are, use temp CS and update listbox accordingly # Yes they are, use temp CS and update listbox accordingly
nodePath = self.tempCS nodePath = self.tempCS
self.refNodePathMenu.selectitem('parent') self.refNodePathMenu.selectitem('parent')
@ -508,7 +508,7 @@ class Placer(AppShell):
dictName = name dictName = name
else: else:
# Generate a unique name for the dict # Generate a unique name for the dict
dictName = name + '-' + `nodePath.id()` dictName = name + '-' + `nodePath.get_key()`
if not dict.has_key(dictName): if not dict.has_key(dictName):
# Update combo box to include new item # Update combo box to include new item
names.append(dictName) names.append(dictName)

View File

@ -141,7 +141,7 @@ class seSceneGraphExplorer(Pmw.MegaWidget, DirectObject):
self._node.deselecttree() self._node.deselecttree()
def selectNodePath(self,nodePath, callBack=True): def selectNodePath(self,nodePath, callBack=True):
item = self._node.find(nodePath.id()) item = self._node.find(nodePath.get_key())
if item!= None: if item!= None:
item.select(callBack) item.select(callBack)
else: else:
@ -164,7 +164,7 @@ class SceneGraphExplorerItem(TreeItem):
return name return name
def GetKey(self): def GetKey(self):
return self.nodePath.id() return self.nodePath.get_key()
def IsEditable(self): def IsEditable(self):
# All nodes' names can be edited nowadays. # All nodes' names can be edited nowadays.

View File

@ -11,7 +11,7 @@
# (If we do change original directools, it will force user has to install the latest version of OUR Panda) # (If we do change original directools, it will force user has to install the latest version of OUR Panda)
# #
################################################################# #################################################################
from pandac.PandaModules import GeomNode from panda3d.core import GeomNode
from direct.directtools.DirectGlobals import * from direct.directtools.DirectGlobals import *
from direct.directtools.DirectUtil import * from direct.directtools.DirectUtil import *
from seGeometry import * from seGeometry import *
@ -78,7 +78,7 @@ class SelectedNodePaths(DirectObject):
self.deselectAll() self.deselectAll()
# Get this pointer # Get this pointer
id = nodePath.id() id = nodePath.get_key()
# First see if its already in the selected dictionary # First see if its already in the selected dictionary
dnp = self.getSelectedDict(id) dnp = self.getSelectedDict(id)
# If so, we're done # If so, we're done
@ -96,7 +96,7 @@ class SelectedNodePaths(DirectObject):
# Show its bounding box # Show its bounding box
dnp.highlight() dnp.highlight()
# Add it to the selected dictionary # Add it to the selected dictionary
self.selectedDict[dnp.id()] = dnp self.selectedDict[dnp.get_key()] = dnp
# And update last # And update last
__builtins__["last"] = self.last = dnp __builtins__["last"] = self.last = dnp
return dnp return dnp
@ -104,7 +104,7 @@ class SelectedNodePaths(DirectObject):
def deselect(self, nodePath): def deselect(self, nodePath):
""" Deselect the specified node path """ """ Deselect the specified node path """
# Get this pointer # Get this pointer
id = nodePath.id() id = nodePath.get_key()
# See if it is in the selected dictionary # See if it is in the selected dictionary
dnp = self.getSelectedDict(id) dnp = self.getSelectedDict(id)
if dnp: if dnp:
@ -204,15 +204,24 @@ class SelectedNodePaths(DirectObject):
# Remove all selected nodePaths from the Scene Graph # Remove all selected nodePaths from the Scene Graph
self.forEachSelectedNodePathDo(NodePath.remove) self.forEachSelectedNodePathDo(NodePath.remove)
def toggleVis(self, nodePath):
if nodePath.is_hidden():
nodePath.show()
else:
nodePath.hide()
def toggleVisSelected(self): def toggleVisSelected(self):
selected = self.last selected = self.last
# Toggle visibility of selected node paths # Toggle visibility of selected node paths
if selected: if selected:
selected.toggleVis() if selected.is_hidden():
selected.show()
else:
selected.hide()
def toggleVisAll(self): def toggleVisAll(self):
# Toggle viz for all selected node paths # Toggle viz for all selected node paths
self.forEachSelectedNodePathDo(NodePath.toggleVis) self.forEachSelectedNodePathDo(self.toggleVis)
def isolateSelected(self): def isolateSelected(self):
selected = self.last selected = self.last
@ -221,7 +230,7 @@ class SelectedNodePaths(DirectObject):
def getDirectNodePath(self, nodePath): def getDirectNodePath(self, nodePath):
# Get this pointer # Get this pointer
id = nodePath.id() id = nodePath.get_key()
# First check selected dict # First check selected dict
dnp = self.getSelectedDict(id) dnp = self.getSelectedDict(id)
if dnp: if dnp:

View File

@ -388,7 +388,7 @@ class SeSession(DirectObject): ### Customized DirectSession
messenger.send('DIRECT_preSelectNodePath', [dnp]) messenger.send('DIRECT_preSelectNodePath', [dnp])
if fResetAncestry: if fResetAncestry:
# Update ancestry # Update ancestry
self.ancestry = dnp.getAncestors() self.ancestry = list(dnp.getAncestors())
self.ancestry.reverse() self.ancestry.reverse()
self.ancestryIndex = 0 self.ancestryIndex = 0
# Update the selectedNPReadout # Update the selectedNPReadout
@ -479,7 +479,7 @@ class SeSession(DirectObject): ### Customized DirectSession
def isNotCycle(self, nodePath, parent): def isNotCycle(self, nodePath, parent):
if nodePath.id() == parent.id(): if nodePath.get_key() == parent.get_key():
print 'DIRECT.reparent: Invalid parent' print 'DIRECT.reparent: Invalid parent'
return 0 return 0
elif parent.hasParent(): elif parent.hasParent():
@ -520,7 +520,10 @@ class SeSession(DirectObject): ### Customized DirectSession
nodePath = self.selected.last nodePath = self.selected.last
if nodePath: if nodePath:
# Now toggle node path's visibility state # Now toggle node path's visibility state
nodePath.toggleVis() if nodePath.is_hidden():
nodePath.show()
else:
nodePath.hide()
def removeNodePath(self, nodePath = 'None Given'): def removeNodePath(self, nodePath = 'None Given'):
if nodePath == 'None Given': if nodePath == 'None Given':

View File

@ -15,7 +15,7 @@
import os, sys, string, Pmw, Tkinter import os, sys, string, Pmw, Tkinter
from direct.showbase.DirectObject import DirectObject from direct.showbase.DirectObject import DirectObject
from Tkinter import IntVar, Menu, PhotoImage, Label, Frame, Entry from Tkinter import IntVar, Menu, PhotoImage, Label, Frame, Entry
from pandac.PandaModules import * from panda3d.core import *
# Initialize icon directory # Initialize icon directory
ICONDIR = getModelPath().findFile(Filename('icons')).toOsSpecific() ICONDIR = getModelPath().findFile(Filename('icons')).toOsSpecific()