Jump to content

Lookat From Rotation


symek

Recommended Posts

hi,

Can anybody help me with this piece of code.

I'd like to compute camera lookat vector from its position/rotation.

There is mistake somewhere here but not sure where. Vector corespondes to my expectation but there is some error ie respect to camera position.

set sx = `sin($RotX)`

set cx = `cos($RotX)`

set sy = `sin($RotY)`

set cy = `cos($RotY)`

set x = `$sy*$cx*`

set y = `-$sx`

set z = `$cy*$cx*`

set lookat = `normalize(vector3($x, $y, $z))`

echo $lookat

thanks in advance!

sy.

EDIT:

ok I did it like this:

set lookat = normalize(vector3(0,0,-1) * (rotate($RX, "x") * rotate($RY, "y") * rotate($RZ, "z")))

BTW

Am I wrong or hscript can not save matrix to variable? Above code doeasn't want to work divided into sections... only in one expression

Edited by SYmek
Link to comment
Share on other sites

hi,

Can anybody help me with this piece of code.

I'd like to compute camera lookat vector from its position/rotation.

There is mistake somewhere here but not sure where. Vector corespondes to my expectation but there is some error ie respect to camera position.

thanks in advance!

sy.

EDIT:

ok I did it like this:

BTW

Am I wrong or hscript can not save matrix to variable? Above code doeasn't want to work divided into sections... only in one expression

I posted a reply on the SESI forums.

On a side note, there a couple of useful expression functions for dealing with look ats: mlookat(), mlookatup(), mobjlookat() and objlookat().

Edited by Wolfwood
Link to comment
Share on other sites

Thanks again Wolfwood,

I've checked all these expressions before my questions. Just I'm new at it ;) (they need target coordinates to compute lookat vactor. This was something I didn't have or I couldn't get. Now problem is solved anyway!)

cheers :)

sy.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...