def explode(self): # This is stolen from the Texture-Swapping sample self.expPlane = loader.loadModel( 'assets/models/plane') #load the object self.expPlane.reparentTo(self.baseNode) #reparent to render self.expPlane.setTransparency(1) #enable transparency self.expPlane.setScale(3) self.expPlane.setBin("fixed", 40) self.expPlane.setDepthTest(False) self.expPlane.setDepthWrite(False) #load the texture movie self.expTexs = self.loadTextureMovie( 51, 'assets/textures/explosion/explosion', 'png', padding=4) #create the animation task self.expTaskCounter = 0 self.expTask = taskMgr.add(self.textureMovie, "explosionTask") self.expTask.fps = 30 #set framerate self.expTask.obj = self.expPlane #set object self.expTask.textures = self.expTexs #set texture list #This create the "billboard" effect that will rotate the object soremove that it #is always rendered as facing the eye (camera) self.expPlane.node().setEffect(BillboardEffect.makePointEye())
def explode(self): # This is stolen from the Texture-Swapping sample self.expPlane = loader.loadModel('assets/models/plane') #load the object self.expPlane.reparentTo(self.baseNode) #reparent to render self.expPlane.setTransparency(1) #enable transparency self.expPlane.setScale(3) self.expPlane.setBin("fixed", 40) self.expPlane.setDepthTest(False) self.expPlane.setDepthWrite(False) #load the texture movie self.expTexs = self.loadTextureMovie(51, 'assets/textures/explosion/explosion', 'png', padding = 4) #create the animation task self.expTaskCounter = 0 self.expTask = taskMgr.add(self.textureMovie, "explosionTask") self.expTask.fps = 30 #set framerate self.expTask.obj = self.expPlane #set object self.expTask.textures = self.expTexs #set texture list #This create the "billboard" effect that will rotate the object soremove that it #is always rendered as facing the eye (camera) self.expPlane.node().setEffect(BillboardEffect.makePointEye())
def setupHpMeter(self): if self.hpMeter: return zAdj = 50 self.smokeZAdj = zAdj self.fortPart = self.fortNode.find('**/top_interior_wall_collision') if self.fortPart.isEmpty(): self.fortPart = self.fortNode.find('**/col_TopFloor1') if self.fortPart.isEmpty(): self.fortPart = self.fortNode.find('**/pPlane4') zAdj = 150 self.smokeZAdj = 100 if self.fortPart.isEmpty(): self.fortPart = self.fortNode.find('**/*tower*') if self.fortPart.isEmpty(): self.fortPart = self.fortNode.find('**/*buttress*') if self.fortPart.isEmpty(): self.fortPart = self.fortNode.find('**/*floor*') fortPartBounds = self.fortPart.getBounds() self.hpAnchor = NodePath('hpAnchor') self.hpAnchor.setPos(fortPartBounds.getApproxCenter()) self.hpAnchor.setZ(self.hpAnchor.getZ() + zAdj) self.hpAnchor.reparentTo(self.fortNode) self.hpMeter = HpMeter.HpMeter(fadeOut=0, parent=self.hpAnchor, originAtMidPt=True) self.hpMeter.setScale(200) self.hpMeter.setBin('fixed', 130) self.hpMeter.setDepthWrite(False) myEffect = BillboardEffect.make(Vec3(0, 0, 1), True, False, 150, NodePath(), Point3(0, 0, 0)) self.hpMeter.node().setEffect(myEffect) self.hpMeter.update(self.hp, self.maxHp) self.hideFortHpMeter()
def __init__(self, parent, pos=Vec3(0, 0, 0), size=1, color=Vec4(0, 0, 0, 1)): print(" Creating circle at " + str(pos)) self.aaLevel= 16 self.pos = pos self.size = size self.color = color self._np = self.draw() self._np.setTwoSided(True) self._np.setTransparency(1) self._np.setAttrib(DepthTestAttrib.make(RenderAttrib.MNone)) self._np.setEffect(BillboardEffect.makePointEye()) if self.aaLevel > 0: self._np.setAntialias(AntialiasAttrib.MPolygon, self.aaLevel) self._np.reparentTo(parent)
def CreateRing( self, vector, colour, lookAt ): # Create the billboard effect bbe = BillboardEffect.make( vector, False, True, 0, lookAt, (0, 0, 0) ) # Create an arc arc = Arc( numSegs=32, degrees=180, axis=Vec3(0, 0, 1) ) arc.setH( 180 ) arc.setEffect( bbe ) # Create the axis from the arc axis = Axis( self.name, vector, colour ) axis.AddGeometry( arc, sizeStyle=SCALE ) axis.AddCollisionSolid( self.collSphere, sizeStyle=SCALE ) axis.reparentTo( self ) return axis
def __init__(self, parent, pos=Vec3(0, 0, 0), size=1, color=Vec4(0, 0, 0, 1)): print(" Creating circle at " + str(pos)) self.aaLevel = int(GameSettings().getSetting('ANTIALIAS')) self.pos = pos self.size = size self.color = color self._np = self.draw() self._np.setTwoSided(True) self._np.setTransparency(1) self._np.setAttrib(DepthTestAttrib.make(RenderAttrib.MNone)) self._np.setEffect(BillboardEffect.makePointEye()) if self.aaLevel > 0: self._np.setAntialias(AntialiasAttrib.MPolygon, self.aaLevel) self._np.reparentTo(parent)
def CreateRing( self, vector, colour, lookAt ): # Create the billboard effect bbe = BillboardEffect.make( vector, False, True, 0, lookAt, (0, 0, 0) ) # Create an arc arc = Arc( numSegs=32, degrees=180, axis=Vec3(0, 0, 1) ) #line = Line(start=Vec3(0,0,0), end=Vec3(0, 0, 1)) arc.setH( 180 ) arc.setEffect( bbe ) # Create the axis from the arc axis = Axis( self.name, vector, colour ) axis.AddGeometry( arc, sizeStyle=SCALE , vector=str(vector)) #axis.AddGeometry( line, sizeStyle=SCALE ) axis.AddCollisionSolid( self.collSphere, sizeStyle=SCALE, vector=str(vector)) axis.reparentTo( self ) #== line = Line( (0, 0, 0), vector ) cone = Cone( 0.05, 0.25, axis=vector, origin=vector * 0.25 ) axis.AddGeometry( line, sizeStyle=SCALE ) axis.AddGeometry( cone, vector, colour ) #== return axis
def CreateRing( self, vector, colour, rot ): # Create an arc arc = Arc( numSegs=32, degrees=180, axis=Vec3(0, 0, 1) ) arc.setH( 180 ) # Create the axis from the arc axis = Axis( self.name, vector, colour ) axis.AddGeometry( arc, sizeStyle=SCALE ) axis.AddCollisionSolid( self.collSphere, sizeStyle=SCALE ) axis.reparentTo( self ) # Create the billboard effect and apply it to the arc. We need an # extra NodePath to help the billboard effect so it orients properly. hlpr = NodePath( 'helper' ) hlpr.setHpr( rot ) hlpr.reparentTo( self ) arc.reparentTo( hlpr ) bbe = BillboardEffect.make( Vec3(0, 0, 1), False, True, 0, self.camera, (0, 0, 0) ) arc.setEffect( bbe ) return axis
def setupHpMeter(self): if self.hpMeter: return None zAdj = 50 self.smokeZAdj = zAdj self.fortPart = self.fortNode.find("**/top_interior_wall_collision") if self.fortPart.isEmpty(): self.fortPart = self.fortNode.find("**/col_TopFloor1") if self.fortPart.isEmpty(): self.fortPart = self.fortNode.find("**/pPlane4") zAdj = 150 self.smokeZAdj = 100 if self.fortPart.isEmpty(): self.fortPart = self.fortNode.find("**/*tower*") if self.fortPart.isEmpty(): self.fortPart = self.fortNode.find("**/*buttress*") if self.fortPart.isEmpty(): self.fortPart = self.fortNode.find("**/*floor*") fortPartBounds = self.fortPart.getBounds() self.hpAnchor = NodePath("hpAnchor") self.hpAnchor.setPos(fortPartBounds.getApproxCenter()) self.hpAnchor.setZ(self.hpAnchor.getZ() + zAdj) self.hpAnchor.reparentTo(self.fortNode) self.hpMeter = HpMeter.HpMeter(fadeOut=0, parent=self.hpAnchor, originAtMidPt=True) self.hpMeter.setScale(200) self.hpMeter.setBin("fixed", 130) self.hpMeter.setDepthWrite(False) myEffect = BillboardEffect.make(Vec3(0, 0, 1), True, False, 150, NodePath(), Point3(0, 0, 0)) self.hpMeter.node().setEffect(myEffect) self.hpMeter.update(self.hp, self.maxHp) self.hideFortHpMeter()