def load(self): DistributedPartyFireworksActivity.notify.debug('load') DistributedPartyActivity.load(self) self.eventId = PartyGlobals.FireworkShows.Summer self.launchPadModel = loader.loadModel('phase_13/models/parties/launchPad') self.launchPadModel.setH(90.0) self.launchPadModel.setPos(0.0, -18.0, 0.0) self.launchPadModel.reparentTo(self.root) railingsCollection = self.launchPadModel.findAllMatches('**/launchPad_mesh/*railing*') for i in xrange(railingsCollection.getNumPaths()): railingsCollection[i].setAttrib(AlphaTestAttrib.make(RenderAttrib.MGreater, 0.75)) leverLocator = self.launchPadModel.find('**/RocketLever_locator') self.lever.setPosHpr(Vec3.zero(), Vec3.zero()) self.lever.reparentTo(leverLocator) self.toonPullingLeverInterval = None self.sign.reparentTo(self.launchPadModel.find('**/launchPad_sign_locator')) self.rocketActor = Actor('phase_13/models/parties/rocket_model', {'launch': 'phase_13/models/parties/rocket_launch'}) rocketLocator = self.launchPadModel.find('**/rocket_locator') self.rocketActor.reparentTo(rocketLocator) self.rocketActor.node().setBound(OmniBoundingVolume()) self.rocketActor.node().setFinal(True) effectsLocator = self.rocketActor.find('**/joint1') self.rocketExplosionEffect = RocketExplosion(effectsLocator, rocketLocator) self.rocketParticleSeq = None self.launchSound = base.loadSfx('phase_13/audio/sfx/rocket_launch.ogg') self.activityFSM = FireworksActivityFSM(self) self.activityFSM.request('Idle') return
def load(self): DistributedPartyFireworksActivity.notify.debug('load') DistributedPartyActivity.load(self) self.eventId = PartyGlobals.FireworkShows.Summer self.launchPadModel = loader.loadModel('phase_13/models/parties/launchPad') self.launchPadModel.setH(90.0) self.launchPadModel.setPos(0.0, -18.0, 0.0) self.launchPadModel.reparentTo(self.root) railingsCollection = self.launchPadModel.findAllMatches('**/launchPad_mesh/*railing*') for i in xrange(railingsCollection.getNumPaths()): railingsCollection[i].setAttrib(AlphaTestAttrib.make(RenderAttrib.MGreater, 0.75)) leverLocator = self.launchPadModel.find('**/RocketLever_locator') self.lever.setPosHpr(Vec3.zero(), Vec3.zero()) self.lever.reparentTo(leverLocator) self.toonPullingLeverInterval = None self.sign.reparentTo(self.launchPadModel.find('**/launchPad_sign_locator')) self.rocketActor = Actor('phase_13/models/parties/rocket_model', {'launch': 'phase_13/models/parties/rocket_launch'}) rocketLocator = self.launchPadModel.find('**/rocket_locator') self.rocketActor.reparentTo(rocketLocator) self.rocketActor.node().setBound(OmniBoundingVolume()) self.rocketActor.node().setFinal(True) effectsLocator = self.rocketActor.find('**/joint1') self.rocketExplosionEffect = RocketExplosion(effectsLocator, rocketLocator) self.rocketParticleSeq = None self.launchSound = base.loader.loadSfx('phase_13/audio/sfx/rocket_launch.ogg') self.activityFSM = FireworksActivityFSM(self) self.activityFSM.request('Idle') return
def load(self): """ Load the necessary assets """ DistributedPartyFireworksActivity.notify.debug("load") DistributedPartyActivity.load(self) self.eventId = PartyGlobals.FireworkShows.Summer # load the rocket platform and place it in party space self.launchPadModel = loader.loadModel('phase_13/models/parties/launchPad') # Compensate for pivot of fireworks model and center it in 2x4 space self.launchPadModel.setH(90.0) self.launchPadModel.setPos(0.0, -18.0, 0.0) # reparent to root self.launchPadModel.reparentTo( self.root ) # special case the depth testing on the railings to prevent # transparency oddness railingsCollection = self.launchPadModel.findAllMatches("**/launchPad_mesh/*railing*") for i in range( railingsCollection.getNumPaths() ): railingsCollection[i].setAttrib(AlphaTestAttrib.make(RenderAttrib.MGreater, 0.75)) # place the lever on the platform leverLocator = self.launchPadModel.find("**/RocketLever_locator") self.lever.setPosHpr(Vec3.zero(), Vec3.zero()) self.lever.reparentTo(leverLocator) self.toonPullingLeverInterval = None # place the activity sign self.sign.reparentTo( self.launchPadModel.find("**/launchPad_sign_locator") ) # load the rocket with animation and place it on the platform self.rocketActor = Actor( 'phase_13/models/parties/rocket_model', {'launch':'phase_13/models/parties/rocket_launch'}, ) rocketLocator = self.launchPadModel.find("**/rocket_locator") self.rocketActor.reparentTo(rocketLocator) # ensure the rocket is never culled self.rocketActor.node().setBound( OmniBoundingVolume() ) self.rocketActor.node().setFinal( True ) effectsLocator = self.rocketActor.find("**/joint1") self.rocketExplosionEffect = RocketExplosion(effectsLocator, rocketLocator) self.rocketParticleSeq = None self.launchSound = base.loadSfx("phase_13/audio/sfx/rocket_launch.mp3") # create state machine and set initial state self.activityFSM = FireworksActivityFSM( self ) self.activityFSM.request("Idle")
def __init__(self): # Make a way out of here! base.accept("escape", exit) # Initiate the shadows self.sMgr = ShadowManager(render) self.sMgr.setAmbient(0.2) # Most of these five are the default self.sMgr.setHardness(20) # values so it was kinda unnecessary to self.sMgr.setFov(40) # set them explicitly but I wanted to self.sMgr.setNearFar(10, 100) # show how to set them anyway. # Create the 'table' self.table = loader.loadModel("tableplane.egg") self.table.reparentTo(render) tableTex = loader.loadTexture("tree-bark-89a.jpg") tableTex.setMinfilter( Texture.FTLinearMipmapLinear) # Enable texture mipmapping self.table.setTexture(tableTex) # Load the teapot self.teapot = loader.loadModel("teapot") self.teapot.setTwoSided(True) self.teapot.reparentTo(render) # The teapot has no texture, so you have to tell it to the ShadowManager # Otherwise the model will turn up black. self.sMgr.flagUntexturedObject(self.teapot) # Set intervals to move the teapot self.teapot.hprInterval(5.0, Vec3.zero(), Vec3(360, 0, 0)).loop() Sequence(self.teapot.posInterval(2.0, Point3.zero(), Point3(2, 0, 1)), self.teapot.posInterval(2.0, Point3(2, 0, 1), Point3.zero())).loop() # Setup the camera base.disableMouse() camPivot = render.attachNewNode("cameraPivotPoint") base.cam.reparentTo(camPivot) base.camLens.setNearFar(1, 1000) base.camLens.setFov(75) base.cam.setPos(-10, -10, 15) base.cam.lookAt(self.teapot) # Setup an interval to rotate the camera around camPivot camPivot.hprInterval(15.0, Vec3.zero(), Vec3(360, 0, 0)).loop() # Position the shadow camera self.sMgr.light.setPos(0, 20, 15) self.sMgr.light.lookAt(self.teapot) self.sMgr.light.node().showFrustum() # Show the frustrum
def __init__(self): # Make a way out of here! base.accept("escape", exit) # Initiate the shadows self.sMgr = ShadowManager(render) self.sMgr.setAmbient(0.2) # Most of these five are the default self.sMgr.setHardness(20) # values so it was kinda unnecessary to self.sMgr.setFov(40) # set them explicitly but I wanted to self.sMgr.setNearFar(10, 100) # show how to set them anyway. # Create the 'table' self.table = loader.loadModel("tableplane.egg") self.table.reparentTo(render) tableTex = loader.loadTexture("tree-bark-89a.jpg") tableTex.setMinfilter(Texture.FTLinearMipmapLinear) # Enable texture mipmapping self.table.setTexture(tableTex) # Load the teapot self.teapot = loader.loadModel("teapot") self.teapot.setTwoSided(True) self.teapot.reparentTo(render) # The teapot has no texture, so you have to tell it to the ShadowManager # Otherwise the model will turn up black. self.sMgr.flagUntexturedObject(self.teapot) # Set intervals to move the teapot self.teapot.hprInterval(5.0, Vec3.zero(), Vec3(360, 0, 0)).loop() Sequence(self.teapot.posInterval(2.0, Point3.zero(), Point3(2, 0, 1)), self.teapot.posInterval(2.0, Point3(2, 0, 1), Point3.zero())).loop() # Setup the camera base.disableMouse() camPivot = render.attachNewNode("cameraPivotPoint") base.cam.reparentTo(camPivot) base.camLens.setNearFar(1,1000) base.camLens.setFov(75) base.cam.setPos(-10,-10,15) base.cam.lookAt(self.teapot) # Setup an interval to rotate the camera around camPivot camPivot.hprInterval(15.0, Vec3.zero(), Vec3(360, 0, 0)).loop() # Position the shadow camera self.sMgr.light.setPos(0,20,15) self.sMgr.light.lookAt(self.teapot) self.sMgr.light.node().showFrustum() # Show the frustrum
def keybControl(self,dt): move=self.spd_forward*dt vel=Vec3(0,0,0) if self.keys['up']: vel+=self.up(move) if self.keys['down']: vel+=self.down(move) if self.keys['right']: vel+=self.right(move) if self.keys['left']: vel+=self.left(move) ###self.avatar.setPos(self.avatar.getPos()+vel) self.avatar.setFluidPos(self.avatar.getPos()+vel) if self.lockY != None: self.avatar.setY(self.lockY) if (vel <> Vec3.zero()): self.walk(dt, vel) if self.keys['jump']: self.jump(dt)
def keybControl(self, dt): move = self.spd_forward * dt vel = Vec3(0, 0, 0) if self.keys['up']: vel += self.up(move) if self.keys['down']: vel += self.down(move) if self.keys['right']: vel += self.right(move) if self.keys['left']: vel += self.left(move) ###self.avatar.setPos(self.avatar.getPos()+vel) self.avatar.setFluidPos(self.avatar.getPos() + vel) if self.lockY != None: self.avatar.setY(self.lockY) if (vel <> Vec3.zero()): self.walk(dt, vel) if self.keys['jump']: self.jump(dt)