Пример #1
0
    def __init__(self, imageSrc, **kwArgs):
        super().__init__(**kwArgs)

        #	Set Image/Animation
        if isinstance(imageSrc, Animation):
            self._animation = AnimationState(imageSrc)
            self._texture = self._animation.getImage().get_texture()
        else:
            self._animation = None
            self._texture = imageSrc.get_texture()

        #	Create the Scene Object representation
        self._sceneObject = SceneObject(dataSrc = DiscreteRect(self._texture.width, self._texture.height),	\
         t=self.getTransform(), ed=[('t3f', self._texture.tex_coords)], batch=kwArgs.get('batch', None), group=kwArgs.get('group', None))
        self._sceneObject.isDrawn = False
Пример #2
0
class Sprite(Transformable):

	def __init__(self, imageSrc, **kwArgs):
		super().__init__(**kwArgs)

		#	Set Image/Animation
		if isinstance(imageSrc, Animation):
			self._animation = AnimationState(imageSrc)
			self._texture = self._animation.getImage().get_texture()
		else:
			self._animation = None
			self._texture = imageSrc.get_texture()
			
		#	Create the Scene Object representation
		self._sceneObject = SceneObject(dataSrc = DiscreteRect(self._texture.width, self._texture.height),	\
			t=self.getTransform(), ed=[('t3f', self._texture.tex_coords)], batch=kwArgs.get('batch', None), group=kwArgs.get('group', None))
		self._sceneObject.isDrawn = False
		
	''''''''''''''''''''''''''''''''''''''''''''''''''''''
	
	def update(self, dt):
		if self._animation and self._animation.update(dt):
			self._texture = self._animation.getImage().get_texture()
	
	def draw(self):
		glBindTexture(self._texture.target, self._texture.id)
		glEnable(self._texture.target)
		
		self._sceneObject.draw()
		
		glDisable(self._texture.target)

	
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	
	def getImage(self):
		return self._texture
		
	def setAnimation(self, animState):
		self._animation.setState(animState)
	def getAnimation(self):
		return self._animation
Пример #3
0
class Sprite(Transformable):
    def __init__(self, imageSrc, **kwArgs):
        super().__init__(**kwArgs)

        #	Set Image/Animation
        if isinstance(imageSrc, Animation):
            self._animation = AnimationState(imageSrc)
            self._texture = self._animation.getImage().get_texture()
        else:
            self._animation = None
            self._texture = imageSrc.get_texture()

        #	Create the Scene Object representation
        self._sceneObject = SceneObject(dataSrc = DiscreteRect(self._texture.width, self._texture.height),	\
         t=self.getTransform(), ed=[('t3f', self._texture.tex_coords)], batch=kwArgs.get('batch', None), group=kwArgs.get('group', None))
        self._sceneObject.isDrawn = False

    '''''' '''''' '''''' '''''' '''''' '''''' '''''' '''''' ''''''

    def update(self, dt):
        if self._animation and self._animation.update(dt):
            self._texture = self._animation.getImage().get_texture()

    def draw(self):
        glBindTexture(self._texture.target, self._texture.id)
        glEnable(self._texture.target)

        self._sceneObject.draw()

        glDisable(self._texture.target)

    '''''' '''''' '''''' '''''' '''''' '''''' '''''' '''''' '''''' ''

    def getImage(self):
        return self._texture

    def setAnimation(self, animState):
        self._animation.setState(animState)

    def getAnimation(self):
        return self._animation
Пример #4
0
	def __init__(self, imageSrc, **kwArgs):
		super().__init__(**kwArgs)

		#	Set Image/Animation
		if isinstance(imageSrc, Animation):
			self._animation = AnimationState(imageSrc)
			self._texture = self._animation.getImage().get_texture()
		else:
			self._animation = None
			self._texture = imageSrc.get_texture()
			
		#	Create the Scene Object representation
		self._sceneObject = SceneObject(dataSrc = DiscreteRect(self._texture.width, self._texture.height),	\
			t=self.getTransform(), ed=[('t3f', self._texture.tex_coords)], batch=kwArgs.get('batch', None), group=kwArgs.get('group', None))
		self._sceneObject.isDrawn = False
