Example #1
0
def update_gui(scn, openvr_frame_renderer, gui):
    global switch_object_textures, path_object_textures
    if gui.Button("Load switch object textures file"):
        current_filename = gs.OpenFileDialog(
            "Load switch object textures file", "*.json", "")[1]
        if current_filename != "":
            with open(current_filename, 'r') as outfile:
                switch_object_textures = json.load(outfile)
                path_object_textures = current_filename

                post_load_scene(scn, openvr_frame_renderer, gui)
Example #2
0
def load_record(scn, openvr_frame_renderer):
    global records, current_filename, saved_cam_matrix, records_save_folder
    current_filename = gs.OpenFileDialog("Load a record", "*.json",
                                         records_save_folder)[1]
    records = None
    if current_filename != "":
        records_save_folder = os.path.dirname(current_filename)
        with open(current_filename, 'r') as outfile:
            records = json.load(outfile)
            load_calibration()

            saved_cam_matrix = scn.GetCurrentCamera().GetTransform().GetWorld()
            scn.GetCurrentCamera().GetCamera().SetZoomFactor(
                gs.FovToZoomFactor(calibration_fov * 3.1415 / 180.0))
            # remove vr
            if openvr_frame_renderer is not None:
                scn.GetSystem("Renderable").SetFrameRenderer(None)
Example #3
0
def update_gui(scn, openvr_frame_renderer, gui):
	global playing, timer, max_timer, animations
	if gui.CollapsingHeader("Animate Object"):
		gui.Indent()

		if gui.Button("Play Animation"):
			current_filename = gs.OpenFileDialog("Load an animation file",  "*.json", "")[1]
			animations = None
			if current_filename != "":
				with open(current_filename, 'r') as outfile:
					animations = json.load(outfile)

					# get the max timer
					max_timer = 0.0
					for key, obj in animations.items():
						max_obj = max([float(i["time"]) for i in obj])
						if max_timer < max_obj:
							max_timer = max_obj

					# remove anim key
					for key, obj in animations.items():
						for obj_key in obj:
							n = scn.GetNode(obj_key["object_name"])
							if n is not None:
								n.SetEnabled(False)

					playing = True
		gui.SameLine()
		if gui.Button("Stop Animation"):
			playing = False

		timer = gui.SliderFloat("Timeline animation", timer, 0, max_timer)[1]
		# loop
		if timer > max_timer:
			timer = 0.0

		gui.Unindent()
Example #4
0
        m.GetRow(3).x,
        m.GetRow(3).y,
        m.GetRow(3).z)


def deserialize_matrix(s):
    f = s.split(";")
    m = gs.Matrix4()
    m.SetRow(0, gs.Vector3(float(f[0]), float(f[1]), float(f[2])))
    m.SetRow(1, gs.Vector3(float(f[3]), float(f[4]), float(f[5])))
    m.SetRow(2, gs.Vector3(float(f[6]), float(f[7]), float(f[8])))
    m.SetRow(3, gs.Vector3(float(f[9]), float(f[10]), float(f[11])))
    return m


current_filename = gs.OpenFileDialog("Load a record", "*.json", "")[1]
# current_filename = "C:/boulot/works/VRViewer/source/capture_video/melanie1.json"

# pivot de camera sous max  (90, 0, -180)
if current_filename != "":
    with open(current_filename, 'r') as outfile:
        records = json.load(outfile)
        records = collections.OrderedDict(
            sorted(records.items(), key=lambda t: float(t[0])))
        load_calibration()

        def write_matrix(time, mat):
            def convert_to_max(pos):
                return gs.Vector3(pos.x, pos.z, pos.y)

            row0 = convert_to_max(mat.GetRow(0))
Example #5
0
            if gui.Button("Quit"):
                uninit()

            if fbx_converter_ret_val:
                gui.Text(
                    "There is a bug in the convert FBX, look at the log !!")

            camera_handler.set_speed(
                gui.SliderFloat("Cam Speed", camera_handler.get_speed(), 0,
                                50)[1])
            camera_handler.set_rot_speed(
                gui.SliderFloat("Cam Rot Speed",
                                camera_handler.get_rot_speed(), 0, 50)[1])

            if gui.Button("OpenFbx"):
                filename = gs.OpenFileDialog("Select a fbx", "*.fbx;*.FBX;*.*",
                                             "")[1]
                if filename != "":
                    load_fbx(os.path.normpath(filename))

            if gui.Button("OpenScn"):
                filename = gs.OpenFileDialog("Select a scn", "*.scn;*.*",
                                             "")[1]
                if filename != "":
                    load_new_scene(os.path.normpath(filename))

            if gui.Button("Reset View"):
                camera.reset_view(scn, cam, camera_handler,
                                  openvr_frame_renderer)

            show_sky = gui.Checkbox("ShowSky", show_sky)
            if (sky_script is not None and not show_sky) or (sky_script is None