def apply_distance_events(distance_events, ground_following): distance_events.DistanceToGround.connect_from(ground_following.DistanceToGround) distance_events.smaller_than(0.013, "jump_fwd_loop", AnimationConfig("jump_fwd_preland", False), 0.1) distance_events.smaller_than(0.01, "jump_bwd_loop", AnimationConfig("jump_bwd_preland", False), 0.1) distance_events.smaller_than(0.01, "jump_lt_loop", AnimationConfig("jump_lt_preland", False), 0.1) distance_events.smaller_than(0.01, "jump_rt_loop", AnimationConfig("jump_rt_preland", False), 0.1) distance_events.smaller_than(0.012, "jump_loop", AnimationConfig("jump_preland", False), 0.1) distance_events.smaller_than(0.008, "jump_preland", AnimationConfig("jump_land", False), 0.1) distance_events.smaller_than(0.008, "jump_fwd_preland", AnimationConfig("jump_fwd_land", False), 0.25) distance_events.smaller_than(0.008, "jump_bwd_preland", AnimationConfig("jump_bwd_land", False), 0.25) distance_events.smaller_than(0.008, "jump_lt_preland", AnimationConfig("jump_lt_land", False), 0.25) distance_events.smaller_than(0.008 , "jump_rt_preland", AnimationConfig("jump_rt_land", False), 0.25)
def apply_character_control_settings_mixamo(character_control, device_sensor = None): # optional / additional xbox controller settings: if device_sensor != None: character_control.XBOX_X.connect_from(device_sensor.Value0) character_control.XBOX_Y.connect_from(device_sensor.Value1) character_control.XBOX_BTN_A.connect_from(device_sensor.Button2) character_control.XBOX_BTN_X.connect_from(device_sensor.Button0) character_control.xbox_override_key(character_control.XBOX_Y,83,0.1) character_control.xbox_override_key(character_control.XBOX_Y,87,-0.1,-1.0) character_control.xbox_override_key(character_control.XBOX_X,68,0.1) character_control.xbox_override_key(character_control.XBOX_X,65,-0.1,-1.0) character_control.xbox_override_key(character_control.XBOX_BTN_A,32) character_control.xbox_override_key(character_control.XBOX_BTN_X,67) character_control.xbox_animation_speed(character_control.XBOX_Y,"run_fwd") # A character_control.bind_rotation(65, "run_fwd", avango.gua.Vec4(4.0, 0.0, 1.0,0.0)) character_control.bind_rotation(65, "idle", avango.gua.Vec4(4.0, 0.0, 1.0,0.0)) # D character_control.bind_rotation(68, "run_fwd", avango.gua.Vec4(-4.0, 0.0, 1.0,0.0)) character_control.bind_rotation(68, "idle", avango.gua.Vec4(-4.0, 0.0, 1.0,0.0)) # W character_control.on_key_down(87, "idle", AnimationConfig("run_fwd")) character_control.on_key_up(87, "run_fwd", AnimationConfig("idle")) # SPACE BAR character_control.on_key_down(32, "idle", AnimationConfig("jump", False),0.1) character_control.on_key_down(32, "run_fwd", AnimationConfig("jump_fwd", False, 1.0, 0.6),0.1) # animation dependend translations: character_control.bind_translation("run_fwd",avango.gua.Vec3(0.0,0.0,0.00125)) character_control.bind_translation("jump_fwd",avango.gua.Vec3(0.0, 0.0015, 0.001)) character_control.bind_translation("run_fwd_fall",avango.gua.Vec3(0.0, 0.0, 0.001)) character_control.on_animation_end("jump",AnimationConfig("idle")) character_control.on_animation_end("jump_fwd",AnimationConfig("run_fwd_fall", True, 1.0, 0.5)) character_control.on_animation_end("run_fwd_fall",AnimationConfig("idle"))
def start(): # setup scenegraph graph = avango.gua.nodes.SceneGraph(Name="scenegraph") #environment: tri_mesh_loader = avango.gua.nodes.TriMeshLoader() path_plane = "/opt/project_animation/demo/data/objects/cube2.obj" flags_plane = avango.gua.LoaderFlags.NORMALIZE_POSITION \ | avango.gua.LoaderFlags.NORMALIZE_SCALE \ | avango.gua.LoaderFlags.OPTIMIZE_GEOMETRY \ | avango.gua.LoaderFlags.MAKE_PICKABLE \ | avango.gua.LoaderFlags.LOAD_MATERIALS plane = tri_mesh_loader.create_geometry_from_file("cube", path_plane, flags_plane) plane.Transform.value *= \ avango.gua.make_scale_mat(10.0, 0.01, 10.0) * \ avango.gua.make_trans_mat(0, -3, 0) path_normal = "/opt/project_animation/demo/data/objects/glass_2_3_nm.TGA" plane.Material.value.set_uniform("NormalMap", path_normal) sunlight = \ avango.gua.nodes.LightNode( Type=avango.gua.LightType.SUN, Name="light", Color=avango.gua.Color(245.0/255.0, 246.0/255.0, 178.0/255.0), Brightness=5.0, Transform=(avango.gua.make_rot_mat(119.5, 0.0, 1.0, 0.0) * avango.gua.make_rot_mat(-10, 1.0, 0.0, 0.0)) ) #view setup: size = avango.gua.Vec2ui(2560, 1440) window = avango.gua.nodes.GlfwWindow(Size=size, LeftResolution=size) window.CursorMode.value = 2 window.EnableFullscreen.value = False cam = avango.gua.nodes.CameraNode(LeftScreenPath="/screen", SceneGraph="scenegraph", Resolution=size, OutputWindowName="window") #render pipeline pipeline_description = avango.gua.nodes.PipelineDescription(Passes=[ avango.gua.nodes.TriMeshPassDescription(), avango.gua.nodes.LightVisibilityPassDescription(), avango.gua.skelanim.nodes.SkeletalAnimationPassDescription(), avango.gua.nodes.ResolvePassDescription(), avango.gua.nodes.SSAAPassDescription(), ]) pipeline_description.Passes.value[3].EnableSSAO.value = True pipeline_description.Passes.value[3].SSAORadius.value = 2.0 pipeline_description.Passes.value[3].SSAOIntensity.value = 2.0 pipeline_description.Passes.value[3].BackgroundMode.value = 1 pipeline_description.Passes.value[3].BackgroundTexture.value = \ "/opt/guacamole/resources/skymaps/skymap.jpg" pipeline_description.Passes.value[3].ToneMappingMode.value = \ avango.gua.ToneMappingMode.LINEAR #pipeline_description.EnableABuffer.value = True cam.PipelineDescription.value = pipeline_description cam.Transform.value = avango.gua.make_trans_mat(0.0, 0.0, 0.4) cam.FarClip.value = 300 cam.NearClip.value = 0.01 screen = avango.gua.nodes.ScreenNode(Name="screen", Width=0.8, Height=0.45) screen.Children.value = [cam] screen.Transform.value = avango.gua.make_trans_mat(0, 0.1, -2) graph.Root.value.Children.value = [screen, plane, sunlight] avango.gua.register_window("window", window) #setup viewer viewer = avango.gua.nodes.Viewer() viewer.SceneGraphs.value = [graph] viewer.Windows.value = [window] window.CursorMode.value = avango.gua.CursorMode.DISABLED #XBOX Controller device_sensor = avango.daemon.nodes.DeviceSensor( DeviceService=avango.daemon.DeviceService()) device_sensor.Station.value = "device-xbox-1" #mixamo character skel_mesh_loader = avango.gua.skelanim.nodes.SkeletalAnimationLoader() #scenegraph setup: #root -> kachujin_ground -> kachujin_nav -> kachujin # ground following character control geometry kachujin_ground = avango.gua.nodes.TransformNode(Name="kachujin_ground") graph.Root.value.Children.value.append(kachujin_ground) kachujin_nav = avango.gua.nodes.TransformNode(Name="kachujin_nav") #set initial position of character here: #kachujin_nav.Transform.value = avango.gua.make_trans_mat(0.0, 0.0, 0.0) kachujin = skel_mesh_loader.create_geometry_from_file( "kachujin", "/opt/project_animation/Assets/Mixamo/Kachujin/Kachujin_G_Rosales.FBX", avango.gua.LoaderFlags.LOAD_MATERIALS | avango.gua.LoaderFlags.NORMALIZE_SCALE) kachujin.Transform.value = \ kachujin.Transform.value * \ avango.gua.make_rot_mat(-90.0, 1.0, 0.0, 0.0) * \ avango.gua.make_scale_mat(0.02, 0.02, 0.02) #load animations from character settings load_mixamo_animations_kachujin(kachujin) kachujin_ground.Children.value = [kachujin_nav] kachujin_nav.Children.value = [kachujin] #character control kachujin_character_control = CharacterControl() kachujin_character_control.my_constructor(kachujin, kachujin_nav, AnimationConfig("idle"), window) #override keyboard events with xbox controller events: #apply_character_control_settings_mixamo(kachujin_character_control, # device_sensor) apply_character_control_settings_mixamo(kachujin_character_control) #wall detection kachujin_character_control.activate_wall_detection(0.0075, 0.009, "idle", graph) #camera control kachujin_camera_control = CameraControl() kachujin_camera_control.my_constructor(kachujin, window, -17.0) screen.Transform.connect_from(kachujin_camera_control.OutTransform) #camera_control_xbox_connect(kachujin_camera_control, device_sensor) #ground following kachujin_ground_following = GroundFollowing(SceneGraph=graph, OffsetToGround=0.01, MaxDistanceToGround=100.0) kachujin_ground_following.my_constructor(gravity=-0.00005) kachujin_ground_following.InTransform.connect_from(kachujin.WorldTransform) kachujin_ground.Transform.connect_from( kachujin_ground_following.OutTransform) guaVE = GuaVE() guaVE.start(locals(), globals()) viewer.run()
def start(): # setup scenegraph graph = avango.gua.nodes.SceneGraph(Name="scenegraph") #environment: tri_mesh_loader = avango.gua.nodes.TriMeshLoader() path = "/opt/project_animation/demo/data/objects/cube2.obj" flags = avango.gua.LoaderFlags.NORMALIZE_POSITION \ | avango.gua.LoaderFlags.NORMALIZE_SCALE \ | avango.gua.LoaderFlags.OPTIMIZE_GEOMETRY \ | avango.gua.LoaderFlags.MAKE_PICKABLE \ | avango.gua.LoaderFlags.LOAD_MATERIALS plane = \ tri_mesh_loader.create_geometry_from_file("cube", path, flags) plane.Transform.value *= \ avango.gua.make_scale_mat(10.0, 0.01, 10.0) *\ avango.gua.make_trans_mat(0, -3, 0) path2 = "/opt/project_animation/demo/data/objects/glass_2_3_nm.TGA" plane.Material.value.set_uniform("NormalMap", path2) sunlight = avango.gua.nodes.LightNode( Type=avango.gua.LightType.SUN, Name="light", Color=avango.gua.Color(245.0/255.0, 246.0/255.0, 178.0/255.0), Brightness=5.0, Transform=(avango.gua.make_rot_mat(119.5, 0.0, 1.0, 0.0) * avango.gua.make_rot_mat(-10, 1.0, 0.0, 0.0)) ) #view setup: size = avango.gua.Vec2ui(2560, 1440) window = avango.gua.nodes.GlfwWindow( Size=size, LeftResolution=size ) window.CursorMode.value = 2 window.EnableFullscreen.value = True cam = avango.gua.nodes.CameraNode(LeftScreenPath="/screen", SceneGraph="scenegraph", Resolution=size, OutputWindowName="window") #render pipeline pipeline_description = avango.gua.nodes.PipelineDescription( Passes=[ avango.gua.nodes.TriMeshPassDescription(), avango.gua.nodes.LightVisibilityPassDescription(), avango.gua.skelanim.nodes.SkeletalAnimationPassDescription(), avango.gua.nodes.ResolvePassDescription(), avango.gua.nodes.SSAAPassDescription(), ]) pipeline_description.Passes.value[3].EnableSSAO.value = True pipeline_description.Passes.value[3].SSAORadius.value = 2.0 pipeline_description.Passes.value[3].SSAOIntensity.value = 2.0 pipeline_description.Passes.value[3].BackgroundMode.value = 1 pipeline_description.Passes.value[3].BackgroundTexture.value = \ "/opt/avango/master/examples/picking/data/textures/skymap.jpg" pipeline_description.Passes.value[3].ToneMappingMode.value = \ avango.gua.ToneMappingMode.LINEAR #pipeline_description.EnableABuffer.value = True cam.PipelineDescription.value = pipeline_description cam.Transform.value = avango.gua.make_trans_mat(0.0, 0.0, 0.4) cam.FarClip.value = 300 cam.NearClip.value = 0.01 screen = avango.gua.nodes.ScreenNode(Name="screen", Width=0.8, Height=0.45) screen.Children.value = [cam] screen.Transform.value = avango.gua.make_trans_mat(0, 0.1, -2) graph.Root.value.Children.value = [screen, plane, sunlight] avango.gua.register_window("window", window) #setup viewer viewer = avango.gua.nodes.Viewer() viewer.SceneGraphs.value = [graph] viewer.Windows.value = [window] window.CursorMode.value = avango.gua.CursorMode.DISABLED #navigation navigator = examples_common.navigator.Navigator() #navigator.StartLocation.value = screen.Transform.value.get_translate() navigator.StartRotation.value = avango.gua.Vec2(0, 790) navigator.OutTransform.connect_from(screen.Transform) navigator.RotationSpeed.value = 0.2 navigator.MotionSpeed.value = 0.004 # enable navigation screen.Transform.connect_from(navigator.OutTransform) #XBOX Controller device_sensor = avango.daemon.nodes.DeviceSensor( DeviceService=avango.daemon.DeviceService()) device_sensor.Station.value = "device-xbox-1" #unreal tournament characters skel_mesh_loader = avango.gua.skelanim.nodes.SkeletalAnimationLoader() #LOOP MODE DEMO BOB path_bob = "/opt/project_animation/Assets/UnrealTournament/Characters/" +\ "Necris_Male/necris_male_ut4_SKELMESH.FBX" flags_bob = avango.gua.LoaderFlags.LOAD_MATERIALS \ | avango.gua.LoaderFlags.NORMALIZE_SCALE bob_loop = \ skel_mesh_loader.create_geometry_from_file("bob_loop", path_bob, flags_bob) bob_loop.Transform.value = avango.gua.make_trans_mat(0.0, -0.01, 0.0) *\ bob_loop.Transform.value *\ avango.gua.make_rot_mat(-90.0, 1.0, 0.0, 0.0) *\ avango.gua.make_scale_mat(0.2, 0.2, 0.2) graph.Root.value.Children.value.append(bob_loop) #load animations path_idle = "/opt/project_animation/Assets/" + \ "UnrealTournament/UniversalAnimations/Idle_Ready_Rif.FBX" path_run = "/opt/project_animation/Assets/" + \ "UnrealTournament/UniversalAnimations/Run_Fwd_Rif.FBX" bob_loop.load_animation(path_idle, "idle") bob_loop.load_animation(path_idle, "idle2") bob_loop.load_animation(path_run, "run_fwd") bob_loop.load_animation(path_run, "run_fwd2") #character control character_control_loop = CharacterControl() character_control_loop.my_constructor(bob_loop, bob_loop, AnimationConfig("idle"), window) character_control_loop.on_animation_end("idle", AnimationConfig("run_fwd", loop=True, speed=1.0, duration=3.0)) character_control_loop.on_animation_end("run_fwd", AnimationConfig("idle2", loop=False, speed=1.0, duration=3.0)) character_control_loop.on_animation_end("idle2", AnimationConfig("run_fwd2", loop=False, speed=1.0, duration=3.0)) character_control_loop.on_animation_end("run_fwd2", AnimationConfig("idle", loop=True, speed=1.0, duration=3.0)) #SPEED DEMO BOB bob_speed = skel_mesh_loader.create_geometry_from_file("bob_speed", path_bob, flags_bob) bob_speed.Transform.value = avango.gua.make_trans_mat(0.1, -0.01, 0.0) * \ bob_speed.Transform.value * \ avango.gua.make_rot_mat(-90.0, 1.0, 0.0, 0.0) * \ avango.gua.make_scale_mat(0.2, 0.2, 0.2) graph.Root.value.Children.value.append(bob_speed) #load animations bob_speed.load_animation(path_idle, "idle") bob_speed.load_animation(path_idle, "idle2") bob_speed.load_animation(path_run, "run_fwd") bob_speed.load_animation(path_run, "run_fwd2") #character control character_control_speed = CharacterControl() character_control_speed.my_constructor(bob_speed, bob_speed, AnimationConfig("idle"), window) character_control_speed.on_animation_end("idle", AnimationConfig("run_fwd", loop=True, speed=1.0, duration=3.0)) character_control_speed.on_animation_end("run_fwd", AnimationConfig("idle2", loop=True, speed=1.5, duration=3.0)) character_control_speed.on_animation_end("idle2", AnimationConfig("run_fwd2", loop=True, speed=1.5, duration=3.0)) character_control_speed.on_animation_end("run_fwd2", AnimationConfig("idle", loop=True, speed=1.0, duration=3.0)) #DURATION DEMO BOB bob_duration = skel_mesh_loader.create_geometry_from_file("bob_duration", path_bob, flags_bob) bob_duration.Transform.value = \ avango.gua.make_trans_mat(0.2, -0.01, 0.0) * \ bob_duration.Transform.value * \ avango.gua.make_rot_mat(-90.0, 1.0, 0.0, 0.0) * \ avango.gua.make_scale_mat(0.2, 0.2, 0.2) graph.Root.value.Children.value.append(bob_duration) #load animations bob_duration.load_animation(path_idle, "idle") bob_duration.load_animation(path_idle, "idle2") bob_duration.load_animation(path_run, "run_fwd") bob_duration.load_animation(path_run, "run_fwd2") #character control character_control_duration = CharacterControl() character_control_duration.my_constructor(bob_duration, bob_duration, AnimationConfig("idle"), window) character_control_duration.on_animation_end("idle", AnimationConfig("run_fwd", loop=True, speed=1.0, duration=1.0)) character_control_duration.on_animation_end("run_fwd", AnimationConfig("idle2", loop=True, speed=1.0, duration=2.0)) character_control_duration.on_animation_end("idle2", AnimationConfig("run_fwd2", loop=True, speed=1.0, duration=2.0)) character_control_duration.on_animation_end("run_fwd2", AnimationConfig("idle", loop=True, speed=1.0, duration=1.0)) #start animation sequence character_control_loop.switch_animation(AnimationConfig("idle", loop=False)) character_control_speed.switch_animation(AnimationConfig("idle", loop=False)) character_control_duration.switch_animation(AnimationConfig("idle", loop=False)) guaVE = GuaVE() guaVE.start(locals(), globals()) viewer.run()
def activate_wall_detection(self, dir_offset, height_offset, idle_animation_name, scene_graph): self._wall_detect_offset = dir_offset self._wall_detect_height = height_offset self._wall_detect_idle = AnimationConfig(idle_animation_name) self._scene_graph = scene_graph
def start(): # setup scenegraph graph = avango.gua.nodes.SceneGraph(Name="scenegraph") #environment: tri_mesh_loader = avango.gua.nodes.TriMeshLoader() tower = tri_mesh_loader.create_geometry_from_file( "tower", "/opt/project_animation/highrise/tower.fbx", avango.gua.LoaderFlags.MAKE_PICKABLE | avango.gua.LoaderFlags.LOAD_MATERIALS) tower.Transform.value = \ tower.Transform.value * \ avango.gua.make_rot_mat(235.0, 0.0, 1.0, 0.0) environment = tri_mesh_loader.create_geometry_from_file( "environment", "/opt/project_animation/highrise/environment.fbx", avango.gua.LoaderFlags.MAKE_PICKABLE | avango.gua.LoaderFlags.LOAD_MATERIALS) environment.Transform.value = \ environment.Transform.value * \ avango.gua.make_scale_mat(0.1) * \ avango.gua.make_rot_mat(235.0, 0.0, 1.0, 0.0) sunlight = avango.gua.nodes.LightNode( Type=avango.gua.LightType.SUN, Name="light", Color=avango.gua.Color(245.0 / 255.0, 246.0 / 255.0, 178.0 / 255.0), Brightness=5.0, Transform=(avango.gua.make_rot_mat(119.5, 0.0, 1.0, 0.0) * avango.gua.make_rot_mat(-10, 1.0, 0.0, 0.0))) #view setup: size = avango.gua.Vec2ui(2560, 1440) window = avango.gua.nodes.GlfwWindow(Size=size, LeftResolution=size) window.CursorMode.value = 2 window.EnableFullscreen.value = True def handle_key(ascii, unknown, event, unknown2): global character_controls global ground_followings if (ascii == 82 and event == 1 and len(character_controls) > 0 and len(ground_followings) > 0): character_controls[current_character].reset_transform() ground_followings[current_character].reset_transform() if ascii == 257 and event == 1: next_character() window.on_key_press(handle_key) cam = avango.gua.nodes.CameraNode(LeftScreenPath="/screen", SceneGraph="scenegraph", Resolution=size, OutputWindowName="window") #render pipeline pipeline_description = avango.gua.nodes.PipelineDescription(Passes=[ avango.gua.nodes.TriMeshPassDescription(), avango.gua.nodes.LightVisibilityPassDescription(), avango.gua.skelanim.nodes.SkeletalAnimationPassDescription(), avango.gua.nodes.ResolvePassDescription(), avango.gua.nodes.SSAAPassDescription(), ]) pipeline_description.Passes.value[3].EnableSSAO.value = True pipeline_description.Passes.value[3].SSAORadius.value = 2.0 pipeline_description.Passes.value[3].SSAOIntensity.value = 2.0 pipeline_description.Passes.value[3].BackgroundMode.value = 1 pipeline_description.Passes.value[3].BackgroundTexture.value = \ "/opt/avango/master/examples/picking/data/textures/skymap.jpg" pipeline_description.Passes.value[3].ToneMappingMode.value = \ avango.gua.ToneMappingMode.LINEAR #pipeline_description.EnableABuffer.value = True cam.PipelineDescription.value = pipeline_description cam.Transform.value = avango.gua.make_trans_mat(0.0, 0.0, 0.4) cam.FarClip.value = 300 cam.NearClip.value = 0.01 global screen screen = avango.gua.nodes.ScreenNode(Name="screen", Width=0.8, Height=0.45) screen.Children.value = [cam] screen.Transform.value = avango.gua.make_trans_mat(0, 0.1, -2) graph.Root.value.Children.value = [screen, tower, environment, sunlight] avango.gua.register_window("window", window) #setup viewer viewer = avango.gua.nodes.Viewer() viewer.SceneGraphs.value = [graph] viewer.Windows.value = [window] window.CursorMode.value = avango.gua.CursorMode.DISABLED # XBOX Controller global device_sensor device_sensor = avango.daemon.nodes.DeviceSensor( DeviceService=avango.daemon.DeviceService()) device_sensor.Station.value = "device-xbox-1" xbox_listener = XBOX_Listener() xbox_listener.XBOX_BTN_B.connect_from(device_sensor.Button1) xbox_listener.XBOX_BTN_Y.connect_from(device_sensor.Button3) #unreal tournament character skel_mesh_loader = avango.gua.skelanim.nodes.SkeletalAnimationLoader() # #scenegraph setup: # #root -> bob_ground -> bob_nav -> bob # # ground following character control geometry # bob_ground = avango.gua.nodes.TransformNode(Name="bob_ground") # graph.Root.value.Children.value.append(bob_ground) # bob_nav = avango.gua.nodes.TransformNode(Name="bob_nav") # #set initial position of character here: # #bob_nav.Transform.value = avango.gua.make_trans_mat(0.0,0.05,0.0) # bob = skel_mesh_loader.create_geometry_from_file( # "bob", # "/opt/project_animation/Assets/UnrealTournament/Characters/" + # "Necris_Male/necris_male_ut4_SKELMESH.FBX", # avango.gua.LoaderFlags.LOAD_MATERIALS # | avango.gua.LoaderFlags.NORMALIZE_SCALE) # bob.Transform.value = \ # bob.Transform.value * \ # avango.gua.make_rot_mat(-90.0, 1.0, 0.0, 0.0) * \ # avango.gua.make_scale_mat(0.02, 0.02, 0.02) # #load animations from character settings # load_unreal_animations1(bob) # bob_ground.Children.value = [bob_nav] # bob_nav.Children.value = [bob] # #character control # character_control = CharacterControl() # character_control.my_constructor(bob, bob_nav, # AnimationConfig("idle"), window) # #override keyboard events with xbox controller events: # #apply_character_control_settings1(character_control, device_sensor) # apply_character_control_settings1(character_control) # #wall detection # character_control.activate_wall_detection(0.0075, 0.009, "idle", graph) # character_controls.append(character_control) # #camera control # camera_control = CameraControl() # camera_control.my_constructor(bob, window, -17.0) # camera_controls.append(camera_control) # #ground following # ground_following = GroundFollowing( # SceneGraph=graph, # OffsetToGround=0.01, # MaxDistanceToGround=100.0 # ) # ground_following.my_constructor(gravity=-0.000075) # ground_following.InTransform.connect_from(bob.WorldTransform) # ground_followings.append(ganfault_ground_following) # bob_ground.Transform.connect_from(ground_following.OutTransform) # graph.Root.value.Children.value.append(bob_ground) # #distance events # distance_events = DistanceEvents() # distance_events.my_constructor(character_control) # apply_distance_events(distance_events, ground_following) ganfault_nav = avango.gua.nodes.TransformNode(Name="ganfault_nav") ganfault_ground = avango.gua.nodes.TransformNode(Name="ganfault_ground") ganfault = skel_mesh_loader.create_geometry_from_file( "ganfault", "/opt/project_animation/Assets/Mixamo/" + "Ganfault/Mixamo_Ganfault_Aure.FBX", avango.gua.LoaderFlags.LOAD_MATERIALS | avango.gua.LoaderFlags.NORMALIZE_SCALE) ganfault.Transform.value = \ ganfault.Transform.value * \ avango.gua.make_rot_mat(-90.0, 1.0, 0.0, 0.0) * \ avango.gua.make_scale_mat(0.02, 0.02, 0.02) load_mixamo_animations_ganfault(ganfault) ganfault_nav.Transform.value = \ ganfault_nav.Transform.value * \ avango.gua.make_trans_mat(-0.26, 0.012, 0.376) ganfault_ground.Children.value = [ganfault_nav] ganfault_nav.Children.value = [ganfault] ganfault_character_control = CharacterControl() ganfault_character_control.my_constructor(ganfault, ganfault_nav, AnimationConfig("idle"), window) #apply_character_control_settings_mixamo(ganfault_character_control, # device_sensor) apply_character_control_settings_mixamo(ganfault_character_control) character_controls.append(ganfault_character_control) #ganfault_character_control.listen_keyboard(False) ganfault_character_control.activate_wall_detection(0.0075, 0.009, "idle", graph) ganfault_camera_control = CameraControl() ganfault_camera_control.my_constructor(ganfault, window, -17.0) camera_controls.append(ganfault_camera_control) #ganfault_camera_control.listen_mouse(False) ganfault_ground_following = GroundFollowing(SceneGraph=graph, OffsetToGround=0.01, MaxDistanceToGround=100.0) ganfault_ground_following.my_constructor(gravity=-0.000075) ganfault_ground_following.InTransform.connect_from(ganfault.WorldTransform) ganfault_ground.Transform.connect_from( ganfault_ground_following.OutTransform) ground_followings.append(ganfault_ground_following) graph.Root.value.Children.value.append(ganfault_ground) kachujin_nav = avango.gua.nodes.TransformNode(Name="kachujin_nav") kachujin_ground = avango.gua.nodes.TransformNode(Name="kachujin_ground") kachujin = skel_mesh_loader.create_geometry_from_file( "kachujin", "/opt/project_animation/Assets/Mixamo/Kachujin/Kachujin_G_Rosales.FBX", avango.gua.LoaderFlags.LOAD_MATERIALS | avango.gua.LoaderFlags.NORMALIZE_SCALE) kachujin.Transform.value = \ kachujin.Transform.value * \ avango.gua.make_rot_mat(-90.0, 1.0, 0.0, 0.0) * \ avango.gua.make_scale_mat(0.02, 0.02, 0.02) load_mixamo_animations_kachujin(kachujin) kachujin_nav.Transform.value = \ kachujin_nav.Transform.value * \ avango.gua.make_trans_mat(-0.576, 0.087, 0.813) kachujin_ground.Children.value = [kachujin_nav] kachujin_nav.Children.value = [kachujin] kachujin_character_control = CharacterControl() kachujin_character_control.my_constructor(kachujin, kachujin_nav, AnimationConfig("idle"), window) apply_character_control_settings_mixamo(kachujin_character_control) #apply_character_control_settings_mixamo(kachujin_character_control, # device_sensor) character_controls.append(kachujin_character_control) kachujin_character_control.listen_keyboard(False) kachujin_character_control.activate_wall_detection(0.0075, 0.009, "idle", graph) kachujin_camera_control = CameraControl() kachujin_camera_control.my_constructor(kachujin, window, -17.0) camera_controls.append(kachujin_camera_control) kachujin_camera_control.listen_mouse(False) kachujin_ground_following = GroundFollowing(SceneGraph=graph, OffsetToGround=0.01, MaxDistanceToGround=100.0) kachujin_ground_following.my_constructor(gravity=-0.000075) kachujin_ground_following.InTransform.connect_from(kachujin.WorldTransform) kachujin_ground.Transform.connect_from( kachujin_ground_following.OutTransform) ground_followings.append(kachujin_ground_following) graph.Root.value.Children.value.append(kachujin_ground) maria_nav = avango.gua.nodes.TransformNode(Name="maria_nav") maria_ground = avango.gua.nodes.TransformNode(Name="maria_ground") maria = skel_mesh_loader.create_geometry_from_file( "maria", "/opt/project_animation/Assets/Mixamo/Maria/Maximo_Maria.FBX", avango.gua.LoaderFlags.LOAD_MATERIALS | avango.gua.LoaderFlags.NORMALIZE_SCALE) maria.Transform.value = \ maria.Transform.value * \ avango.gua.make_rot_mat(-90.0, 1.0, 0.0, 0.0) * \ avango.gua.make_scale_mat(0.02, 0.02, 0.02) load_mixamo_animations_maria(maria) maria_nav.Transform.value = \ maria_nav.Transform.value * \ avango.gua.make_trans_mat(-0.927, 0.0762, 0.127) maria_ground.Children.value = [maria_nav] maria_nav.Children.value = [maria] maria_character_control = CharacterControl() maria_character_control.my_constructor(maria, maria_nav, AnimationConfig("idle"), window) apply_character_control_settings_mixamo(maria_character_control) #apply_character_control_settings_mixamo(maria_character_control, # device_sensor) character_controls.append(maria_character_control) maria_character_control.listen_keyboard(False) maria_character_control.activate_wall_detection(0.0075, 0.009, "idle", graph) maria_camera_control = CameraControl() maria_camera_control.my_constructor(maria, window, -17.0) camera_controls.append(maria_camera_control) maria_camera_control.listen_mouse(False) maria_ground_following = GroundFollowing(SceneGraph=graph, OffsetToGround=0.01, MaxDistanceToGround=100.0) maria_ground_following.my_constructor(gravity=-0.000075) maria_ground_following.InTransform.connect_from(maria.WorldTransform) maria_ground.Transform.connect_from(maria_ground_following.OutTransform) ground_followings.append(maria_ground_following) graph.Root.value.Children.value.append(maria_ground) maw_nav = avango.gua.nodes.TransformNode(Name="maw_nav") maw_ground = avango.gua.nodes.TransformNode(Name="maw_ground") maw = skel_mesh_loader.create_geometry_from_file( "maw", "/opt/project_animation/Assets/Mixamo/Maw/Maw_J_Laygo.FBX", avango.gua.LoaderFlags.LOAD_MATERIALS | avango.gua.LoaderFlags.NORMALIZE_SCALE) maw.Transform.value = \ maw.Transform.value * \ avango.gua.make_rot_mat(-90.0, 1.0, 0.0, 0.0) * \ avango.gua.make_scale_mat(0.04, 0.04, 0.04) load_mixamo_animations_maw(maw) maw_nav.Transform.value = \ maw_nav.Transform.value * \ avango.gua.make_trans_mat(-0.05, 0.055, 0.081) maw_ground.Children.value = [maw_nav] maw_nav.Children.value = [maw] maw_character_control = CharacterControl() maw_character_control.my_constructor(maw, maw_nav, AnimationConfig("idle"), window) apply_character_control_settings_mixamo(maw_character_control) #apply_character_control_settings_mixamo(maw_character_control, # device_sensor) character_controls.append(maw_character_control) maw_character_control.listen_keyboard(False) maw_character_control.activate_wall_detection(0.0075, 0.009, "idle", graph) maw_camera_control = CameraControl() maw_camera_control.my_constructor(maw, window, -9.0) camera_controls.append(maw_camera_control) maw_camera_control.listen_mouse(False) maw_ground_following = GroundFollowing(SceneGraph=graph, OffsetToGround=0.01, MaxDistanceToGround=100.0) maw_ground_following.my_constructor(gravity=-0.000075) maw_ground_following.InTransform.connect_from(maw.WorldTransform) maw_ground.Transform.connect_from(maw_ground_following.OutTransform) ground_followings.append(maw_ground_following) graph.Root.value.Children.value.append(maw_ground) vampire_nav = avango.gua.nodes.TransformNode(Name="vampire_nav") vampire_ground = avango.gua.nodes.TransformNode(Name="vampire_ground") vampire = skel_mesh_loader.create_geometry_from_file( "vampire", "/opt/project_animation/Assets/Mixamo/Vampire/Vampire_A_Lusth.FBX", avango.gua.LoaderFlags.LOAD_MATERIALS | avango.gua.LoaderFlags.NORMALIZE_SCALE) vampire.Transform.value = \ vampire.Transform.value * \ avango.gua.make_rot_mat(-90.0, 1.0, 0.0, 0.0) * \ avango.gua.make_scale_mat(0.02, 0.02, 0.02) load_mixamo_animations_vampire(vampire) vampire_nav.Transform.value = \ vampire_nav.Transform.value * \ avango.gua.make_trans_mat(0.163, 0.077, 0.992) vampire_ground.Children.value = [vampire_nav] vampire_nav.Children.value = [vampire] vampire_character_control = CharacterControl() vampire_character_control.my_constructor(vampire, vampire_nav, AnimationConfig("idle"), window) apply_character_control_settings_mixamo(vampire_character_control) #apply_character_control_settings_mixamo(vampire_character_control, # device_sensor) character_controls.append(vampire_character_control) vampire_character_control.listen_keyboard(False) vampire_character_control.activate_wall_detection(0.0075, 0.009, "idle", graph) vampire_camera_control = CameraControl() vampire_camera_control.my_constructor(vampire, window, -17.0) camera_controls.append(vampire_camera_control) vampire_camera_control.listen_mouse(False) vampire_ground_following = GroundFollowing(SceneGraph=graph, OffsetToGround=0.01, MaxDistanceToGround=100.0) vampire_ground_following.my_constructor(gravity=-0.000075) vampire_ground_following.InTransform.connect_from(vampire.WorldTransform) vampire_ground.Transform.connect_from( vampire_ground_following.OutTransform) ground_followings.append(vampire_ground_following) graph.Root.value.Children.value.append(vampire_ground) if len(camera_controls) > 0: camera_control_xbox_connect(camera_controls[0], device_sensor) screen.Transform.connect_from(camera_controls[0].OutTransform) guaVE = GuaVE() guaVE.start(locals(), globals()) viewer.run()
def apply_character_control_settings2(character_control, device_sensor = None): # optional / additional xbox controller settings: if device_sensor != None: character_control.XBOX_X.connect_from(device_sensor.Value0) character_control.XBOX_Y.connect_from(device_sensor.Value1) character_control.XBOX_BTN_A.connect_from(device_sensor.Button2) character_control.XBOX_BTN_X.connect_from(device_sensor.Button0) character_control.xbox_override_key(character_control.XBOX_Y,83,0.1) character_control.xbox_override_key(character_control.XBOX_Y,87,-0.1,-1.0) character_control.xbox_override_key(character_control.XBOX_X,68,0.1) character_control.xbox_override_key(character_control.XBOX_X,65,-0.1,-1.0) character_control.xbox_override_key(character_control.XBOX_BTN_A,32) character_control.xbox_override_key(character_control.XBOX_BTN_X,67) character_control.xbox_animation_speed(character_control.XBOX_Y,"run_fwd") character_control.xbox_animation_speed(character_control.XBOX_Y,"run_bwd") character_control.xbox_animation_speed(character_control.XBOX_X,"run_lt") character_control.xbox_animation_speed(character_control.XBOX_X,"run_rt") character_control.xbox_animation_speed(character_control.XBOX_Y,"crouch_fwd") character_control.xbox_animation_speed(character_control.XBOX_Y,"crouch_bwd") character_control.xbox_animation_speed(character_control.XBOX_X,"crouch_lt") character_control.xbox_animation_speed(character_control.XBOX_X,"crouch_rt") # A character_control.bind_transformation(65, "run_fwd", avango.gua.make_rot_mat(4.0, 0.0, 1.0,0.0)) character_control.bind_transformation(65, "run_bwd", avango.gua.make_rot_mat(4.0, 0.0, 1.0,0.0)) character_control.bind_transformation(65, "crouch_fwd", avango.gua.make_rot_mat(2.0, 0.0, 1.0,0.0)) character_control.bind_transformation(65, "crouch_bwd", avango.gua.make_rot_mat(2.0, 0.0, 1.0,0.0)) character_control.on_key_down(65, "idle", AnimationConfig("run_lt")) character_control.on_key_up(65, "run_lt", AnimationConfig("idle")) character_control.on_key_down(65, "crouch", AnimationConfig("crouch_lt")) character_control.on_key_up(65, "crouch_lt", AnimationConfig("crouch")) # D character_control.bind_transformation(68, "run_fwd", avango.gua.make_rot_mat(-4.0, 0.0, 1.0,0.0)) character_control.bind_transformation(68, "run_bwd", avango.gua.make_rot_mat(-4.0, 0.0, 1.0,0.0)) character_control.bind_transformation(68, "crouch_fwd", avango.gua.make_rot_mat(-2.0, 0.0, 1.0,0.0)) character_control.bind_transformation(68, "crouch_bwd", avango.gua.make_rot_mat(-2.0, 0.0, 1.0,0.0)) character_control.on_key_down(68, "idle", AnimationConfig("run_rt")) character_control.on_key_up(68, "run_rt", AnimationConfig("idle")) character_control.on_key_down(68, "crouch", AnimationConfig("crouch_rt")) character_control.on_key_up(68, "crouch_rt", AnimationConfig("crouch")) # W character_control.on_key_down(87, "idle", AnimationConfig("run_fwd")) character_control.on_key_up(87, "run_fwd", AnimationConfig("idle")) character_control.on_key_down(87, "crouch", AnimationConfig("crouch_fwd")) character_control.on_key_up(87, "crouch_fwd", AnimationConfig("crouch")) character_control.bind_transformation(87, "run_rt", avango.gua.make_trans_mat(0.0,0.0,0.0005)) character_control.bind_transformation(87, "run_lt", avango.gua.make_trans_mat(0.0,0.0,0.0005)) character_control.bind_transformation(87, "crouch_rt", avango.gua.make_trans_mat(0.0,0.0,0.00035)) character_control.bind_transformation(87, "crouch_lt", avango.gua.make_trans_mat(0.0,0.0,0.00035)) # S character_control.on_key_down(83, "idle", AnimationConfig("run_bwd")) character_control.on_key_up(83, "run_bwd", AnimationConfig("idle")) character_control.on_key_down(83, "crouch", AnimationConfig("crouch_bwd")) character_control.on_key_up(83, "crouch_bwd", AnimationConfig("crouch")) character_control.bind_transformation(83, "run_rt", avango.gua.make_trans_mat(0.0,0.0,-0.0005)) character_control.bind_transformation(83, "run_lt", avango.gua.make_trans_mat(0.0,0.0,-0.0005)) character_control.bind_transformation(83, "crouch_rt", avango.gua.make_trans_mat(0.0,0.0,-0.00035)) character_control.bind_transformation(83, "crouch_lt", avango.gua.make_trans_mat(0.0,0.0,-0.00035)) # C character_control.on_key_down(67, "idle", AnimationConfig("crouch"),0.2) character_control.on_key_up(67, "crouch", AnimationConfig("idle"),0.4) character_control.on_key_down(67, "run_fwd", AnimationConfig("crouch_fwd")) character_control.on_key_up(67, "crouch_fwd", AnimationConfig("run_fwd")) character_control.on_key_down(67, "run_bwd", AnimationConfig("crouch_bwd")) character_control.on_key_up(67, "crouch_bwd", AnimationConfig("run_bwd")) character_control.on_key_down(67, "run_lt", AnimationConfig("crouch_lt")) character_control.on_key_up(67, "crouch_lt", AnimationConfig("run_lt")) character_control.on_key_down(67, "run_rt", AnimationConfig("crouch_rt")) character_control.on_key_up(67, "crouch_rt", AnimationConfig("run_rt")) # F character_control.on_key_down(70, "idle", AnimationConfig("taunt1")) character_control.on_key_up(70, "taunt1", AnimationConfig("idle")) # G character_control.on_key_down(71, "idle", AnimationConfig("taunt2")) character_control.on_key_up(71, "taunt2", AnimationConfig("idle")) # H character_control.on_key_down(72, "idle", AnimationConfig("taunt3")) character_control.on_key_up(72, "taunt3", AnimationConfig("idle")) # J character_control.on_key_down(74, "idle", AnimationConfig("taunt4")) character_control.on_key_up(74, "taunt4", AnimationConfig("idle")) # K character_control.on_key_down(75, "idle", AnimationConfig("taunt5")) character_control.on_key_up(75, "taunt5", AnimationConfig("idle")) # L character_control.on_key_down(76, "idle", AnimationConfig("taunt6")) character_control.on_key_up(76, "taunt6", AnimationConfig("idle")) # SPACE BAR character_control.on_key_down(32, "idle", AnimationConfig("jump", False),0.1) character_control.on_key_down(32, "run_fwd", AnimationConfig("jump_fwd", False, 1.5),0.25) character_control.on_key_down(32, "run_bwd", AnimationConfig("jump_bwd", False),0.25) character_control.on_key_down(32, "run_lt", AnimationConfig("jump_lt", False),0.25) character_control.on_key_down(32, "run_rt", AnimationConfig("jump_rt", False),0.25) # animation dependend translations: character_control.bind_translation("run_fwd",avango.gua.Vec3(0.0,0.0,0.001)) character_control.bind_translation("run_bwd",avango.gua.Vec3(0.0,0.0,-0.001)) character_control.bind_translation("run_lt",avango.gua.Vec3(0.001,0.0,0.0)) character_control.bind_translation("run_rt",avango.gua.Vec3(-0.001,0.0,0.0)) character_control.bind_translation("crouch_fwd",avango.gua.Vec3(0.0,0.0,0.0007)) character_control.bind_translation("crouch_bwd",avango.gua.Vec3(0.0,0.0,-0.0007)) character_control.bind_translation("crouch_lt",avango.gua.Vec3(0.0007,0.0,0.0)) character_control.bind_translation("crouch_rt",avango.gua.Vec3(-0.0007,0.0,0.0)) character_control.bind_translation("jump",avango.gua.Vec3(0.0, 0.0016, 0.0)) character_control.bind_translation("jump_loop",avango.gua.Vec3(0.0, 0.0016, 0.0)) character_control.bind_translation("jump_preland",avango.gua.Vec3(0.0, 0.0016, 0.0)) character_control.bind_translation("jump_fwd",avango.gua.Vec3(0.0, 0.0016, 0.0008)) character_control.bind_translation("jump_fwd_loop",avango.gua.Vec3(0.0, 0.0016, 0.0008)) character_control.bind_translation("jump_fwd_preland",avango.gua.Vec3(0.0, 0.0016, 0.0008)) character_control.bind_translation("jump_fwd_land",avango.gua.Vec3(0.0, 0.0, 0.0008)) character_control.bind_translation("jump_bwd",avango.gua.Vec3(0.0, 0.0016, -0.0008)) character_control.bind_translation("jump_bwd_loop",avango.gua.Vec3(0.0, 0.0016, -0.0008)) character_control.bind_translation("jump_bwd_preland",avango.gua.Vec3(0.0, 0.0016, -0.0008)) character_control.bind_translation("jump_bwd_land",avango.gua.Vec3(0.0, 0.0, -0.0008)) character_control.bind_translation("jump_lt",avango.gua.Vec3(0.0008, 0.0016, 0.0)) character_control.bind_translation("jump_lt_loop",avango.gua.Vec3(0.0008, 0.0016, 0.0)) character_control.bind_translation("jump_lt_preland",avango.gua.Vec3(0.0008, 0.0016, 0.0)) character_control.bind_translation("jump_lt_land",avango.gua.Vec3(0.0008, 0.0, 0.0)) character_control.bind_translation("jump_rt",avango.gua.Vec3(-0.0008, 0.0016, 0.0)) character_control.bind_translation("jump_rt_loop",avango.gua.Vec3(-0.0008, 0.0016, 0.0)) character_control.bind_translation("jump_rt_preland",avango.gua.Vec3(-0.0008, 0.0016, 0.0)) character_control.bind_translation("jump_rt_land",avango.gua.Vec3(-0.0008, 0.0, 0.0)) # animations only played once and followed by another one character_control.on_animation_end("jump", AnimationConfig("jump_loop"),0.1) character_control.on_animation_end("jump_fwd", AnimationConfig("jump_fwd_loop"),0.1) character_control.on_animation_end("jump_bwd", AnimationConfig("jump_bwd_loop"),0.1) character_control.on_animation_end("jump_lt", AnimationConfig("jump_lt_loop"),0.1) character_control.on_animation_end("jump_rt", AnimationConfig("jump_rt_loop"),0.1) character_control.on_animation_end("jump_land", AnimationConfig("idle"),0.25) character_control.on_animation_end("jump_fwd_land", AnimationConfig("idle"),0.25) character_control.on_animation_end("jump_bwd_land", AnimationConfig("idle"),0.25) character_control.on_animation_end("jump_lt_land", AnimationConfig("idle"),0.25) character_control.on_animation_end("jump_rt_land", AnimationConfig("idle"),0.25)