I am in a special situation to use Open GL. I have a 3D object model I need to render using Open GL. By some knowledge from other domain, I already have the transformation of any 3D points on this object to 2D screen pixel. The transformation is a 3 by 4 matrix. What I need to do is to set the OpenGL ModelView matrix correctly so the whole Open GL transformation is identical to the transformation I already have.
Any idea how to do this?
It depends on what the contents of this “3 by 4 matrix” of yours are. I’m curious as to what kind of transformation can go from 3D to 2D without a division. Is this an orthographic projection, and you’re just dropping the Z coordinate?
Thank you for posting. It does have a division. It works like this
|x| | m11, m12, m13, m14| |x_3d|
|y| = | m21, m22, m23, m24| * |y_3d|
|m| | m31, m32, m33, m34| |x_3d|
|1 |
the final x_2d, y_2d on screent is
x_2d = x / m;
y_2d = y / m;
x =
Reformating
vecter(x, y, m) = M matrix * vector(x_36, y_3d, z_3d, 1)
and then divide.
x_2d = x / m;
y_2d = y / m;
Forget to mention that I also know the frustumf matrix in OpenES if I need it.