Rakehell

08-13-2013, 08:08 AM

I have an object at x,y,z and I want it to point toward another object in space at x2,y2,z2. Is there an easy way to do this in the vertex shader?

View Full Version : How can I make an object face a certain direction?

Rakehell

08-13-2013, 08:08 AM

I have an object at x,y,z and I want it to point toward another object in space at x2,y2,z2. Is there an easy way to do this in the vertex shader?

tonyo_au

08-13-2013, 07:56 PM

Yes but you will probably need to pass either the rotation matrix or the object center and lookat point as uniforms to the shader (so you can calculate the rotation matrix). Then you multiple each vertex position by this matrix prior to the usually projection-viewmodel matrix multiply.

Rakehell

08-14-2013, 08:26 PM

How do I calculate the rotation matrix?

GClements

08-14-2013, 08:53 PM

How do I calculate the rotation matrix?

gluLookAt() is one option.

gluLookAt() is one option.

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.