Jump to content
• ### What is your GameDev Story?

• Advertisement

# Scene Nodes

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

If you intended to correct an error in the post then please contact us.

## 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 this post

##### Share on other sites
Advertisement
Have you tried this:

childWorldQuat = parentWorldQuat * childLocalQuat;

?

#### Share this post

##### 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 this post

##### 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 this post

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

#### Share this post

##### 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)

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement
• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• ### Popular Now

• 9
• 34
• 16
• 11
• 12
• Advertisement
• ### Forum Statistics

• Total Topics
634123
• Total Posts
3015649
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!