Jump to content

[SOLVED] Strange behaviour when rotating an Object


photo

Recommended Posts

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.

post-86-0-24795300-1392194311_thumb.png

levels.rar

Link to comment

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:

Link to comment

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

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:

Link to comment

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:

  1. setWorldtransform(quat(vec3(), float angle));
  2. setWorldtransform(quat(float x, float y, float z, float angle));
  3. 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:

Link to comment
×
×
  • Create New...