Пример #5
0
counter = [None]*5
counter[0] = 0

DISPLAY = pi3d.Display.create(frames_per_second=30)

ShaderTypes()

mykeys = pi3d.Keyboard()

perspectiveCamera = pi3d.Camera(is_3d=True)
ortographicCamera = pi3d.Camera(is_3d=False)

box = GeometryTypeSimpleCube(perspectiveCamera)
background = Background(perspectiveCamera)

animation_state = AnimationState()
midground = Midground()

writeState = 0 # waiting / sliding in / blink-in / showing / blinkout / sliding out
startSlideInMs = 0
startBlinkInMS = 0
startShowInMS = 0
startBlinkOutMS = 0
startSlideOutMS = 0

while DISPLAY.loop_running():

  animation_state.updateTimeAndFrameCount()
  if (animation_state.frameCount % 10) == 0:
    animation_state.randomiseOne()
  midground.draw(animation_state)
Пример #6
0
########################################################################
ShaderTypes()

mykeys = pi3d.Keyboard()

perspectiveCamera = pi3d.Camera(is_3d=True)
#perspectiveCamera.rotateX(-5)
#perspectiveCamera.rotateY(35)

box = SimpleCube(perspectiveCamera)
points = SimplePoints(perspectiveCamera)
sphere = SimpleSphere(perspectiveCamera)
foreground = box
background = Background(perspectiveCamera)

animation_state = AnimationState()

if MASTER:
    #### server process and queue
    app = Flask(__name__)
    queue_down = Queue()  # from main animation loop TO flask server
    queue_up = Queue()  # flask server TO animation
    STATE = {}  # copy of animation state in the flask subprocess
    IPLIST = {}  # to keep track of which requests need full update

    @app.route("/")
    def hello():
        """ default return a basic js page for interacting with the
    animation
    """
        templateData = {'fields': fields}
Пример #7
0
counter = [None] * 5
counter[0] = 0

DISPLAY = pi3d.Display.create(frames_per_second=30)

ShaderTypes()

mykeys = pi3d.Keyboard()

perspectiveCamera = pi3d.Camera(is_3d=True)
ortographicCamera = pi3d.Camera(is_3d=False)

box = GeometryTypeSimpleCube(perspectiveCamera)
background = Background(perspectiveCamera)

animation_state = AnimationState()
midground = Midground()

writeState = 0  # waiting / sliding in / blink-in / showing / blinkout / sliding out
startSlideInMs = 0
startBlinkInMS = 0
startShowInMS = 0
startBlinkOutMS = 0
startSlideOutMS = 0

while DISPLAY.loop_running():

    animation_state.updateTimeAndFrameCount()
    if (animation_state.frameCount % 10) == 0:
        animation_state.randomiseOne()
    midground.draw(animation_state)
Пример #8
0
########################################################################
ShaderTypes()

mykeys = pi3d.Keyboard()

perspectiveCamera = pi3d.Camera(is_3d=True)
#perspectiveCamera.rotateX(-5)
#perspectiveCamera.rotateY(35)

box = SimpleCube(perspectiveCamera)
points = SimplePoints(perspectiveCamera)
sphere = SimpleSphere(perspectiveCamera)
foreground = box
background = Background(perspectiveCamera)

animation_state = AnimationState()

if MASTER:
  #### server process and queue
  app = Flask(__name__)
  queue_down = Queue() # from main animation loop TO flask server
  queue_up = Queue()   # flask server TO animation
  STATE = {} # copy of animation state in the flask subprocess
  IPLIST = {} # to keep track of which requests need full update

  @app.route("/")
  def hello():
    """ default return a basic js page for interacting with the
    animation
    """
    templateData = {'fields': fields}