本文整理汇总了Python中panda3d.core.DirectionalLight.setSpecularColor方法的典型用法代码示例。如果您正苦于以下问题:Python DirectionalLight.setSpecularColor方法的具体用法?Python DirectionalLight.setSpecularColor怎么用?Python DirectionalLight.setSpecularColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.DirectionalLight
的用法示例。
在下文中一共展示了DirectionalLight.setSpecularColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createLighting
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
def createLighting(self):
#creates lighting for the scene
aLightVal = 0.3
dLightVal1 = -5
dLightVal2 = 5
#set up the ambient light
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(aLightVal, aLightVal, aLightVal, 1))
ambientLight1 = AmbientLight("ambientLight1")
ambientLight1.setColor(Vec4(aLightVal, aLightVal, aLightVal, 1))
ambientLight2 = AmbientLight("ambientLight2")
ambientLight2.setColor(Vec4(aLightVal, aLightVal, aLightVal, 1))
#sets a directional light
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(Vec3(dLightVal1, dLightVal1, dLightVal1))
directionalLight.setColor(Vec4(1, 1, 1, 1))
directionalLight.setSpecularColor(Vec4(0, 0, 0, 1))
#sets a directional light
directionalLight1 = DirectionalLight("directionalLight2")
directionalLight1.setDirection(Vec3(dLightVal2, dLightVal1, dLightVal1))
directionalLight1.setColor(Vec4(1, 1, 1, 1))
directionalLight1.setSpecularColor(Vec4(1, 1, 1, 1))
#attaches lights to scene
render.setLight(render.attachNewNode(ambientLight))
render.setLight(render.attachNewNode(ambientLight1))
render.setLight(render.attachNewNode(ambientLight1))
render.setLight(render.attachNewNode(directionalLight))
render.setLight(render.attachNewNode(directionalLight1))
示例2: __init__
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
def __init__(self):
self.setAI()
self.keyMap = {"left": 0, "right": 0, "forward": 0, "backward": 0, "cam-left": 0, "cam-right": 0}
base.win.setClearColor(Vec4(0, 0, 0, 1))
# the menu
self.loadAudio()
self.showMenu()
# keyboard and mouse events
self.accept("escape", sys.exit)
self.accept("w", self.setKey, ["forward", 1])
self.accept("a", self.setKey, ["left", 1])
self.accept("s", self.setKey, ["backward", 1])
self.accept("d", self.setKey, ["right", 1])
self.accept("w-up", self.setKey, ["forward", 0])
self.accept("a-up", self.setKey, ["left", 0])
self.accept("s-up", self.setKey, ["backward", 0])
self.accept("d-up", self.setKey, ["right", 0])
self.accept("arrow_left", self.setKey, ["cam-left", 1])
self.accept("arrow_left-up", self.setKey, ["cam-left", 0])
self.accept("arrow_right", self.setKey, ["cam-right", 1])
self.accept("arrow_right-up", self.setKey, ["cam-right", 0])
# create some lighting
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(0.3, 0.3, 0.3, 1))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(Vec3(-5, -5, -5))
directionalLight.setColor(Vec4(1, 1, 1, 1))
directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
render.setLight(render.attachNewNode(ambientLight))
render.setLight(render.attachNewNode(directionalLight))
示例3: light
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
def light(self):
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(.3, .3, .3, 1))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(Vec3(-5, -5, -5))
directionalLight.setColor(Vec4(1, 1, 1, 1))
directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
render.setLight(render.attachNewNode(ambientLight))
render.setLight(render.attachNewNode(directionalLight))
示例4: __init__
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
def __init__(self):
__builtin__.main = self
self.taskMgr = taskMgr
self.base = base
# Connect to the server
self.cManager = ConnectionManager()
self.startConnection()
self.characters = dict()
self.cpList = dict()
base.win.setClearColor(Vec4(0,0,0,1))
self.environ = loader.loadModel("models/world")
self.environ.reparentTo(render)
self.environ.setPos(0,0,0)
self.ralphStartPos = self.environ.find("**/start_point").getPos()
# Create a floater object. We use the "floater" as a temporary
# variable in a variety of calculations.
self.floater = NodePath(PandaNode("floater"))
self.floater.reparentTo(render)
self.accept("escape", sys.exit)
# Login as 'CPHandler'
# Temporary workaround, can add a seperate request/response for client/NPC client logins later
self.name = "CPHandler"
factionId = 0
self.cManager.sendRequest(Constants.CMSG_AUTH, [self.name, factionId])
# Create two control points
cp1 = ControlPoint(1, -107.575, 0.6066, 0.490075, 10, RED)
cp2 = ControlPoint(2, -100.575, -35.6066, 0.090075, 10, BLUE)
self.cpList[1] = cp1
self.cpList[2] = cp2
taskMgr.doMethodLater(0.1, self.refresh, "heartbeat")
taskMgr.doMethodLater(1, self.CPHandler, 'CPHandler')
# Set up the camera
base.disableMouse()
#base.camera.setPos(self.character.actor.getX(),self.character.actor.getY()+10,2)
# Create some lighting
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(.3, .3, .3, 1))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(Vec3(-5, -5, -5))
directionalLight.setColor(Vec4(1, 1, 1, 1))
directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
render.setLight(render.attachNewNode(ambientLight))
render.setLight(render.attachNewNode(directionalLight))
示例5: __init__
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
def __init__(self, aCol, dDir, dCol):
render.setAttrib(LightRampAttrib.makeHdr1())
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(aCol)
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(dDir)
directionalLight.setColor(dCol)
directionalLight.setSpecularColor(Vec4(2.0, 2.0, 2.0, 0))
render.setLight(render.attachNewNode(ambientLight))
render.setLight(render.attachNewNode(directionalLight))
示例6: init
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
def init(self):
# window setup
base.win.setClearColor(Vec4(0, 0, 0, 1))
# display instructions
addTitle("CS454 HW2")
addInstructions(0.95, "[ESC]: Quit")
addInstructions(0.90, "[Mouse Move]: Move camera")
addInstructions(0.85, "[Mouse Wheel]: Zoom camera")
addInstructions(0.80, "[W,A,S,D]: Move character")
addInstructions(0.75, "[T]: Open chat box")
addInstructions(0.70, "[Y]: Open whisper box")
addInstructions(0.65, "[Up,Down]: Select whisper target")
addInstructions(0.60, "[Tab]: Show players")
# create environment
environ = loader.loadModel("models/square")
environ.reparentTo(render)
environ.setPos(0, 0, 0)
environ.setScale(100, 100, 1)
environ.setTexture(loader.loadTexture("models/moon_1k_tex.jpg"), 1)
# create lighting
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(0.3, 0.3, 0.3, 1))
render.setLight(render.attachNewNode(ambientLight))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(Vec3(-5, -5, -5))
directionalLight.setColor(Vec4(1, 1, 1, 1))
directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
render.setLight(render.attachNewNode(directionalLight))
# accept special keys
base.accept("escape", self.exit)
base.accept("shift-escape", self.exit)
# create spheres
sun = Sphere(self, "sun")
sun.model.setPos(-15, -15, 8)
earth = Sphere(self, "earth")
earth.model.setPos(-12, 12, 5)
venus = Sphere(self, "venus")
venus.model.setPos(10, 10, 3.5)
# track game entities
self.character = None
self.player = None
self.camera = None
self.characters = {}
self.chat = Chat(self)
self.playerList = PlayerList(self)
示例7: __init__
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
def __init__(self):
base.win.setClearColor(Vec4(0,0,0,1))
# Network Setup
print "before"
self.cManager = ConnectionManager(self)
self.startConnection()
print "after"
# Set up the environment
#
self.environ = loader.loadModel("models/square")
self.environ.reparentTo(render)
self.environ.setPos(0,0,0)
self.environ.setScale(100,100,1)
self.moon_tex = loader.loadTexture("models/moon_1k_tex.jpg")
self.environ.setTexture(self.moon_tex, 1)
self.floater = NodePath(PandaNode("floater"))
self.floater.reparentTo(render)
# add spheres
earth = Earth(self)
sun = Sun(self)
venus = Venus(self)
controls = Control()
chat = Chat(self)
player = Ralph(self)
# player = Panda(self)
# player = Car(self)
taskMgr.add(player.move,"moveTask" )
taskMgr.add(sun.rotatePlanets,"rotateSun", extraArgs = [self.player], appendTask = True)
taskMgr.add(earth.rotatePlanets,"rotateEarth", extraArgs = [self.player], appendTask = True)
taskMgr.add(venus.rotatePlanets,"rotateVenus", extraArgs = [self.player], appendTask = True)
# Create some lighting
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(.3, .3, .3, 1))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(Vec3(-5, -5, -5))
directionalLight.setColor(Vec4(1, 1, 1, 1))
directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
render.setLight(render.attachNewNode(ambientLight))
render.setLight(render.attachNewNode(directionalLight))
示例8: setupLights
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
def setupLights(self):
# Create some lighting
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(.3, .3, .3, 1))
directionalLight1 = DirectionalLight("directionalLight")
directionalLight1.setDirection(Vec3(5, 5, -5))
directionalLight1.setColor(Vec4(1, 1, 1, 1))
directionalLight1.setSpecularColor(Vec4(1, 1, 1, 1))
directionalLight2 = DirectionalLight("directionalLight")
directionalLight2.setDirection(Vec3(5, -5, -5))
directionalLight2.setColor(Vec4(1, 1, 1, 1))
directionalLight2.setSpecularColor(Vec4(1, 1, 1, 1))
directionalLight3 = DirectionalLight("directionalLight")
directionalLight3.setDirection(Vec3(-5, -5, -5))
directionalLight3.setColor(Vec4(1, 1, 1, 1))
directionalLight3.setSpecularColor(Vec4(1, 1, 1, 1))
directionalLight4 = DirectionalLight("directionalLight")
directionalLight4.setDirection(Vec3(-5, 5, -5))
directionalLight4.setColor(Vec4(1, 1, 1, 1))
directionalLight4.setSpecularColor(Vec4(1, 1, 1, 1))
render.setLight(render.attachNewNode(ambientLight))
render.setLight(render.attachNewNode(directionalLight1))
render.setLight(render.attachNewNode(directionalLight2))
render.setLight(render.attachNewNode(directionalLight3))
render.setLight(render.attachNewNode(directionalLight4))
示例9: __init__
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
def __init__(self):
self.root = render.attachNewNode("Root")
base.setBackgroundColor(0,0,0)
# This code puts the standard title and instruction text on screen
self.title = OnscreenText(text="Ball In Maze",
style=1, fg=(1,1,0,1),
pos=(0.7,-0.95), scale = .07)
self.instructions = OnscreenText(text="Press Esc to exit",
pos = (-1.3, .95), fg=(1,1,0,1),
align = TextNode.ALeft, scale = .05)
self.central_msg = OnscreenText(text="",
pos = (0, 0), fg=(1, 1, 0, 1),
scale = .1
)
self.central_msg.hide()
self.accept("escape", sys.exit) # Escape quits
base.disableMouse() # Disable mouse-based camera control
camera.setPosHpr(0, 0, 25, 0, -90, 0) # Place the camera
# Load the maze and place it in the scene
self.maze = loader.loadModel("models/maze")
self.maze.reparentTo(render)
# Load the ball and attach it to the scene
# It is on a root dummy node so that we can rotate the ball itself without
# rotating the ray that will be attached to it
self.ballRoot = render.attachNewNode("ballRoot")
self.ball = loader.loadModel("models/ball")
self.ball.reparentTo(self.ballRoot)
# This section deals with lighting for the ball. Only the ball was lit
# because the maze has static lighting pregenerated by the modeler
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(.55, .55, .55, 1))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(Vec3(0, 0, -1))
directionalLight.setColor(Vec4(0.375, 0.375, 0.375, 1))
directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
self.ballRoot.setLight(render.attachNewNode(ambientLight))
self.ballRoot.setLight(render.attachNewNode(directionalLight))
# This section deals with adding a specular highlight to the ball to make
# it look shiny
m = Material()
m.setSpecular(Vec4(1,1,1,1))
m.setShininess(96)
self.ball.setMaterial(m, 1)
示例10: start
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
def start(self, myPlayerName, players):
"""
Takes a list of player names and positions,
initializes the players and sets up the scene
"""
# Load the environment model.
self.levelNode = render.attachNewNode("Level node")
self.level = LevelContainer(self.levelName)
self.level.render(self.levelNode, base.loader)
self.levelNode.setAttrib(ShadeModelAttrib.make(ShadeModelAttrib.MFlat))
base.win.setClearColor(Vec4(0,0,0,1))
self.title = addTitle("PushBack")
self.players = dict()
self.playersNode = render.attachNewNode("Players Root Node")
self.healthbar = DirectWaitBar(range=1.0, barColor=(1.0, 0.0, 0.0, 1.0),
value=1.0, frameSize=(-0.45,0.45,1.0,0.98))
base.disableMouse()
base.cam.reparentTo(self.playersNode)
base.cam.setCompass()
base.cam.setH(0)
base.cam.setZ(CAM_HEIGHT)
base.cam.setY(-CAM_HEIGHT)
base.cam.setP(-CAM_ANGLE)
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(.3, .3, .3, 1))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(Vec3(-5, -5, -5))
directionalLight.setColor(Vec4(1, 1, 1, 1))
directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
render.setLight(render.attachNewNode(ambientLight))
render.setLight(render.attachNewNode(directionalLight))
skins = ["stony_green", "stony_red", "stony_blue", "bonbon_blue","bonbon_green", "red", "pushette", "blue"]
for player in players:
print "Init player %s" % player[0]
p = Player(player[0])
p.reparentTo(self.playersNode)
p.setPos(player[1])
p.setColor(skins.pop())
self.players[player[0]] = p
if myPlayerName == player[0]:
self.myPlayer = p
base.cam.reparentTo(self.myPlayer)
示例11: loadBall
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
def loadBall(self):
self.ballRoot = render.attachNewNode("ballRoot")
self.ball = load_model("ball")
self.ball.reparentTo(self.ballRoot)
self.ball_tex = load_tex("pokeball.png")
self.ball.setTexture(self.ball_tex,1)
self.ball.setScale(0.8)
# Find the collision sphere for the ball in egg.
self.ballSphere = self.ball.find("**/ball")
self.ballSphere.node().setFromCollideMask(BitMask32.bit(0))
self.ballSphere.node().setIntoCollideMask(BitMask32.allOff())
#self.ballSphere.show()
# Now we create a ray to cast down at the ball.
self.ballGroundRay = CollisionRay()
self.ballGroundRay.setOrigin(0,0,10)
self.ballGroundRay.setDirection(0,0,-1)
# Collision solids go in CollisionNode
self.ballGroundCol = CollisionNode('groundRay')
self.ballGroundCol.addSolid(self.ballGroundRay)
self.ballGroundCol.setFromCollideMask(BitMask32.bit(1))
self.ballGroundCol.setIntoCollideMask(BitMask32.allOff())
self.ballGroundColNp = self.ballRoot.attachNewNode(self.ballGroundCol)
# light
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(.55, .55, .55, 1))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(Vec3(0,0,-1))
directionalLight.setColor(Vec4(0.375,0.375,0.375,1))
directionalLight.setSpecularColor(Vec4(1,1,1,1))
self.ballRoot.setLight(render.attachNewNode(ambientLight))
self.ballRoot.setLight(render.attachNewNode(directionalLight))
# material to the ball
m = Material()
m.setSpecular(Vec4(1,1,1,1))
m.setShininess(96)
self.ball.setMaterial(m,1)
示例12: __init__
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
def __init__(self):
#Load switch model
self.glowswitch = loader.loadModel("glowswitch")
self.sphere=self.glowswitch.find("**/sphere") #finds a subcomponent of the .egg model... sphere is the name of the sphere geometry in the .egg file
self.glowswitch.reparentTo(render)
base.disableMouse() #mouse-controlled camera cannot be moved within the program
camera.setPosHpr( 0, -6.5, 1.4, 0, -2, 0)
#Light up everything an equal amount
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(.95, .95, 1.05, 1))
render.setLight(render.attachNewNode(ambientLight))
#Add lighting that only casts light on one side of everything in the scene
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(Vec3(-5, -5, -5))
directionalLight.setColor(Vec4(.2, .2, .2, .1)) #keepin it dim
directionalLight.setSpecularColor(Vec4(0.2, 0.2, 0.2, 0.2))
render.setLight(render.attachNewNode(directionalLight))
#initalize sequence variable
self.ChangeColorSeq = Sequence(Wait(.1))
#start with blue by default
self.changeOrbColor(.1,0,.6,.3,.2,1)
#^(R min, Gmin, Bmin, Rmax, Gmax, Bmax)
#user controls
#note that changing the color means it will "pulse" that color and therefore needs a range of color values
self.accept("1", self.changeOrbColor,[.6,.1,.1,1,.3,.3]) #change orb color to red
self.accept("2", self.changeOrbColor,[.1,.6,.1,.3,1,.3])#change orb color to green
self.accept("3", self.changeOrbColor,[.1,0,.6,.3,.2,1]) #change orb color to blue
self.accept("escape", sys.exit)
instructions = OnscreenText(text="1: Change to red \n2: Change to Green \n3: Change to Blue \nEsc: Exit",
fg=(1,1,1,1), pos = (-1.3, -.82), scale = .05, align = TextNode.ALeft)
示例13: initWorld
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
#.........这里部分代码省略.........
#Collision Code
# Initialize the collision traverser.
base.cTrav = CollisionTraverser()
# Initialize the Pusher collision handler.
self.pusher = CollisionHandlerPusher()
self.bTrav = base.cTrav
# Create the main character, Ralph
self.mainCharRef = Character(self, chosenCharId, True)
self.mainCharRef.setPlayerId(playerId)
self.characters.append(self.mainCharRef)
self.mainChar = self.mainCharRef.getActor()
#Create second bike
self.mainCharRef2 = Character(self, 3, True)
self.mainCharRef2.setPlayerId(2)
self.characters.append(self.mainCharRef2)
self.mainChar2 = self.mainCharRef2.getActor()
resetPos = True
if (x == 0 and y == 0):
resetPos = False
if resetPos:
self.mainChar.setPos(x, y, 0)
self.mainChar.setH(h)
self.cManager.sendRequest(Constants.CMSG_CREATE_CHARACTER, [playerId,
chosenCharId,
self.mainChar.getX(),
self.mainChar.getY(),
self.mainChar.getZ()])
self.previousPos = self.mainChar.getPos()
taskMgr.doMethodLater(.1, self.updateMove, 'updateMove')
# Creating Stationary spheres
self.spheres = []
self.sphereCount = 3
for x in range(self.sphereCount):
self.spheres.append(StationarySphere(self))
for sphere in self.spheres:
taskMgr.add(sphere.rotateForAll, "rotateSphere")
self.floater = NodePath(PandaNode("floater"))
self.floater.reparentTo(render)
floorNode = render.attachNewNode("Floor NodePath")
# Create a collision plane solid.
collPlane = CollisionPlane(Plane(Vec3(0, 0, 1), Point3(0, 0, 0)))
# Call our function that creates a nodepath with a collision node.
floorCollisionNP = self.makeCollisionNodePath(floorNode, collPlane)
# Accept the control keys for movement and rotation
self.accept("escape", self.quitGame)
self.accept("a", self.setKey, ["left",1])
self.accept("d", self.setKey, ["right",1])
self.accept("w", self.setKey, ["forward",1])
self.accept("s", self.setKey, ["backward",1])
self.accept("lshift", self.setKey, ["fast", 1])
self.accept("arrow_left", self.setKey, ["cam-left",1])
self.accept("arrow_right", self.setKey, ["cam-right",1])
self.accept("a-up", self.setKey, ["left",0])
self.accept("d-up", self.setKey, ["right",0])
self.accept("w-up", self.setKey, ["forward",0])
self.accept("s-up", self.setKey, ["backward",0])
self.accept("lshift-up", self.setKey, ["fast", 0])
self.accept("arrow_left-up", self.setKey, ["cam-left",0])
self.accept("arrow_right-up", self.setKey, ["cam-right",0])
self.accept("h", self.setKey, ["hello",1])
self.accept("h-up", self.setKey, ["hello",0])
self.accept("0", self.setKey, ["chat0", 1])
self.accept("0-up", self.setKey, ["chat0", 0])
self.accept("1", self.setKey, ["chat1", 1])
self.accept("1-up", self.setKey, ["chat1", 0])
self.accept("l", self.setKey, ["users", 1])
self.accept("l-up", self.setKey, ["users", 0])
taskMgr.add(self.move,"moveTask")
# Game state variables
self.isMoving = False
# Set up the camera
base.disableMouse()
base.camera.setPos(self.mainChar.getX(),self.mainChar.getY()+10,2)
# Create some lighting
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(.3, .3, .3, 1))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(Vec3(-5, -5, -5))
directionalLight.setColor(Vec4(1, 1, 1, 1))
directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
render.setLight(render.attachNewNode(ambientLight))
render.setLight(render.attachNewNode(directionalLight))
示例14: __init__
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
def __init__(self):
self.itemID = 0
self.switchState = True
self.iAktion = "E"
self.altIPos = [0,0]
self.switchCam = False
self.kampf = Battle.Kampf()
self.itemDa = False
self.keyMap = {"left":0, "right":0, "forward":0, "cam-left":0, "cam-right":0}
base.win.setClearColor(Vec4(0,0,0,1))
self.environ = loader.loadModel("models/world")
self.environ.reparentTo(render)
self.environ.setPos(0,0,0)
self.spieler = Players.Player(Actor("models/box.x"))
self.spieler.actor.reparentTo(render)
spielerStartPos = (-107.575, 26.6066, -0.490075)
self.spieler.actor.setPos(spielerStartPos)
self.textObjectSpieler = OnscreenText(text = self.spieler.name+": "+str(self.spieler.energie)+"/"+str(self.spieler.maxenergie)+" HP", pos = (-0.90, -0.98), scale = 0.07, fg = (1,0,0,1))
# Erstellt Gegner
self.gegnerStartPos = ([(-39.1143569946,25.1781406403,-0.136657714844),
(-102.375793457,-30.6321983337,0.0),
(-56.927986145, -34.6329650879, -0.16748046875),
(-79.6673126221,30.8231620789,2.89721679688),
(-4.37648868561,30.5158863068,2.18450927734),
(22.6527004242,4.99837779999,3.11364746094),
(-23.8257598877,-7.87773084641,1.36920166016),
(-80.6140823364,19.5769443512,4.70764160156),
(-75.0773696899,-15.2991075516,6.24676513672)
])
gegnerPos = random.choice(self.gegnerStartPos)
self.gegnerErstellen(gegnerPos)
self.textObjectGegner = OnscreenText(text = str(self.gegner.name)+": "+str(self.gegner.energie)+"/"+str(self.gegner.maxenergie)+" HP", pos = (0.90, -0.98), scale = 0.07, fg = (1,0,0,1))
self.floater = NodePath(PandaNode("floater"))
self.floater.reparentTo(render)
self.item = None
# Handling der Usereingaben für Bewegung
self.accept("escape", sys.exit)
self.accept("arrow_left", self.setKey, ["left",1])
self.accept("arrow_right", self.setKey, ["right",1])
self.accept("arrow_up", self.setKey, ["forward",1])
self.accept("a", self.setKey, ["cam-left",1])
self.accept("s", self.setKey, ["cam-right",1])
self.accept("i", self.setKey, ["inventar",1])
self.accept("arrow_left-up", self.setKey, ["left",0])
self.accept("arrow_right-up", self.setKey, ["right",0])
self.accept("arrow_up-up", self.setKey, ["forward",0])
self.accept("a-up", self.setKey, ["cam-left",0])
self.accept("s-up", self.setKey, ["cam-right",0])
self.accept("e", self.iAktionsHandler,["e"])
self.accept("v", self.iAktionsHandler,["v"])
self.accept("w", self.iAktionsHandler,["w"])
taskMgr.add(self.move,"moveTask")
taskMgr.add(self.erkenneKampf,"Kampferkennung")
taskMgr.add(self.screentexts,"Screentexte")
# Menü erstellen
self.createMenu()
# Kameraeinstellungen
base.disableMouse()
base.camera.setPos(self.spieler.actor.getX(),self.spieler.actor.getY()+10,2)
self.collisionInit();
self.setAI()
# Licht
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(.3, .3, .3, 1))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(Vec3(-5, -5, -5))
directionalLight.setColor(Vec4(1, 1, 1, 1))
directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
render.setLight(render.attachNewNode(ambientLight))
render.setLight(render.attachNewNode(directionalLight))
# Hintergrund (Himmel)
self.setupSkySphere()
示例15: __init__
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setSpecularColor [as 别名]
#.........这里部分代码省略.........
"walk":"models/ralph-walk"})
self.ralph.reparentTo(render)
self.ralph.setScale(.2)
self.ralph.setPos(ralphStartPos)
nameplate = TextNode('textNode username_' + str(self.userName))
nameplate.setText(self.userName)
npNodePath = self.ralph.attachNewNode(nameplate)
npNodePath.setScale(0.8)
npNodePath.setBillboardPointEye()
#npNodePath.setPos(1.0,0,6.0)
npNodePath.setZ(6.5)
bar = DirectWaitBar(value=100, scale=1.0)
bar.setColor(255,0,0)
#bar.setBarRelief()
bar.setZ(6.0)
bar.setBillboardPointEye()
bar.reparentTo(self.ralph)
# Create a floater object. We use the "floater" as a temporary
# variable in a variety of calculations.
self.floater = NodePath(PandaNode("floater"))
self.floater.reparentTo(render)
# Accept the control keys for movement and rotation
self.accept("escape", sys.exit)
self.accept("arrow_left", self.setKey, ["left",1])
self.accept("arrow_right", self.setKey, ["right",1])
self.accept("arrow_up", self.setKey, ["forward",1])
self.accept("a", self.setKey, ["cam-left",1])
self.accept("s", self.setKey, ["cam-right",1])
self.accept("arrow_left-up", self.setKey, ["left",0])
self.accept("arrow_right-up", self.setKey, ["right",0])
self.accept("arrow_up-up", self.setKey, ["forward",0])
self.accept("a-up", self.setKey, ["cam-left",0])
self.accept("s-up", self.setKey, ["cam-right",0])
self.accept("c", self.setKey, ["charge",1])
self.accept("c-up", self.setKey, ["charge",0])
taskMgr.add(self.move,"moveTask")
# Game state variables
self.isMoving = False
# Set up the camera
base.disableMouse()
base.camera.setPos(self.ralph.getX(),self.ralph.getY()+10,2)
# 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 ralph'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
# else, we rule that the move is illegal.
self.cTrav = CollisionTraverser()
self.ralphGroundRay = CollisionRay()
self.ralphGroundRay.setOrigin(0,0,1000)
self.ralphGroundRay.setDirection(0,0,-1)
self.ralphGroundCol = CollisionNode('ralphRay')
self.ralphGroundCol.addSolid(self.ralphGroundRay)
self.ralphGroundCol.setFromCollideMask(BitMask32.bit(0))
self.ralphGroundCol.setIntoCollideMask(BitMask32.allOff())
self.ralphGroundColNp = self.ralph.attachNewNode(self.ralphGroundCol)
self.ralphGroundHandler = CollisionHandlerQueue()
self.cTrav.addCollider(self.ralphGroundColNp, self.ralphGroundHandler)
self.camGroundRay = CollisionRay()
self.camGroundRay.setOrigin(0,0,1000)
self.camGroundRay.setDirection(0,0,-1)
self.camGroundCol = CollisionNode('camRay')
self.camGroundCol.addSolid(self.camGroundRay)
self.camGroundCol.setFromCollideMask(BitMask32.bit(0))
self.camGroundCol.setIntoCollideMask(BitMask32.allOff())
self.camGroundColNp = base.camera.attachNewNode(self.camGroundCol)
self.camGroundHandler = CollisionHandlerQueue()
self.cTrav.addCollider(self.camGroundColNp, self.camGroundHandler)
# Uncomment this line to see the collision rays
#self.ralphGroundColNp.show()
#self.camGroundColNp.show()
# Uncomment this line to show a visual representation of the
# collisions occuring
#self.cTrav.showCollisions(render)
# Create some lighting
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(.3, .3, .3, 1))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(Vec3(-5, -5, -5))
directionalLight.setColor(Vec4(1, 1, 1, 1))
directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
render.setLight(render.attachNewNode(ambientLight))
render.setLight(render.attachNewNode(directionalLight))