My eyes hurt in eye-space
Hello,
I want to do something incredibly easy, but apparently I'm missing something and I was hoping you guys could help me out.
I have some vertices and I want to know which one is the furthest from the camera. So I thought the easiest way to do it is to multiply the vertices with opengl's modelview matrix, so that they are in eye-space, and then find out which coord has the greatest Z value.
Now a vertex is indeed found, but for some reason it's allways around 119.0f
Am I missing something and could you explain what I did wrong please?
Jeroen
Quote:Original post by s3mt3xNo, that's not right - the modelview matrix itself transforms geometry directly from local object space to view/camera space, so multiplying by the modelview matrix should give the correct results.
Try the inverse of the modelview matrix :)
@The OP: Perhaps there's a problem with your matrix-vector multiplication code, or how you're querying the matrix from OpenGL. If you're not sure, you might post these particular code excerpts.
the easiest way (+ prolly the quickest)
loop_all_verts
{
dist = SQUAREDLENGTHOFVECTOR( vertpos - campos );
if ( dist > furtherest )
...
}
loop_all_verts
{
dist = SQUAREDLENGTHOFVECTOR( vertpos - campos );
if ( dist > furtherest )
...
}
Quote:Original post by zedzeekBy 'distance from the camera' I think the OP means the distance from the plane defined by the camera's side and up vectors, not the Euclidean distance.
the easiest way (+ prolly the quickest)
loop_all_verts
{
dist = SQUAREDLENGTHOFVECTOR( vertpos - campos );
if ( dist > furtherest )
...
}
Hello,
I'm implementing parallel split shadow maps and I want to adjust the camera's farplane to the furthest vertex of the scene's bounding box so the frustum would fit tightly around my geometry, so using Euclidian distance isn't an option here I'm afraid. I 'm gonna take a good look again through my vector-matrix multiplication code as soon as possible, but I don't think they're the problem because I've used them in a couple of other projects.
I query my modelview matrix in my rendering loop, right before I use it like this:
CMatrix4x4 modelview;
glGetFloatv(GL_MODELVIEW, modelview);
// ... use the matrix here
Jeroen
I'm implementing parallel split shadow maps and I want to adjust the camera's farplane to the furthest vertex of the scene's bounding box so the frustum would fit tightly around my geometry, so using Euclidian distance isn't an option here I'm afraid. I 'm gonna take a good look again through my vector-matrix multiplication code as soon as possible, but I don't think they're the problem because I've used them in a couple of other projects.
I query my modelview matrix in my rendering loop, right before I use it like this:
CMatrix4x4 modelview;
glGetFloatv(GL_MODELVIEW, modelview);
// ... use the matrix here
Jeroen
I found the solution. It turns out I had to query the matrix with GL_MODELVIEW_MATRIX instead of with GL_MODELVIEW.
What a stupid error after all...
But what's strange is that I have to multiply my vertex with the modelview matrix AND the projection matrix (modelviewproj) to get it to work. Any idea why this is?
Thanx guys,
Jeroen
What a stupid error after all...
But what's strange is that I have to multiply my vertex with the modelview matrix AND the projection matrix (modelviewproj) to get it to work. Any idea why this is?
Thanx guys,
Jeroen
Quote:Original post by godmodderPerhaps you have the wrong matrix modes set when you set up your initial matrices (e.g. loading the view matrix while in PROJECTION_MATRIX mode).
But what's strange is that I have to multiply my vertex with the modelview matrix AND the projection matrix (modelviewproj) to get it to work. Any idea why this is?
In any case you should only need to transform by the modelview matrix, so I suspect something may still be off somewhere in your code.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement