예제 #1
0
    def load(self):
        if self.onScreenText:
            return

        fontPath = ConfigVariableString("on-screen-debug-font", "cmtt12").value
        fontScale = ConfigVariableDouble("on-screen-debug-font-scale",
                                         0.05).value

        color = {
            "black": Vec4(0, 0, 0, 1),
            "white": Vec4(1, 1, 1, 1),
        }
        fgColor = color[ConfigVariableString("on-screen-debug-fg-color",
                                             "white").value]
        bgColor = color[ConfigVariableString("on-screen-debug-bg-color",
                                             "black").value]
        fgColor.setW(
            ConfigVariableDouble("on-screen-debug-fg-alpha", 0.85).value)
        bgColor.setW(
            ConfigVariableDouble("on-screen-debug-bg-alpha", 0.85).value)

        font = loader.loadFont(fontPath)
        if not font.isValid():
            print "failed to load OnScreenDebug font", fontPath
            font = TextNode.getDefaultFont()
        self.onScreenText = OnscreenText.OnscreenText(pos=(-1.0, 0.9),
                                                      fg=fgColor,
                                                      bg=bgColor,
                                                      scale=(fontScale,
                                                             fontScale, 0.0),
                                                      align=TextNode.ALeft,
                                                      mayChange=1,
                                                      font=font)
        # Make sure readout is never lit or drawn in wireframe
        DirectUtil.useDirectRenderStyle(self.onScreenText)
예제 #2
0
    def load(self):
        if self.onScreenText:
            return
        
        fontPath = config.GetString("on-screen-debug-font", "cmtt12")
        fontScale = config.GetFloat("on-screen-debug-font-scale", 0.05)

        color = {
            "black": Vec4(0, 0, 0, 1),
            "white": Vec4(1, 1, 1, 1),
            }
        fgColor = color[config.GetString("on-screen-debug-fg-color", "white")]
        bgColor = color[config.GetString("on-screen-debug-bg-color", "black")]
        fgColor.setW(config.GetFloat("on-screen-debug-fg-alpha", 0.85))
        bgColor.setW(config.GetFloat("on-screen-debug-bg-alpha", 0.85))
        
        font = loader.loadFont(fontPath)
        if not font.isValid():
            print "failed to load OnScreenDebug font", fontPath
            font = TextNode.getDefaultFont()
        self.onScreenText = OnscreenText.OnscreenText(
                pos = (-1.0, 0.9), fg=fgColor, bg=bgColor,
                scale = (fontScale, fontScale, 0.0), align = TextNode.ALeft,
                mayChange = 1, font = font)
        # Make sure readout is never lit or drawn in wireframe
        DirectUtil.useDirectRenderStyle(self.onScreenText)
예제 #3
0
    def load(self):
        if self.onScreenText:
            return None

        fontPath = config.GetString('on-screen-debug-font', 'cmtt12')
        fontScale = config.GetFloat('on-screen-debug-font-scale',
                                    0.050000000000000003)
        color = {'black': Vec4(0, 0, 0, 1), 'white': Vec4(1, 1, 1, 1)}
        fgColor = color[config.GetString('on-screen-debug-fg-color', 'white')]
        bgColor = color[config.GetString('on-screen-debug-bg-color', 'black')]
        fgColor.setW(
            config.GetFloat('on-screen-debug-fg-alpha', 0.84999999999999998))
        bgColor.setW(
            config.GetFloat('on-screen-debug-bg-alpha', 0.84999999999999998))
        font = loader.loadFont(fontPath)
        if not font.isValid():
            print 'failed to load OnScreenDebug font', fontPath
            font = TextNode.getDefaultFont()

        self.onScreenText = OnscreenText.OnscreenText(
            pos=(-1.0, 0.90000000000000002),
            fg=fgColor,
            bg=bgColor,
            scale=(fontScale, fontScale, 0.0),
            align=TextNode.ALeft,
            mayChange=1,
            font=font)
        DirectUtil.useDirectRenderStyle(self.onScreenText)
예제 #4
0
 def load(self):
     if self.onScreenText:
         return
     fontPath = config.GetString('on-screen-debug-font', 'cmtt12')
     fontScale = config.GetFloat('on-screen-debug-font-scale', 0.05)
     color = {'black': Vec4(0, 0, 0, 1),
      'white': Vec4(1, 1, 1, 1)}
     fgColor = color[config.GetString('on-screen-debug-fg-color', 'white')]
     bgColor = color[config.GetString('on-screen-debug-bg-color', 'black')]
     fgColor.setW(config.GetFloat('on-screen-debug-fg-alpha', 0.85))
     bgColor.setW(config.GetFloat('on-screen-debug-bg-alpha', 0.85))
     font = loader.loadFont(fontPath)
     if not font.isValid():
         print 'failed to load OnScreenDebug font', fontPath
         font = TextNode.getDefaultFont()
     self.onScreenText = OnscreenText.OnscreenText(pos=(-1.0, 0.9), fg=fgColor, bg=bgColor, scale=(fontScale, fontScale, 0.0), align=TextNode.ALeft, mayChange=1, font=font)
     DirectUtil.useDirectRenderStyle(self.onScreenText)
예제 #5
0
파일: seLights.py 프로젝트: Astron/panda3d
    def __init__(self, light, parent, type,
                 lightcolor=VBase4(0.3,0.3,0.3,1),
                 specularColor = VBase4(1),
                 position = Point3(0,0,0),
                 orientation = Vec3(1,0,0),
                 constant = 1.0,
                 linear = 0.0,
                 quadratic = 0.0,
                 exponent = 0.0,
                 tag="",
                 lence = None):
        #################################################################
        # __init__(self, light, parent, type,
        #          lightcolor=VBase4(0.3,0.3,0.3,1),
        #          specularColor = VBase4(1),
        #          position = Point3(0,0,0),
        #          orientation = Vec3(1,0,0),
        #          constant = 1.0,
        #          linear = 0.0,
        #          quadratic = 0.0,
        #          exponent = 0.0,
        #          tag="",
        #          lence = None):
        # This constructor will create a light node inside it and upcast
        # this light node to itself as a nodePath.
        # Also, it will load a model as a reference to itself on the secene so that
        # user can easily recognize where is the light and can easily manipulate
        # by mouse picking and widget control.
        #################################################################
        # Initialize the super class
        NodePath.__init__(self)
        # Initialize and save values
        self.light = light
        self.type = type
        self.lightcolor=lightcolor
        self.specularColor = specularColor
        self.position = position
        self.orientation = orientation
        self.constant = constant
        self.linear = linear
        self.quadratic = quadratic
        self.exponent = exponent
        self.lence = lence
        self.active = True

        # Attach node to self
        self.LightNode=parent.attachNewNode(light)
        self.LightNode.setTag("Metadata",tag)
        if(self.type=='spot'):
            self.LightNode.setHpr(self.orientation)
            self.LightNode.setPos(self.position)
        else:
            self.LightNode.setHpr(self.orientation)
            self.LightNode.setPos(self.position)


        self.assign(self.LightNode)
        if(self.type=='spot'):
            self.helpModel = loader.loadModel( "models/misc/Spotlight" )
        elif(self.type=='point'):
            self.helpModel = loader.loadModel( "models/misc/Pointlight" )
        elif(self.type=='directional'):
            self.helpModel = loader.loadModel( "models/misc/Dirlight" )
        else:
            self.helpModel = loader.loadModel( "models/misc/sphere" )
        self.helpModel.setColor(self.lightcolor)
        self.helpModel.reparentTo(self)
        DirectUtil.useDirectRenderStyle(self.helpModel)
        if not ((self.type == 'directional')or(self.type == 'point')or(self.type == 'spot')):
            self.helpModel.hide()
    def __init__(self,
                 light,
                 parent,
                 type,
                 lightcolor=VBase4(0.3, 0.3, 0.3, 1),
                 specularColor=VBase4(1),
                 position=Point3(0, 0, 0),
                 orientation=Vec3(1, 0, 0),
                 constant=1.0,
                 linear=0.0,
                 quadratic=0.0,
                 exponent=0.0,
                 tag="",
                 lence=None):
        #################################################################
        # __init__(self, light, parent, type,
        #          lightcolor=VBase4(0.3,0.3,0.3,1),
        #          specularColor = VBase4(1),
        #          position = Point3(0,0,0),
        #          orientation = Vec3(1,0,0),
        #          constant = 1.0,
        #          linear = 0.0,
        #          quadratic = 0.0,
        #          exponent = 0.0,
        #          tag="",
        #          lence = None):
        # This constructor will create a light node inside it and upcast
        # this light node to itself as a nodePath.
        # Also, it will load a model as a reference to itself on the secene so that
        # user can easily recognize where is the light and can easily manipulate
        # by mouse picking and widget control.
        #################################################################
        # Initialize the super class
        NodePath.__init__(self)
        # Initialize and save values
        self.light = light
        self.type = type
        self.lightcolor = lightcolor
        self.specularColor = specularColor
        self.position = position
        self.orientation = orientation
        self.constant = constant
        self.linear = linear
        self.quadratic = quadratic
        self.exponent = exponent
        self.lence = lence
        self.active = True

        # Attach node to self
        self.LightNode = parent.attachNewNode(light)
        self.LightNode.setTag("Metadata", tag)
        if (self.type == 'spot'):
            self.LightNode.setHpr(self.orientation)
            self.LightNode.setPos(self.position)
        else:
            self.LightNode.setHpr(self.orientation)
            self.LightNode.setPos(self.position)

        self.assign(self.LightNode)
        if (self.type == 'spot'):
            self.helpModel = loader.loadModel("models/misc/Spotlight")
        elif (self.type == 'point'):
            self.helpModel = loader.loadModel("models/misc/Pointlight")
        elif (self.type == 'directional'):
            self.helpModel = loader.loadModel("models/misc/Dirlight")
        else:
            self.helpModel = loader.loadModel("models/misc/sphere")
        self.helpModel.setColor(self.lightcolor)
        self.helpModel.reparentTo(self)
        DirectUtil.useDirectRenderStyle(self.helpModel)
        if not ((self.type == 'directional') or (self.type == 'point') or
                (self.type == 'spot')):
            self.helpModel.hide()