Jump to content

add a lookAt function for Node class


photo

Recommended Posts

I know there are some functions can also do this, the setDirection and setWorldDirection function. but these two functions need the direction vector to be normalized, so they're not convenient, for example, to use these function in a worldExpression, you need to first get the target objects posistion, then get the normalized direction vector between target and the node.

 

if there is a lookAt function, that will be much handy, just use one line of code to do all this:

   node.lookAt(target.getWorldPosition());

 

adding this function is very easy, I've already added it to my unigine engine. but I think other people might also need this.

Link to comment

I know there are some functions can also do this, the setDirection and setWorldDirection function. but these two functions need the direction vector to be normalized, so they're not convenient

 

So why then not just add direction/up normalization into existing setDirection/setWorldDirection() function.

 

Also (not sure, but you should check it) a lookat function on node class might cause consistency problems between orientation of general node class and player class as player viewfrustum is oriented in -Z-axis direction, while general node orientation axis depends on you local model coordinate system definition (e.g. in our case Model "forward" is +Y axis)

Link to comment

yes, that still confused me. if an object's forward direction is -z axis, then a character's foward direction should be same.

 

apparently, -z axis should not be the forward position for character.

Link to comment
×
×
  • Create New...