示例#1
0
    def draw(self, screen):
        # Translate to position of camera
        canv3d.setMatCameraPosition(MAT_T)
        # Compile matrices into single matrix
        canv3d.compileMats()

        # Revert drawing color back to white if not already white
        canv3d.setRGB(255, 255, 255)

        # Draw top
        canv3d.setTexture(self.upP, self.imgSize, self.imgSize)
        canv3d.draw3dFloor(-self.boxSize, self.boxSize, self.boxSize,
                           -self.boxSize, self.boxSize)
        # Draw front
        canv3d.setTexture(self.ftP, self.imgSize, self.imgSize)
        canv3d.draw3dWall(self.boxSize, -self.boxSize, self.boxSize,
                          self.boxSize, self.boxSize, -self.boxSize)
        # Draw left
        canv3d.setTexture(self.lfP, self.imgSize, self.imgSize)
        canv3d.draw3dWall(self.boxSize, self.boxSize, self.boxSize,
                          -self.boxSize, self.boxSize, -self.boxSize)
        # Draw right
        canv3d.setTexture(self.rtP, self.imgSize, self.imgSize)
        canv3d.draw3dWall(-self.boxSize, -self.boxSize, self.boxSize,
                          self.boxSize, -self.boxSize, -self.boxSize)
        # Draw back
        canv3d.setTexture(self.bkP, self.imgSize, self.imgSize)
        canv3d.draw3dWall(-self.boxSize, self.boxSize, self.boxSize,
                          -self.boxSize, -self.boxSize, -self.boxSize)
        # Draw bottom
        canv3d.setTexture(self.dnP, self.imgSize, self.imgSize)
        canv3d.draw3dFloor(-self.boxSize, -self.boxSize, self.boxSize,
                           self.boxSize, -self.boxSize)
示例#2
0
	def draw(self, screen):
		# Translate to position of camera
		canv3d.setMatCameraPosition(MAT_T)
		# Compile matrices into single matrix
		canv3d.compileMats()

		# Revert drawing color back to white if not already white
		canv3d.setRGB(255,255,255)


		# Draw top
		canv3d.setTexture(self.upP, self.imgSize,self.imgSize);		
		canv3d.draw3dFloor(-self.boxSize,self.boxSize,self.boxSize,-self.boxSize, self.boxSize)
		# Draw front
		canv3d.setTexture(self.ftP, self.imgSize,self.imgSize);		
		canv3d.draw3dWall(self.boxSize,-self.boxSize,self.boxSize, self.boxSize,self.boxSize, -self.boxSize)
		# Draw left
		canv3d.setTexture(self.lfP, self.imgSize,self.imgSize);		
		canv3d.draw3dWall(self.boxSize,self.boxSize,self.boxSize, -self.boxSize,self.boxSize, -self.boxSize)
		# Draw right
		canv3d.setTexture(self.rtP, self.imgSize,self.imgSize);		
		canv3d.draw3dWall(-self.boxSize,-self.boxSize,self.boxSize, self.boxSize,-self.boxSize, -self.boxSize)
		# Draw back
 		canv3d.setTexture(self.bkP, self.imgSize,self.imgSize);		
		canv3d.draw3dWall(-self.boxSize,self.boxSize,self.boxSize, -self.boxSize,-self.boxSize, -self.boxSize)
		# Draw bottom
		canv3d.setTexture(self.dnP, self.imgSize,self.imgSize);
		canv3d.draw3dFloor(-self.boxSize,-self.boxSize,self.boxSize,self.boxSize, -self.boxSize)
示例#3
0
    def draw(self, screen):
        canv3d.setMatIdentity(MAT_T)
        canv3d.addMatTranslation(MAT_T, self.ori[0], self.ori[1], self.ori[2])

        spd = 8
        for i in range(0, 3):
            self.dpos[i] += (self.ori[i] - self.dpos[i]) / spd
            self.dtoPos[i] += (self.ori[3 + i] - self.dtoPos[i]) / spd
            self.dupNorm[i] += (self.ori[6 + i] - self.dupNorm[i]) / spd

        nX = self.dtoPos[0] - self.dpos[0]
        nY = self.dtoPos[1] - self.dpos[1]
        nZ = self.dtoPos[2] - self.dpos[2]

        canv3d.addMatAntiLook(MAT_T, 0, 0, 0, nX, nY, nZ, self.dupNorm[0],
                              self.dupNorm[1], self.dupNorm[2])

        canv3d.addMatRotationX(MAT_T, self.drawPitch)
        canv3d.addMatRotationY(MAT_T, self.drawYaw)

        if self.hurtAnimation > -1:
            cR = 255
            cG = cB = int(255 * abs(cosd(720 * self.hurtAnimation)))
            canv3d.addMatRotationY(MAT_T, -45)
            canv3d.addMatRotationZ(
                MAT_T, 45 * cosd(360 * 4 * self.hurtAnimation) *
                (1 - self.hurtAnimation))
            canv3d.addMatRotationY(MAT_T, 45)
        else:
            cR = cG = cB = 255

        # Further transform model

        canv3d.addMatRotationZ(MAT_T, self.drawRoll + self.barrelRoll)
        canv3d.addMatTranslation(MAT_T, 0, -10, 0)
        canv3d.addMatScale(MAT_T, .25, .25, .25)

        # Compile matrices into completeMat before drawing
        canv3d.compileMats()

        # Draw Arwing, modifying color if damage animation is playing
        canv3d.setRGB(cR, cG, cB)
        canv3d.drawObj(Arwing.MOD_ARWING)
        canv3d.setRGB(255, 255, 255)

        # Draw exhaust behind ship
        xs = 50 * (1 + .5 * rnd()) * (.25 + .75 * self.speed / Arwing.SPD_BASE)
        ys = xs * .8
        up = 10
        back = -80
        canv3d.setTexture(Arwing.TEX_JET, Arwing.TEX_JET_WIDTH,
                          Arwing.TEX_JET_HEIGHT)
        canv3d.draw3dFloor(-xs, up - ys, xs, up + ys, back)
