00001 #include "vuSphericViewWin.h"
00002 #include <math.h>
00003 #include "vuLinAlg/vuMatrix.h"
00004 #include "vuLinAlg/vuSpherical.h"
00005
00006
00007
00008
00009
00010 BEGIN_EVENT_TABLE(vuSphericViewWin, vuGLCanvas)
00011 EVT_MOUSE_EVENTS(vuSphericViewWin::glOnMouse)
00012 END_EVENT_TABLE()
00013
00014 vuSphericViewWin::vuSphericViewWin(vuBasicUtility *parent, int size_x, int size_y)
00015 : vuGLCanvas(parent,-1,wxPoint(0,0),wxSize(size_x,size_y)), m_Parent(parent)
00016 {
00017 m_Volume = NULL;
00018 }
00019
00020 vuSphericViewWin::~vuSphericViewWin()
00021 {
00022 }
00023
00024 void vuSphericViewWin::setVolume(vu1611_ST* vol)
00025 {
00026 m_Volume = vol;
00027 }
00028
00029 void vuSphericViewWin::render()
00030 {
00031 if (m_Volume == NULL) {
00032 cerr << "vuSphericViewWin.render(): no camera set" << endl;
00033 return;
00034 }
00035 glClear(GL_COLOR_BUFFER_BIT);
00036 m_Volume->preview();
00037 }
00038
00039 bool vuSphericViewWin::glInit()
00040 {
00041 return true;
00042 }
00043
00044
00045
00046
00047
00048 void vuSphericViewWin::glOnMouse(wxMouseEvent &ev)
00049 {
00050 }
00051
00052 #if 0
00053 {
00054
00055 vuVector look=m_Data->getCameraPtr()->getLookAtVector().makeUnit()*-1;
00056
00057 vuMatrix rotX = vuMatrix().makeRotateX(90);
00058 vuVector tmp = rotX * look;
00059 vuSpherical sph = vuSpherical(tmp);
00060 float alpha = (-sph.getLongitude() * 180 / M_PI) + 270;
00061 float beta = -((sph.getLatitude() * 180 / M_PI) - 90);
00062
00063 glMatrixMode(GL_MODELVIEW);
00064 glPushMatrix();
00065 glLoadIdentity();
00066
00067 glRotatef(beta, 1.0f, 0.0f, 0.0f);
00068 glRotatef(alpha, 0.0f, 1.0f, 0.0f);
00069
00070 #if 0
00071 int width = 500;
00072 int height = 500;
00073 cerr << " look=" << look.getString() << endl;
00074
00075 glLineWidth(1.0f);
00076 glColor3ub(255,255,255);
00077
00078 glBegin(GL_LINES);
00079 glVertex2i(width/2 - 40, height/2);
00080 glVertex2i(width/2 - 5, height/2);
00081
00082 glVertex2i(width/2, height/2 - 40);
00083 glVertex2i(width/2, height/2 - 5);
00084
00085 glVertex2i(width/2 + 5, height/2);
00086 glVertex2i(width/2 + 40, height/2);
00087
00088 glVertex2i(width/2, height/2 + 5);
00089 glVertex2i(width/2, height/2 + 40);
00090 glEnd();
00091 #endif
00092 glPointSize(5.0);
00093 glColor3ub(255,0,255);
00094 glBegin(GL_POINTS);
00095 glVertex3f(look[0],look[1],look[2]);
00096 glEnd();
00097
00098
00099 glPointSize(2.0);
00100
00101 glBegin(GL_POINTS);
00102 glColor3ub(255, 255, 0);
00103
00104 dword i, cnt = m_Data->getNumberOfViews();
00105
00106 for(i=0;i<cnt;++i) {
00107 vuVector lookFrom = m_Data->getView(i)->getLookFrom().makeUnit();
00108 if (look.dot(lookFrom) >= 0)
00109 glVertex3f(lookFrom[0], lookFrom[1], lookFrom[2]);
00110 }
00111 glEnd();
00112 glPopMatrix();
00113 }
00114 #endif