Changeset 404 for trunk/gui/vizservers


Ignore:
Timestamp:
Apr 17, 2006 6:28:46 PM (18 years ago)
Author:
qiaow
Message:

Added Camera class to hide OpenGL viewing setup.

Location:
trunk/gui/vizservers/nanovis
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/vizservers/nanovis/Lic.cpp

    r401 r404  
    3737{
    3838  scale = Vector3(scalex, scaley, scalez);
    39   slice_vector = new float[NMESH*NMESH*4];
     39  slice_vector = new float[size*size*4];
    4040
    4141  //initialize the pattern texture
  • trunk/gui/vizservers/nanovis/Lic.h

    r401 r404  
    4040  int width, height;
    4141  int size;             //the lic is a square of size, it can be stretched
    42   float* slice_vector; //storage for the per slice vectors driving the follow
     42  float* slice_vector;  //storage for the per slice vectors driving the follow
    4343  Vector3 scale;        //scaling factor stretching the lic plane to fit the actual dimensions
    4444  float offset;         //[0,1] offset could be x, y, or z direction
     
    6565public:
    6666  Vector3 normal; //the normal vector of the Lic plane,
    67                 // the inherited Vector3 location is its center
     67                  //the inherited Vector3 location is its center
    6868  Lic(int _size, int _width, int _height, float _offset,
    6969          CGcontext _context, NVISid _vector_field,
  • trunk/gui/vizservers/nanovis/Makefile

    r401 r404  
    33                PerfQuery.o TransferFunction.o ControlPoint.o ColorGradient.o ColorPaletteWindow.o\
    44                ColorGradientGLUTWindow.o TransferFunctionGLUTWindow.o MainWindow.o Event.o \
    5                 Lic.o Renderable.o
     5                Lic.o Renderable.o Camera.o
    66
    77OBJ_CLIENT = Socket.o ClientSocket.o RenderClient.o Event.o
     
    8888        gcc $(CFLAG) ParticleSystem.cpp
    8989
    90 Renderable.o: Renderable.cpp
     90Renderable.o: Vector3.o Renderable.cpp
    9191        gcc $(CFLAG) Renderable.cpp
     92
     93Camera.o: Vector3.o Camera.cpp
     94        gcc $(CFLAG) Camera.cpp
    9295
    9396Lic.o: Renderable.o Lic.cpp Lic.h $(AUXSRC)
  • trunk/gui/vizservers/nanovis/Sphere.cpp

    r401 r404  
    4141  //draw it
    4242  gluSphere(quad, radius, stack, slice);
     43
    4344  glPopMatrix();
    4445}
  • trunk/gui/vizservers/nanovis/nanovis.cpp

    r401 r404  
    3535//render server
    3636
     37Camera* cam;
    3738float color_table[256][4];     
    3839
     
    7475//Nvidia CG shaders and their parameters
    7576CGcontext g_context;
    76 CGprogram m_pos_fprog;
    77 CGparameter m_vel_tex_param, m_pos_tex_param;
    78 CGparameter m_pos_timestep_param, m_pos_spherePos_param;
    79 
    80 CGprogram m_vel_fprog;
    81 CGparameter m_vel_timestep_param, m_vel_damping_param, m_vel_gravity_param;
    82 CGparameter m_vel_spherePos_param, m_vel_sphereVel_param, m_vel_sphereRadius_param;
    8377
    8478CGprogram m_passthru_fprog;
     
    9892CGparameter m_mvi_vert_std_param;
    9993
    100 
    10194using namespace std;
    10295
     
    10699  live_rot_z = z_angle;
    107100}
    108 
    109101
    110102
     
    850842   init_glew();
    851843
    852    glViewport(0, 0, (GLsizei) NPIX, (GLsizei) NPIX);
    853    glMatrixMode(GL_PROJECTION);
    854    glLoadIdentity();
    855    glTranslatef(-1.0, -1.0, 0.0);
    856    glScalef(2.0, 2.0, 1.0);
     844   //create the camera with default setting
     845   cam = new Camera(win_width, win_height,
     846                   live_obj_x, live_obj_y, live_obj_z,
     847                   0., 0., 100.,
     848                   live_rot_x, live_rot_y, live_rot_z);
    857849
    858850   glEnable(GL_TEXTURE_2D);
     
    15131505        glDisable(GL_BLEND);
    15141506
    1515         int segments = 20;
     1507        int segments = 50;
    15161508
    15171509        glColor3f(0.8, 0.8, 0.8);
    15181510        glPushMatrix();
    1519         glTranslatef(-0.45, -0.5, -0.5);
    1520         glScalef(0.001, 0.001, 0.001);
     1511        glTranslatef(0.4, 0., 0.);
     1512        glScalef(0.0005, 0.0005, 0.0005);
    15211513        glutStrokeCharacter(GLUT_STROKE_ROMAN, 'x');
    15221514        glPopMatrix(); 
    15231515
    15241516        glPushMatrix();
    1525         glTranslatef(-0.7, -0.25, -0.5);
    1526         glScalef(0.001, 0.001, 0.001);
     1517        glTranslatef(0., 0.4, 0.);
     1518        glScalef(0.0005, 0.0005, 0.0005);
    15271519        glutStrokeCharacter(GLUT_STROKE_ROMAN, 'y');
    15281520        glPopMatrix(); 
    15291521
    15301522        glPushMatrix();
    1531         glTranslatef(-0.7, -0.5, -0.2);
    1532         glScalef(0.001, 0.001, 0.001);
     1523        glTranslatef(0., 0., 0.4);
     1524        glScalef(0.0005, 0.0005, 0.0005);
    15331525        glutStrokeCharacter(GLUT_STROKE_ROMAN, 'z');
    15341526        glPopMatrix(); 
     
    15391531        glColor3f(0.2, 0.2, 0.8);
    15401532        glPushMatrix();
    1541         glTranslatef(-0.7, -0.5, -0.5);
    15421533        glutSolidSphere(0.02, segments, segments );
    15431534        glPopMatrix();
    15441535
    15451536        glPushMatrix();
    1546         glTranslatef(-0.7, -0.5, -0.5);
    15471537        glRotatef(-90, 1, 0, 0);       
    1548         gluCylinder(obj, 0.01, 0.01, 0.15, segments, segments);
     1538        gluCylinder(obj, 0.01, 0.01, 0.3, segments, segments);
    15491539        glPopMatrix(); 
    15501540
    15511541        glPushMatrix();
    1552         glTranslatef(-0.7, -0.35, -0.5);
     1542        glTranslatef(0., 0.3, 0.);
    15531543        glRotatef(-90, 1, 0, 0);       
    15541544        gluCylinder(obj, 0.02, 0.0, 0.06, segments, segments);
     
    15561546
    15571547        glPushMatrix();
    1558         glTranslatef(-0.7, -0.5, -0.5);
    15591548        glRotatef(90, 0, 1, 0);
    1560         gluCylinder(obj, 0.01, 0.01, 0.15, segments, segments);
     1549        gluCylinder(obj, 0.01, 0.01, 0.3, segments, segments);
    15611550        glPopMatrix(); 
    15621551
    15631552        glPushMatrix();
    1564         glTranslatef(-0.55, -0.5, -0.5);
     1553        glTranslatef(0.3, 0., 0.);
    15651554        glRotatef(90, 0, 1, 0);
    15661555        gluCylinder(obj, 0.02, 0.0, 0.06, segments, segments);
     
    15681557
    15691558        glPushMatrix();
    1570         glTranslatef(-0.7, -0.5, -0.5);
    1571         gluCylinder(obj, 0.01, 0.01, 0.15, segments, segments);
     1559        gluCylinder(obj, 0.01, 0.01, 0.3, segments, segments);
    15721560        glPopMatrix(); 
    15731561
    15741562        glPushMatrix();
    1575         glTranslatef(-0.7, -0.5, -0.35);
     1563        glTranslatef(0., 0., 0.3);
    15761564        gluCylinder(obj, 0.02, 0.0, 0.06, segments, segments);
    15771565        glPopMatrix(); 
     
    15981586  glEnd();
    15991587
    1600 
    16011588  //blue y
    16021589  glColor3f(0,0,1);
     
    16061593  glEnd();
    16071594
    1608 
    16091595  //green z
    16101596  glColor3f(0,1,0);
     
    16401626   glEnable(GL_DEPTH_TEST);
    16411627
    1642    glViewport(0, 0, NPIX, NPIX);
    1643    glMatrixMode(GL_PROJECTION);
    1644    glLoadIdentity();
    1645    gluPerspective(60, (GLdouble)1, 0.1, 50.0);
    1646    
    1647    glMatrixMode(GL_MODELVIEW);
    1648    glLoadIdentity();
    1649    glTranslatef(live_obj_x, live_obj_y, live_obj_z);
    1650 
    1651    glRotated(live_rot_x, 1., 0., 0.);
    1652    glRotated(live_rot_y, 0., 1., 0.);
    1653    glRotated(live_rot_z, 0., 0., 1.);
    1654 
     1628   //camera setting activated
     1629   cam->activate();
     1630
     1631   //now render things in the scene
     1632   //
    16551633   draw_3d_axis();
    16561634   
     
    17421720        else if(live_rot_y < -360.0)
    17431721                live_rot_y += 360.0;
     1722
     1723        cam->rotate(live_rot_x, live_rot_y, live_rot_z);
    17441724}
    17451725
     
    17921772                live_obj_z-=0.05;
    17931773                log = true;
     1774                cam->move(live_obj_x, live_obj_y, live_obj_z);
    17941775                break;
    17951776        case 's': //zoom in
    17961777                live_obj_z+=0.05;
    17971778                log = true;
     1779                cam->move(live_obj_x, live_obj_y, live_obj_z);
    17981780                break;
    17991781        case 'a': //left
    18001782                live_obj_x-=0.05;
    18011783                log = true;
     1784                cam->move(live_obj_x, live_obj_y, live_obj_z);
    18021785                break;
    18031786        case 'd': //right
    18041787                live_obj_x+=0.05;
    18051788                log = true;
     1789                cam->move(live_obj_x, live_obj_y, live_obj_z);
    18061790                break;
    18071791        case 'i':
  • trunk/gui/vizservers/nanovis/nanovis.h

    r397 r404  
    2828#include "global.h"
    2929#include "socket/Socket.h"
    30 #include "RenderVertexArray.h"
     30#include "Camera.h"
    3131#include "ConvexPolygon.h"
    3232#include "Texture3D.h"
Note: See TracChangeset for help on using the changeset viewer.