def step( self, dt ): """Updates our scene and triggers the on_draw event. This is scheduled in our __init__ method and called periodically by pyglet's event callbacks. We need to manually call 'on_draw' as we patched it our of pyglets event loop when we patched it out with pygly.monkey_patch. Because we called 'on_draw', we also need to perform the buffer flip at the end. """ # setup the scene # rotate the scene nodes about their vertical axis self.grid_root.transform.object.rotate_y( dt * 0.2 ) # this will trigger the draw event and buffer flip CoreApplication.step( self, dt ) if self.time_accumulator == 0.0: self.mesh_node.mesh.set_skeleton( self.frames[ self.frame ] ) self.mesh_node.skeleton.set_skeleton( self.frames[ self.frame ] ) self.time_accumulator += dt if self.time_accumulator > self.time_per_frame: self.time_accumulator = 0.0 self.frame += 1 self.frame %= len( self.frames )
def step(self, dt): """Updates our scene and triggers the on_draw event. This is scheduled in our __init__ method and called periodically by pyglet's event callbacks. We need to manually call 'on_draw' as we patched it our of pyglets event loop when we patched it out with pygly.monkey_patch. Because we called 'on_draw', we also need to perform the buffer flip at the end. """ # setup the scene # rotate the scene nodes about their vertical axis self.grid_root.transform.object.rotate_y(dt * 0.2) # update our frame rates self.frame_rate[:] = [ mesh_node.mesh.frame_rate for mesh_node in self.renderables ] # increment our frame #self.frames += dt * fps self.frames += dt * self.frame_rate numpy.mod(self.frames, self.renderables[0].mesh.num_frames, self.frames) # print the animation name of the first mesh curr_anim = self.renderables[0].mesh.animation if self.animation != curr_anim: self.animation = curr_anim print 'Curren animation:', self.animation # this will trigger the draw event and buffer flip CoreApplication.step(self, dt)
def step(self, dt): """Updates our scene and triggers the on_draw event. This is scheduled in our __init__ method and called periodically by pyglet's event callbacks. We need to manually call 'on_draw' as we patched it our of pyglets event loop when we patched it out with pygly.monkey_patch. Because we called 'on_draw', we also need to perform the buffer flip at the end. """ # setup the scene # rotate the scene nodes about their vertical axis self.grid_root.transform.object.rotate_y(dt * 0.2) # update our frame rates frame_rate = self.mesh_node.mesh.frame_rate # increment our frame self.mesh_node.mesh.interpolation += dt * frame_rate # calculate the current and next frame # and the blending fraction fraction, whole = math.modf(self.mesh_node.mesh.interpolation) whole = int(whole) # check if we're moving to the next keyframe if whole > 0: # ensure fraction remains < 1.0 self.mesh_node.mesh.interpolation = fraction # increment our frames self.mesh_node.mesh.frame_1 += whole self.mesh_node.mesh.frame_2 += whole # get the animation's start and end frame start, end = self.mesh_node.mesh.animation_start_end_frame( self.animation) num_frames = self.mesh_node.mesh.num_frames if start >= num_frames: start = num_frames end = num_frames print 'Animation has insufficient frames' elif end >= num_frames: end = num_frames print 'Animation has insufficient frames' # ensure we don't go outside the animation animation_size = (end - start) + 1 if self.mesh_node.mesh.frame_1 > end: self.mesh_node.mesh.frame_1 -= animation_size if self.mesh_node.mesh.frame_2 > end: self.mesh_node.mesh.frame_2 -= animation_size # this will trigger the draw event and buffer flip CoreApplication.step(self, dt)
def step(self, dt): """Updates our scene and triggers the on_draw event. This is scheduled in our __init__ method and called periodically by pyglet's event callbacks. We need to manually call 'on_draw' as we patched it our of pyglets event loop when we patched it out with pygly.monkey_patch. Because we called 'on_draw', we also need to perform the buffer flip at the end. """ # setup the scene # rotate the scene nodes about their vertical axis self.grid_root.transform.object.rotate_y(dt * 0.2) # this will trigger the draw event and buffer flip CoreApplication.step(self, dt)