示例#4
0
	def draw(self, screen):			
		canv3d.setMatIdentity(MAT_T)
		canv3d.addMatTranslation(MAT_T, self.ori[0],self.ori[1],self.ori[2])

		spd = 8
		for i in range(0,3):
			self.dpos[i] += (self.ori[i] - self.dpos[i])/spd;
			self.dtoPos[i] += (self.ori[3+i] - self.dtoPos[i])/spd;
			self.dupNorm[i] += (self.ori[6+i] - self.dupNorm[i])/spd;
		
		nX = self.dtoPos[0]-self.dpos[0]
		nY = self.dtoPos[1]-self.dpos[1]
		nZ = self.dtoPos[2]-self.dpos[2]
		
		canv3d.addMatAntiLook(MAT_T, 0,0,0,		nX,nY,nZ,		self.dupNorm[0],self.dupNorm[1],self.dupNorm[2]);

		canv3d.addMatRotationX(MAT_T, self.drawPitch)
		canv3d.addMatRotationY(MAT_T, self.drawYaw)

		if self.hurtAnimation > -1:
			cR = 255
			cG = cB = int(255 * abs(cosd(720 * self.hurtAnimation)))
			canv3d.addMatRotationY(MAT_T, -45)
			canv3d.addMatRotationZ(MAT_T, 45 * cosd(360*4 * self.hurtAnimation) * (1 - self.hurtAnimation) )
			canv3d.addMatRotationY(MAT_T, 45)
		else:
			cR = cG = cB = 255

		# Further transform model

		canv3d.addMatRotationZ(MAT_T, self.drawRoll + self.barrelRoll)
		canv3d.addMatTranslation(MAT_T, 0,-10,0)		
		canv3d.addMatScale(MAT_T,.25,.25,.25);

		# Compile matrices into completeMat before drawing
		canv3d.compileMats()

		
		# Draw Arwing, modifying color if damage animation is playing
		canv3d.setRGB(cR,cG,cB)	
		canv3d.drawObj(Arwing.MOD_ARWING);
		canv3d.setRGB(255,255,255)
		
		# Draw exhaust behind ship
		xs = 50 * (1 + .5*rnd()) * (.25 + .75*self.speed / Arwing.SPD_BASE)
		ys = xs * .8
		up = 10
		back = -80
		canv3d.setTexture(Arwing.TEX_JET, Arwing.TEX_JET_WIDTH, Arwing.TEX_JET_HEIGHT)
		canv3d.draw3dFloor(-xs,up-ys,xs,up+ys,back);
示例#5
0
	def draw(self, screen):
		# Play animation
		if self.spriteIndex < self.sprite.frameNum:
			# Transform matrix to position, and face towards camera
			canv3d.setMatTranslation(MAT_T, self.ori[0],self.ori[1],self.ori[2])
			canv3d.addMatCameraAntiRotation(MAT_T)
			canv3d.compileMats()

			# Set texture to given frame, and draw
			s = 96
			canv3d.setTexture(self.spritePixels[int(self.spriteIndex)], self.sprite.w, self.sprite.h)
			canv3d.draw3dFloor(-s,-s, s,s, 0)
		# Once done, destroy object
		else:
			self.destroy()
示例#6
0
    def draw(self, screen):
        # Translate asteroid to position
        canv3d.setMatTranslation(MAT_T, self.x, self.y, self.z)

        # Rotate along axes
        canv3d.addMatRotationX(MAT_T, self.rotX)
        canv3d.addMatRotationX(MAT_T, self.rotY)
        canv3d.addMatRotationX(MAT_T, self.rotZ)

        # Scale
        canv3d.addMatScale(MAT_T, self.scale, self.scale, self.scale)

        # Compile into single matrix
        canv3d.compileMats()

        # Draw
        canv3d.drawObj(Asteroid.MOD_ASTEROID)
示例#7
0
    def draw(self, screen):
        # Play animation
        if self.spriteIndex < self.sprite.frameNum:
            # Transform matrix to position, and face towards camera
            canv3d.setMatTranslation(MAT_T, self.ori[0], self.ori[1],
                                     self.ori[2])
            canv3d.addMatCameraAntiRotation(MAT_T)
            canv3d.compileMats()

            # Set texture to given frame, and draw
            s = 96
            canv3d.setTexture(self.spritePixels[int(self.spriteIndex)],
                              self.sprite.w, self.sprite.h)
            canv3d.draw3dFloor(-s, -s, s, s, 0)
        # Once done, destroy object
        else:
            self.destroy()
示例#8
0
	def draw(self, screen):	
		canv3d.setMatTranslation(MAT_T, self.ori[0],self.ori[1],self.ori[2])
		
		nX = self.ori[3]-self.ori[0]
		nY = self.ori[4]-self.ori[1]
		nZ = self.ori[5]-self.ori[2]

		# Rotate laser to direction
		canv3d.addMatAntiLook(MAT_T, 0,0,0,		nX,nY,nZ,		self.ori[6],self.ori[7],self.ori[8]);
		# Translate laser model into place
		canv3d.addMatTranslation(MAT_T, 0,-5,0)

		# Compile matrices into single matrix
		canv3d.compileMats()
		
		# Disable texture
		canv3d.unsetTexture()
		
		# Draw model
		canv3d.drawObj(Laser.MOD_LASER)