Log in or register to post comments

orientating model to face camera

February 13, 2012 - 4:45am #1

Hi,

i have a 3d model of a character on screen which id like to rotate along the y-axis and always face the camera.

ive tried a few things but no cigar.

has anyone else done something like this?
or can point me in the right direction?

thx,
Lukasz.

Re: orientating model to face camera

February 23, 2012 - 4:08pm #5

thx Kim.
some good points there.
will give it a go.

Re: orientating model to face camera

February 14, 2012 - 6:45pm #4

That code provides the means of getting the camera position in relation to the target. The "cameraPosition" variable should hold the position of the camera in 3D space if the center of the target is the origin (0, 0, 0). That means the cameraPosition can also be used as the vector pointing from the center of the target to the camera (although you'll want to normalize it first).

You probably want a matrix that describes the rotation between your object's forward vector and the vector pointing at the camera. Look into creating a rotation matrix given two vectors. Or, look into creating a LookAt matrix given the position of the camera.

- Kim

Re: orientating model to face camera

February 13, 2012 - 9:57pm #3

Hi Kim,

thanks for your reply.
the example you've provided assumes the character is standing on the marker and that the rotation happens around the axis pointing out of the marker.

im interested in working out the rotation 3D vector of the marker to the camera. so if there was a arrow pointing out from the marker center, it would always be pointing at the center of the screen. thats the math i need to work out... any ideas?

thx,
Lukasz.

Re: orientating model to face camera

February 13, 2012 - 6:00pm #2

This thread has some code that might provide a starting point:

http://ar.qualcomm.at/node/2000605

Note that it depends on the SampleMath class from the Dominoes sample.

- Kim

Log in or register to post comments