Changeset 1489 for trunk/packages
- Timestamp:
- Jun 3, 2009, 11:47:01 AM (15 years ago)
- Location:
- trunk/packages/vizservers/nanovis
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Makefile.in
r1484 r1489 148 148 TransferFunction.o \ 149 149 Util.o \ 150 VelocityArrow Slice.o \150 VelocityArrowsSlice.o \ 151 151 Volume.o \ 152 152 VolumeInterpolator.o \ … … 160 160 resources = \ 161 161 $(srcdir)/resources/Font.bmp \ 162 $(srcdir)/resource/arrows_flip2.png \ 162 163 $(srcdir)/resources/particle2.bmp \ 163 164 $(srcdir)/resources/verdana.fnt \ … … 170 171 $(srcdir)/shaders/one_plane.cg \ 171 172 $(srcdir)/shaders/one_volume.cg \ 173 $(srcdir)/shaders/particle_common.cg \ 172 174 $(srcdir)/shaders/passthru.cg \ 173 175 $(srcdir)/shaders/pointsvp.cg \ … … 179 181 $(srcdir)/shaders/vertex_std.cg \ 180 182 $(srcdir)/shaders/volqd_volume.cg \ 183 $(srcdir)/shaders/velocityslicevp.cg \ 184 $(srcdir)/shaders/velocityslicefp.cg \ 181 185 $(srcdir)/shaders/zincblende_volume.cg 182 186 … … 294 298 VolumeInterpolator.o: VolumeInterpolator.cpp VolumeInterpolator.h 295 299 GradientFilter.o: GradientFilter.cpp GradientFilter.h 296 VelocityArrow Slice.o: VelocityArrowSlice.cpp VelocityArrowSlice.h300 VelocityArrowsSlice.o: VelocityArrowsSlice.cpp VelocityArrowsSlice.h 297 301 298 302 Util.o: Util.cpp Util.h -
trunk/packages/vizservers/nanovis/R2/src/R2FilePath.cpp
r1380 r1489 83 83 84 84 path = new char[strlen((char *)(*iter)) + 1 + nameLength + 1]; 85 sprintf(path, "%s/%s", (char *)(*iter), fileName); 85 //sprintf(path, "%s/%s", (char *)(*iter), fileName); 86 sprintf(path, "%s%s", (char *)(*iter), fileName); 86 87 if (access(path, R_OK) == 0) { 87 88 return path; -
trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp
r1487 r1489 5 5 #include <GL/gl.h> 6 6 #include "VelocityArrowsSlice.h" 7 #ifdef WIN32 8 #include <GL/glaux.h> 9 #else 10 //#include <opencv/cv.h> 11 //#include <opencv/highgui.h> 12 #endif 13 14 #ifdef USE_NANOVIS_LIB 7 15 #include "global.h" 8 16 #include "Nv.h" 17 #include "R2/R2FilePath.h" 18 #endif 19 20 #define USE_VERTEX_BUFFER 9 21 10 22 VelocityArrowsSlice::VelocityArrowsSlice() 11 23 { 24 printf("test\n"); 25 _enabled = true; 12 26 _context = cgCreateContext(); 13 27 _vectorFieldGraphicsID = 0; 14 28 _vfXscale = _vfYscale = _vfZscale = 0; 15 29 _slicePos = 0.5f; 16 _enabled =true; 17 30 _vertexBufferGraphicsID = 0; 18 31 axis(2); 19 32 //_renderMode = GLYPHES; 33 _renderMode = LINES; 20 34 21 35 _tickCountForMinSizeAxis = 10; 22 36 23 _queryVelocityFP = LoadCgSourceProgram(_context, "queryvelocity.cg", 24 CG_PROFILE_FP30, "main"); 25 _ipVectorFieldParam = cgGetNamedParameter(_queryVelocityFP, "vfield"); 37 _queryVelocityFP = 38 #ifdef USE_NANOVIS_LIB 39 LoadCgSourceProgram(_context, "queryvelocity.cg", CG_PROFILE_FP30, "main"); 40 #else 41 cgCreateProgramFromFile(_context, CG_SOURCE, "queryvelocity.cg", 42 CG_PROFILE_FP30, "main", NULL); 43 cgGLLoadProgram(_queryVelocityFP); 44 #endif 45 _qvVectorFieldParam = cgGetNamedParameter(_queryVelocityFP, "vfield"); 26 46 27 47 _dirty = true; … … 33 53 _renderTargetHeight = 128; 34 54 _velocities = new Vector3[_renderTargetWidth * _renderTargetHeight]; 55 56 ::glGenBuffers(1, &_vertexBufferGraphicsID); 57 glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vertexBufferGraphicsID); 58 glBufferDataARB(GL_ARRAY_BUFFER, _renderTargetWidth * _renderTargetHeight * 3 * sizeof(float), 59 0, GL_DYNAMIC_DRAW_ARB); 60 glBindBufferARB(GL_ARRAY_BUFFER, 0); 35 61 createRenderTarget(); 36 62 _pointCount = 0; 37 _vectorFieldGraphicsID = 0; 38 39 _arrowColor.set(1, 1, 0); 63 64 /* 65 _particleVP = 66 #ifdef USE_NANOVIS_LIB 67 LoadCgSourceProgram(_context, "velocityslicevp.cg", CG_PROFILE_VP40, "vpmain"); 68 #else 69 cgCreateProgramFromFile(_context, CG_SOURCE, "velocityslicevp.cg", 70 CG_PROFILE_VP40, "vpmain", NULL); 71 cgGLLoadProgram(_particleVP); 72 #endif 73 _mvpParticleParam = cgGetNamedParameter(_particleVP, "mvp"); 74 _mvParticleParam = cgGetNamedParameter(_particleVP, "modelview"); 75 _mvTanHalfFOVParam = cgGetNamedParameter(_particleVP, "tanHalfFOV"); 76 77 // TBD.. 78 //_particleFP = 79 #ifdef USE_NANOVIS_LIB 80 // LoadCgSourceProgram(_context, "velocityslicefp.cg", CG_PROFILE_FP40, "fpmain"); 81 #else 82 cgCreateProgramFromFile(_context, CG_SOURCE, "velocityslicefp.cg", 83 CG_PROFILE_FP40, "fpmain", NULL); 84 cgGLLoadProgram(_particleFP); 85 #endif 86 _vectorParticleParam = cgGetNamedParameter(_particleVP, "vfield"); 87 */ 88 89 #ifdef USE_NANOVIS_LIB 90 91 #ifdef WIN32 92 AUX_RGBImageRec *pTextureImage = auxDIBImageLoad("arrows.bmp"); 93 _arrowsTex->setPixels(CF_RGB, DT_UBYTE, pTextureImage->sizeX, pTextureImage->sizeY, (void*) pTextureImage->data); 94 95 _arrowsTex = new Texture2D(pTextureImage->sizeX, pTextureImage->sizeY, GL_FLOAT, GL_LINEAR, 3, (void*) pTextureImage->data); 96 97 //delete pTextureImage; 98 #else 99 /* 100 printf("test1\n"); 101 const char *path = R2FilePath::getInstance()->getPath("arrows_flip2.png"); 102 if (path) printf("test2 %s\n", path); 103 else printf("tt\n"); 104 IplImage* pTextureImage = cvLoadImage(path); 105 printf("test3\n"); 106 if (pTextureImage) 107 { 108 printf("file(%s) has been loaded\n", path); 109 _arrowsTex = new Texture2D(pTextureImage->width, pTextureImage->height, GL_FLOAT, GL_LINEAR, 3, (float*) pTextureImage->imageData); 110 printf("file(%s) has been loaded\n", path); 111 //cvReleaseImage(&pTextureImage); 112 } 113 else 114 { 115 printf("not found\n"); 116 } 117 if (path) delete [] path; 118 */ 119 120 #endif 121 122 #else 123 _arrowsTex = new Texture2D(); 124 _arrowsTex->setWrapS(TW_MIRROR); 125 _arrowsTex->setWrapT(TW_MIRROR); 126 #ifdef WIN32 127 AUX_RGBImageRec *pTextureImage = auxDIBImageLoad("arrows.bmp"); 128 _arrowsTex->setPixels(CF_RGB, DT_UBYTE, pTextureImage->sizeX, pTextureImage->sizeY, (void*) pTextureImage->data); 129 130 //delete pTextureImage; 131 #else 132 IplImage* pTextureImage = cvLoadImage("arrows_flip2.png"); 133 _arrowsTex->setPixels(CF_RGB, DT_UBYTE, pTextureImage->width, pTextureImage->height, (void*) pTextureImage->imageData); 134 135 //cvReleaseImage(&pTextureImage); 136 #endif 137 138 #endif 139 _arrowColor.set(1, 1, 0); 140 141 printf("test1\n"); 40 142 } 41 143 … … 47 149 glDeleteFramebuffersEXT(1, &_fbo); 48 150 49 delete [] _velocities; 151 #ifdef USE_NANOVIS_LIB 152 delete _arrowsTex; 153 #else 154 _arrowsTex->unref(); 155 #endif 156 cgDestroyProgram(_particleFP); 157 cgDestroyProgram(_particleVP); 158 159 glDeleteBuffers(1, &_vertexBufferGraphicsID); 160 delete [] _velocities; 50 161 } 51 162 … … 103 214 _dirtySamplingPosition = true; 104 215 _dirtyRenderTarget = true; 105 216 //_dirty = true; 106 217 } 107 218 … … 115 226 cgGLBindProgram(_queryVelocityFP); 116 227 cgGLEnableProfile(CG_PROFILE_FP30); 117 cgGLSetTextureParameter(_ ipVectorFieldParam, _vectorFieldGraphicsID);118 cgGLEnableTextureParameter(_ ipVectorFieldParam);228 cgGLSetTextureParameter(_qvVectorFieldParam, _vectorFieldGraphicsID); 229 cgGLEnableTextureParameter(_qvVectorFieldParam); 119 230 120 231 glPushAttrib(GL_VIEWPORT_BIT); … … 129 240 glBegin(GL_POINTS); 130 241 131 for ( int index = 0; index < _samplingPositions.size(); ++index)242 for (unsigned int index = 0; index < _samplingPositions.size(); ++index) 132 243 { 133 244 glMultiTexCoord3f(0, _samplingPositions[index].x,_samplingPositions[index].y,_samplingPositions[index].z); … … 139 250 140 251 glDisable(GL_TEXTURE_RECTANGLE_NV); 141 cgGLDisableTextureParameter(_ ipVectorFieldParam);252 cgGLDisableTextureParameter(_qvVectorFieldParam); 142 253 cgGLDisableProfile(CG_PROFILE_FP30); 143 254 … … 155 266 void VelocityArrowsSlice::render() 156 267 { 157 if (!_enabled || _vectorFieldGraphicsID == 0) return; 268 //if (!_enabled || (_vectorFieldGraphicsID == 0)) return; 269 if (!_enabled) return; 270 158 271 if (_dirty) 159 272 { … … 165 278 166 279 glPushMatrix(); 280 167 281 glScalef(_vfXscale,_vfYscale, _vfZscale); 168 282 glTranslatef(-0.5f, -0.5f, -0.5f); 169 glDisable(GL_TEXTURE_2D); 170 glLineWidth(2.0); 171 glColor3f(_arrowColor.x, _arrowColor.y, _arrowColor.z); 172 glBegin(GL_LINES); 173 Vector3 pos; 174 Vector3 pos2; 175 Vector3 vel(1, 0, 0); 176 Vector3 v, v2; 177 if (_axis == 2) 178 { 179 int index = 0; 180 for (int y = 1; y <= _tickCountY; ++y) 181 for (int x = 1; x <= _tickCountX; ++x, ++index) 182 { 183 pos = this->_samplingPositions[index]; 184 pos2 = this->_velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos; 185 glVertex3f(pos.x, pos.y, pos.z); 186 glVertex3f(pos2.x, pos2.y, pos2.z); 187 188 } 189 } 190 else if (_axis == 1) 191 { 192 int index = 0; 193 for (int z = 1; z <= _tickCountZ; ++z) 194 for (int x = 1; x <= _tickCountX; ++x, ++index) 195 { 196 pos = _samplingPositions[index]; 197 pos2 = _velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos; 198 199 glVertex3f(pos.x, pos.y, pos.z); 200 glVertex3f(pos2.x, pos2.y, pos2.z); 201 } 202 } 203 else if (_axis == 0) 204 { 205 int index = 0; 206 for (int z = 1; z <= _tickCountZ; ++z) 207 for (int y = 1; y <= _tickCountY; ++y, ++index) 208 { 209 pos = _samplingPositions[index]; 210 pos2 = _velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos; 211 212 glVertex3f(pos.x, pos.y, pos.z); 213 glVertex3f(pos2.x, pos2.y, pos2.z); 214 } 215 } 216 217 glEnd(); 283 if (_renderMode == LINES) 284 { 285 286 glDisable(GL_TEXTURE_2D); 287 glLineWidth(2.0); 288 glColor3f(_arrowColor.x, _arrowColor.y, _arrowColor.z); 289 glBegin(GL_LINES); 290 Vector3 pos; 291 Vector3 pos2; 292 Vector3 vel(1, 0, 0); 293 Vector3 v, v2; 294 if (_axis == 2) 295 { 296 int index = 0; 297 for (int y = 1; y <= _tickCountY; ++y) 298 for (int x = 1; x <= _tickCountX; ++x, ++index) 299 { 300 pos = this->_samplingPositions[index]; 301 pos2 = this->_velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos; 302 glVertex3f(pos.x, pos.y, pos.z); 303 glVertex3f(pos2.x, pos2.y, pos2.z); 304 /*v = pos - pos2; 305 306 307 v2.x = 1; 308 v2.y = 1; 309 v2.z = (-(x1-x2)-(y1-y2))/(z1-z2) 310 adj = v.length() / (4 * sqrt((x3^2)+(y3^2)+(z3^2))); 311 x3 *= adj 312 y3 *= adj 313 z3 *= adj 314 */ 315 316 } 317 } 318 else if (_axis == 1) 319 { 320 int index = 0; 321 for (int z = 1; z <= _tickCountZ; ++z) 322 for (int x = 1; x <= _tickCountX; ++x, ++index) 323 { 324 pos = _samplingPositions[index]; 325 pos2 = this->_velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos; 326 327 glVertex3f(pos.x, pos.y, pos.z); 328 glVertex3f(pos2.x, pos2.y, pos2.z); 329 } 330 } 331 else if (_axis == 0) 332 { 333 int index = 0; 334 for (int z = 1; z <= _tickCountZ; ++z) 335 for (int y = 1; y <= _tickCountY; ++y, ++index) 336 { 337 pos = _samplingPositions[index]; 338 pos2 = this->_velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos; 339 340 glVertex3f(pos.x, pos.y, pos.z); 341 glVertex3f(pos2.x, pos2.y, pos2.z); 342 } 343 } 344 345 glEnd(); 346 glLineWidth(1.0); 347 } 348 else 349 { 350 glColor3f(_arrowColor.x, _arrowColor.y, _arrowColor.z); 351 glEnable(GL_BLEND); 352 glBlendFunc(GL_SRC_ALPHA, GL_ONE); 353 glEnable(GL_POINT_SPRITE_NV); 354 glPointSize(20); 355 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_NV); 356 357 #ifdef USE_NANOVIS_LIB 358 _arrowsTex->activate(); 359 #else 360 _arrowsTex->bind(0); 361 glEnable(GL_TEXTURE_2D); 362 #endif 363 glPointParameterfARB( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 0.0f ); 364 365 glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, 1.0f); 366 glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, 100.0f); 367 glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE ); 368 369 cgGLBindProgram(_particleVP); 370 cgGLBindProgram(_particleFP); 371 cgGLEnableProfile(CG_PROFILE_VP40); 372 cgGLEnableProfile(CG_PROFILE_FP40); 373 374 cgGLSetTextureParameter(_vectorParticleParam, _vectorFieldGraphicsID); 375 cgGLEnableTextureParameter(_vectorParticleParam); 376 377 378 //cgSetParameter1f(_mvTanHalfFOVParam, -tan(_fov * 0.5) * _screenHeight * 0.5); 379 380 cgGLSetStateMatrixParameter(_mvpParticleParam, 381 CG_GL_MODELVIEW_PROJECTION_MATRIX, 382 CG_GL_MATRIX_IDENTITY); 383 cgGLSetStateMatrixParameter(_mvParticleParam, 384 CG_GL_MODELVIEW_MATRIX, 385 CG_GL_MATRIX_IDENTITY); 386 387 glEnableClientState(GL_VERTEX_ARRAY); 388 glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vertexBufferGraphicsID); 389 glVertexPointer(3, GL_FLOAT, 0, 0); 390 //glEnableClientState(GL_COLOR_ARRAY); 391 392 // TBD.. 393 glDrawArrays(GL_POINTS, 0, _pointCount); 394 glPointSize(1); 395 glDrawArrays(GL_POINTS, 0, _pointCount); 396 397 glDisableClientState(GL_VERTEX_ARRAY); 398 399 cgGLDisableProfile(CG_PROFILE_VP40); 400 cgGLDisableProfile(CG_PROFILE_FP40); 401 402 glDepthMask(GL_TRUE); 403 404 glDisable(GL_POINT_SPRITE_NV); 405 glDisable(GL_VERTEX_PROGRAM_POINT_SIZE_NV); 406 407 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 408 glDisable(GL_BLEND); 409 #ifdef USE_NANOVIS_LIB 410 _arrowsTex->deactivate(); 411 #else 412 _arrowsTex->unbind(); 413 #endif 414 } 218 415 glPopMatrix(); 219 glLineWidth(1.0);220 416 } 221 417 … … 228 424 float xScale, float yScale, float zScale) 229 425 { 230 _vectorFieldGraphicsID = vfGraphicsID; 231 _vfXscale = xScale; 232 _vfYscale = yScale; 233 _vfZscale = zScale; 426 _vectorFieldGraphicsID = vfGraphicsID; 427 _vfXscale = xScale; 428 _vfYscale = yScale; 429 _vfZscale = zScale; 430 431 //_dirty = true; 234 432 } 235 433 … … 238 436 _tickCountForMinSizeAxis = tickCount; 239 437 438 //_dirty = true; 240 439 } 241 440 … … 316 515 } 317 516 318 319 Vector3 pos; 320 if (_axis == 2) 321 { 322 for (int y = 1; y <= _tickCountY; ++y) 323 for (int x = 1; x <= _tickCountX; ++x) 324 { 325 pos.x = (1.0f / (_tickCountX + 1)) * x; 326 pos.y = (1.0f / (_tickCountY + 1)) * y; 327 pos.z = _slicePos; 328 _samplingPositions.push_back(pos); 517 if (_renderMode == LINES) 518 { 519 Vector3 pos; 520 if (_axis == 2) 521 { 522 for (int y = 1; y <= _tickCountY; ++y) 523 for (int x = 1; x <= _tickCountX; ++x) 524 { 525 pos.x = (1.0f / (_tickCountX + 1)) * x; 526 pos.y = (1.0f / (_tickCountY + 1)) * y; 527 pos.z = _slicePos; 528 _samplingPositions.push_back(pos); 529 530 } 531 } 532 else if (_axis == 1) 533 { 534 for (int z = 1; z <= _tickCountZ; ++z) 535 for (int x = 1; x <= _tickCountX; ++x) 536 { 537 pos.x = (1.0f / (_tickCountX + 1)) * x; 538 pos.y = _slicePos; 539 pos.z = (1.0f / (_tickCountZ + 1)) * z; 540 _samplingPositions.push_back(pos); 541 } 542 } 543 else if (_axis == 0) 544 { 545 for (int z = 1; z <= _tickCountZ; ++z) 546 for (int y = 1; y <= _tickCountY; ++y) 547 { 548 pos.x = _slicePos; 549 pos.y = (1.0f / (_tickCountY + 1)) * y; 550 pos.z = (1.0f / (_tickCountZ + 1)) * z; 551 _samplingPositions.push_back(pos); 552 } 553 } 554 } 555 else 556 { 557 glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vertexBufferGraphicsID); 558 Vector3* pinfo = (Vector3*) glMapBufferARB(GL_ARRAY_BUFFER, GL_WRITE_ONLY_ARB); 559 560 Vector3 pos; 561 if (_axis == 2) 562 { 563 for (int y = 1; y <= _tickCountY; ++y) 564 for (int x = 1; x <= _tickCountX; ++x) 565 { 566 pos.x = (1.0f / (_tickCountX + 1)) * x; 567 pos.y = (1.0f / (_tickCountY + 1)) * y; 568 pos.z = _slicePos; 569 570 *pinfo = pos; 571 ++pinfo; 329 572 } 330 } 331 else if (_axis == 1) 332 { 333 for (int z = 1; z <= _tickCountZ; ++z) 334 for (int x = 1; x <= _tickCountX; ++x) 335 { 336 pos.x = (1.0f / (_tickCountX + 1)) * x; 337 pos.y = _slicePos; 338 pos.z = (1.0f / (_tickCountZ + 1)) * z; 339 _samplingPositions.push_back(pos); 340 } 341 } 342 else if (_axis == 0) 343 { 344 for (int z = 1; z <= _tickCountZ; ++z) 345 for (int y = 1; y <= _tickCountY; ++y) 346 { 347 pos.x = _slicePos; 348 pos.y = (1.0f / (_tickCountY + 1)) * y; 349 pos.z = (1.0f / (_tickCountZ + 1)) * z; 350 _samplingPositions.push_back(pos); 351 } 352 } 353 } 354 355 void VelocityArrowsSlice::slicePos(float pos) 573 } 574 else if (_axis == 1) 575 { 576 for (int z = 1; z <= _tickCountZ; ++z) 577 for (int x = 1; x <= _tickCountX; ++x) 578 { 579 pos.x = (1.0f / (_tickCountX + 1)) * x; 580 pos.y = _slicePos; 581 pos.z = (1.0f / (_tickCountZ + 1)) * z; 582 583 *pinfo = pos; 584 ++pinfo; 585 } 586 } 587 else if (_axis == 0) 588 { 589 for (int z = 1; z <= _tickCountZ; ++z) 590 for (int y = 1; y <= _tickCountY; ++y) 591 { 592 pos.x = _slicePos; 593 pos.y = (1.0f / (_tickCountY + 1)) * y; 594 pos.z = (1.0f / (_tickCountZ + 1)) * z; 595 596 *pinfo = pos; 597 ++pinfo; 598 } 599 } 600 601 glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); 602 } 603 } 604 605 void VelocityArrowsSlice::slicePos(float pos) 356 606 { 357 607 _slicePos = pos; 358 608 _dirty = true; 359 609 } 610 -
trunk/packages/vizservers/nanovis/VelocityArrowsSlice.h
r1487 r1489 4 4 #include <Cg/cgGL.h> 5 5 #include <vector> 6 7 #define USE_NANOVIS_LIB 8 9 #ifdef USE_NANOVIS_LIB 10 #include "Texture2D.h" 6 11 #include "Vector3.h" 12 #else 13 #include <vr3d/vrTexture2D.h> 14 15 typedef vrTexture2D Texture2D; 16 17 class Vector3 { 18 public : 19 float x, y, z; 20 Vector3() : x(0.0f), y(0.0f), z(0.0f) {} 21 Vector3(float x1, float y1, float z1) : x(x1), y(y1), z(z1) {} 22 Vector3 operator*(float scale) 23 { 24 Vector3 vec; 25 vec.x = x * scale; 26 vec.y = y * scale; 27 vec.z = z * scale; 28 return vec; 29 } 30 Vector3 scale(const Vector3& scale) 31 { 32 Vector3 vec; 33 vec.x = x * scale.x; 34 vec.y = y * scale.y; 35 vec.z = z * scale.z; 36 return vec; 37 } 38 39 Vector3 operator*(const Vector3& scale) 40 { 41 Vector3 vec; 42 vec.x = x * scale.x; 43 vec.y = y * scale.y; 44 vec.z = z * scale.z; 45 return vec; 46 47 } 48 friend Vector3 operator+(const Vector3& value1, const Vector3& value2); 49 50 void set(float x1, float y1, float z1) 51 { 52 x = x1; y = y1; z = z1; 53 } 54 }; 55 56 inline Vector3 operator+(const Vector3& value1, const Vector3& value2) 57 { 58 return Vector3(value1.x + value2.x, value1.y + value2.y, value1.z + value2.z); 59 } 60 61 #endif 62 7 63 8 64 class VelocityArrowsSlice { 9 65 public : 66 enum RenderMode { 67 LINES, 68 GLYPHES, 69 }; 70 private : 10 71 unsigned int _vectorFieldGraphicsID; 11 72 float _vfXscale; … … 20 81 CGcontext _context; 21 82 CGprogram _queryVelocityFP; 22 CGparameter _ ipVectorFieldParam;83 CGparameter _qvVectorFieldParam; 23 84 24 85 int _renderTargetWidth; … … 36 97 37 98 Vector3 _maxVelocityScale; 38 99 Vector3 _arrowColor; 39 100 40 101 bool _enabled; … … 42 103 bool _dirtySamplingPosition; 43 104 bool _dirtyRenderTarget; 105 106 unsigned int _vertexBufferGraphicsID; 107 108 CGprogram _particleVP; 109 CGparameter _mvpParticleParam; 110 CGparameter _mvParticleParam; 111 CGparameter _mvTanHalfFOVParam; 112 CGparameter _mvCurrentTimeParam; 44 113 114 CGprogram _particleFP; 115 CGparameter _vectorParticleParam; 116 117 Texture2D* _arrowsTex; 118 119 RenderMode _renderMode; 45 120 private : 46 121 void createRenderTarget(); … … 48 123 public : 49 124 VelocityArrowsSlice(); 50 125 ~VelocityArrowsSlice(); 51 126 52 127 void vectorField(unsigned int vfGraphicsID, float xScale, float yScale, float zScale); … … 60 135 bool enabled() const; 61 136 void tickCountForMinSizeAxis(int tickCount); 62 int tickCountForMinSizeAxis() const; 63 void arrowColor(const Vector3& color); 137 int tickCountForMinSizeAxis() const; 138 void arrowColor(const Vector3& color); 139 void renderMode(RenderMode mode); 140 RenderMode renderMode() const; 64 141 }; 65 142 … … 90 167 } 91 168 169 inline void VelocityArrowsSlice::renderMode(VelocityArrowsSlice::RenderMode mode) 170 { 171 _renderMode = mode; 172 _dirty = true; 173 } 174 175 inline VelocityArrowsSlice::RenderMode VelocityArrowsSlice::renderMode() const 176 { 177 return _renderMode; 178 }
Note: See TracChangeset
for help on using the changeset viewer.