Changeset 2836 for trunk/packages
- Timestamp:
- Mar 9, 2012 3:58:03 PM (12 years ago)
- Location:
- trunk/packages/vizservers/nanovis
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/NvCamera.cpp
r2798 r2836 14 14 * ====================================================================== 15 15 */ 16 #include <stdio.h> 16 17 17 #include <stdio.h> 18 #include <GL/glew.h> 19 #include <GL/glu.h> 20 21 #include "NvCamera.h" 18 22 #include "Trace.h" 19 #include <GL/glu.h>20 #include "NvCamera.h"21 23 22 24 NvCamera::NvCamera(int startx, int starty, int w, int h, 23 25 float loc_x, float loc_y, float loc_z, 24 26 float target_x, float target_y, float target_z, 25 float angle_x, float angle_y, float angle_z): 26 location_(Vector3(loc_x, loc_y, loc_z)), 27 target_(Vector3(target_x, target_y, target_z)), 28 angle_(Vector3(angle_x, angle_y, angle_z)), 29 width_(w), 30 height_(h), 31 startX_(startx), 32 startY_(starty) 33 { 34 /*empty*/ 27 float angle_x, float angle_y, float angle_z) : 28 _location(loc_x, loc_y, loc_z), 29 _target(target_x, target_y, target_z), 30 _angle(angle_x, angle_y, angle_z), 31 _width(w), 32 _height(h), 33 _startX(startx), 34 _startY(starty) 35 { 35 36 } 36 37 37 38 38 void 39 39 NvCamera::initialize() 40 40 { 41 TRACE("camera: %d, %d\n", width_, height_);42 glViewport( startX_, startY_, width_, height_);41 TRACE("camera: %d, %d\n", _width, _height); 42 glViewport(_startX, _startY, _width, _height); 43 43 glMatrixMode(GL_PROJECTION); 44 44 glLoadIdentity(); 45 45 gluPerspective(30, 46 (GLdouble)( width_ - startX_)/(GLdouble)(height_ - startY_),46 (GLdouble)(_width - _startX)/(GLdouble)(_height - _startY), 47 47 0.1, 50.0); 48 48 … … 50 50 glLoadIdentity(); 51 51 52 gluLookAt( location_.x, location_.y, location_.z,53 target_.x, target_.y, target_.z,52 gluLookAt(_location.x, _location.y, _location.z, 53 _target.x, _target.y, _target.z, 54 54 0., 1., 0.); 55 55 56 glRotated( angle_.x, 1., 0., 0.);57 glRotated( angle_.y, 0., 1., 0.);58 glRotated( angle_.z, 0., 0., 1.);56 glRotated(_angle.x, 1., 0., 0.); 57 glRotated(_angle.y, 0., 1., 0.); 58 glRotated(_angle.z, 0., 0., 1.); 59 59 } 60 60 -
trunk/packages/vizservers/nanovis/NvCamera.h
r2798 r2836 14 14 * ====================================================================== 15 15 */ 16 17 #ifndef _CAMERA_H_ 18 #define _CAMERA_H_ 16 #ifndef CAMERA_H 17 #define CAMERA_H 19 18 20 19 #include "Vector3.h" 21 20 22 class NvCamera { 23 24 Vector3 location_; //Location of the camera in the scene 25 Vector3 target_; //Location the camera is looking at. 26 //location and target: two points define the 27 //line-of-sight 28 Vector3 angle_; //rotation angles of camera along x, y, z 29 int width_; //screen width 30 int height_; //screen height 31 int startX_; 32 int startY_; 33 21 class NvCamera 22 { 34 23 public: 35 ~NvCamera(void) {36 /*empty*/37 }38 24 NvCamera(int startx, int starty, int w, int h, 39 25 float loc_x, float loc_y, float loc_z, … … 41 27 float angle_x, float angle_y, float angle_z); 42 28 29 ~NvCamera() 30 {} 31 32 43 33 //move location of camera 44 void x(float loc_x) { 45 location_.x = loc_x; 34 void x(float loc_x) 35 { 36 _location.x = loc_x; 46 37 } 47 float x(void) { 48 return location_.x; 38 39 float x() const 40 { 41 return _location.x; 49 42 } 50 void y(float loc_y) { 51 location_.y = loc_y; 43 44 void y(float loc_y) 45 { 46 _location.y = loc_y; 52 47 } 53 float y(void) { 54 return location_.y; 48 49 float y() const 50 { 51 return _location.y; 55 52 } 56 void z(float loc_z) { 57 location_.z = loc_z; 53 54 void z(float loc_z) 55 { 56 _location.z = loc_z; 58 57 } 59 float z(void) { 60 return location_.z; 58 59 float z() const 60 { 61 return _location.z; 61 62 } 62 63 63 64 //move location of target 64 void xAim(float x) { 65 target_.x = x; 66 } 67 float xAim(void) { 68 return target_.x; 69 } 70 void yAim(float y) { 71 target_.y = y; 72 } 73 float yAim(void) { 74 return target_.y; 75 } 76 void zAim(float z) { 77 target_.z = z; 78 } 79 float zAim(void) { 80 return target_.z; 65 void xAim(float x) 66 { 67 _target.x = x; 81 68 } 82 69 83 void rotate(float angle_x, float angle_y, float angle_z) { 84 angle_ = Vector3(angle_x, angle_y, angle_z); 70 float xAim() const 71 { 72 return _target.x; 85 73 } 86 void rotate(Vector3 angle) { 87 angle_ = angle; 74 75 void yAim(float y) 76 { 77 _target.y = y; 88 78 } 89 Vector3 rotate(void) { 90 return angle_; 79 80 float yAim() const 81 { 82 return _target.y; 91 83 } 92 void set_screen_size(int sx, int sy, int w, int h) { 93 width_ = w, height_ = h; 94 startX_ = sx, startY_ = sy; 84 85 void zAim(float z) 86 { 87 _target.z = z; 95 88 } 96 void initialize(void); //make the camera setting active, this has to be 97 //called before drawing things. 89 90 float zAim() const 91 { 92 return _target.z; 93 } 94 95 void rotate(float angle_x, float angle_y, float angle_z) 96 { 97 _angle = Vector3(angle_x, angle_y, angle_z); 98 } 99 100 void rotate(const Vector3& angle) 101 { 102 _angle = angle; 103 } 104 105 Vector3 rotate() const 106 { 107 return _angle; 108 } 109 110 void set_screen_size(int sx, int sy, int w, int h) 111 { 112 _width = w; 113 _height = h; 114 _startX = sx; 115 _startY = sy; 116 } 117 118 //make the camera setting active, this has to be 119 //called before drawing things 120 void initialize(); 121 122 private: 123 Vector3 _location; //Location of the camera in the scene 124 Vector3 _target; //Location the camera is looking at. 125 //location and target: two points define the 126 //line-of-sight 127 Vector3 _angle; //rotation angles of camera along x, y, z 128 int _width; //screen width 129 int _height; //screen height 130 int _startX; 131 int _startY; 98 132 }; 99 133 -
trunk/packages/vizservers/nanovis/NvColorTableRenderer.cpp
r2798 r2836 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include <R2/R2Fonts.h>3 #include "NvColorTableRenderer.h"4 2 #include <stdlib.h> 5 3 6 NvColorTableRenderer::NvColorTableRenderer() 7 : _fonts(NULL) 4 #include <R2/R2Fonts.h> 5 6 #include "NvColorTableRenderer.h" 7 8 NvColorTableRenderer::NvColorTableRenderer() : 9 _fonts(NULL) 8 10 { 9 11 _shader = new NvColorTableShader(); … … 15 17 } 16 18 17 void NvColorTableRenderer::render(int width, int height, Texture2D* texture, TransferFunction* tf, double rangeMin, double rangeMax) 19 void NvColorTableRenderer::render(int width, int height, 20 Texture2D *texture, TransferFunction *tf, 21 double rangeMin, double rangeMax) 18 22 { 19 23 glEnable(GL_TEXTURE_2D); … … 31 35 glLoadIdentity(); 32 36 33 //glColor3f(1., 1.,1.); //MUST HAVE THIS LINE!!!37 //glColor3f(1., 1., 1.); //MUST HAVE THIS LINE!!! 34 38 _shader->bind(texture, tf); 35 39 … … 43 47 _shader->unbind(); 44 48 45 if (_fonts) 46 { 49 if (_fonts) { 47 50 _fonts->resize(width, height); 48 51 _fonts->begin(); -
trunk/packages/vizservers/nanovis/NvColorTableRenderer.h
r2798 r2836 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __NV_COLORTABLE_RENDERER_H__ 3 #define __NV_COLORTABLE_RENDERER_H__ 2 #ifndef NV_COLORTABLE_RENDERER_H 3 #define NV_COLORTABLE_RENDERER_H 4 5 #include <R2/R2Fonts.h> 4 6 5 7 #include "Texture2D.h" … … 7 9 #include "NvColorTableShader.h" 8 10 9 #include <R2/R2Fonts.h> 10 11 class NvColorTableRenderer { 12 NvColorTableShader* _shader; 13 R2Fonts* _fonts; 11 class NvColorTableRenderer 12 { 14 13 public : 15 14 NvColorTableRenderer(); 16 15 ~NvColorTableRenderer(); 17 16 18 public : 19 void render(int width, int height, Texture2D* texture, TransferFunction* tf, double rangeMin, double rageMax); 20 void setFonts(R2Fonts* fonts); 17 void render(int width, int height, 18 Texture2D *texture, TransferFunction *tf, 19 double rangeMin, double rageMax); 20 21 void setFonts(R2Fonts *fonts) 22 { 23 _fonts = fonts; 24 } 25 26 private: 27 NvColorTableShader* _shader; 28 R2Fonts* _fonts; 21 29 }; 22 30 23 inline void NvColorTableRenderer::setFonts(R2Fonts* fonts)24 {25 _fonts = fonts;26 }27 28 31 #endif 29 -
trunk/packages/vizservers/nanovis/NvColorTableShader.cpp
r2831 r2836 18 18 { 19 19 _cgFP = LoadCgSourceProgram(g_context, "one_plane.cg", CG_PROFILE_FP30, 20 20 "main"); 21 21 _dataParam = cgGetNamedParameter(_cgFP, "data"); 22 22 _tfParam = cgGetNamedParameter(_cgFP, "tf"); 23 23 _renderParam = cgGetNamedParameter(_cgFP, "render_param"); 24 24 } 25 26 27 -
trunk/packages/vizservers/nanovis/NvColorTableShader.h
r2798 r2836 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __NV_COLORTABLE_SHADER_H__ 3 #define __NV_COLORTABLE_SHADER_H__ 2 #ifndef NV_COLORTABLE_SHADER_H 3 #define NV_COLORTABLE_SHADER_H 4 5 #include <Cg/cg.h> 4 6 5 7 #include "Texture2D.h" … … 7 9 #include "NvShader.h" 8 10 9 class NvColorTableShader : public NvShader { 11 class NvColorTableShader : public NvShader 12 { 13 public: 14 NvColorTableShader(); 15 16 ~NvColorTableShader(); 17 18 void bind(Texture2D *plane, TransferFunction *tf); 19 20 void unbind(); 21 22 private : 23 void init(); 24 10 25 CGparameter _dataParam; 11 26 CGparameter _tfParam; 12 27 CGparameter _renderParam; 13 14 public :15 NvColorTableShader();16 ~NvColorTableShader();17 18 private :19 void init();20 public :21 void bind(Texture2D* plane, TransferFunction* tf);22 void unbind();23 28 }; 24 29 25 inline void NvColorTableShader::bind(Texture2D * plane, TransferFunction*tf)30 inline void NvColorTableShader::bind(Texture2D *plane, TransferFunction *tf) 26 31 { 27 32 cgGLSetTextureParameter(_dataParam, plane->id); -
trunk/packages/vizservers/nanovis/NvEventLog.cpp
r2798 r2836 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include "config.h"3 2 #include <stdio.h> 4 3 #include <assert.h> … … 9 8 #include <stdlib.h> 10 9 #include <string.h> 10 11 #include "config.h" 12 #include "nanovis.h" 11 13 #include "NvEventLog.h" 12 #include "nanovis.h"13 14 14 15 FILE* event_log; 16 double cur_time; //in seconds 15 static FILE *event_log; 16 static double cur_time; //in seconds 17 17 18 18 #ifdef XINETD … … 25 25 if (user == NULL) { 26 26 logNameLen = 20+1; 27 logName = (char *) calloc(logNameLen,sizeof(char));28 strncpy(logName, "/tmp/nanovis_log.txt",logNameLen);27 logName = (char *)calloc(logNameLen, sizeof(char)); 28 strncpy(logName, "/tmp/nanovis_log.txt", logNameLen); 29 29 } else { 30 30 logNameLen = 17+1+strlen(user); 31 logName = (char *) calloc(logNameLen,sizeof(char));32 strncpy(logName, "/tmp/nanovis_log_",logNameLen);31 logName = (char *)calloc(logNameLen, sizeof(char)); 32 strncpy(logName, "/tmp/nanovis_log_", logNameLen); 33 33 strncat(logName, user, strlen(user)); 34 34 } … … 58 58 { 59 59 event_log = fopen("event.txt", "w"); 60 assert(event_log !=0);60 assert(event_log != NULL); 61 61 62 62 struct timeval time; -
trunk/packages/vizservers/nanovis/NvEventLog.h
r2798 r2836 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __NV_EVENT_LOG_H__3 #define __NV_EVENT_LOG_H__2 #ifndef NV_EVENT_LOG_H 3 #define NV_EVENT_LOG_H 4 4 5 5 extern void NvInitEventLog(); … … 8 8 extern void NvExitService(); 9 9 10 #endif //10 #endif -
trunk/packages/vizservers/nanovis/NvFlowVisRenderer.cpp
r2835 r2836 28 28 #define NV_32 29 29 30 NvFlowVisRenderer::NvFlowVisRenderer(int w, int h , CGcontext context) :30 NvFlowVisRenderer::NvFlowVisRenderer(int w, int h) : 31 31 _activated(true) 32 32 { 33 33 _psys_width = w; 34 34 _psys_height = h; 35 36 // licRenderer[0] = new NvLIC(NMESH, NPIX, NPIX, 0,37 // Vector3(0, 0, 0), g_context);38 // licRenderer[1] = new NvLIC(NMESH, NPIX, NPIX, 1,39 // Vector3(0, 0, 0), g_context);40 // licRenderer[2] = new NvLIC(NMESH, NPIX, NPIX, 2,41 // Vector3(0, 0, 0), g_context);42 35 } 43 36 … … 48 41 delete (*iter).second; 49 42 } 50 51 /*52 for (int i = 0; i < 3; ++i) {53 delete licRenderer[i];54 }55 */56 43 } 57 44 -
trunk/packages/vizservers/nanovis/NvFlowVisRenderer.h
r2833 r2836 22 22 class NvParticleRenderer; 23 23 24 class NvFlowVisRenderer { 24 class NvFlowVisRenderer 25 { 25 26 public: 26 NvFlowVisRenderer(int w, int h , CGcontext context);27 NvFlowVisRenderer(int w, int h); 27 28 28 29 ~NvFlowVisRenderer(); … … 98 99 int _psys_width; 99 100 int _psys_height; 100 CGcontext context;101 101 102 102 std::map<std::string, NvVectorField *> _vectorFieldMap; -
trunk/packages/vizservers/nanovis/config.h
r2831 r2836 33 33 #define PROTOTYPE 0 34 34 35 #define NEW_FLOW_ENGINE 136 37 35 //#define USE_POINTSET_RENDERER 38 36 -
trunk/packages/vizservers/nanovis/nanovis.cpp
r2835 r2836 130 130 NvColorTableRenderer *NanoVis::color_table_renderer = NULL; 131 131 132 #ifndef NEW_FLOW_ENGINE133 NvParticleRenderer *NanoVis::flowVisRenderer = NULL;134 #else135 132 NvFlowVisRenderer *NanoVis::flowVisRenderer = NULL; 136 #endif137 133 VelocityArrowsSlice *NanoVis::velocityArrowsSlice = NULL; 138 134 … … 211 207 const float def_eye_y = -0.0f; 212 208 const float def_eye_z = -2.5f; 213 214 209 215 210 #ifndef XINETD … … 755 750 color_table_renderer = new NvColorTableRenderer(); 756 751 color_table_renderer->setFonts(fonts); 757 #ifndef NEW_FLOW_ENGINE 758 flowVisRenderer = new NvParticleRenderer(NMESH, NMESH, g_context); 759 #else 760 flowVisRenderer = new NvFlowVisRenderer(NMESH, NMESH, g_context); 761 #endif 752 flowVisRenderer = new NvFlowVisRenderer(NMESH, NMESH); 762 753 763 754 NanoVis::velocityArrowsSlice = new VelocityArrowsSlice; … … 1733 1724 } 1734 1725 1735 #ifdef NEW_FLOW_ENGINE1736 1726 void addVectorField(const char* filename, const char* vf_name, 1737 1727 const char* plane_name1, const char* plane_name2, … … 1794 1784 //NanoVis::initParticle(); 1795 1785 } 1796 #endif1797 1786 1798 1787 void … … 1811 1800 #endif 1812 1801 1813 #ifdef NEW_FLOW_ENGINE1814 1802 switch (key) { 1815 1803 case 'a' : … … 1997 1985 break; 1998 1986 } 1999 #endif2000 1987 } 2001 1988 -
trunk/packages/vizservers/nanovis/nanovis.h
r2835 r2836 108 108 109 109 static VolumeRenderer *vol_renderer; 110 #ifndef NEW_FLOW_ENGINE111 static NvParticleRenderer *flowVisRenderer;112 #else113 110 static NvFlowVisRenderer *flowVisRenderer; 114 #endif115 111 static VelocityArrowsSlice *velocityArrowsSlice; 116 112 static NvLIC *licRenderer;
Note: See TracChangeset
for help on using the changeset viewer.