belal jafar
belal jafar

Reputation: 131

OpenGL get 2d projection from 3d points

I have display a collection of 3d cloud points by this code:

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
if (keyframes[i]->numberOf3DPoints > 0)
{
    glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(PointColor), ((uint8_t*)keyframes[i]->points+12));
    glVertexPointer(3, GL_FLOAT, sizeof(PointColor), ((float*)keyframes[i]->points));
    glDrawArrays(GL_POINTS, 0, keyframes[i]->numberOf3DPoints);
}
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);

This code displays an array of 3d point clouds with its color values, I want to get an array of 2d points and display these points in 2d (the upper view of 3d points)

Upvotes: 0

Views: 3551

Answers (1)

BЈовић
BЈовић

Reputation: 64203

This projection tutorial explains the projection matrix transformations in detail.

To get the projection from above, set the projection matrix and set the camera above and point it in the direction toward the plane. And that should be enough.

Upvotes: 1

Related Questions