Please help! =) I can't get the correct transformation in OpleGL.
I have point3D - P(X,Y,Z), and projection matrix M, which equal to K*(R|T) where
K - camera calibration matrix
(R|T) - point (object) coordinate system transformation (R - rotation matrix, T - translation vector)
As a result we have projected point as p = M*P
I know P,K,R,T, and I wont to calculate p in OpenGl terms.
In OpenCV terms it will be look as follows (little abstraction code):
CvMat* R = cvCreateMat(4,4, CV_32F, getRotationData());
CvMat* T = cvCreateMat(4,1, CV_32F, getTranslationData());
CvMat* K = cvCreateMat(4,4, CV_32F, getCameraCalibrationData());
// (R|T)
R->data.fl[3] = T->data.fl[0];
R->data.fl[7] = T->data.fl[1];
R->data.fl[11] = T->data.fl[2];
R->data.fl[15] = T->data.fl[3];
CvMat M = cvMat(4,4, CV_32F);
// M = R*(R|T)
cvMulMat(K, R, &M);
CvMat* P = cvCreateMat(4,1, CV_32F, getTestedPoint3D());
cvMar p = cvMat(4,1, CV_32F); // result transformation
// p = M*P
cvMulMat(&M, P, &p);
// project
float z = p.data.fl[2];
float x = p.data.fl[0] / z;
float y = p.data.fl[1] / z;
printf("Point projection [%f,%f]", x, y);
cvDrawPonit(img, cvPoint(x,y), CV_RGB(255,0,0)); /// <- !!!!
Sombody help me to translate this logic to OpenGl! =(
How could I set GL_PROJECTION and what could i do in GL_MODELVIEW mode or some else? =(