Ejemplo n.º 1
0
    def generate(self, helperInfo):
        color = self.mapObject.getPropertyValue("_light",
                                                default=Vec4(
                                                    255, 255, 255, 255))
        color = CIGlobals.colorFromRGBScalar255(color)
        color = CIGlobals.vec3GammaToLinear(color)

        constant = float(
            self.mapObject.getPropertyValue("_constant_attn", default="0.0"))
        linear = float(
            self.mapObject.getPropertyValue("_linear_attn", default="0.0"))
        quadratic = float(
            self.mapObject.getPropertyValue("_quadratic_attn", default="1.0"))

        # Scale intensity for unit 100 distance
        ratio = (constant + 100 * linear + 100 * 100 * quadratic)
        if ratio > 0:
            color *= ratio

        pl = PointLight("lightHelper-light")
        pl.setColor(Vec4(color[0], color[1], color[2], 1.0))
        pl.setAttenuation(Vec3(constant, linear, quadratic))
        self.light = self.mapObject.helperRoot.attachNewNode(pl)
        if self.mapObject.doc.numlights < 128:
            self.mapObject.doc.render.setLight(self.light)
            self.mapObject.doc.numlights += 1
            self.hasLight = True
Ejemplo n.º 2
0
 def makeLampLight(self, lamp):
     col = (255, 255, 255, 350)
     lightNP = CIGlobals.makePointLight(
         'DLlamp', CIGlobals.colorFromRGBScalar255(col),
         lamp.getPos(render) + (0, 0, 9.5), 0.1)
     lamp.setLightOff(1)
     return lightNP
Ejemplo n.º 3
0
    def generate(self, helperInfo):
        MapHelper.generate(self)

        # Check for a color255 to tint the sprite
        color255Props = self.mapObject.getPropsWithValueType(
            ['color255', 'color1'])
        # If we have a color255 property, select the first one.
        color255Prop = color255Props[0] if len(color255Props) > 0 else None
        if color255Prop:
            color = self.mapObject.getPropertyValue(color255Prop)
            color = CIGlobals.colorFromRGBScalar255(color)
        else:
            color = Vec4(1)

        spritePath = helperInfo['args'][0].replace("\"", "")

        cm = CardMaker("sprite")
        cm.setFrame(-12, 12, -12, 12)
        np = NodePath(cm.generate())
        np.setBSPMaterial(spritePath)
        np.setColorScale(color)
        np.setLightOff(1)
        np.setFogOff(1)
        np.setBillboardPointEye()
        np.setTransparency(True)
        np.hide(~VIEWPORT_3D_MASK)
        np.reparentTo(self.mapObject.helperRoot)
        self.sprite = np