manuel.gysin Posted July 18, 2011 Posted July 18, 2011 Hello We are using the camera script like in the tropics demo. To create the file I wrote a simply script which saves the pos.xyz, rot.xyzw and fov to a text file while the designer clicks on a button within unigine. It takes the needed information from a PlayerSpectator instance. While loading the camera file and play it, the camera rotation is very strange in all directions. The position is of the camera is right. What could be wrong with the rotation? At the end I read world coordinates from the PlayerSpecator and set it later for the camera in the same world, that should work? Thanks a lot
manuel.gysin Posted July 18, 2011 Author Posted July 18, 2011 Thanks for the hint but rotation is still wrong.
steve3d Posted July 19, 2011 Posted July 19, 2011 then, what you are trying to do have already provided in unigine, check scripts in data\core\scripts\camera.h
manuel.gysin Posted July 19, 2011 Author Posted July 19, 2011 then, what you are trying to do have already provided in unigine, check scripts in data\core\scripts\camera.h This is exactly what I use, my problem is that the following code to create a camera.txt is not working. (The rotation is not right) // Get player pos vec3 pos = player.getPosition(); // Get player rot quat rot = player.getRotation(); // Get player fov float fov = player.getFov(); // Save the values file.puts (string(pos.x) + " " + string(pos.y) + " " + string(pos.z) + " " + string(rot.x) + " " + string(rot.y) + " " + string(rot.z) + " " + string(rot.w) + " " + string(fov) + "\n"); // Flush the file file.flush(); In camera.h they read the values this way: pos[i].x = float(file.readToken()) * scale + offset.x; pos[i].y = float(file.readToken()) * scale + offset.y; pos[i].z = float(file.readToken()) * scale + offset.z; rot[i].x = float(file.readToken()); rot[i].y = float(file.readToken()); rot[i].z = float(file.readToken()); rot[i].w = float(file.readToken()); fov[i] = float(file.readToken()); My code must do something wrong while saving the rotation.
steve3d Posted July 19, 2011 Posted July 19, 2011 ha , that's simple , you should use inverse quatenion to save the data :)
binstream Posted July 19, 2011 Posted July 19, 2011 Take a look inside plugins/Max/UnigineExport/UnigineMenu.ms
manuel.gysin Posted July 19, 2011 Author Posted July 19, 2011 ha , that's simple , you should use inverse quatenion to save the data :) Take a look inside plugins/Max/UnigineExport/UnigineMenu.ms Thanks, inverse did the trick!
Recommended Posts