当前位置: 首页>>代码示例>>Python>>正文


Python PointLight.setAttenuation方法代码示例

本文整理汇总了Python中panda3d.core.PointLight.setAttenuation方法的典型用法代码示例。如果您正苦于以下问题:Python PointLight.setAttenuation方法的具体用法?Python PointLight.setAttenuation怎么用?Python PointLight.setAttenuation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在panda3d.core.PointLight的用法示例。


在下文中一共展示了PointLight.setAttenuation方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setupLights

# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setAttenuation [as 别名]
    def setupLights(self):
        base.setBackgroundColor(0.0, 0.0, 0.0, 1)
        base.setFrameRateMeter(True)
        # Add a light to the scene.
        self.lightpivot = render.attachNewNode("lightpivot")
        self.lightpivot.setPos(0, 0, 5)
        self.lightpivot.hprInterval(10, Point3(360, 0, 0)).loop()
        plight = PointLight('plight')
        plight.setColor(Vec4(1, 0, 0, 1))
        plight.setAttenuation(Vec3(0.37, 0.025, 0))
        plnp = self.lightpivot.attachNewNode(plight)
        plnp.setPos(45, 0, 0)
        plnp.lookAt(*Vec3(0, 0, 0, ))

        # Light
        alight = AmbientLight('ambientLight')
        alight.setColor(Vec4(0.2, 0.2, 0.2, 1))
        alightNP = render.attachNewNode(alight)

        #   dlight = DirectionalLight('directionalLight')
        #   dlight.setDirection(Vec3(1, 1, -1))
        #   dlight.setColor(Vec4(0.7, 0.7, 0.7, 1))
        #   dlightNP = render.attachNewNode(dlight)

        render.clearLight()
        render.setLight(alightNP)
        #   render.setLight(dlightNP)
        render.setLight(plnp)

        # create a sphere to denote the light
        sphere = loader.loadModel("models/sphere")
        sphere.reparentTo(plnp)

        render.setShaderAuto()
开发者ID:genusgant,项目名称:CS594-ThrottleThunder-GameClient,代码行数:36,代码来源:RRMain.py

示例2: Bullet

# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setAttenuation [as 别名]
class Bullet(DirectObject):
  def __init__(self, ship, bulletPos, bulletVelocityVec, collisionHandler):
    self.model = game.loader.loadModel("Models/bullet.egg.pz")
    self.model.setPos(bulletPos)
    self.model.setScale(BULLET_SIZE)
    self.model.reparentTo(render)
    self.model.setPythonTag("owner", self)
    self.ship = ship
    finalPosition = bulletPos + (bulletVelocityVec * BULLET_TRAVEL_TIME)
    self.trajectory = self.model.posInterval(BULLET_TRAVEL_TIME, finalPosition).start()

    self.collisionNode = self.model.attachNewNode(CollisionNode("bullet"))
    self.collisionNode.node().addSolid(CollisionSphere(0,0,0,1))
    base.cTrav.addCollider(self.collisionNode, collisionHandler)

    # Add Point Light to the bullet
    self.plight = PointLight('plight'+str(random()))
    self.plight.setColor(Vec4(1,1,1,1))
    self.plight.setAttenuation(Vec3(0.7, 0.05, 0))
    self.plnp = self.model.attachNewNode(self.plight)
    render.setLight(self.plnp)
    render.setShaderInput("light", self.plnp)


  ###
  # Bullet.remove
  #
  #  Removes this asteroid from rendering and registering collisions.
  ## 
  def remove(self):
    self.ignoreAll()
    self.model.remove()
    self.collisionNode.remove()
开发者ID:cconger,项目名称:Asteroi3ds,代码行数:35,代码来源:main.py

示例3: __init__

# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setAttenuation [as 别名]
    def __init__(self):
        base.disableMouse()
        base.cam.node().getLens().setNear(10.0)
        base.cam.node().getLens().setFar(9999999)
        camera.setPos(0, -50, 0)
        
        # Check video card capabilities.
        
        if (base.win.getGsg().getSupportsBasicShaders() == 0):
            addTitle("Toon Shader: Video driver reports that shaders are not supported.")
            return
        
        # Enable a 'light ramp' - this discretizes the lighting,
        # which is half of what makes a model look like a cartoon.
        # Light ramps only work if shader generation is enabled,
        # so we call 'setShaderAuto'.

        tempnode = NodePath(PandaNode("temp node"))
        tempnode.setAttrib(LightRampAttrib.makeSingleThreshold(0.5, 0.4))
        tempnode.setShaderAuto()
        base.cam.node().setInitialState(tempnode.getState())
        
        # Use class 'CommonFilters' to enable a cartoon inking filter.
        # This can fail if the video card is not powerful enough, if so,
        # display an error and exit.
        
        self.separation = 1 # Pixels
        self.filters = CommonFilters(base.win, base.cam)
        filterok = self.filters.setCartoonInk(separation=self.separation)
        if (filterok == False):
            addTitle("Toon Shader: Video card not powerful enough to do image postprocessing")
            return
        
        # Create a non-attenuating point light and an ambient light.
        
        plightnode = PointLight("point light")
        plightnode.setAttenuation(Vec3(1,0,0))
        plight = render.attachNewNode(plightnode)
        plight.setPos(30,-50,0)
        alightnode = AmbientLight("ambient light")
        alightnode.setColor(Vec4(0.8,0.8,0.8,1))
        alight = render.attachNewNode(alightnode)
        render.setLight(alight)
        render.setLight(plight)
        
        # Panda contains a built-in viewer that lets you view the 
        # results of all render-to-texture operations.  This lets you
        # see what class CommonFilters is doing behind the scenes.
        
        self.accept("v", base.bufferViewer.toggleEnable)
        self.accept("V", base.bufferViewer.toggleEnable)
        base.bufferViewer.setPosition("llcorner")
        self.accept("s", self.filters.manager.resizeBuffers)
        
        # These allow you to change cartooning parameters in realtime
        
        self.accept("escape", sys.exit, [0])
