def duplicate_node_object(original_node: hg.Node, name): node = hg.Node(name) trans = hg.Transform() node.AddComponent(trans) obj = hg.Object() obj.SetGeometry(original_node.GetObject().GetGeometry()) node.AddComponent(obj) return node
def update_track_translation(camera: hg.Node, dts): global camera_move trans = camera.GetTransform() camera_pos = trans.GetPosition() new_position = target_point + target_matrix.GetX( ) * track_position.x + target_matrix.GetY( ) * track_position.y + target_matrix.GetZ() * track_position.z trans.SetPosition(new_position) camera_move = new_position - camera_pos return new_position
def update_track_direction(camera: hg.Node, dts, noise_level): # v = target_point - camera.GetTransform().GetPosition() f = radians(noise_level) rot = target_matrix.ToEuler() rot += hg.Vector3( noise_x.temporal_Perlin_noise(dts) * f, noise_y.temporal_Perlin_noise(dts) * f, noise_z.temporal_Perlin_noise(dts) * f) rot_mat = hg.Matrix3.FromEuler(rot) rot_mat = rot_mat * track_orientation camera.GetTransform().SetRotationMatrix(rot_mat) return rot_mat # camera.GetTransform().GetWorld().GetRotationMatrix().LookAt(v, target_matrix.GetY()))
def update_follow_translation(camera: hg.Node, dts): global camera_move trans = camera.GetTransform() camera_pos = trans.GetPosition() aX = trans.GetWorld().GetX() target_pos = target_node.GetTransform().GetPosition() # Wall v = target_pos - camera_pos target_dir = v.Normalized() target_dist = v.Len() v_trans = target_dir * (target_dist - follow_distance) + aX * 20 new_position = camera_pos + v_trans * follow_inertia * 60 * dts trans.SetPosition(new_position) camera_move = new_position - camera_pos return new_position
def setup_satellite_camera(camera: hg.Node): camera.GetCamera().SetOrthographic(True) camera.GetCamera().SetOrthographicSize(satellite_view_size) camera.GetTransform().SetRotation(hg.Vector3(radians(90), 0, 0))
def update_follow_direction(camera: hg.Node): v = target_point - camera.GetTransform().GetPosition() rot_mat = camera.GetTransform().GetWorld().GetRotationMatrix().LookAt( v, hg.Vector3.Up) camera.GetTransform().SetRotationMatrix(rot_mat) return rot_mat