Cristianwolf712 Posted February 12, 2014 Share Posted February 12, 2014 Hi guys, I have a strange issue with rotating an object via setWorldRotation. I never had that issue before and I can't get what's wrong with it. If the user pressed the right mouse button, the selected object should be rotated around the z-axis. Whenever I called the setWorldRotation, the node also rescaling and change the local/world-transformation. I created a litte test-scene and posted the neccessary lines from the log-file. levels.rar Link to comment
Cristianwolf712 Posted February 13, 2014 Author Share Posted February 13, 2014 Okay, I found a workaround for that. Save the scaling before and rescaling the mesh after the rotation seems to work for now. Link to comment
silent Posted February 14, 2014 Share Posted February 14, 2014 Hi Chrisitian, Your code doesn't work because of getWorldRotation() function called in each update. getWorldRotation() gets rotation of the node from it's transformation matrix. And because of floating point calculations precision you can get slightly different values of node position. You can easily fix this issue by modifying SimpleLevel.h. Please, take a look into the attached fixed SimpleLevel.h. Thanks! SimpleLevel.zip How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Cristianwolf712 Posted February 14, 2014 Author Share Posted February 14, 2014 Thanks silent, but it doesn't solve the problem. Magically, the droid doesn't rotate at all. I added a log.message right after the rotation = quat() line and it seems it doesn't do anything. I have to manually set the rotation.z-parameter in the update file. Again, the droid are scaled in the setWorldRotation too. Link to comment
silent Posted February 21, 2014 Share Posted February 21, 2014 Hi Christian, Simple workaround for this issue (also, please check attached test scene): if (engine.app.getMouseButtonState(APP_BUTTON_RIGHT)) { float a; a += engine.game.getIFps() * 10.0f; rotatedNode.setWorldRotation(quat(0.0f,0.0f,1.0f,a)); } I've sent this information to the developers. Thanks! test.zip How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
silent Posted February 21, 2014 Share Posted February 21, 2014 And fast responce from the developers: this is not a bug. If you want to set up rotation for the object you need to pass to setWorldTransform quat constructor: setWorldtransform(quat(vec3(), float angle)); setWorldtransform(quat(float x, float y, float z, float angle)); setWorldtransform(quat(vec4())); Unfortunately, if you set quat components directly (like newQuat.w and newQuat.z in your example) it will lead to incorrect transformations as quaternions are not that simple as angle-axis. Also, please, check the documentation about Unigine data types (quat section). How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts