Hello,
First POST here and new to OpenGL so please be gentle with me.
What I want to do is to plot three lines that are NOT rotated and at 90 degress to each other so as you may guess I can only see to of the but that is fine as I will do the rotation of the line at a later time. But what I am trying to do is to setup a viewing/camera angle so I can see all three, the snippet below is the product of much trial and error and little understanding so can someone help me please with a how to setup camera/viewing/perspective some the vector are plotted in the centre of viewport and can be seen correctly.
Many thanks in advance IMK
void COGLPLOT_1View::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
if(cy > 0)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, cx , cy );
gluPerspective( 45.0f, (GLdouble)cx/cy , 1.0, 100 );
gluLookAt( 3, 3, 5 , 1 , 1 , -2.5 , 0.0 , 1.0 , 0.0 );
glMatrixMode(GL_MODELVIEW);
}
}
void COGLPLOT_1View::DrawAccelerometerOrientation( double X, double Y, double Z )
{
float Axis_wAngleX = (float)X;
float Axis_wAngleY = (float)Y;
float Axis_wAngleZ = (float)Z;
glPushMatrix();
glTranslatef( 0.0f, 0.0f, -m_fRadius);
glRotatef(Axis_wAngleX, 1.0, 0.0, 0.0);
glRotatef(Axis_wAngleY, 0.0, 1.0, 0.0);
glRotatef(Axis_wAngleZ, 0.0, 0.0, 1.0);
glEnable( GL_POINT_SMOOTH );
glLineWidth( 5.0 );
glBegin(GL_LINES);
// Plot the Accelerometer X Axis
glColor3f( 1.0,0.0,0.0);
glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, 0.0f, -3.0f);
// Plot the Accelerometer Y Axis
glColor3f(0.9f,1.0,0.0);
glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(-3.0f, 0.0f, 0.0f);
// Plot the Accelerometer Z Axis
glColor3f(0.0f, 1.0f, 0.0f); // Green
glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, -3.0f, 0.0f);
glEnd();
glPopMatrix();
}