开发者ID:mitchellvitez,项目名称:Bubble-Bonanza,代码行数:59,代码来源:fishtank_single_copy.py

示例4: setupLightSources

# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setAttenuation [as 别名]
	def setupLightSources(self, base, scene):
		for np in self.model.findAllMatches('**/=Light'):
			if np.getTag('Light') == 'Point':
				light = PointLight('PointLight.%d' % (len(self.lights) + 1,))
			elif np.getTag('Light') == 'Spot':
				light = Spotlight('Spotlight.%d' % (len(self.lights) + 1,))
				
				fov = np.getTag('Fov')
				if fov:
					light.getLens().setFov(float(fov))
					
				nf = np.getTag('NearFar').split(',')
				if len(nf) > 1:
					light.getLens().setNearFar(float(nf[0]), float(nf[1]))
				
				exp = np.getTag('Exponent')
				if exp:
					light.setExponent(float(exp))
					
			elif np.getTag('Light') == 'Directional':
				light = DirectionalLight('DirectionalLight.%d' % (len(self.lights) + 1,))	
			
			materials = np.findAllMaterials()
			if len(materials) > 0:
				light.setColor(materials[0].getDiffuse())
			
			attenuation = np.getTag('Attenuation').split(',')
			if len(attenuation) > 0 and not isinstance(light, DirectionalLight):
				light.setAttenuation(tuple([float(a) for a in attenuation]))
				
# 			if np.getTag('Shadow'):
# 				self.model.setShaderAuto()
# 				light.setShadowCaster(True)
			
			self.lights.append(light)
			
			lightNP = self.model.attachNewNode(light)
			lightNP.setPos(np.getPos())
			lightNP.setHpr(np.getHpr())
# 			lightNP.setCompass()
			self.model.setLight(lightNP)
开发者ID:danielpintocoutinho,项目名称:metalslender,代码行数:43,代码来源:room.py

示例5: __setPointLight

# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setAttenuation [as 别名]
	def __setPointLight(self,props):		
		light = PointLight(props['name'])
		light.setAttenuation(props['attenuation'])
		return self.__createLight(light,props)
开发者ID:fredukita,项目名称:Pandark-Project,代码行数:6,代码来源:lightsmanager.py

示例6: __init__

# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setAttenuation [as 别名]
    def __init__(self):
        # Initialize the ShowBase class from which we inherit, which will
        # create a window and set up everything we need for rendering into it.
        ShowBase.__init__(self)

        self.disableMouse()
        self.cam.node().getLens().setNear(10.0)
        self.cam.node().getLens().setFar(200.0)
        camera.setPos(0, -50, 0)

        # Check video card capabilities.
        if not self.win.getGsg().getSupportsBasicShaders():
            addTitle("Toon Shader: Video driver reports that Cg shaders are not supported.")
            return

        # Enable a 'light ramp' - this discretizes the lighting,
        # which is half of what makes a model look like a cartoon.
        # Light ramps only work if shader generation is enabled,
        # so we call 'setShaderAuto'.

        tempnode = NodePath(PandaNode("temp node"))
        tempnode.setAttrib(LightRampAttrib.makeSingleThreshold(0.5, 0.4))
        tempnode.setShaderAuto()
        self.cam.node().setInitialState(tempnode.getState())

        # Use class 'CommonFilters' to enable a cartoon inking filter.
        # This can fail if the video card is not powerful enough, if so,
        # display an error and exit.

        self.separation = 1  # Pixels
        self.filters = CommonFilters(self.win, self.cam)
        filterok = self.filters.setCartoonInk(separation=self.separation)
        if (filterok == False):
            addTitle(
                "Toon Shader: Video card not powerful enough to do image postprocessing")
            return

        # Show instructions in the corner of the window.
        self.title = addTitle(
            "Panda3D: Tutorial - Toon Shading with Normals-Based Inking")
        self.inst1 = addInstructions(0.06, "ESC: Quit")
        self.inst2 = addInstructions(0.12, "Up/Down: Increase/Decrease Line Thickness")
        self.inst3 = addInstructions(0.18, "V: View the render-to-texture results")

        # Load a dragon model and animate it.
        self.character = Actor()
        self.character.loadModel('models/nik-dragon')
        self.character.reparentTo(render)
        self.character.loadAnims({'win': 'models/nik-dragon'})
        self.character.loop('win')
        self.character.hprInterval(15, (360, 0, 0)).loop()

        # Create a non-attenuating point light and an ambient light.
        plightnode = PointLight("point light")
        plightnode.setAttenuation((1, 0, 0))
        plight = render.attachNewNode(plightnode)
        plight.setPos(30, -50, 0)
        alightnode = AmbientLight("ambient light")
        alightnode.setColor((0.8, 0.8, 0.8, 1))
        alight = render.attachNewNode(alightnode)
        render.setLight(alight)
        render.setLight(plight)

        # Panda contains a built-in viewer that lets you view the
        # results of all render-to-texture operations.  This lets you
        # see what class CommonFilters is doing behind the scenes.
        self.accept("v", self.bufferViewer.toggleEnable)
        self.accept("V", self.bufferViewer.toggleEnable)
        self.bufferViewer.setPosition("llcorner")
        self.accept("s", self.filters.manager.resizeBuffers)

        # These allow you to change cartooning parameters in realtime
        self.accept("escape", sys.exit, [0])
        self.accept("arrow_up", self.increaseSeparation)
        self.accept("arrow_down", self.decreaseSeparation)
