Scene Nodes

This topic is 4847 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I read about Scene Nodes recently and liked it very much. I am currently designing an Engine based on it. Is it though, meant for Low End PCs. I do not think so considering the overhad of vftb look ups. Anyway, my question is what do you do to transform a child node to world using parent World Transform give the parent quaternion(in world axis) and offset vector(in world coord system) and a local vector and quat for child, remembering quat needs to be in same coord system to get multiplied. I did this(which is wrong I guess) without result: childWorldQuat = childLocalQuat * parentWorldQuat; childWorldOffset = parentWorldQuat.rotateVector(childLocalOffset) + parentWoirldOffset; -Obi

Share on other sites
Have you tried this:

childWorldQuat = parentWorldQuat * childLocalQuat;

?

Share on other sites
I'm lot late, anyway two mistakes to be pointed out:
firstly the thing i read was "scene graphs". And abt the quaternion thing,
the logic is different. granted i didn't tried the one i am asked to, but would you expect the math to change just because you are using quaternions. take for example a basis object and a vector, if you try what i said earlier the thing will work just fine. so why should quaternion be different. i'm rather guessing that coordinate systems are the culprit, but gotta kno more abt quats before guessing
-Obi

Share on other sites
Well, it depends to what convention of converting quaternion to matrices you are using.

It's better to use convention that these equations is true:
quaternion_to_matrix(q)*v = q*v*~q
quaternion_to_matrix(q1)*quaternion_to_matrix(q2) = quaternion_to_matrix(q1*q2)
where q is quaternion and v is vector. This convention is quite consistant, in sense most of math is same for quaternions and orthonormal 3x3 matrices.

This way, you transform from child to parent using
v'=qc*v*~qc + offsetc
where qc is child/s quaternion and offsetc is child's offset
and then transform from parent to world using
v"=qp*v'*~qp + offsetp = qp*(qc*v*~qc + offsetc)*~qp + offsetp =
qp*qc*v*~qc*~qp + qp*offsetc*~qp + offsetp = (qp*qc)*v*~(qp*qc) + qp*offsetc*~qp + offsetp = Q*v*~Q + O

where
qp is parent's quaternion and offsetp is parent's offset.
So if you compute
Q=qp*qc
O=qp*offsetc*~qp + offsetp
that is,
ChildToWorldQuat=ParentToWorldQuat*ChildToParentQuat
ChildToWorldOffset=ParentToWorldOffset + ParentToWorldQuat.RotateVector(ChildToParentOffset);
It's same as what you need to do with 3x3 matrix and offset, if you use column vectors (matrix*vector) convention.

Share on other sites
Thnks for that info! I'll try that right away
-Obi

Share on other sites
As first thing I'd check if these equations works:
quaternion_to_matrix(q)*v = q*v*~q
(i suppose q.RotateVector(v) is equal to q*v*~q)

quaternion_to_matrix(q1)*quaternion_to_matrix(q2) = quaternion_to_matrix(q1*q2)
Especially second one.
(note that on computer it will not be exact because of roundoff errors, but must be very close. In fact I checked this right after writing my quaternion class)

1. 1
Rutin
44
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• Forum Statistics

• Total Topics
633409
• Total Posts
3011702
• Who's Online (See full list)

There are no registered users currently online

×