Closed alenko closed 11 years ago
Are you loading in an obj or making geometry in the code?
i am loading OBJ.
Is your object at 0,0,0 with no rotation prior to export? If it is off the origin or rotated at all it will throw the transform in rajawali all off because the object pivot will always be at 0,0,0
Well yes. I know that. My object is on 0. Problem is that not the object only is rotating. But all 3 axis. I am rotating on z and is fin. But it seems when rotating on z the y axis goes around too and cant rotate on y. Y doesnt stays up. So i can rotate only on 1 axis normaly.
I'm not sure then. I animate like this all the time and so far never had a problem like you are describing.
Test it on simple plain. You will see what i want to tell. First rotate only on y. You will see how does it rotates. Then add z .
Can you test this.i am at wrok atm and cant.
obj.setRotZ(getRotZ()+0.01f);
obj.setRotY(getRotY()+0.01f);
obj.setRotX(getRotX()-0.01f);
tested not good
Let me explain more how and what i am supposed to have and do,
I have a bullet, bullet has 2 sides, front side and back, well, bullet rotates on Z axis so it rotates around when was fired up, and i want Y to rotate based where is moving. so is always rotated to front
I'm no expert and I'm not sure what you mean by the bullet having 2 sides, but it sounds like maybe you want the bullet to rotate around its own long axis (i.e. rifling) regardless of which direction the gun is pointed? If so, I think you may have to compute the spin-axis vector of the bullet based on where the gun is pointed (y-axis) first, and then rotateAround() that (rather than the Z-axis) to get the bullet spin aligned with the direction of travel... In other words, rotating happens on the object only, not on the x/y/z coordinate axes; rotating the bullet around Y does not also rotate the bullet's Z-axis...
If this is not helpful, please ignore. If I'm wrong, somebody please correct me; I have to solve a similar problem in my project.
As you can see i draw a pic, to see. I need rotating bullet on z Axis, and with Y should be rotated where is moving(np i can make this calculation), but problem is, let say we set Z axis on angle 90, then Y will be on X axis.
OK I think I understand. The behavior you are seeing is correct, the way to work around this is to make your bullet the child of another "empty" BaseObject3D
Something like this:
private BaseObject3D nullObject, bullet;
....
initScene(){
nullObject = new BaseObject3D();
//load your bullet from OBJ or SER
bullet = LoadedOBJ
bullet.setMaterial();
....
nullObject.addChild(bullet);
addChild(nullObject);
}
....
onDrawFrame(){
//Spin bullet on Z
bullet.setRotZ(bullet.getRotZ()+zOffest);
//Rotate container on Y
nullObject.getRotY(nullObject.getRotY()+yOffset);
}
This should enable you to freely spin the bullet on Z and maintain proper orientation in Y.
I encountered this with my plane and helicopter. The propeller needed to spin on one axis, but yet had to follow the yaw, pitch, and roll of the fuselage.
hihihih. thnx alot ;)
I really wanted to make a picture, so I illustrated the concept. Sounds like you already understand, but maybe it will be helpful for someone else.
You learned this already!
on this issue looks like i didnt even saw what the real issue is. :P
ill close the issue while is solved
Hello, i have problem when i use
3dObject.setRotX(getRotX()+0.01f)
Basicly, when it rotates on X axis, the axis z and y are rotating within, so if i want to rotate the X axis and Z axis, the rotations comes wrong. How to make that only object is rotating and the axis comes fixed? Basicly rotate on axis not rotate axis.
and no, i cant use RotateAnim.