- Timestamp:
- Mar 7, 2012 8:46:09 AM (12 years ago)
- Location:
- trunk/packages/vizservers/nanovis
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/ParticleEmitter.h
r2817 r2818 17 17 float _minLifeTime; 18 18 float _maxLifeTime; 19 19 20 20 // [0..1] * _maxPositionOffset; 21 21 vrVector3f _maxPositionOffset; -
trunk/packages/vizservers/nanovis/ParticleSystem.cpp
r2817 r2818 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include "nvconf.h" 2 3 3 4 #include <time.h> … … 6 7 #include <pthread.h> 7 8 9 #ifdef _WIN32 10 #include <GL/glaux.h> 11 #else 12 #ifdef HAVE_OPENCV_H 13 #include <opencv/cv.h> 14 #endif 15 #ifdef HAVE_OPENCV_HIGHGUI_H 16 #include <opencv/highgui.h> 17 #endif 18 #endif 19 8 20 #include <vr3d/vr3d.h> 9 21 #include <vr3d/vrTexture3D.h> … … 16 28 #include <vrmath/vrVector3f.h> 17 29 #include <vrmath/vrVector4f.h> 18 19 #ifdef _WIN3220 #include <GL/glaux.h>21 #else22 #ifdef notdef23 #include <opencv/cv.h>24 #include <opencv/highgui.h>25 #endif26 #endif27 30 28 31 #include "ParticleSystem.h" … … 226 229 _currentTime = 0; 227 230 _sortEnabled = false; 228 _glyp Enabled = false;231 _glyphEnabled = false; 229 232 _advectionEnabled = false; 230 233 _streamlineEnabled = false; … … 347 350 _arrows->setPixels(CF_RGB, DT_UBYTE, pTextureImage->width, pTextureImage->height, (void*) pTextureImage->imageData); 348 351 #else 349 350 352 #ifdef notdef 351 353 // TBD.. … … 928 930 return _sortEnabled; 929 931 break; 930 case PS_GLYP E:931 return _glyp Enabled;932 case PS_GLYPH : 933 return _glyphEnabled; 932 934 break; 933 935 case PS_DRAW_BBOX : … … 948 950 _sortEnabled = true; 949 951 break; 950 case PS_GLYP E:951 _glyp Enabled = true;952 case PS_GLYPH : 953 _glyphEnabled = true; 952 954 break; 953 955 case PS_DRAW_BBOX : … … 969 971 _sortEnabled = false; 970 972 break; 971 case PS_GLYP E:972 _glyp Enabled = false;973 case PS_GLYPH : 974 _glyphEnabled = false; 973 975 break; 974 976 case PS_DRAW_BBOX : … … 1673 1675 glScalef(_scalex, _scaley, _scalez); 1674 1676 glTranslatef(-0.5f, -0.5f, -0.5f); 1675 if (_glyp Enabled) {1677 if (_glyphEnabled) { 1676 1678 if (_drawBBoxEnabled) drawUnitBox(); 1677 1679 glColor3f(1, 1, 1); -
trunk/packages/vizservers/nanovis/ParticleSystem.h
r2817 r2818 70 70 enum EnableEnum { 71 71 PS_SORT = 1, 72 PS_GLYP E= 2,72 PS_GLYPH = 2, 73 73 PS_DRAW_BBOX = 4, 74 74 PS_ADVECTION = 8, … … 155 155 color4 *_colorBuffer; 156 156 unsigned _colorBufferID; 157 158 157 ////////////////////////////////////////// 159 158 vrTexture2D *_arrows; … … 166 165 167 166 bool _sortEnabled; 168 bool _glyp Enabled;167 bool _glyphEnabled; 169 168 bool _drawBBoxEnabled; 170 169 bool _advectionEnabled; … … 268 267 void createSortRenderTargets(); 269 268 void createStreamlineRenderTargets(); 270 271 269 void advectStreamlines(); 272 270 void renderStreamlines(); -
trunk/packages/vizservers/nanovis/ParticleSystemFactory.cpp
r2817 r2818 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include <stdio.h> 3 #include <string.h> 4 5 #include <expat.h> 2 6 3 7 #include <vrutil/vrFilePath.h> … … 5 9 #include "ParticleSystemFactory.h" 6 10 #include "ParticleSystem.h" 7 8 #include <stdio.h>9 11 #include "Trace.h" 10 12 11 #include <expat.h>12 13 #include <string.h>14 15 13 #define BUFSIZE 4096 16 14 17 15 void ParticleSystemFactory::text(void *data, const XML_Char *txt, int len) 18 16 { 19 } 17 } 20 18 21 19 void ParticleSystemFactory::startElement(void *userData, const char *elementName, const char **attrs) … … 85 83 int numOfUsedParticles = -1; 86 84 bool sortEnabled = false; 87 bool glyp Enabled = false;85 bool glyphEnabled = false; 88 86 bool bboxVisible = false; 89 87 bool advectionEnabled = false; … … 114 112 if (!strcmp(attrs[i + 1], "true")) 115 113 sortEnabled = true; 116 } else if (!strcmp(attrs[i], "glyp -enabled")) {117 if (!strcmp(attrs[i + 1], "true")) 118 glyp Enabled = true;114 } else if (!strcmp(attrs[i], "glyph-enabled")) { 115 if (!strcmp(attrs[i + 1], "true")) 116 glyphEnabled = true; 119 117 } else if (!strcmp(attrs[i], "bbox-draw-enabled")) { 120 118 if (!strcmp(attrs[i + 1], "true")) … … 158 156 dir = path.substr(0, index + 1); 159 157 path = dir + fileName; 160 161 _newParticleSystem = new ParticleSystem(width, height, path.c_str(), fieldWidth, fieldHeight, fieldDepth, timeVaryingData, startIndex, endIndex); 158 159 _newParticleSystem = 160 new ParticleSystem(width, height, path.c_str(), 161 fieldWidth, fieldHeight, fieldDepth, 162 timeVaryingData, startIndex, endIndex); 162 163 } else { 163 _newParticleSystem = new ParticleSystem(width, height, fileName.c_str(), fieldWidth, fieldHeight, fieldDepth, timeVaryingData, startIndex, endIndex); 164 _newParticleSystem = 165 new ParticleSystem(width, height, fileName.c_str(), 166 fieldWidth, fieldHeight, fieldDepth, 167 timeVaryingData, startIndex, endIndex); 164 168 } 165 169 } else { 166 170 std::string path = vrFilePath::getInstance()->getPath(fileName.c_str()); 167 _newParticleSystem = new ParticleSystem(width, height, path.c_str(), fieldWidth, fieldHeight, fieldDepth, timeVaryingData, startIndex, endIndex); 171 _newParticleSystem = 172 new ParticleSystem(width, height, path.c_str(), 173 fieldWidth, fieldHeight, fieldDepth, 174 timeVaryingData, startIndex, endIndex); 168 175 } 169 176 170 177 if (pointSize != -1.0f) _newParticleSystem->setDefaultPointSize(pointSize); 171 178 if (sortEnabled) _newParticleSystem->enable(ParticleSystem::PS_SORT); 172 if (glyp Enabled) _newParticleSystem->enable(ParticleSystem::PS_GLYPE);179 if (glyphEnabled) _newParticleSystem->enable(ParticleSystem::PS_GLYPH); 173 180 if (bboxVisible) _newParticleSystem->enable(ParticleSystem::PS_DRAW_BBOX); 174 181 if (advectionEnabled) _newParticleSystem->enable(ParticleSystem::PS_ADVECTION); -
trunk/packages/vizservers/nanovis/ParticleSystemFactory.h
r2817 r2818 12 12 { 13 13 ParticleSystem *_newParticleSystem; 14 public 14 public: 15 15 ParticleSystemFactory(); 16 16 ~ParticleSystemFactory(); … … 18 18 ParticleSystem *create(const std::string& fileName); 19 19 20 private 20 private: 21 21 void parseParticleSysInfo(const char **attrs); 22 22 void parseEmitterInfo(const char **attrs); -
trunk/packages/vizservers/nanovis/RpDX.h
r2798 r2818 18 18 #define RAPPTURE_DX_H 19 19 20 // #include "rappture2.h"21 20 #include <dx/dx.h> 22 21 #include <RpOutcome.h> -
trunk/packages/vizservers/nanovis/Texture2D.h
r2798 r2818 20 20 #include <GL/glew.h> 21 21 22 class Texture2D {23 22 class Texture2D 23 { 24 24 public: 25 25 int width; -
trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp
r2798 r2818 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include "nvconf.h" 3 2 4 #include <GL/glew.h> 3 5 #ifdef _WIN32 … … 5 7 #endif 6 8 #include <GL/gl.h> 7 #include "VelocityArrowsSlice.h"8 9 #ifdef WIN32 9 10 #include <GL/glaux.h> 10 11 #else 11 //#include <opencv/cv.h> 12 //#include <opencv/highgui.h> 13 #endif 12 #ifdef HAVE_OPENCV_H 13 #include <opencv/cv.h> 14 #endif 15 #ifdef HAVE_OPENCV_HIGHGUI_H 16 #include <opencv/highgui.h> 17 #endif 18 #endif 19 20 #include "VelocityArrowsSlice.h" 14 21 15 22 #ifdef USE_NANOVIS_LIB … … 24 31 { 25 32 _enabled = false; 26 27 28 29 30 31 32 //_renderMode = GLYPHES;33 34 35 36 37 38 #ifdef USE_NANOVIS_LIB 39 40 #else 41 42 43 44 #endif 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 /*65 66 #ifdef USE_NANOVIS_LIB 67 68 #else 69 70 71 72 #endif 73 74 75 76 77 78 //_particleFP =79 #ifdef USE_NANOVIS_LIB 80 //LoadCgSourceProgram(_context, "velocityslicefp.cg", CG_PROFILE_FP40, "fpmain");81 #else 82 83 84 85 #endif 86 87 */33 _context = cgCreateContext(); 34 _vectorFieldGraphicsID = 0; 35 _vfXscale = _vfYscale = _vfZscale = 0; 36 _slicePos = 0.5f; 37 _vertexBufferGraphicsID = 0; 38 axis(2); 39 //_renderMode = GLYPHS; 40 _renderMode = LINES; 41 42 _tickCountForMinSizeAxis = 10; 43 44 _queryVelocityFP = 45 #ifdef USE_NANOVIS_LIB 46 LoadCgSourceProgram(_context, "queryvelocity.cg", CG_PROFILE_FP30, "main"); 47 #else 48 cgCreateProgramFromFile(_context, CG_SOURCE, "queryvelocity.cg", 49 CG_PROFILE_FP30, "main", NULL); 50 cgGLLoadProgram(_queryVelocityFP); 51 #endif 52 _qvVectorFieldParam = cgGetNamedParameter(_queryVelocityFP, "vfield"); 53 54 _dirty = true; 55 _dirtySamplingPosition = true; 56 _dirtyRenderTarget = true; 57 _maxVelocityScale.x = _maxVelocityScale.y = _maxVelocityScale.z = 1.0f; 58 59 _renderTargetWidth = 128; 60 _renderTargetHeight = 128; 61 _velocities = new Vector3[_renderTargetWidth * _renderTargetHeight]; 62 63 ::glGenBuffers(1, &_vertexBufferGraphicsID); 64 glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vertexBufferGraphicsID); 65 glBufferDataARB(GL_ARRAY_BUFFER, _renderTargetWidth * _renderTargetHeight * 3 * sizeof(float), 66 0, GL_DYNAMIC_DRAW_ARB); 67 glBindBufferARB(GL_ARRAY_BUFFER, 0); 68 createRenderTarget(); 69 _pointCount = 0; 70 71 /* 72 _particleVP = 73 #ifdef USE_NANOVIS_LIB 74 LoadCgSourceProgram(_context, "velocityslicevp.cg", CG_PROFILE_VP40, "vpmain"); 75 #else 76 cgCreateProgramFromFile(_context, CG_SOURCE, "velocityslicevp.cg", 77 CG_PROFILE_VP40, "vpmain", NULL); 78 cgGLLoadProgram(_particleVP); 79 #endif 80 _mvpParticleParam = cgGetNamedParameter(_particleVP, "mvp"); 81 _mvParticleParam = cgGetNamedParameter(_particleVP, "modelview"); 82 _mvTanHalfFOVParam = cgGetNamedParameter(_particleVP, "tanHalfFOV"); 83 84 // TBD.. 85 _particleFP = 86 #ifdef USE_NANOVIS_LIB 87 LoadCgSourceProgram(_context, "velocityslicefp.cg", CG_PROFILE_FP40, "fpmain"); 88 #else 89 cgCreateProgramFromFile(_context, CG_SOURCE, "velocityslicefp.cg", 90 CG_PROFILE_FP40, "fpmain", NULL); 91 cgGLLoadProgram(_particleFP); 92 #endif 93 _vectorParticleParam = cgGetNamedParameter(_particleVP, "vfield"); 94 */ 88 95 89 96 #ifdef USE_NANOVIS_LIB 90 97 91 98 #ifdef WIN32 92 93 94 95 96 97 99 AUX_RGBImageRec *pTextureImage = auxDIBImageLoad("arrows.bmp"); 100 _arrowsTex->setPixels(CF_RGB, DT_UBYTE, pTextureImage->sizeX, pTextureImage->sizeY, (void*) pTextureImage->data); 101 102 _arrowsTex = new Texture2D(pTextureImage->sizeX, pTextureImage->sizeY, GL_FLOAT, GL_LINEAR, 3, (void*) pTextureImage->data); 103 104 //delete pTextureImage; 98 105 #else 99 106 /* 100 107 TRACE("test1\n"); 101 102 if (path) TRACE("test2 %s\n", path);103 else TRACE("tt\n");104 IplImage* pTextureImage = cvLoadImage(path); 105 TRACE("test3\n");106 if (pTextureImage)107 {108 TRACE("file(%s) has been loaded\n", path);109 _arrowsTex = new Texture2D(pTextureImage->width, pTextureImage->height, GL_FLOAT, GL_LINEAR, 3, (float*) pTextureImage->imageData);110 111 //cvReleaseImage(&pTextureImage);112 }113 else114 115 116 117 118 */119 120 #endif 121 122 #else 123 124 125 108 const char *path = R2FilePath::getInstance()->getPath("arrows_flip2.png"); 109 if (path) { 110 TRACE("test2 %s\n", path); 111 } else { 112 TRACE("tt\n"); 113 } 114 IplImage* pTextureImage = cvLoadImage(path); 115 TRACE("test3\n"); 116 if (pTextureImage) { 117 TRACE("file(%s) has been loaded\n", path); 118 _arrowsTex = new Texture2D(pTextureImage->width, pTextureImage->height, GL_FLOAT, GL_LINEAR, 3, (float*) pTextureImage->imageData); 119 TRACE("file(%s) has been loaded\n", path); 120 //cvReleaseImage(&pTextureImage); 121 } else { 122 TRACE("not found\n"); 123 } 124 if (path) delete [] path; 125 */ 126 127 #endif 128 129 #else 130 _arrowsTex = new Texture2D(); 131 _arrowsTex->setWrapS(TW_MIRROR); 132 _arrowsTex->setWrapT(TW_MIRROR); 126 133 #ifdef WIN32 127 128 129 130 131 #else 132 133 134 135 134 AUX_RGBImageRec *pTextureImage = auxDIBImageLoad("arrows.bmp"); 135 _arrowsTex->setPixels(CF_RGB, DT_UBYTE, pTextureImage->sizeX, pTextureImage->sizeY, (void*) pTextureImage->data); 136 137 //delete pTextureImage; 138 #else 139 IplImage* pTextureImage = cvLoadImage("arrows_flip2.png"); 140 _arrowsTex->setPixels(CF_RGB, DT_UBYTE, pTextureImage->width, pTextureImage->height, (void*) pTextureImage->imageData); 141 142 //cvReleaseImage(&pTextureImage); 136 143 #endif 137 144 … … 150 157 151 158 #ifdef USE_NANOVIS_LIB 152 153 #else 154 155 #endif 156 157 158 159 160 159 delete _arrowsTex; 160 #else 161 _arrowsTex->unref(); 162 #endif 163 cgDestroyProgram(_particleFP); 164 cgDestroyProgram(_particleVP); 165 166 glDeleteBuffers(1, &_vertexBufferGraphicsID); 167 delete [] _velocities; 161 168 } 162 169 163 170 void VelocityArrowsSlice::createRenderTarget() 164 171 { 165 172 glGenFramebuffersEXT(1, &_fbo); 166 173 glGenTextures(1, &_tex); 167 174 168 175 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fbo); 169 176 170 171 172 173 174 175 177 glViewport(0, 0, _renderTargetWidth, _renderTargetHeight); 178 glMatrixMode(GL_PROJECTION); 179 glLoadIdentity(); 180 glOrtho(0, _renderTargetWidth, 0, _renderTargetHeight, -10.0f, 10.0f); 181 glMatrixMode(GL_MODELVIEW); 182 glLoadIdentity(); 176 183 177 184 glBindTexture(GL_TEXTURE_RECTANGLE_NV, _tex); 178 185 glTexParameterf(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 179 186 glTexParameterf(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 180 181 187 glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 188 glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 182 189 183 190 glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_FLOAT_RGBA32_NV, 184 _renderTargetWidth, _renderTargetHeight, 0, GL_RGBA, GL_FLOAT, NULL); 185 191 _renderTargetWidth, _renderTargetHeight, 0, 192 GL_RGBA, GL_FLOAT, NULL); 186 193 187 188 194 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, 195 GL_TEXTURE_RECTANGLE_NV, _tex, 0); 189 196 190 197 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); … … 193 200 void VelocityArrowsSlice::axis(int axis) 194 201 { 195 _axis = axis; 196 switch (_axis) 197 { 198 case 0 : 199 _projectionVector.x = 0; 200 _projectionVector.y = 1; 201 _projectionVector.z = 1; 202 break; 203 case 1 : 204 _projectionVector.x = 1; 205 _projectionVector.y = 0; 206 _projectionVector.z = 1; 207 break; 208 case 2 : 209 _projectionVector.x = 1; 210 _projectionVector.y = 1; 211 _projectionVector.z = 0; 212 break; 213 } 214 _dirtySamplingPosition = true; 215 _dirtyRenderTarget = true; 202 _axis = axis; 203 switch (_axis) { 204 case 0: 205 _projectionVector.x = 0; 206 _projectionVector.y = 1; 207 _projectionVector.z = 1; 208 break; 209 case 1 : 210 _projectionVector.x = 1; 211 _projectionVector.y = 0; 212 _projectionVector.z = 1; 213 break; 214 case 2: 215 _projectionVector.x = 1; 216 _projectionVector.y = 1; 217 _projectionVector.z = 0; 218 break; 219 } 220 _dirtySamplingPosition = true; 221 _dirtyRenderTarget = true; 216 222 //_dirty = true; 217 223 } 218 224 219 220 225 void VelocityArrowsSlice::queryVelocity() 221 226 { 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 glBegin(GL_POINTS); 241 242 for (unsigned int index = 0; index < _samplingPositions.size(); ++index) 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 227 if (!_enabled) return; 228 229 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fbo); 230 glDisable(GL_DEPTH_TEST); 231 cgGLBindProgram(_queryVelocityFP); 232 cgGLEnableProfile(CG_PROFILE_FP30); 233 cgGLSetTextureParameter(_qvVectorFieldParam, _vectorFieldGraphicsID); 234 cgGLEnableTextureParameter(_qvVectorFieldParam); 235 236 glPushAttrib(GL_VIEWPORT_BIT); 237 glViewport(0, 0, _renderTargetWidth, _renderTargetHeight); 238 glMatrixMode(GL_PROJECTION); 239 glPushMatrix(); 240 glLoadIdentity(); 241 glOrtho(0, _renderTargetWidth, 0, _renderTargetHeight, -10.0f, 10.0f); 242 glMatrixMode(GL_MODELVIEW); 243 glPushMatrix(); 244 glLoadIdentity(); 245 246 glBegin(GL_POINTS); 247 248 for (unsigned int index = 0; index < _samplingPositions.size(); ++index) { 249 glMultiTexCoord3f(0, _samplingPositions[index].x,_samplingPositions[index].y,_samplingPositions[index].z); 250 glVertex2f(index % _renderTargetWidth, 251 index / _renderTargetHeight); 252 } 253 254 glEnd(); 255 256 glDisable(GL_TEXTURE_RECTANGLE_NV); 257 cgGLDisableTextureParameter(_qvVectorFieldParam); 258 cgGLDisableProfile(CG_PROFILE_FP30); 259 260 glReadPixels(0, 0, _renderTargetWidth, _renderTargetHeight, GL_RGB, GL_FLOAT, _velocities); 261 262 glMatrixMode(GL_PROJECTION); 263 glPopMatrix(); 264 glMatrixMode(GL_MODELVIEW); 265 glPopMatrix(); 266 glPopAttrib(); 267 268 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 264 269 } 265 270 … … 268 273 //if (!_enabled || (_vectorFieldGraphicsID == 0)) return; 269 274 if (!_enabled) return; 270 275 271 276 if (_dirty) { 272 277 computeSamplingTicks(); … … 274 279 _dirty = false; 275 280 } 276 277 281 278 282 glPushMatrix(); 279 283 280 284 glScalef(_vfXscale,_vfYscale, _vfZscale); 281 285 glTranslatef(-0.5f, -0.5f, -0.5f); 282 286 if (_renderMode == LINES) { 283 284 287 glDisable(GL_TEXTURE_2D); 285 288 glLineWidth(2.0); … … 299 302 glVertex3f(pos2.x, pos2.y, pos2.z); 300 303 /*v = pos - pos2; 301 302 303 v2.x = 1; 304 v2.y = 1; 305 v2.z = (-(x1-x2)-(y1-y2))/(z1-z2) 306 adj = v.length() / (4 * sqrt((x3^2)+(y3^2)+(z3^2))); 307 x3 *= adj 308 y3 *= adj 309 z3 *= adj 304 v2.x = 1; 305 v2.y = 1; 306 v2.z = (-(x1-x2)-(y1-y2))/(z1-z2) 307 adj = v.length() / (4 * sqrt((x3^2)+(y3^2)+(z3^2))); 308 x3 *= adj 309 y3 *= adj 310 z3 *= adj 310 311 */ 311 312 312 } 313 313 } 314 314 } else if (_axis == 1) { 315 315 int index = 0; 316 for (int z = 1; z <= _tickCountZ; ++z) 316 for (int z = 1; z <= _tickCountZ; ++z) { 317 317 for (int x = 1; x <= _tickCountX; ++x, ++index) { 318 318 pos = _samplingPositions[index]; … … 322 322 glVertex3f(pos2.x, pos2.y, pos2.z); 323 323 } 324 } 324 325 } else if (_axis == 0) { 325 326 int index = 0; 326 for (int z = 1; z <= _tickCountZ; ++z) 327 for (int z = 1; z <= _tickCountZ; ++z) { 327 328 for (int y = 1; y <= _tickCountY; ++y, ++index) { 328 329 pos = _samplingPositions[index]; … … 332 333 glVertex3f(pos2.x, pos2.y, pos2.z); 333 334 } 335 } 334 336 } 335 337 336 338 glEnd(); 337 339 glLineWidth(1.0); … … 420 422 void VelocityArrowsSlice::tickCountForMinSizeAxis(int tickCount) 421 423 { 422 424 _tickCountForMinSizeAxis = tickCount; 423 425 424 426 //_dirty = true; 425 427 } 426 428 427 428 429 void VelocityArrowsSlice::computeSamplingTicks() 429 430 { 430 if (_vfXscale < _vfYscale) 431 { 432 if (_vfXscale < _vfZscale) 433 { 434 // vfXscale 435 _tickCountX = _tickCountForMinSizeAxis; 431 if (_vfXscale < _vfYscale) { 432 if (_vfXscale < _vfZscale) { 433 // vfXscale 434 _tickCountX = _tickCountForMinSizeAxis; 436 435 437 436 float step = _vfXscale / (_tickCountX + 1); 438 437 439 _tickCountY = (int) (_vfYscale/step); 440 _tickCountZ = (int) (_vfZscale/step); 441 //vscalex = 1; 442 //vscaley = _vfXscale / _vfXscale; 443 //vscalez = _vfZscale / _vfXscale; 444 } 445 else 446 { 447 // vfZscale 448 _tickCountZ = _tickCountForMinSizeAxis; 449 450 float step = _vfZscale / (_tickCountZ + 1); 451 _tickCountX = (int) (_vfXscale/step); 452 _tickCountY = (int) (_vfYscale/step); 453 //vscalex = _vfXscale / _vfZscale; 454 //vscaley = _vfYscale / _vfZscale; 455 //vscalez = 1; 456 } 457 458 } 459 else 460 { 461 if (_vfYscale < _vfZscale) 462 { 463 // _vfYscale 464 _tickCountY = _tickCountForMinSizeAxis; 465 466 float step = _vfYscale / (_tickCountY + 1); 467 _tickCountX = (int) (_vfXscale/step); 468 _tickCountZ = (int) (_vfZscale/step); 469 470 //vscalex = _vfXscale / _vfYscale; 471 //vscaley = 1; 472 //vscalez = _vfZscale / _vfYscale; 473 } 474 else 475 { 476 // vfZscale 477 _tickCountZ = _tickCountForMinSizeAxis; 438 _tickCountY = (int)(_vfYscale/step); 439 _tickCountZ = (int)(_vfZscale/step); 440 //vscalex = 1; 441 //vscaley = _vfXscale / _vfXscale; 442 //vscalez = _vfZscale / _vfXscale; 443 } else { 444 // vfZscale 445 _tickCountZ = _tickCountForMinSizeAxis; 446 447 float step = _vfZscale / (_tickCountZ + 1); 448 _tickCountX = (int)(_vfXscale/step); 449 _tickCountY = (int)(_vfYscale/step); 450 //vscalex = _vfXscale / _vfZscale; 451 //vscaley = _vfYscale / _vfZscale; 452 //vscalez = 1; 453 } 454 } else { 455 if (_vfYscale < _vfZscale) { 456 // _vfYscale 457 _tickCountY = _tickCountForMinSizeAxis; 458 459 float step = _vfYscale / (_tickCountY + 1); 460 _tickCountX = (int)(_vfXscale/step); 461 _tickCountZ = (int)(_vfZscale/step); 462 463 //vscalex = _vfXscale / _vfYscale; 464 //vscaley = 1; 465 //vscalez = _vfZscale / _vfYscale; 466 } else { 467 // vfZscale 468 _tickCountZ = _tickCountForMinSizeAxis; 478 469 479 float step = _vfZscale / (_tickCountZ + 1); 480 _tickCountX = (int) (_vfXscale/step); 481 _tickCountY = (int) (_vfYscale/step); 482 483 //vscalex = _vfXscale / _vfZscale; 484 //vscaley = _vfYscale / _vfZscale; 485 //vscalez = 1; 486 487 488 } 489 } 490 491 _maxVelocityScale.x = 1.0f / _tickCountX * 0.8f; 492 _maxVelocityScale.y = 1.0f / _tickCountY * 0.8f; 493 _maxVelocityScale.z = 1.0f / _tickCountZ * 0.8f; 494 495 int pointCount = _tickCountX * _tickCountY * _tickCountZ; 496 if (_pointCount != pointCount) 497 { 498 _samplingPositions.clear(); 499 _samplingPositions.reserve(pointCount); 500 _pointCount = pointCount; 501 } 502 503 if (_renderMode == LINES) 504 { 505 Vector3 pos; 506 if (_axis == 2) 507 { 508 for (int y = 1; y <= _tickCountY; ++y) 509 for (int x = 1; x <= _tickCountX; ++x) 510 { 511 pos.x = (1.0f / (_tickCountX + 1)) * x; 512 pos.y = (1.0f / (_tickCountY + 1)) * y; 513 pos.z = _slicePos; 514 _samplingPositions.push_back(pos); 515 516 } 517 } 518 else if (_axis == 1) 519 { 520 for (int z = 1; z <= _tickCountZ; ++z) 521 for (int x = 1; x <= _tickCountX; ++x) 522 { 523 pos.x = (1.0f / (_tickCountX + 1)) * x; 524 pos.y = _slicePos; 525 pos.z = (1.0f / (_tickCountZ + 1)) * z; 526 _samplingPositions.push_back(pos); 527 } 528 } 529 else if (_axis == 0) 530 { 531 for (int z = 1; z <= _tickCountZ; ++z) 532 for (int y = 1; y <= _tickCountY; ++y) 533 { 534 pos.x = _slicePos; 535 pos.y = (1.0f / (_tickCountY + 1)) * y; 536 pos.z = (1.0f / (_tickCountZ + 1)) * z; 537 _samplingPositions.push_back(pos); 538 } 539 } 540 } 541 else 542 { 543 glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vertexBufferGraphicsID); 544 Vector3* pinfo = (Vector3*) glMapBufferARB(GL_ARRAY_BUFFER, GL_WRITE_ONLY_ARB); 545 546 Vector3 pos; 547 if (_axis == 2) 548 { 549 for (int y = 1; y <= _tickCountY; ++y) 550 for (int x = 1; x <= _tickCountX; ++x) 551 { 552 pos.x = (1.0f / (_tickCountX + 1)) * x; 553 pos.y = (1.0f / (_tickCountY + 1)) * y; 554 pos.z = _slicePos; 555 556 *pinfo = pos; 557 ++pinfo; 558 } 559 } 560 else if (_axis == 1) 561 { 562 for (int z = 1; z <= _tickCountZ; ++z) 563 for (int x = 1; x <= _tickCountX; ++x) 564 { 565 pos.x = (1.0f / (_tickCountX + 1)) * x; 566 pos.y = _slicePos; 567 pos.z = (1.0f / (_tickCountZ + 1)) * z; 568 569 *pinfo = pos; 570 ++pinfo; 571 } 572 } 573 else if (_axis == 0) 574 { 575 for (int z = 1; z <= _tickCountZ; ++z) 576 for (int y = 1; y <= _tickCountY; ++y) 577 { 578 pos.x = _slicePos; 579 pos.y = (1.0f / (_tickCountY + 1)) * y; 580 pos.z = (1.0f / (_tickCountZ + 1)) * z; 581 582 *pinfo = pos; 583 ++pinfo; 584 } 585 } 586 587 glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); 588 } 470 float step = _vfZscale / (_tickCountZ + 1); 471 _tickCountX = (int)(_vfXscale/step); 472 _tickCountY = (int)(_vfYscale/step); 473 474 //vscalex = _vfXscale / _vfZscale; 475 //vscaley = _vfYscale / _vfZscale; 476 //vscalez = 1; 477 } 478 } 479 480 _maxVelocityScale.x = 1.0f / _tickCountX * 0.8f; 481 _maxVelocityScale.y = 1.0f / _tickCountY * 0.8f; 482 _maxVelocityScale.z = 1.0f / _tickCountZ * 0.8f; 483 484 int pointCount = _tickCountX * _tickCountY * _tickCountZ; 485 if (_pointCount != pointCount) { 486 _samplingPositions.clear(); 487 _samplingPositions.reserve(pointCount); 488 _pointCount = pointCount; 489 } 490 491 if (_renderMode == LINES) { 492 Vector3 pos; 493 if (_axis == 2) { 494 for (int y = 1; y <= _tickCountY; ++y) { 495 for (int x = 1; x <= _tickCountX; ++x) { 496 pos.x = (1.0f / (_tickCountX + 1)) * x; 497 pos.y = (1.0f / (_tickCountY + 1)) * y; 498 pos.z = _slicePos; 499 _samplingPositions.push_back(pos); 500 } 501 } 502 } else if (_axis == 1) { 503 for (int z = 1; z <= _tickCountZ; ++z) { 504 for (int x = 1; x <= _tickCountX; ++x) { 505 pos.x = (1.0f / (_tickCountX + 1)) * x; 506 pos.y = _slicePos; 507 pos.z = (1.0f / (_tickCountZ + 1)) * z; 508 _samplingPositions.push_back(pos); 509 } 510 } 511 } else if (_axis == 0) { 512 for (int z = 1; z <= _tickCountZ; ++z) { 513 for (int y = 1; y <= _tickCountY; ++y) { 514 pos.x = _slicePos; 515 pos.y = (1.0f / (_tickCountY + 1)) * y; 516 pos.z = (1.0f / (_tickCountZ + 1)) * z; 517 _samplingPositions.push_back(pos); 518 } 519 } 520 } 521 } else { 522 glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vertexBufferGraphicsID); 523 Vector3* pinfo = (Vector3*) glMapBufferARB(GL_ARRAY_BUFFER, GL_WRITE_ONLY_ARB); 524 525 Vector3 pos; 526 if (_axis == 2) { 527 for (int y = 1; y <= _tickCountY; ++y) { 528 for (int x = 1; x <= _tickCountX; ++x) { 529 pos.x = (1.0f / (_tickCountX + 1)) * x; 530 pos.y = (1.0f / (_tickCountY + 1)) * y; 531 pos.z = _slicePos; 532 533 *pinfo = pos; 534 ++pinfo; 535 } 536 } 537 } else if (_axis == 1) { 538 for (int z = 1; z <= _tickCountZ; ++z) { 539 for (int x = 1; x <= _tickCountX; ++x) { 540 pos.x = (1.0f / (_tickCountX + 1)) * x; 541 pos.y = _slicePos; 542 pos.z = (1.0f / (_tickCountZ + 1)) * z; 543 544 *pinfo = pos; 545 ++pinfo; 546 } 547 } 548 } else if (_axis == 0) { 549 for (int z = 1; z <= _tickCountZ; ++z) { 550 for (int y = 1; y <= _tickCountY; ++y) { 551 pos.x = _slicePos; 552 pos.y = (1.0f / (_tickCountY + 1)) * y; 553 pos.z = (1.0f / (_tickCountZ + 1)) * z; 554 555 *pinfo = pos; 556 ++pinfo; 557 } 558 } 559 } 560 561 glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); 562 } 589 563 } 590 564 … … 594 568 _dirty = true; 595 569 } 596 -
trunk/packages/vizservers/nanovis/VelocityArrowsSlice.h
r2798 r2818 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 2 #ifndef VELOCITY_ARROW_SLICE_H 3 #define VELOCITY_ARROW_SLICE_H 13 #define VELOCITY_ARROW_SLICE_H 4 4 5 5 #include <Cg/cg.h> … … 17 17 typedef vrTexture2D Texture2D; 18 18 19 class Vector3 { 20 public : 21 float x, y, z; 22 Vector3() : x(0.0f), y(0.0f), z(0.0f) {} 23 Vector3(float x1, float y1, float z1) : x(x1), y(y1), z(z1) {} 24 Vector3 operator*(float scale) 25 { 26 Vector3 vec; 27 vec.x = x * scale; 28 vec.y = y * scale; 29 vec.z = z * scale; 30 return vec; 31 } 19 class Vector3 20 { 21 public: 22 float x, y, z; 23 24 Vector3() : 25 x(0.0f), y(0.0f), z(0.0f) 26 {} 27 28 Vector3(float x1, float y1, float z1) : 29 x(x1), y(y1), z(z1) 30 {} 31 32 Vector3 operator*(float scale) 33 { 34 Vector3 vec; 35 vec.x = x * scale; 36 vec.y = y * scale; 37 vec.z = z * scale; 38 return vec; 39 } 40 32 41 Vector3 scale(const Vector3& scale) 33 42 { … … 36 45 vec.y = y * scale.y; 37 46 vec.z = z * scale.z; 38 47 return vec; 39 48 } 40 49 41 Vector3 operator*(const Vector3& scale) 42 { 43 Vector3 vec; 44 vec.x = x * scale.x; 45 vec.y = y * scale.y; 46 vec.z = z * scale.z; 47 return vec; 50 Vector3 operator*(const Vector3& scale) 51 { 52 Vector3 vec; 53 vec.x = x * scale.x; 54 vec.y = y * scale.y; 55 vec.z = z * scale.z; 56 return vec; 57 } 48 58 49 } 50 friend Vector3 operator+(const Vector3& value1, const Vector3& value2); 59 friend Vector3 operator+(const Vector3& value1, const Vector3& value2); 51 60 52 61 void set(float x1, float y1, float z1) … … 58 67 inline Vector3 operator+(const Vector3& value1, const Vector3& value2) 59 68 { 60 69 return Vector3(value1.x + value2.x, value1.y + value2.y, value1.z + value2.z); 61 70 } 62 71 … … 64 73 65 74 66 class VelocityArrowsSlice { 67 public : 68 enum RenderMode { 69 LINES, 70 GLYPHES, 71 }; 72 private : 73 unsigned int _vectorFieldGraphicsID; 74 float _vfXscale; 75 float _vfYscale; 76 float _vfZscale; 77 float _slicePos; 78 int _axis; 75 class VelocityArrowsSlice 76 { 77 public: 78 enum RenderMode { 79 LINES, 80 GLYPHS, 81 }; 82 83 private: 84 unsigned int _vectorFieldGraphicsID; 85 float _vfXscale; 86 float _vfYscale; 87 float _vfZscale; 88 float _slicePos; 89 int _axis; 79 90 80 91 unsigned int _fbo; 81 92 unsigned int _tex; 82 93 83 84 85 94 CGcontext _context; 95 CGprogram _queryVelocityFP; 96 CGparameter _qvVectorFieldParam; 86 97 87 88 89 Vector3*_velocities;90 91 98 int _renderTargetWidth; 99 int _renderTargetHeight; 100 Vector3 *_velocities; 101 std::vector<Vector3> _samplingPositions; 102 Vector3 _projectionVector; 92 103 93 94 95 96 104 int _tickCountForMinSizeAxis; 105 int _tickCountX; 106 int _tickCountY; 107 int _tickCountZ; 97 108 98 109 int _pointCount; 99 110 100 101 111 Vector3 _maxVelocityScale; 112 Vector3 _arrowColor; 102 113 103 104 105 106 114 bool _enabled; 115 bool _dirty; 116 bool _dirtySamplingPosition; 117 bool _dirtyRenderTarget; 107 118 108 119 unsigned int _vertexBufferGraphicsID; 109 120 110 111 112 113 114 121 CGprogram _particleVP; 122 CGparameter _mvpParticleParam; 123 CGparameter _mvParticleParam; 124 CGparameter _mvTanHalfFOVParam; 125 CGparameter _mvCurrentTimeParam; 115 126 116 117 127 CGprogram _particleFP; 128 CGparameter _vectorParticleParam; 118 129 119 Texture2D*_arrowsTex;130 Texture2D *_arrowsTex; 120 131 121 RenderMode _renderMode; 122 private : 123 void createRenderTarget(); 124 void computeSamplingTicks(); 125 public : 126 VelocityArrowsSlice(); 127 ~VelocityArrowsSlice(); 132 RenderMode _renderMode; 128 133 129 void vectorField(unsigned int vfGraphicsID, float xScale, float yScale, float zScale); 130 void axis(int axis); 131 int axis() const; 132 void slicePos(float pos); 133 float slicePos() const; 134 void queryVelocity(); 135 void render(); 136 void enabled(bool enabled) { 137 _enabled = enabled; 134 void createRenderTarget(); 135 void computeSamplingTicks(); 136 137 public: 138 VelocityArrowsSlice(); 139 ~VelocityArrowsSlice(); 140 141 void vectorField(unsigned int vfGraphicsID, float xScale, float yScale, float zScale); 142 void axis(int axis); 143 int axis() const; 144 void slicePos(float pos); 145 float slicePos() const; 146 void queryVelocity(); 147 void render(); 148 void enabled(bool enabled) 149 { 150 _enabled = enabled; 138 151 } 139 bool enabled(void) const { 140 return _enabled; 152 bool enabled(void) const 153 { 154 return _enabled; 141 155 } 142 156 void tickCountForMinSizeAxis(int tickCount); … … 149 163 inline int VelocityArrowsSlice::axis() const 150 164 { 151 165 return _axis; 152 166 } 153 167 154 168 inline float VelocityArrowsSlice::slicePos() const 155 169 { 156 170 return _slicePos; 157 171 } 158 172 … … 160 174 inline int VelocityArrowsSlice::tickCountForMinSizeAxis() const 161 175 { 162 176 return _tickCountForMinSizeAxis; 163 177 } 164 178 … … 170 184 inline void VelocityArrowsSlice::renderMode(VelocityArrowsSlice::RenderMode mode) 171 185 { 172 173 186 _renderMode = mode; 187 _dirty = true; 174 188 } 175 189 176 190 inline VelocityArrowsSlice::RenderMode VelocityArrowsSlice::renderMode() const 177 191 { 178 192 return _renderMode; 179 193 } 180 194 181 #endif /* VELOCITY_ARROW_SLICE_H */195 #endif -
trunk/packages/vizservers/nanovis/nanovis.h
r2801 r2818 41 41 #include <signal.h> 42 42 43 #include <rappture.h> 44 43 45 #include "define.h" 44 46 #include "global.h" 45 #include "rappture.h"46 47 #include "NvCamera.h" 47 48 #include "ConvexPolygon.h"
Note: See TracChangeset
for help on using the changeset viewer.