开发者ID:AdrianF98,项目名称:Toontown-2-Revised,代码行数:77,代码来源:basic.py

示例7: __init__

# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setAttenuation [as 别名]
    def __init__(self, img_size=512, screen_off=True):
        self.img_size = img_size
        loadPrcFileData("", "transform-cache false")
        loadPrcFileData("", "audio-library-name null")  # Prevent ALSA errors
        loadPrcFileData("", "win-size %d %d" % (img_size, img_size))
        loadPrcFileData("", "parallax-mapping-samples 3\n"
                            "parallax-mapping-scale 0.1")

        if screen_off:
            # Spawn an offscreen buffer
            loadPrcFileData("", "window-type offscreen")
        # Initialize the ShowBase class from which we inherit, which will
        # create a window and set up everything we need for rendering into it.
        ShowBase.__init__(self)

        # Load the 'abstract room' model.  This is a model of an
        # empty room containing a pillar, a pyramid, and a bunch
        # of exaggeratedly bumpy textures.

        self.room = loader.loadModel("models/abstractroom")
        self.room.reparentTo(render)

        # Create the main character, Ralph

        self.ralph = Actor("models/ralph",
                           {"run": "models/ralph-run",
                            "walk": "models/ralph-walk"})
        self.ralph.reparentTo(render)
        self.ralph.setScale(.2)
        self.reset()

        self.pieces = [Piece(self.room) for _ in range(200)]
        ##################################################
        cnodePath = self.room.attachNewNode(CollisionNode('cnode'))
        plane = CollisionPlane(Plane(Vec3(1, 0, 0), Point3(-60, 0, 0)))  # left
        cnodePath.node().addSolid(plane)
        plane = CollisionPlane(
            Plane(Vec3(-1, 0, 0), Point3(60, 0, 0)))  # right
        cnodePath.node().addSolid(plane)
        plane = CollisionPlane(Plane(Vec3(0, 1, 0), Point3(0, -60, 0)))  # back
        cnodePath.node().addSolid(plane)
        plane = CollisionPlane(
            Plane(Vec3(0, -1,  0), Point3(0, 60,  0)))  # front
        cnodePath.node().addSolid(plane)

        sphere = CollisionSphere(-25, -25, 0, 12.5)
        cnodePath.node().addSolid(sphere)

        box = CollisionBox(Point3(5, 5, 0), Point3(45, 45, 10))
        cnodePath.node().addSolid(box)

        # Make the mouse invisible, turn off normal mouse controls
        self.disableMouse()
        self.camLens.setFov(80)

        # Set the current viewing target
        self.focus = LVector3(55, -55, 20)
        self.heading = 180
        self.pitch = 0
        self.mousex = 0
        self.mousey = 0
        self.last = 0
        self.mousebtn = [0, 0, 0]

        # Add a light to the scene.
        self.lightpivot = render.attachNewNode("lightpivot")
        self.lightpivot.setPos(0, 0, 25)
        self.lightpivot.hprInterval(10, LPoint3(360, 0, 0)).loop()
        plight = PointLight('plight')
        plight.setColor((5, 5, 5, 1))
        plight.setAttenuation(LVector3(0.7, 0.05, 0))
        plnp = self.lightpivot.attachNewNode(plight)
        plnp.setPos(45, 0, 0)
        self.room.setLight(plnp)

        # Add an ambient light
        alight = AmbientLight('alight')
        alight.setColor((0.2, 0.2, 0.2, 1))
        alnp = render.attachNewNode(alight)
        self.room.setLight(alnp)

        # Create a sphere to denote the light
        sphere = loader.loadModel("models/icosphere")
        sphere.reparentTo(plnp)

        self.cameraModel = self.ralph
        camera.reparentTo(self.cameraModel)
        camera.setZ(2)

        self.cTrav = CollisionTraverser()

        cs = CollisionSphere(0, 0, 0, 1)
        cnodePath = self.ralph.attachNewNode(CollisionNode('cnode'))
        cnodePath.node().addSolid(cs)

        cnodePath.show()
        self.ralphGroundHandler = CollisionHandlerQueue()
        self.cTrav.addCollider(cnodePath, self.ralphGroundHandler)

        self.cnodePath = cnodePath
