in GLScene we have three parameters (开发者_JAVA百科RollAngle, PitchAngle and TurnAngle) for rotation around local orientation. in the image below, how can I rotate cube around global orientation (orange axis)?
You would need to convert the axis angle rotation to Euler angles. Here is a link explaining this process in some detail with code:
http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToEuler/index.htm
From the article:
yaw = atan2(y * sin(angle)- x * z * (1 - cos(angle))
, 1 - (y2 + z2 ) * (1 - cos(angle)))
pitch = asin(x * y * (1 - cos(angle)) + z * sin(angle))
roll = atan2(x * sin(angle)-y * z * (1 - cos(angle))
, 1 - (x2 + z2) * (1 - cos(angle)))
EDIT: Renamed the variables to be consistent with the pitch, yaw, roll naming convention.
Maybe you could use "DummyCube" object as a parent. Then you can rotate first the cube inside dummy cube and then the DummyCube.
This is a dirty cheat, but if the object is at the origin (0,0,0) and there is only one object in the scene, you could swing the camera (and light source) around the object instead of rotating the object.
精彩评论