Go to the documentation of this file.00001
00006
00007
00008
00009
00010 #include <qapplication.h>
00011 #include <QGLViewer/qglviewer.h>
00012
00013 using namespace qglviewer;
00014
00015
00016
00017
00018
00019 class FrameTransform : public QGLViewer
00020 {
00021 protected :
00022 virtual void draw();
00023 virtual void init();
00024 virtual QString helpString() const;
00025 };
00026
00027
00028
00029
00030
00031 void FrameTransform::init()
00032 {
00033 restoreStateFromFile();
00034
00035 setSceneRadius(1.5);
00036 showEntireScene();
00037 setAxisIsDrawn();
00038 glDisable(GL_LIGHTING);
00039
00040 help();
00041 }
00042
00043 void FrameTransform::draw()
00044 {
00045
00046
00047 const float nbLines = 50.0;
00048
00049 glBegin(GL_LINES);
00050
00051 for (float i=0; i<nbLines; ++i)
00052 {
00053 float angle = 2.0*M_PI*i/nbLines;
00054
00055 glColor3f(0.8f, 0.2f, 0.2f);
00056
00057 glVertex3fv(camera()->position());
00058 glVertex3f (cos(angle), sin(angle), 0.0);
00059
00060 glColor3f(0.2f, 0.8f, 0.2f);
00061
00062 glVertex3fv(camera()->worldCoordinatesOf(Vec(.3*cos(angle), .3*sin(angle), -2.0)));
00063 glVertex3f (cos(angle), sin(angle), 0.0);
00064
00065 glColor3f(0.2f, 0.2f, 0.8f);
00066
00067 glVertex3f(1.5*cos(angle), 1.5*sin(angle), -1.0);
00068 glVertex3f(cos(angle), sin(angle), 0.0);
00069 }
00070 glEnd();
00071
00072
00073
00074 }
00075
00076 QString FrameTransform::helpString() const
00077 {
00078 QString text("<h2>F r a m e T r a n s f o r m</h2>");
00079 text += "This example illustrates how easy it is to switch between the camera and ";
00080 text += "the world coordinate systems using the <i>camera()->cameraCoordinatesOf()</i> ";
00081 text += "and <i>camera::worldCoordinatesOf()</i> functions.<br><br>";
00082 text += "You can create your own hierarchy of local coordinates systems and each of ";
00083 text += "them can be manipulated with the mouse (see the <i>manipulatedFrame</i> and <i>luxo</i> examples). ";
00084 text += "Standard functions allow you to convert from any local frame to any other, ";
00085 text += "the world/camera conversion presented here simply being an illustration.<br><br>";
00086 text += "See <i>examples/frameTransform.html</i> for an explanation of the meaning of these weird lines.";
00087 return text;
00088 }
00089
00090
00091
00092
00093
00094 int main(int argc, char** argv)
00095 {
00096 QApplication application(argc,argv);
00097
00098 FrameTransform viewer;
00099
00100 viewer.setWindowTitle("keyFrames");
00101
00102 viewer.show();
00103
00104 return application.exec();
00105 }