#.........这里部分代码省略.........
开发者ID:rbn42,项目名称:ChessBox,代码行数:103,代码来源:chessbox.py

示例8: __init__

# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setAttenuation [as 别名]
    def __init__(self):
        # Configure the parallax mapping settings (these are just the defaults)
        loadPrcFileData("", "parallax-mapping-samples 3\n"
                            "parallax-mapping-scale 0.1")

        # Initialize the ShowBase class from which we inherit, which will
        # create a window and set up everything we need for rendering into it.
        ShowBase.__init__(self)

        # Check video card capabilities.
        if not self.win.getGsg().getSupportsBasicShaders():
            addTitle("Bump Mapping: "
                "Video driver reports that Cg shaders are not supported.")
            return

        # Post the instructions
        self.title = addTitle("Panda3D: Tutorial - Bump Mapping")
        self.inst1 = addInstructions(0.06, "Press ESC to exit")
        self.inst2 = addInstructions(0.12, "Move mouse to rotate camera")
        self.inst3 = addInstructions(0.18, "Left mouse button: Move forwards")
        self.inst4 = addInstructions(0.24, "Right mouse button: Move backwards")
        self.inst5 = addInstructions(0.30, "Enter: Turn bump maps Off")

        # Load the 'abstract room' model.  This is a model of an
        # empty room containing a pillar, a pyramid, and a bunch
        # of exaggeratedly bumpy textures.

        self.room = loader.loadModel("models/abstractroom")
        self.room.reparentTo(render)

        # Make the mouse invisible, turn off normal mouse controls
        self.disableMouse()
        props = WindowProperties()
        props.setCursorHidden(True)
        self.win.requestProperties(props)
        self.camLens.setFov(60)

        # Set the current viewing target
        self.focus = LVector3(55, -55, 20)
        self.heading = 180
        self.pitch = 0
        self.mousex = 0
        self.mousey = 0
        self.last = 0
        self.mousebtn = [0, 0, 0]

        # Start the camera control task:
        taskMgr.add(self.controlCamera, "camera-task")
        self.accept("escape", sys.exit, [0])
        self.accept("mouse1", self.setMouseBtn, [0, 1])
        self.accept("mouse1-up", self.setMouseBtn, [0, 0])
        self.accept("mouse2", self.setMouseBtn, [1, 1])
        self.accept("mouse2-up", self.setMouseBtn, [1, 0])
        self.accept("mouse3", self.setMouseBtn, [2, 1])
        self.accept("mouse3-up", self.setMouseBtn, [2, 0])
        self.accept("enter", self.toggleShader)
        self.accept("j", self.rotateLight, [-1])
        self.accept("k", self.rotateLight, [1])
        self.accept("arrow_left", self.rotateCam, [-1])
        self.accept("arrow_right", self.rotateCam, [1])

        # Add a light to the scene.
        self.lightpivot = render.attachNewNode("lightpivot")
        self.lightpivot.setPos(0, 0, 25)
        self.lightpivot.hprInterval(10, LPoint3(360, 0, 0)).loop()
        plight = PointLight('plight')
        plight.setColor((1, 1, 1, 1))
        plight.setAttenuation(LVector3(0.7, 0.05, 0))
        plnp = self.lightpivot.attachNewNode(plight)
        plnp.setPos(45, 0, 0)
        self.room.setLight(plnp)

        # Add an ambient light
        alight = AmbientLight('alight')
        alight.setColor((0.2, 0.2, 0.2, 1))
        alnp = render.attachNewNode(alight)
        self.room.setLight(alnp)

        # Create a sphere to denote the light
        sphere = loader.loadModel("models/icosphere")
        sphere.reparentTo(plnp)

        # Tell Panda that it should generate shaders performing per-pixel
        # lighting for the room.
        self.room.setShaderAuto()

        self.shaderenable = 1
开发者ID:AdrianF98,项目名称:Toontown-2-Revised,代码行数:89,代码来源:main.py

示例9: __init__

# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setAttenuation [as 别名]
    def __init__(self):

        # Check video card capabilities.

        if base.win.getGsg().getSupportsBasicShaders() == 0:
            addTitle("Bump Mapping: Video driver reports that shaders are not supported.")
            return

        # Post the instructions
        self.title = addTitle("Panda3D: Tutorial - Bump Mapping")
        self.inst1 = addInstructions(0.95, "Press ESC to exit")
        self.inst2 = addInstructions(0.90, "Move mouse to rotate camera")
        self.inst3 = addInstructions(0.85, "Left mouse button: Move forwards")
        self.inst4 = addInstructions(0.80, "Right mouse button: Move backwards")
        self.inst5 = addInstructions(0.75, "Enter: Turn bump maps Off")

        # Load the 'abstract room' model.  This is a model of an
        # empty room containing a pillar, a pyramid, and a bunch
        # of exaggeratedly bumpy textures.

        self.room = loader.loadModel("models/abstractroom")
        self.room.reparentTo(render)

        # Make the mouse invisible, turn off normal mouse controls
        base.disableMouse()
        props = WindowProperties()
        props.setCursorHidden(True)
        base.win.requestProperties(props)

        # Set the current viewing target
        self.focus = Vec3(55, -55, 20)
        self.heading = 180
        self.pitch = 0
        self.mousex = 0
        self.mousey = 0
        self.last = 0
        self.mousebtn = [0, 0, 0]

        # Start the camera control task:
        taskMgr.add(self.controlCamera, "camera-task")
        self.accept("escape", sys.exit, [0])
        self.accept("mouse1", self.setMouseBtn, [0, 1])
        self.accept("mouse1-up", self.setMouseBtn, [0, 0])
        self.accept("mouse2", self.setMouseBtn, [1, 1])
        self.accept("mouse2-up", self.setMouseBtn, [1, 0])
        self.accept("mouse3", self.setMouseBtn, [2, 1])
        self.accept("mouse3-up", self.setMouseBtn, [2, 0])
        self.accept("enter", self.toggleShader)
        self.accept("j", self.rotateLight, [-1])
        self.accept("k", self.rotateLight, [1])
        self.accept("arrow_left", self.rotateCam, [-1])
        self.accept("arrow_right", self.rotateCam, [1])

        # Add a light to the scene.
        self.lightpivot = render.attachNewNode("lightpivot")
        self.lightpivot.setPos(0, 0, 25)
        self.lightpivot.hprInterval(10, Point3(360, 0, 0)).loop()
        plight = PointLight("plight")
        plight.setColor(Vec4(1, 1, 1, 1))
        plight.setAttenuation(Vec3(0.7, 0.05, 0))
        plnp = self.lightpivot.attachNewNode(plight)
        plnp.setPos(45, 0, 0)
        self.room.setLight(plnp)

        # Add an ambient light
        alight = AmbientLight("alight")
        alight.setColor(Vec4(0.2, 0.2, 0.2, 1))
        alnp = render.attachNewNode(alight)
        self.room.setLight(alnp)

        # create a sphere to denote the light
        sphere = loader.loadModel("models/sphere")
        sphere.reparentTo(plnp)

        # load and apply the shader.  This is using panda's
        # built-in shader generation capabilities to create the
        # shader for you.  However, if desired, you can supply
        # the shader manually.  Change this line of code to:
        #   self.room.setShaderInput("light", plnp)
        #   self.room.setShader(Shader.load("bumpMapper.sha"))
        self.room.setShaderAuto()

        self.shaderenable = 1
开发者ID:lolman8776,项目名称:ToontownInfinite,代码行数:85,代码来源:Tut-Bump-Mapping.py

示例10: __init__

# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setAttenuation [as 别名]

#.........这里部分代码省略.........
        self.mousex = 0
        self.mousey = 0
        self.last = 0
        self.mousebtn = [0, 0, 0]

        # Start the camera control task:
        # taskMgr.add(self.controlCamera, "camera-task")
        # self.accept("escape", sys.exit, [0])
        # self.accept("enter", self.toggleShader)
        # self.accept("j", self.rotateLight, [-1])
        # self.accept("k", self.rotateLight, [1])
        # self.accept("arrow_left", self.rotateCam, [-1])
        # self.accept("arrow_right", self.rotateCam, [1])

        # Accept the control keys for movement and rotation

        self.accept("escape", sys.exit)
        self.accept("arrow_left", self.setKey, ["left", True])
        self.accept("arrow_right", self.setKey, ["right", True])
        self.accept("arrow_up", self.setKey, ["forward", True])
        self.accept("a", self.setKey, ["cam-left", True])
        self.accept("s", self.setKey, ["cam-right", True])
        self.accept("arrow_left-up", self.setKey, ["left", False])
        self.accept("arrow_right-up", self.setKey, ["right", False])
        self.accept("arrow_up-up", self.setKey, ["forward", False])
        self.accept("a-up", self.setKey, ["cam-left", False])
        self.accept("s-up", self.setKey, ["cam-right", False])
        # Add a light to the scene.
        self.lightpivot = render.attachNewNode("lightpivot")
        self.lightpivot.setPos(0, 0, 25)
        self.lightpivot.hprInterval(10, LPoint3(360, 0, 0)).loop()
        plight = PointLight('plight')
        plight.setColor((5, 5, 5, 1))
        plight.setAttenuation(LVector3(0.7, 0.05, 0))
        plnp = self.lightpivot.attachNewNode(plight)
        plnp.setPos(45, 0, 0)
        self.room.setLight(plnp)

        # Add an ambient light
        alight = AmbientLight('alight')
        alight.setColor((0.2, 0.2, 0.2, 1))
        alnp = render.attachNewNode(alight)
        self.room.setLight(alnp)

        # Create a sphere to denote the light
        sphere = loader.loadModel("models/icosphere")
        sphere.reparentTo(plnp)

#         self.cameraModel = self.agent

#        self.win2 = self.openWindow()
#        self.win2.removeAllDisplayRegions()
#        self.dr2 = self.win2.makeDisplayRegion()
#        camNode = Camera('cam')
#        camNP = NodePath(camNode)
#        camNP.reparentTo(self.cameraModel)
#        camNP.setZ(150)
#        camNP.lookAt(self.cameraModel)
#        self.dr2.setCamera(camNP)
#        self.cam2 = camNP  # Camera('cam')p

        # We will detect the height of the terrain by creating a collision
        # ray and casting it downward toward the terrain.  One ray will
        # start above agent's head, and the other will start above the camera.
        # A ray may hit the terrain, or it may hit a rock or a tree.  If it
        # hits the terrain, we can detect the height.  If it hits anything
