Jump to content

A Node's Direction property


photo

Recommended Posts

Hi,

I'm having a little trouble understanding the 'Direction' property of a node. This property is not available in the editor AFAIK, and in the editor you control a node's orientation purely through yaw/pitch/roll.

My question - what is the meaning of the 'Direction' of a node returned by Node::getDirection()

I find that by default a node has a direction (0, 0, -1)

 

I assume this is what Unigine does internally when we call Node::setDirection(vDir, vUp)

1. construct an orthonormal basis based on vDir and vUp

2. calculate the rotation required to transform (0, 0, -1) to the new vDir

3. apply this rotation

 

Is this correct?

 

Also, why did Unigine decide to go with two modes of changing the orientation - setDirection() and setRotation()? I feel that it's bad design to expose two ways of doing the same thing, unless of course, I am missing something here.

 

Thanks,

Ashwin.

Link to comment

You are right. setDirection() gets the current transformation matrix, gets node direction, scale and position based on this matrix and updates the direction according to provided values.

So basically there are three ways of setting node orientation: via setTransform(), setDirection() and setRotation(). You can use whatever method is convenient to you. Direction function was requested by our customers as a more simple and intuitive way of setting orientation.

 

Just on a side node, there are two functions composeTransformDirection() and decomposeTransformDirection() in utils.h that can be handy when dealing with direction vector and transformation matrices.

Link to comment
×
×
  • Create New...