• Create Account

## Rear View Camera Matrix

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1DJTN  Members

207
Like
0Likes
Like

Posted 17 June 2011 - 04:03 PM

What I thought would be rather simple has turned into a complicated task. I’m rendering to a surface for a reflection texture I can use like a rear view mirror in a car. The problem is my view matrix. I build it using a lookAt matrix with the camera’s position, target, and up vector. I thought I could simply invert the camera target (-camera target) when building the matrix and I’d be good to go… but I’m not, I get strange results when the camera goes from a positive X Y or Z position into a negative. As long as the camera’s position is in the positive all is well but as soon as I back out to a negative XY or Z position the reflection starts to roll and eventually ends up looking forward and not back.

Am I overlooking something?

### #2scgames  Members

2082
Like
1Likes
Like

Posted 17 June 2011 - 04:46 PM

It's probably the forward vector you want to negate, rather than the target point.

If you're using a 'look at' function that takes a position and a target point, you should be able to compute the adjusted target point as follows (pseudocode):

vector3 forward = target - position;
vector3 adjusted_target = position - forward;

### #3DJTN  Members

207
Like
0Likes
Like

Posted 17 June 2011 - 05:16 PM

It's probably the forward vector you want to negate, rather than the target point.

If you're using a 'look at' function that takes a position and a target point, you should be able to compute the adjusted target point as follows (pseudocode):

vector3 forward = target - position;
vector3 adjusted_target = position - forward;

That did it JYJK. Thanks man!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.