开发者ID:rbn42,项目名称:LearningToDrive,代码行数:70,代码来源:scene2nav.py

示例11: __init__

# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setAttenuation [as 别名]

#.........这里部分代码省略.........
	#self.bluefinal.setPos(7,7,0)	
	
	#self.blue = loader.loadModel("models/blue1")
	#self.blue.reparentTo(render)
	#self.blue.setScale(.1)
	#self.blue.setPos(10,5,0)
	
	self.chik = loader.loadModel("models/chik")
	self.chik.reparentTo(render)
	self.chik.setScale(.1)
	self.chik.setPos(3,13,0)	

        self.pawn = loader.loadModel("pawn")
        self.pawn.reparentTo(render)
        self.pawn.setPos(0,0,0)

        self.shot = loader.loadModel("models/icosphere.egg")
        self.shot.reparentTo(render)
        self.shot.setScale(.5)
        self.shot.setPos(0,0,1)
        self.shot.setColor(1,.3,.3,1)

        self.myShot = loader.loadModel("models/icosphere.egg")
        #self.myShot.reparentTo(render)
        self.myShot.setScale(.1)
        self.myShot.setPos(0,0,1)
        self.myShotVec = LVector3(0,0,0)

        self.lightpivot3 = render.attachNewNode("lightpivot3")
        self.lightpivot3.setPos(0, 0, 0)
        self.lightpivot3.hprInterval(10, LPoint3(0, 0, 0)).loop()
        plight3 = PointLight('plight2')
        plight3.setColor((0, .3,0, 1))
        plight3.setAttenuation(LVector3(0.7, 0.05, 0))
        plnp3 = self.lightpivot3.attachNewNode(plight3)
        plnp3.setPos(0, 0, 0)
        self.room2.setLight(plnp3)
        self.room.setLight(plnp3)
        sphere3 = loader.loadModel("models/icosphere")
        sphere3.reparentTo(plnp3)
        sphere3.setScale(0.1)
        sphere3.setColor((0,1,0,1))

        # Create a floater object, which floats 2 units above ralph.  We
        # use this as a target for the camera to look at.

        self.floater = NodePath(PandaNode("floater"))
        self.floater.reparentTo(self.ralph)
        self.floater.setZ(8.0)

        # Accept the control keys for movement and rotation

        self.accept("escape", sys.exit)
        self.accept("arrow_left", self.setKey, ["left", True])
        self.accept("arrow_right", self.setKey, ["right", True])
        self.accept("arrow_up", self.setKey, ["forward", True])
        self.accept("arrow_down", self.setKey, ["back", True])
        self.accept("a", self.setKey, ["cam-left", True])
        self.accept("s", self.setKey, ["cam-right", True])
        self.accept("arrow_left-up", self.setKey, ["left", False])
        self.accept("arrow_right-up", self.setKey, ["right", False])
        self.accept("arrow_up-up", self.setKey, ["forward", False])
        self.accept("arrow_down-up", self.setKey, ["back", False])
        self.accept("a-up", self.setKey, ["cam-left", False])
        self.accept("s-up", self.setKey, ["cam-right", False])
开发者ID:imelendez,项目名称:TheAmazeingRace,代码行数:69,代码来源:main+with+Room.py

示例12: runViewer

# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setAttenuation [as 别名]
def runViewer(mesh):
    scene_members = getSceneMembers(mesh)
    
    loadPrcFileData('', 'win-size 300 300')
    base = ShowBase()
    globNode = GeomNode("collada")
    nodePath = base.render.attachNewNode(globNode)
    
    rotateNode = GeomNode("rotater")
    rotatePath = nodePath.attachNewNode(rotateNode)
    matrix = numpy.identity(4)
    if mesh.assetInfo.upaxis == collada.asset.UP_AXIS.X_UP:
        r = collada.scene.RotateTransform(0,1,0,90)
        matrix = r.matrix
    elif mesh.assetInfo.upaxis == collada.asset.UP_AXIS.Y_UP:
        r = collada.scene.RotateTransform(1,0,0,90)
        matrix = r.matrix
    rotatePath.setMat(Mat4(*matrix.T.flatten().tolist()))
    
    basecollada = GeomNode("basecollada")
    basecolladaNP = rotatePath.attachNewNode(basecollada)
    for geom, renderstate, mat4 in scene_members:
        node = GeomNode("primitive")
        node.addGeom(geom)
        if renderstate is not None:
            node.setGeomState(0, renderstate)
        geomPath = basecolladaNP.attachNewNode(node)
        geomPath.setMat(mat4)

    for boundlight in mesh.scene.objects('light'):
        
        if len(boundlight.color) == 3:
            color = (boundlight.color[0], boundlight.color[1], boundlight.color[2], 1)
        else:
            color = boundlight.color
        
        if isinstance(boundlight, collada.light.BoundDirectionalLight):
            dl = DirectionalLight('dirLight')
            dl.setColor(Vec4(color[0], color[1], color[2], color[3]))
            lightNP = rotatePath.attachNewNode(dl)
            lightNP.lookAt(Point3(boundlight.direction[0],boundlight.direction[1],boundlight.direction[2]))
        elif isinstance(boundlight, collada.light.BoundAmbientLight):
            ambientLight = AmbientLight('ambientLight')
            ambientLight.setColor(Vec4(color[0], color[1], color[2], color[3]))
            lightNP = rotatePath.attachNewNode(ambientLight)
        elif isinstance(boundlight, collada.light.BoundPointLight):
            pointLight = PointLight('pointLight')
            pointLight.setColor(Vec4(color[0], color[1], color[2], color[3]))
            pointLight.setAttenuation(Vec3(boundlight.constant_att, boundlight.linear_att, boundlight.quad_att))
            lightNP = rotatePath.attachNewNode(pointLight)
            lightNP.setPos(Vec3(boundlight.position[0], boundlight.position[1], boundlight.position[2]))
        elif isinstance(boundlight, collada.light.BoundSpotLight):
            spotLight = Spotlight('spotLight')
            spotLight.setColor(Vec4(color[0], color[1], color[2], color[3]))
            spotLight.setAttenuation(Vec3(boundlight.constant_att, boundlight.linear_att, boundlight.quad_att))
            spotLight.setExponent(boundlight.falloff_exp)
            lightNP = rotatePath.attachNewNode(spotLight)
            lightNP.setPos(Vec3(boundlight.position[0], boundlight.position[1], boundlight.position[2]))
            lightNP.lookAt(Point3(boundlight.direction[0], boundlight.direction[1], boundlight.direction[2]),
                               Vec3(boundlight.up[0], boundlight.up[1], boundlight.up[2]))
        else:
            print('Unknown light type', boundlight)
            continue
            
        base.render.setLight(lightNP)

    for boundcam in mesh.scene.objects('camera'):
        if isinstance(boundcam, collada.camera.BoundPerspectiveCamera):
            base.camera.reparentTo(rotatePath)
            base.camLens.setNear(boundcam.znear)
            base.camLens.setFar(boundcam.zfar)
            
            if boundcam.xfov is not None and boundcam.yfov is not None:
                #xfov + yfov
                base.camLens.setFov(boundcam.xfov, boundcam.yfov)
            elif boundcam.xfov is not None and boundcam.aspect_ratio is not None:
                #xfov + aspect_ratio
                base.camLens.setFov(boundcam.xfov)
                base.camLens.setAspectRatio(boundcam.aspect_ratio)
            elif boundcam.yfov is not None and boundcam.aspect_ratio is not None:
                #yfov + aspect_ratio
                #aspect_ratio = tan(0.5*xfov) / tan(0.5*yfov)
                xfov = math.degrees(2.0 * math.atan(boundcam.aspect_ratio * math.tan(math.radians(0.5 * boundcam.yfov))))
                base.camLens.setFov(xfov, boundcam.yfov)
            elif boundcam.yfov is not None:
                #yfov only
                #aspect_ratio = tan(0.5*xfov) / tan(0.5*yfov)
                xfov = math.degrees(2.0 * math.atan(base.camLens.getAspectRatio() * math.tan(math.radians(0.5 * boundcam.yfov))))
                base.camLens.setFov(xfov, boundcam.yfov)
            elif boundcam.xfov is not None:
                base.camLens.setFov(boundcam.xfov)
            
            base.camera.setPos(Vec3(boundcam.position[0], boundcam.position[1], boundcam.position[2]))
            base.camera.lookAt(Point3(boundcam.direction[0], boundcam.direction[1], boundcam.direction[2]),
                               Vec3(boundcam.up[0], boundcam.up[1], boundcam.up[2]))
        elif isinstance(boundcam, collada.camera.BoundOrthographicCamera):
            
            lens = OrthographicLens()
            base.cam.node().setLens(lens)
            base.camLens = lens
#.........这里部分代码省略.........
开发者ID:QuelleVille,项目名称:-deprecated-meshtool,代码行数:103,代码来源:collada_viewer.py

示例13: MyApp

# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setAttenuation [as 别名]
class MyApp(ShowBase):
 
	def __init__(self):
		ShowBase.__init__(self)
		dir(self)
		self.disableMouse()
 
		# Load the environment model.
		self.environ = self.loader.loadModel("../levels/level01.egg")
		# Reparent the model to render.
		self.environ.reparentTo(self.render)
		'''add a light'''
		self.light = PointLight("dLight")
		self.light.setAttenuation( (.01,.01,.01 ) )
		self.light.setSpecularColor ( VBase4(1,1,0,1 ) )
		self.lightNode = render.attachNewNode(self.light)
		self.lightNode.setZ(10)
		render.setLight(self.lightNode)

		'''move light constants'''
		self.moveLightDirection = -1000

		self.taskMgr.add(self.moveLight,"lightMove")
		self.taskMgr.add(self.fpsInput,"fpsInput")

		'''fps cam controls'''
		self.keymap={"w":0,"a":0,"s":0,"d":0,"e":0,"q":0,
				"j":0,"k":0,"l":0,"i":0}
		
		self.fps = FpsCam(self.camera)
		self.accept("a", self.setKey,     ["a",1] )
		self.accept("a-up", self.setKey,  ['a',0] )
		self.accept("w", self.setKey,     ["w",1] )
		self.accept("w-up", self.setKey,  ["w",0] )
		self.accept("s", self.setKey,     ["s",1] )
		self.accept("s-up", self.setKey,  ["s",0] )
		self.accept("d", self.setKey,     ["d",1] )
		self.accept("d-up", self.setKey,  ["d",0] )
		self.accept("e", self.setKey,     ["e",1] )
		self.accept("e-up", self.setKey,  ["e",0] )
		self.accept("q", self.setKey,     ["q",1] )
		self.accept("q-up", self.setKey,  ["q",0] )
		self.accept("j", self.setKey,     ["j",1] )
		self.accept("j-up", self.setKey,  ["j",0] )
		self.accept("k", self.setKey,     ["k",1] )
		self.accept("k-up", self.setKey,  ["k",0] )
		self.accept("l", self.setKey,     ["l",1] )
		self.accept("l-up", self.setKey,  ["l",0] )
		self.accept("i", self.setKey,     ["i",1] )
		self.accept("i-up", self.setKey,  ["i",0] )
		self.accept("escape",sys.exit )




	def setKey(self,key,value):
		self.keymap[key]=value
		return

	def fpsInput(self,task):
		self.fps.moveX( self.keymap["d"]-self.keymap["a"])
		self.fps.moveY( self.keymap["w"]-self.keymap["s"])
		self.fps.moveZ( self.keymap["e"]-self.keymap["q"])
		self.fps.yaw  ( self.keymap["j"]-self.keymap["l"])
		self.fps.pitch( self.keymap["i"]-self.keymap["k"])
		return task.cont

	def moveLight(self,task):
		#print dir(self.lightNode)
		where = self.lightNode.getX()
		#print where
		self.lightNode.setX(where-task.getDt()*self.moveLightDirection)
		if self.lightNode.getX()< -10:
			self.moveLightDirection *= -1
		elif self.lightNode.getX() > 10:
			self.moveLightDirection *= -1

		return task.cont
开发者ID:zwparchman,项目名称:zwparchmanTank,代码行数:80,代码来源:viewer.py

示例14: World

# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setAttenuation [as 别名]

#.........这里部分代码省略.........
        # Post the instructions
        self.title = addTitle("zonewalk v." + VERSION)
        self.inst0 = addInstructions(0.95, "[FLYMODE][1]")
        self.inst1 = addInstructions(-0.95, "Camera control with WSAD/mouselook. Press K for hotkey list, ESC to exit.")
        self.inst2 = addInstructions(0.9, "Loc:")
        self.inst3 = addInstructions(0.85, "Hdg:")
        self.error_inst = addInstructions(0, "")
        self.kh = []

        self.campos = Point3(155.6, 41.2, 4.93)
        base.camera.setPos(self.campos)

        # Accept the application control keys: currently just esc to exit navgen
        self.accept("escape", self.exitGame)
        self.accept("window-event", self.resizeGame)

        # Create some lighting
        ambient_level = 0.6
        ambientLight = AmbientLight("ambientLight")
        ambientLight.setColor(Vec4(ambient_level, ambient_level, ambient_level, 1.0))
        render.setLight(render.attachNewNode(ambientLight))

        direct_level = 0.8
        directionalLight = DirectionalLight("directionalLight")
        directionalLight.setDirection(Vec3(0.0, 0.0, -1.0))
        directionalLight.setColor(Vec4(direct_level, direct_level, direct_level, 1))
        directionalLight.setSpecularColor(Vec4(direct_level, direct_level, direct_level, 1))
        render.setLight(render.attachNewNode(directionalLight))

        # create a point light that will follow our view point (the camera for now)
        # attenuation is set so that this point light has a torch like effect
        self.plight = PointLight("plight")
        self.plight.setColor(VBase4(0.8, 0.8, 0.8, 1.0))
        self.plight.setAttenuation(Point3(0.0, 0.0, 0.0002))

        self.plnp = base.camera.attachNewNode(self.plight)
        self.plnp.setPos(0, 0, 0)
        render.setLight(self.plnp)
        self.cam_light = 1

        self.keyMap = {
            "left": 0,
            "right": 0,
            "forward": 0,
            "backward": 0,
            "cam-left": 0,
            "cam-right": 0,
            "mouse3": 0,
            "flymode": 1,
        }

        # setup FOG
        self.fog_colour = (0.8, 0.8, 0.8, 1.0)
        self.linfog = Fog("A linear-mode Fog node")
        self.linfog.setColor(self.fog_colour)
        self.linfog.setLinearRange(700, 980)  # onset, opaque distances as params
        # linfog.setLinearFallback(45,160,320)
        base.camera.attachNewNode(self.linfog)
        render.setFog(self.linfog)
        self.fog = 1

        # camera control
        self.campos = Point3(0, 0, 0)
        self.camHeading = 0.0
        self.camPitch = 0.0
        base.camLens.setFov(65.0)
开发者ID:proxeeus,项目名称:panda-zonewalk,代码行数:70,代码来源:zonewalk.py


注:本文中的panda3d.core.PointLight.setAttenuation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。