Changeset 2857 for trunk/packages/vizservers/nanovis
- Timestamp:
- Mar 15, 2012 11:46:42 PM (12 years ago)
- Location:
- trunk/packages/vizservers/nanovis
- Files:
-
- 1 deleted
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Color.h
r2844 r2857 34 34 void getRGB(float *result); 35 35 36 double r() const 37 { 38 return _r; 39 } 40 41 double g() const 42 { 43 return _g; 44 } 45 46 double b() const 47 { 48 return _b; 49 } 50 36 51 /// Limits the color to be in range of [0,1] 37 52 void clamp(); -
trunk/packages/vizservers/nanovis/Makefile.in
r2846 r2857 48 48 VRUTIL_LIB = $(VRUTIL_DIR)/vrutil.a 49 49 VRUTIL_LIB_SPEC = $(VRUTIL_LIB) 50 VR3D_DIR = ./vr3d51 VR3D_INC_SPEC = -I$(srcdir)/$(VR3D_DIR)/include52 VR3D_LIB = $(VR3D_DIR)/vr3d.a53 VR3D_LIB_SPEC = $(VR3D_LIB)54 50 R2_DIR = ./R2 55 51 R2_INC_SPEC = -I$(srcdir)/$(R2_DIR)/include … … 74 70 $(VRMATH_LIB_SPEC) \ 75 71 $(VRUTIL_LIB_SPEC) \ 76 $(VR3D_LIB_SPEC) \77 72 $(TCL_LIB_SPEC) \ 78 73 $(CG_LIB_SPEC) \ … … 90 85 $(VRMATH_INC_SPEC) \ 91 86 $(VRUTIL_INC_SPEC) \ 92 $(VR3D_INC_SPEC) \93 87 $(TCL_INC_SPEC) \ 94 88 $(FF_INC_SPEC) \ … … 217 211 $(srcdir)/shaders/velocity.cg 218 212 219 .PHONY: all install install-resources install-shaders install-nanovis clean distclean newmat11 R2 imgloaders vrmath vrutil vr3dtransfer-function220 221 all: newmat11 R2 imgloaders vrmath vrutil vr3d transfer-functionnanovis213 .PHONY: all install install-resources install-shaders install-nanovis clean distclean newmat11 R2 imgloaders vrmath vrutil transfer-function 214 215 all: newmat11 R2 imgloaders vrmath vrutil nanovis 222 216 223 217 install: install-nanovis install-resources install-shaders … … 227 221 vrmath: $(VRMATH_LIB) 228 222 vrutil: $(VRUTIL_LIB) 229 vr3d: $(VR3D_LIB)230 223 imgloaders: $(IMG_LIB) 231 224 … … 239 232 $(MAKE) -C $(VRUTIL_DIR) all 240 233 241 $(VR3D_LIB):242 $(MAKE) -C $(VR3D_DIR) all243 244 234 $(R2_LIB): 245 235 $(MAKE) -C $(R2_DIR)/src all … … 248 238 $(MAKE) -C $(IMG_DIR) all 249 239 250 nanovis: $(MAT_LIB) $(R2_LIB) $(IMG_LIB) $(VRMATH_LIB) $(VRUTIL_LIB) $( VR3D_LIB) $(OBJS)240 nanovis: $(MAT_LIB) $(R2_LIB) $(IMG_LIB) $(VRMATH_LIB) $(VRUTIL_LIB) $(OBJS) 251 241 $(CXX) $(CXX_SWITCHES) -o $@ $^ $(LIBS) 252 242 … … 288 278 $(MAKE) -C $(VRMATH_DIR) clean 289 279 $(MAKE) -C $(VRUTIL_DIR) clean 290 $(MAKE) -C $(VR3D_DIR) clean291 280 $(MAKE) -C $(R2_DIR)/src clean 292 281 $(MAKE) -C $(IMG_DIR) clean … … 297 286 $(MAKE) -C $(VRMATH_DIR) distclean 298 287 $(MAKE) -C $(VRUTIL_DIR) distclean 299 $(MAKE) -C $(VR3D_DIR) distclean300 288 $(MAKE) -C $(R2_DIR)/src distclean 301 289 $(MAKE) -C $(IMG_DIR) distclean … … 307 295 CmdProc.o: CmdProc.cpp CmdProc.h 308 296 Color.o: Color.cpp Color.h 309 Command.o: Command.cpp dxReader.h297 Command.o: Command.cpp nanovis.h $(AUXSRC) CmdProc.h Trace.h PlaneRenderer.h PointSet.h dxReader.h Grid.h HeightMap.h NvCamera.h NvZincBlendeReconstructor.h Unirect.h VolumeRenderer.h 310 298 ContourLineFilter.o: ContourLineFilter.cpp ContourLineFilter.h 311 299 ConvexPolygon.o: ConvexPolygon.cpp ConvexPolygon.h Vector4.h Mat4x4.h Plane.h -
trunk/packages/vizservers/nanovis/NvColorTableShader.h
r2836 r2857 30 30 inline void NvColorTableShader::bind(Texture2D *plane, TransferFunction *tf) 31 31 { 32 cgGLSetTextureParameter(_dataParam, plane->id );32 cgGLSetTextureParameter(_dataParam, plane->id()); 33 33 cgGLSetTextureParameter(_tfParam, tf->id()); 34 34 cgGLEnableTextureParameter(_dataParam); -
trunk/packages/vizservers/nanovis/NvRegularVolumeShader.h
r2837 r2857 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __NV_REGULAR_SHADER_H__3 #define __NV_REGULAR_SHADER_H__2 #ifndef NV_REGULAR_SHADER_H 3 #define NV_REGULAR_SHADER_H 4 4 5 5 #include "Volume.h" … … 27 27 28 28 inline void 29 NvRegularVolumeShader::bind(unsigned int tfID, Volume *volume, int sliceMode)29 NvRegularVolumeShader::bind(unsigned int tfID, Volume *volume, int sliceMode) 30 30 { 31 31 //regular cubic volume … … 38 38 cgGLEnableTextureParameter(_tf_one_volume_param); 39 39 40 if (!sliceMode)40 if (!sliceMode) { 41 41 cgGLSetParameter4f(_render_param_one_volume_param, 42 42 volume->n_slices(), … … 44 44 volume->diffuse(), 45 45 volume->specular()); 46 else46 } else { 47 47 cgGLSetParameter4f(_render_param_one_volume_param, 48 48 0., … … 50 50 volume->diffuse(), 51 51 volume->specular()); 52 } 52 53 53 54 cgGLSetParameter4f(_option_one_volume_param, -
trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.h
r2844 r2857 34 34 cgGLSetStateMatrixParameter(_mviParam, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE); 35 35 cgGLSetTextureParameter(_tfParam, tfID); 36 cgGLSetParameter4f(_cellSizeParam, vol->cell_size.x, vol->cell_size.y, vol->cell_size.z, 0.); 36 cgGLSetParameter4f(_cellSizeParam, 37 vol->cell_size.x, 38 vol->cell_size.y, 39 vol->cell_size.z, 0.); 37 40 38 41 if (!sliceMode) { … … 56 59 0.0f); 57 60 58 cgGLSetTextureParameter(_volumeAParam, vol->zincblende_tex[0]->id );59 cgGLSetTextureParameter(_volumeBParam, vol->zincblende_tex[1]->id );61 cgGLSetTextureParameter(_volumeAParam, vol->zincblende_tex[0]->id()); 62 cgGLSetTextureParameter(_volumeBParam, vol->zincblende_tex[1]->id()); 60 63 cgGLEnableTextureParameter(_volumeAParam); 61 64 cgGLEnableTextureParameter(_volumeBParam); -
trunk/packages/vizservers/nanovis/ParticleSystem.cpp
r2831 r2857 5 5 #include <stdlib.h> 6 6 #include <stdio.h> 7 #include <math.h> 7 8 #include <pthread.h> 8 9 9 #ifdef HAVE_OPENCV_H 10 #include <opencv/cv.h> 11 #endif 12 #ifdef HAVE_OPENCV_HIGHGUI_H 13 #include <opencv/highgui.h> 14 #endif 15 16 #include <vr3d/vr3d.h> 17 #include <vr3d/vrTexture3D.h> 18 10 #include <GL/glew.h> 19 11 #include <Cg/cgGL.h> 20 12 21 13 #include <vrutil/vrFilePath.h> 14 #include <Image.h> 15 #include <ImageLoader.h> 16 #include <ImageLoaderFactory.h> 22 17 23 18 #include <vrmath/vrMatrix4x4f.h> … … 27 22 #include "ParticleSystem.h" 28 23 #include "ParticleEmitter.h" 24 #include "Texture2D.h" 25 #include "Texture3D.h" 29 26 #include "Trace.h" 30 27 … … 292 289 293 290 if (!this->isTimeVaryingField()) { 294 vrTexture3D* flow = new vrTexture3D(); 295 flow->setMinFilter(TF_LINEAR); 296 flow->setMagFilter(TF_LINEAR); 297 flow->setPixels(CF_RGBA, DT_FLOAT, _flowWidth, _flowHeight, _flowDepth, data); 298 this->_curVectorFieldID = flow->getGraphicsObjectID(); 291 Texture3D *flow = new Texture3D(_flowWidth, _flowHeight, _flowDepth, 292 GL_FLOAT, GL_LINEAR, 4, data); 293 _curVectorFieldID = flow->id(); 299 294 _vectorFieldIDs.push_back(_curVectorFieldID); 300 295 } else { 301 296 for (int i = 0; i < 3; ++i) { 302 vrTexture3D* flow = new vrTexture3D(); 303 flow->setMinFilter(TF_LINEAR); 304 flow->setMagFilter(TF_LINEAR); 305 flow->setPixels(CF_RGBA, DT_FLOAT, _flowWidth, _flowHeight, _flowDepth, data); 297 Texture3D *flow = new Texture3D(_flowWidth, _flowHeight, _flowDepth, 298 GL_FLOAT, GL_LINEAR, 4, data); 306 299 _vectorFields.push_back(flow); 307 _vectorFieldIDs.push_back(flow-> getGraphicsObjectID());300 _vectorFieldIDs.push_back(flow->id()); 308 301 } 309 this->_curVectorFieldID = _vectorFieldIDs[0]; 310 } 311 312 _arrows = new vrTexture2D(); 313 _arrows->setWrapS(TW_MIRROR); 314 _arrows->setWrapT(TW_MIRROR); 315 316 #ifndef USE_RGBA_ARROW 317 IplImage* pTextureImage = cvLoadImage("arrows_flip2.png"); 318 _arrows->setPixels(CF_RGB, DT_UBYTE, pTextureImage->width, pTextureImage->height, pTextureImage->imageData); 302 _curVectorFieldID = _vectorFieldIDs[0]; 303 } 304 305 #ifdef USE_RGBA_ARROW 306 std::string path = vrFilePath::getInstance()->getPath("arrow.bmp"); 319 307 #else 320 #ifdef notdef321 // TBD..322 308 std::string path = vrFilePath::getInstance()->getPath("arrows_red_bg.bmp"); 323 AUX_RGBImageRec *pTextureImage = auxDIBImageLoad(path.c_str()); 324 unsigned char* pixels = new unsigned char [pTextureImage->sizeX * pTextureImage->sizeY * sizeof(unsigned char) * 4]; 325 unsigned char* srcPixels = pTextureImage->data; 326 unsigned char* dstPixels = pixels; 327 for (int i = 0; i < pTextureImage->sizeX * pTextureImage->sizeY; ++i) { 328 *dstPixels = *srcPixels; ++srcPixels; 329 *(dstPixels + 1) = *srcPixels; ++srcPixels; 330 *(dstPixels + 2) = *srcPixels; ++srcPixels; 331 332 if ((*dstPixels > 127) && (*(dstPixels + 1) < 127) && (*(dstPixels + 2) < 127)) { 333 *(dstPixels + 3) = 0; 309 #endif 310 if (!path.empty()) { 311 ImageLoader *loader = ImageLoaderFactory::getInstance()->createLoader("bmp"); 312 if (loader != NULL) { 313 #ifdef USE_RGBA_ARROW 314 Image *image = loader->load(path.c_str(), Image::IMG_RGBA); 315 #else 316 Image *image = loader->load(path.c_str(), Image::IMG_RGB); 317 #endif 318 if (image != NULL) { 319 unsigned char *bytes = (unsigned char *)image->getImageBuffer(); 320 if (bytes != NULL) { 321 #ifdef USE_RGBA_ARROW 322 for (unsigned int y = 0; y < image->getHeight(); ++y) { 323 for (unsigned int x = 0; x < image->getWidth(); ++x, bytes += 4) { 324 bytes[3] = (bytes[0] > 127 && 325 bytes[1] < 127 && 326 bytes[2] < 127) ? 0 : 255; 327 } 328 } 329 _arrows = new Texture2D(image->getWidth(), image->getHeight(), 330 GL_UNSIGNED_BYTE, GL_LINEAR, 4, NULL); 331 #else 332 _arrows = new Texture2D(image->getWidth(), image->getHeight(), 333 GL_UNSIGNED_BYTE, GL_LINEAR, 3, NULL); 334 #endif 335 _arrows->setWrapS(GL_MIRRORED_REPEAT); 336 _arrows->setWrapT(GL_MIRRORED_REPEAT); 337 _arrows->initialize(image->getImageBuffer()); 338 } 339 delete image; 340 } else { 341 ERROR("Failed to load image: arrows.bmp\n"); 342 } 343 delete loader; 334 344 } else { 335 *(dstPixels + 3) = 255;345 ERROR("Couldn't find loader for arrows.bmp\n"); 336 346 } 337 338 dstPixels += 4; 339 } 340 341 _arrows->setPixels(CF_RGBA, DT_UBYTE, pTextureImage->sizeX, pTextureImage->sizeY, (void*) pixels); 342 #endif 343 344 #endif // USE_RGBA_ARROW 347 } else { 348 ERROR("Couldn't find path to arrows.bmp\n"); 349 } 345 350 346 351 #ifdef TEST … … 1034 1039 static bool firstLoad = true; 1035 1040 if (this->isTimeVaryingField()) { 1036 static float oldTime = vrGetTimeStamp();1041 static float oldTime = (float)clock()/(float)CLOCKS_PER_SEC; 1037 1042 #ifdef WANT_TRACE 1038 1043 static int index = 0; 1039 1044 #endif 1040 float time = vrGetTimeStamp();1045 float time = (float)clock()/(float)CLOCKS_PER_SEC; 1041 1046 if ((time - oldTime) > 2.0) { 1042 1047 if (!_queue.isEmpty()) { 1043 float * data = 0;1048 float *data = NULL; 1044 1049 if (_queue.top(data)) { 1045 1050 #ifdef WANT_TRACE 1046 1051 float t = clock() /(float) CLOCKS_PER_SEC; 1047 1052 #endif 1048 _vectorFields[0]->update Pixels(data);1053 _vectorFields[0]->update(data); 1049 1054 #ifdef WANT_TRACE 1050 1055 float ti = clock() / (float) CLOCKS_PER_SEC; … … 1661 1666 1662 1667 #ifndef TEST 1663 _arrows-> bind(0);1668 _arrows->activate(); //_arrows->bind(0); 1664 1669 glEnable(GL_TEXTURE_2D); 1665 1670 //glPointParameterfARB( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f ); … … 1677 1682 cgSetParameter1f(_mvCurrentTimeParam, _currentTime); 1678 1683 //TRACE("%f %f, %f %d\n", _fov, tan(_fov), tan(_fov / 2.0), _screenHeight); 1679 //cgSetParameter1f(_mvTanHalfFOVParam, -tan(_fov * PI / 180 * 0.5) * _screenHeight * 0.5);1680 //float v = tan(_fov * PI / 180 * 0.5) * _screenHeight * 0.5;1681 cgSetParameter1f(_mvTanHalfFOVParam, tan(_fov * PI / 180 * 0.5) * _screenHeight * 0.5);1682 //cgSetParameter1f(_mvTanHalfFOVParam, _screenHeight * 0.5 / tan(_fov * PI / 180 * 0.5));1684 //cgSetParameter1f(_mvTanHalfFOVParam, -tan(_fov * M_PI / 180 * 0.5) * _screenHeight * 0.5); 1685 //float v = tan(_fov * M_PI / 180 * 0.5) * _screenHeight * 0.5; 1686 cgSetParameter1f(_mvTanHalfFOVParam, tan(_fov * M_PI / 180 * 0.5) * _screenHeight * 0.5); 1687 //cgSetParameter1f(_mvTanHalfFOVParam, _screenHeight * 0.5 / tan(_fov * M_PI / 180 * 0.5)); 1683 1688 1684 1689 cgGLSetStateMatrixParameter(_mvpParticleParam, -
trunk/packages/vizservers/nanovis/ParticleSystem.h
r2818 r2857 11 11 #include <Cg/cg.h> 12 12 13 #include <vr3d/vrTexture2D.h>14 #include <vr3d/vrTexture3D.h>15 13 #include <vrmath/vrVector3f.h> 16 14 17 15 #include "ParticleEmitter.h" 18 16 #include "RenderVertexArray.h" 17 #include "Texture2D.h" 18 #include "Texture3D.h" 19 19 20 20 #include "CircularQueue.h" … … 137 137 // TIME SERIES 138 138 std::vector<unsigned int> _vectorFieldIDs; 139 std::vector< vrTexture3D *> _vectorFields;139 std::vector<Texture3D *> _vectorFields; 140 140 unsigned int _curVectorFieldID; 141 141 float _time_series_vel_mag_min; … … 156 156 unsigned _colorBufferID; 157 157 ////////////////////////////////////////// 158 vrTexture2D *_arrows;158 Texture2D *_arrows; 159 159 160 160 float _camx; -
trunk/packages/vizservers/nanovis/PlaneRenderer.cpp
r2835 r2857 109 109 PlaneRenderer::activate_shader(int index) 110 110 { 111 cgGLSetTextureParameter(_data_param, _plane[index]->id );111 cgGLSetTextureParameter(_data_param, _plane[index]->id()); 112 112 cgGLSetTextureParameter(_tf_param, _tf[index]->id()); 113 113 cgGLEnableTextureParameter(_data_param); -
trunk/packages/vizservers/nanovis/PointSetRenderer.cpp
r2831 r2857 30 30 for (unsigned int y = 0; y < image->getHeight(); ++y) { 31 31 for (unsigned int x = 0; x < image->getWidth(); ++x, bytes += 4) { 32 bytes[3] = 32 bytes[3] = (bytes[0] == 0) ? 0 : 255; 33 33 } 34 34 } … … 44 44 45 45 delete loader; 46 delete image; 46 47 _bucketSort = new PCA::BucketSort(1024); 47 48 } -
trunk/packages/vizservers/nanovis/PointShader.cpp
r2833 r2857 13 13 _normal(0) 14 14 { 15 this->loadVertexProgram("pointsvp.cg", "main");15 loadVertexProgram("pointsvp.cg", "main"); 16 16 _modelviewVP = getNamedParameterFromVP("modelview"); 17 17 _projectionVP = getNamedParameterFromVP("projection"); -
trunk/packages/vizservers/nanovis/R2/include/R2/R2FilePath.h
r2841 r2857 28 28 29 29 /// get R2FilePath instance 30 static R2FilePath *getInstance();30 static R2FilePath *getInstance(); 31 31 32 32 private: -
trunk/packages/vizservers/nanovis/R2/src/R2FilePath.cpp
r2841 r2857 112 112 _curDirectory = buff; 113 113 } 114 -
trunk/packages/vizservers/nanovis/Sphere.cpp
r2822 r2857 19 19 Sphere::Sphere(float x, float y, float z, 20 20 float r, float g, float b, 21 float _radius,22 int _stack,23 int _slice) :21 float radius, 22 int stack, 23 int slice) : 24 24 Renderable(Vector3(x, y, z)), 25 radius(_radius),26 color(Color(r,g,b)),27 stack(_stack),28 slice(_slice)25 _radius(radius), 26 _color(Color(r, g, b)), 27 _stack(stack), 28 _slice(slice) 29 29 { 30 boundary = BoundBox(x-r, y-r, z-r, x+r, y+r, z+r);31 30 } 32 31 … … 35 34 } 36 35 37 void 38 Sphere:: render()36 void 37 Sphere::draw(GLUquadric *quad) 39 38 { 40 } 39 glColor3f(_color.r(), _color.g(), _color.b()); 41 40 42 void43 Sphere::draw(GLUquadric* quad)44 {45 glColor3f(color.R, color.G, color.B);46 47 41 glMatrixMode(GL_MODELVIEW); 48 42 glPushMatrix(); 49 glTranslatef( location.x, location.y,location.z);50 43 glTranslatef(_location.x, _location.y, _location.z); 44 51 45 //draw it 52 gluSphere(quad, radius, stack,slice);53 46 gluSphere(quad, _radius, _stack, _slice); 47 54 48 glPopMatrix(); 55 49 } 56 50 57 void 58 Sphere::set_horizontal_res(int _slice) { 59 slice=_slice; 51 void 52 Sphere::set_horizontal_res(int slice) 53 { 54 _slice = slice; 60 55 } 61 56 62 void 63 Sphere::set_vertical_res(int _stack) { 64 stack=_stack; 57 void 58 Sphere::set_vertical_res(int stack) 59 { 60 _stack = stack; 65 61 } 66 -
trunk/packages/vizservers/nanovis/Sphere.h
r2837 r2857 14 14 * ====================================================================== 15 15 */ 16 17 #ifndef _SPHERE_H_ 18 #define _SPHERE_H_ 16 #ifndef SPHERE_H 17 #define SPHERE_H 19 18 20 19 #include <GL/glew.h> … … 29 28 { 30 29 public: 31 Sphere(float x, float y, float z, float r, float g, float b, float _radius, 32 int _stack, int _slice); 30 Sphere(float x, float y, float z, 31 float r, float g, float b, 32 float radius, 33 int stack, int slice); 33 34 34 35 virtual ~Sphere(); 35 36 36 void set_vertical_res(int _stack);37 void set_horizontal_res(int _slice);38 37 void set_vertical_res(int stack); 38 void set_horizontal_res(int slice); 39 39 40 //display the sphere 40 void draw(GLUquadric* q); 41 void render(); 41 void draw(GLUquadric *q); 42 void render() 43 {} 42 44 43 float radius; 44 Color color; 45 int stack; 46 int slice; 45 private: 46 float _radius; 47 Color _color; 48 int _stack; 49 int _slice; 47 50 }; 48 51 -
trunk/packages/vizservers/nanovis/Texture1D.cpp
r2831 r2857 23 23 24 24 Texture1D::Texture1D() : 25 gl_resource_allocated(false), 26 id(0) 25 _width(0), 26 _numComponents(3), 27 _glResourceAllocated(false), 28 _id(0), 29 _type(GL_FLOAT), 30 _interpType(GL_LINEAR), 31 _wrapS(GL_CLAMP_TO_EDGE) 27 32 { 28 33 } … … 31 36 GLuint type, GLuint interp, 32 37 int numComponents, void *data) : 33 gl_resource_allocated(false), 34 id(0) 38 _width(width), 39 _numComponents(numComponents), 40 _glResourceAllocated(false), 41 _id(0), 42 _type(type), 43 _interpType(interp), 44 _wrapS(GL_CLAMP_TO_EDGE) 35 45 { 36 this->width = width;37 this->type = type;38 this->interp_type = interp;39 this->n_components = numComponents;40 41 46 if (data != NULL) 42 47 initialize(data); … … 45 50 Texture1D::~Texture1D() 46 51 { 47 glDeleteTextures(1, & id);52 glDeleteTextures(1, &_id); 48 53 } 49 54 50 55 GLuint Texture1D::initialize(void *data) 51 56 { 52 if ( gl_resource_allocated)53 glDeleteTextures(1, & id);57 if (_glResourceAllocated) 58 glDeleteTextures(1, &_id); 54 59 55 glGenTextures(1, & id);60 glGenTextures(1, &_id); 56 61 57 62 update(data); 58 63 59 gl_resource_allocated = true;60 return id;64 _glResourceAllocated = true; 65 return _id; 61 66 } 62 67 … … 65 70 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 66 71 67 glBindTexture(GL_TEXTURE_1D, id);72 glBindTexture(GL_TEXTURE_1D, _id); 68 73 69 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);70 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, interp_type);71 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, interp_type);74 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, _wrapS); 75 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, _interpType); 76 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, _interpType); 72 77 73 78 GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 74 79 75 glTexImage1D(GL_TEXTURE_1D, 0, format[ n_components],width, 0,76 format[ n_components],type, data);80 glTexImage1D(GL_TEXTURE_1D, 0, format[_numComponents], _width, 0, 81 format[_numComponents], _type, data); 77 82 78 83 assert(glGetError()==0); … … 81 86 void Texture1D::activate() 82 87 { 83 glBindTexture(GL_TEXTURE_1D, id);88 glBindTexture(GL_TEXTURE_1D, _id); 84 89 glEnable(GL_TEXTURE_1D); 85 90 } … … 88 93 { 89 94 glDisable(GL_TEXTURE_1D); 95 } 96 97 void Texture1D::setWrapS(GLuint wrapMode) 98 { 99 _wrapS = wrapMode; 90 100 } 91 101 -
trunk/packages/vizservers/nanovis/Texture1D.h
r2831 r2857 40 40 void deactivate(); 41 41 42 int width() const 43 { 44 return _width; 45 } 46 47 GLuint id() const 48 { 49 return _id; 50 } 51 52 void setWrapS(GLuint wrapMode); 53 42 54 static void check_max_size(); 43 55 44 56 static void check_max_unit(); 45 57 46 int width; 58 private: 59 int _width; 47 60 48 int n_components;61 int _numComponents; 49 62 50 bool gl_resource_allocated; 51 GLuint id; 52 GLuint type; 53 GLuint interp_type; 54 55 //GLuint tex_unit; 63 bool _glResourceAllocated; 64 GLuint _id; 65 GLuint _type; 66 GLuint _interpType; 67 GLuint _wrapS; 56 68 }; 57 69 -
trunk/packages/vizservers/nanovis/Texture2D.cpp
r2831 r2857 24 24 25 25 Texture2D::Texture2D() : 26 gl_resource_allocated(false), 27 id(0) 26 _width(0), 27 _height(0), 28 _numComponents(3), 29 _glResourceAllocated(false), 30 _id(0), 31 _type(GL_FLOAT), 32 _interpType(GL_LINEAR), 33 _wrapS(GL_CLAMP_TO_EDGE), 34 _wrapT(GL_CLAMP_TO_EDGE) 28 35 {} 29 36 … … 31 38 GLuint type, GLuint interp, 32 39 int numComponents, void *data) : 33 gl_resource_allocated(false), 34 id(0) 40 _width(width), 41 _height(height), 42 _numComponents(numComponents), 43 _glResourceAllocated(false), 44 _id(0), 45 _type(type), 46 _interpType(interp), 47 _wrapS(GL_CLAMP_TO_EDGE), 48 _wrapT(GL_CLAMP_TO_EDGE) 35 49 { 36 this->width = width;37 this->height = height;38 this->type = type;39 this->interp_type = interp;40 this->n_components = numComponents;41 42 50 if (data != NULL) 43 51 initialize(data); … … 46 54 Texture2D::~Texture2D() 47 55 { 48 glDeleteTextures(1, & id);56 glDeleteTextures(1, &_id); 49 57 } 50 58 51 59 GLuint Texture2D::initialize(void *data) 52 60 { 53 if ( gl_resource_allocated)54 glDeleteTextures(1, & id);61 if (_glResourceAllocated) 62 glDeleteTextures(1, &_id); 55 63 56 glGenTextures(1, & id);64 glGenTextures(1, &_id); 57 65 58 66 update(data); 59 67 60 gl_resource_allocated = true;61 return id;68 _glResourceAllocated = true; 69 return _id; 62 70 } 63 71 64 72 void Texture2D::update(void *data) 65 73 { 66 glBindTexture(GL_TEXTURE_2D, id);74 glBindTexture(GL_TEXTURE_2D, _id); 67 75 68 76 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 69 77 70 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);71 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);78 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, _wrapS); 79 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, _wrapT); 72 80 73 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, interp_type);74 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, interp_type);81 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, _interpType); 82 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _interpType); 75 83 76 84 //to do: add handling to more formats 77 85 #ifdef NV40 78 if ( type == GL_FLOAT) {86 if (_type == GL_FLOAT) { 79 87 GLuint targetFormat[5] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB }; 80 88 GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 81 glTexImage2D(GL_TEXTURE_2D, 0, targetFormat[ n_components], width,height, 0,82 format[ n_components],type, data);89 glTexImage2D(GL_TEXTURE_2D, 0, targetFormat[_numComponents], _width, _height, 0, 90 format[_numComponents], _type, data); 83 91 } else { 84 92 #endif 85 93 GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 86 glTexImage2D(GL_TEXTURE_2D, 0, format[ n_components], width,height, 0,87 format[ n_components],type, data);94 glTexImage2D(GL_TEXTURE_2D, 0, format[_numComponents], _width, _height, 0, 95 format[_numComponents], _type, data); 88 96 #ifdef NV40 89 97 } 90 98 #endif 91 99 assert(glGetError() == 0); 92 93 gl_resource_allocated = true;94 100 } 95 101 96 void 97 Texture2D::activate() 102 void Texture2D::activate() 98 103 { 99 glBindTexture(GL_TEXTURE_2D, id);104 glBindTexture(GL_TEXTURE_2D, _id); 100 105 glEnable(GL_TEXTURE_2D); 101 106 } 102 107 103 void 104 Texture2D::deactivate() 108 void Texture2D::deactivate() 105 109 { 106 110 glDisable(GL_TEXTURE_2D); 107 111 } 108 112 109 void 110 Texture2D::check_max_size() 113 void Texture2D::setWrapS(GLuint wrapMode) 114 { 115 _wrapS = wrapMode; 116 } 117 118 void Texture2D::setWrapT(GLuint wrapMode) 119 { 120 _wrapT = wrapMode; 121 } 122 123 void Texture2D::check_max_size() 111 124 { 112 125 GLint max = 0; … … 116 129 } 117 130 118 void 119 Texture2D::check_max_unit() 131 void Texture2D::check_max_unit() 120 132 { 121 133 int max = 0; -
trunk/packages/vizservers/nanovis/Texture2D.h
r2831 r2857 40 40 void deactivate(); 41 41 42 int width() const 43 { 44 return _width; 45 } 46 47 int height() const 48 { 49 return _width; 50 } 51 52 GLuint id() const 53 { 54 return _id; 55 } 56 57 void setWrapS(GLuint wrapMode); 58 59 void setWrapT(GLuint wrapMode); 60 42 61 static void check_max_size(); 43 62 44 63 static void check_max_unit(); 45 64 46 int width; 47 int height; 65 private: 66 int _width; 67 int _height; 48 68 49 int n_components;69 int _numComponents; 50 70 51 bool gl_resource_allocated; 52 GLuint id; 53 GLuint type; 54 GLuint interp_type; 71 bool _glResourceAllocated; 72 GLuint _id; 73 GLuint _type; 74 GLuint _interpType; 75 GLuint _wrapS; 76 GLuint _wrapT; 55 77 }; 56 78 -
trunk/packages/vizservers/nanovis/Texture3D.cpp
r2831 r2857 24 24 25 25 Texture3D::Texture3D() : 26 gl_resource_allocated(false), 27 id(0) 26 _width(0), 27 _height(0), 28 _depth(0), 29 _numComponents(3), 30 _glResourceAllocated(false), 31 _id(0), 32 _type(GL_FLOAT), 33 _interpType(GL_LINEAR), 34 _wrapS(GL_CLAMP_TO_EDGE), 35 _wrapT(GL_CLAMP_TO_EDGE), 36 _wrapR(GL_CLAMP_TO_EDGE) 28 37 {} 29 38 … … 31 40 GLuint type, GLuint interp, 32 41 int numComponents, void *data) : 33 gl_resource_allocated(false), 34 id(0) 42 _width(width), 43 _height(height), 44 _depth(depth), 45 _numComponents(numComponents), 46 _glResourceAllocated(false), 47 _id(0), 48 _type(type), 49 _interpType(interp), 50 _wrapS(GL_CLAMP_TO_EDGE), 51 _wrapT(GL_CLAMP_TO_EDGE), 52 _wrapR(GL_CLAMP_TO_EDGE) 35 53 { 36 this->width = width; 37 this->height = height; 38 this->depth = depth; 54 //int m = (_width > _height) ? _width : _height; 55 //m = (m > _depth) ? m : _depth; 39 56 40 //int m = (width > height) ? width : height; 41 //m = (m > depth) ? m : depth; 57 //int m = max(max(_width, _height), _depth); 58 _aspectRatioWidth = 1.; 59 _aspectRatioHeight = (double)_height/(double)_width; 60 _aspectRatioDepth = (double)_depth/(double)_width; 42 61 43 //int m = max(max(width, height), depth); 44 this->aspect_ratio_width = 1.; 45 this->aspect_ratio_height = (double)height/(double)width; 46 this->aspect_ratio_depth = (double)depth/(double)width; 47 48 //this->aspect_ratio_width = (double)width/(double)m; 49 //this->aspect_ratio_height = (double)height/(double)m; 50 //this->aspect_ratio_depth = (double)depth/(double)m; 51 52 this->type = type; 53 this->interp_type = interp; 54 this->n_components = numComponents; 62 //_aspectRatioWidth = (double)_width/(double)m; 63 //_aspectRatioHeight = (double)_height/(double)m; 64 //_aspectRatioDepth = (double)_depth/(double)m; 55 65 56 66 if (data != NULL) … … 60 70 Texture3D::~Texture3D() 61 71 { 62 glDeleteTextures(1, & id);72 glDeleteTextures(1, &_id); 63 73 } 64 74 65 75 GLuint Texture3D::initialize(void *data) 66 76 { 67 if ( id != 0)68 glDeleteTextures(1, & id);77 if (_glResourceAllocated) 78 glDeleteTextures(1, &_id); 69 79 70 glGenTextures(1, & id);80 glGenTextures(1, &_id); 71 81 72 82 update(data); 73 74 return id; 83 84 _glResourceAllocated = true; 85 return _id; 75 86 } 76 87 77 88 void Texture3D::update(void *data) 78 89 { 79 assert(id > 0 && id != (GLuint)-1); 80 glBindTexture(GL_TEXTURE_3D, id); 90 glBindTexture(GL_TEXTURE_3D, _id); 81 91 82 92 //load texture with 16 bit half floating point precision if card is 6 series NV40 … … 85 95 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 86 96 87 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);88 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);89 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);97 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, _wrapS); 98 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, _wrapT); 99 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, _wrapR); 90 100 91 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, interp_type);92 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, interp_type);101 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, _interpType); 102 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, _interpType); 93 103 94 104 //to do: add handling to more formats 95 105 #ifdef NV40 96 if ( type == GL_FLOAT) {106 if (_type == GL_FLOAT) { 97 107 GLuint targetFormat[5] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB }; 98 108 GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 99 glTexImage3D(GL_TEXTURE_3D, 0, targetFormat[ n_components],100 width, height,depth, 0,101 format[ n_components],type, data);109 glTexImage3D(GL_TEXTURE_3D, 0, targetFormat[_numComponents], 110 _width, _height, _depth, 0, 111 format[_numComponents], _type, data); 102 112 } else { 103 113 #endif 104 114 GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 105 glTexImage3D(GL_TEXTURE_3D, 0, format[ n_components],106 width, height,depth, 0,107 format[ n_components],type, data);115 glTexImage3D(GL_TEXTURE_3D, 0, format[_numComponents], 116 _width, _height, _depth, 0, 117 format[_numComponents], _type, data); 108 118 #ifdef NV40 109 119 } … … 111 121 112 122 assert(glGetError()==0); 113 114 gl_resource_allocated = true;115 123 } 116 124 … … 118 126 { 119 127 glEnable(GL_TEXTURE_3D); 120 glBindTexture(GL_TEXTURE_3D, id);128 glBindTexture(GL_TEXTURE_3D, _id); 121 129 } 122 130 … … 124 132 { 125 133 glDisable(GL_TEXTURE_3D); 134 } 135 136 void Texture3D::setWrapS(GLuint wrapMode) 137 { 138 _wrapS = wrapMode; 139 } 140 141 void Texture3D::setWrapT(GLuint wrapMode) 142 { 143 _wrapT = wrapMode; 144 } 145 146 void Texture3D::setWrapR(GLuint wrapMode) 147 { 148 _wrapR = wrapMode; 126 149 } 127 150 -
trunk/packages/vizservers/nanovis/Texture3D.h
r2831 r2857 40 40 void deactivate(); 41 41 42 int width() const 43 { 44 return _width; 45 } 46 47 int height() const 48 { 49 return _width; 50 } 51 52 int depth() const 53 { 54 return _width; 55 } 56 57 double aspectRatioWidth() const 58 { 59 return _aspectRatioWidth; 60 } 61 62 double aspectRatioHeight() const 63 { 64 return _aspectRatioHeight; 65 } 66 67 double aspectRatioDepth() const 68 { 69 return _aspectRatioDepth; 70 } 71 72 GLuint id() const 73 { 74 return _id; 75 } 76 77 void setWrapS(GLuint wrapMode); 78 79 void setWrapT(GLuint wrapMode); 80 81 void setWrapR(GLuint wrapMode); 82 42 83 static void check_max_size(); 43 84 44 85 static void check_max_unit(); 45 86 46 int width; 47 int height; 48 int depth; 87 private: 88 int _width; 89 int _height; 90 int _depth; 49 91 50 double aspect_ratio_width;51 double aspect_ratio_height;52 double aspect_ratio_depth;92 double _aspectRatioWidth; 93 double _aspectRatioHeight; 94 double _aspectRatioDepth; 53 95 54 int n_components;96 int _numComponents; 55 97 56 bool gl_resource_allocated; 57 GLuint id; 58 GLuint type; 59 GLuint interp_type; 60 //GLuint tex_unit; 98 bool _glResourceAllocated; 99 GLuint _id; 100 GLuint _type; 101 GLuint _interpType; 102 GLuint _wrapS; 103 GLuint _wrapT; 104 GLuint _wrapR; 61 105 }; 62 106 -
trunk/packages/vizservers/nanovis/TransferFunction.cpp
r2831 r2857 27 27 28 28 _tex = new Texture1D(size, GL_FLOAT, GL_LINEAR, 4, data); 29 _id = _tex->id ;29 _id = _tex->id(); 30 30 } 31 31 -
trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp
r2831 r2857 4 4 #include <GL/glew.h> 5 5 #include <GL/gl.h> 6 #ifdef HAVE_OPENCV_H7 #include <opencv/cv.h>8 #endif9 #ifdef HAVE_OPENCV_HIGHGUI_H10 #include <opencv/highgui.h>11 #endif12 6 13 7 #include <R2/R2FilePath.h> 8 #include <Image.h> 9 #include <ImageLoaderFactory.h> 10 #include <ImageLoader.h> 14 11 15 12 #include "VelocityArrowsSlice.h" … … 52 49 _pointCount = 0; 53 50 54 /* 55 _particleVP = 56 LoadCgSourceProgram(_context, "velocityslicevp.cg", CG_PROFILE_VP40, "vpmain"); 57 58 _mvpParticleParam = cgGetNamedParameter(_particleVP, "mvp"); 59 _mvParticleParam = cgGetNamedParameter(_particleVP, "modelview"); 60 _mvTanHalfFOVParam = cgGetNamedParameter(_particleVP, "tanHalfFOV"); 61 62 // TBD.. 63 _particleFP = 64 LoadCgSourceProgram(_context, "velocityslicefp.cg", CG_PROFILE_FP40, "fpmain"); 65 66 _vectorParticleParam = cgGetNamedParameter(_particleVP, "vfield"); 67 */ 68 69 /* 70 TRACE("test1\n"); 71 const char *path = R2FilePath::getInstance()->getPath("arrows_flip2.png"); 72 if (path) { 73 TRACE("test2 %s\n", path); 74 } else { 75 TRACE("tt\n"); 76 } 77 IplImage* pTextureImage = cvLoadImage(path); 78 TRACE("test3\n"); 79 if (pTextureImage) { 80 TRACE("file(%s) has been loaded\n", path); 81 _arrowsTex = new Texture2D(pTextureImage->width, pTextureImage->height, GL_FLOAT, GL_LINEAR, 3, pTextureImage->imageData); 82 //_arrowsTex->setWrapS(TW_MIRROR); 83 //_arrowsTex->setWrapT(TW_MIRROR); 84 TRACE("file(%s) has been loaded\n", path); 85 //cvReleaseImage(&pTextureImage); 86 } else { 87 TRACE("not found\n"); 88 } 89 if (path) delete [] path; 90 */ 51 _particleVP = 52 LoadCgSourceProgram(_context, "velocityslicevp.cg", CG_PROFILE_VP40, "vpmain"); 53 54 _mvpParticleParam = cgGetNamedParameter(_particleVP, "mvp"); 55 _mvParticleParam = cgGetNamedParameter(_particleVP, "modelview"); 56 _mvTanHalfFOVParam = cgGetNamedParameter(_particleVP, "tanHalfFOV"); 57 58 // TBD.. 59 _particleFP = 60 LoadCgSourceProgram(_context, "velocityslicefp.cg", CG_PROFILE_FP40, "fpmain"); 61 62 _vectorParticleParam = cgGetNamedParameter(_particleVP, "vfield"); 63 64 const char *path = R2FilePath::getInstance()->getPath("arrows.bmp"); 65 if (path != NULL) { 66 ImageLoader *loader = ImageLoaderFactory::getInstance()->createLoader("bmp"); 67 if (loader != NULL) { 68 Image *image = loader->load(path, Image::IMG_RGBA); 69 delete [] path; 70 if (image != NULL) { 71 unsigned char *bytes = (unsigned char *)image->getImageBuffer(); 72 if (bytes != NULL) { 73 for (unsigned int y = 0; y < image->getHeight(); ++y) { 74 for (unsigned int x = 0; x < image->getWidth(); ++x, bytes += 4) { 75 bytes[3] = (bytes[0] == 0 && 76 bytes[1] == 0 && 77 bytes[2] == 0) ? 0 : 255; 78 } 79 } 80 81 _arrowsTex = new Texture2D(image->getWidth(), image->getHeight(), 82 GL_UNSIGNED_BYTE, GL_LINEAR, 4, NULL); 83 _arrowsTex->setWrapS(GL_MIRRORED_REPEAT); 84 _arrowsTex->setWrapT(GL_MIRRORED_REPEAT); 85 _arrowsTex->initialize(image->getImageBuffer()); 86 } 87 delete image; 88 } else { 89 ERROR("Failed to load image: arrows.bmp\n"); 90 } 91 delete loader; 92 } else { 93 delete [] path; 94 ERROR("Couldn't find loader for arrows.bmp\n"); 95 } 96 } else { 97 ERROR("Couldn't find path to arrows.bmp\n"); 98 } 91 99 92 100 _arrowColor.set(1, 1, 0); 93 101 94 TRACE(" test1\n");102 TRACE("Leaving VelocityArrowsSlice constructor\n"); 95 103 } 96 104 … … 190 198 191 199 for (unsigned int index = 0; index < _samplingPositions.size(); ++index) { 192 glMultiTexCoord3f(0, _samplingPositions[index].x,_samplingPositions[index].y,_samplingPositions[index].z); 200 glMultiTexCoord3f(0, 201 _samplingPositions[index].x, 202 _samplingPositions[index].y, 203 _samplingPositions[index].z); 193 204 glVertex2f(index % _renderTargetWidth, 194 205 index / _renderTargetHeight); … … 214 225 void VelocityArrowsSlice::render() 215 226 { 216 //if (!_enabled || (_vectorFieldGraphicsID == 0)) return;217 if (!_enabled)return;227 if (!_enabled) 228 return; 218 229 219 230 if (_dirty) { 220 221 222 231 computeSamplingTicks(); 232 queryVelocity(); 233 _dirty = false; 223 234 } 224 235 … … 228 239 glTranslatef(-0.5f, -0.5f, -0.5f); 229 240 if (_renderMode == LINES) { 230 231 232 233 234 235 236 237 238 239 240 241 242 pos = this->_samplingPositions[index];243 pos2 = this->_velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos;244 245 246 241 glDisable(GL_TEXTURE_2D); 242 glLineWidth(2.0); 243 glColor3f(_arrowColor.x, _arrowColor.y, _arrowColor.z); 244 glBegin(GL_LINES); 245 Vector3 pos; 246 Vector3 pos2; 247 Vector3 vel(1, 0, 0); 248 Vector3 v, v2; 249 if (_axis == 2) { 250 int index = 0; 251 for (int y = 1; y <= _tickCountY; ++y) { 252 for (int x = 1; x <= _tickCountX; ++x, ++index) { 253 pos = _samplingPositions[index]; 254 pos2 = _velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos; 255 glVertex3f(pos.x, pos.y, pos.z); 256 glVertex3f(pos2.x, pos2.y, pos2.z); 257 /*v = pos - pos2; 247 258 v2.x = 1; 248 259 v2.y = 1; … … 252 263 y3 *= adj 253 264 z3 *= adj 254 255 256 257 258 259 260 261 262 pos2 = this->_velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos;263 264 265 266 267 } 268 269 270 271 272 273 pos2 = this->_velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos;274 275 276 277 278 } 279 280 281 282 265 */ 266 } 267 } 268 } else if (_axis == 1) { 269 int index = 0; 270 for (int z = 1; z <= _tickCountZ; ++z) { 271 for (int x = 1; x <= _tickCountX; ++x, ++index) { 272 pos = _samplingPositions[index]; 273 pos2 = _velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos; 274 275 glVertex3f(pos.x, pos.y, pos.z); 276 glVertex3f(pos2.x, pos2.y, pos2.z); 277 } 278 } 279 } else if (_axis == 0) { 280 int index = 0; 281 for (int z = 1; z <= _tickCountZ; ++z) { 282 for (int y = 1; y <= _tickCountY; ++y, ++index) { 283 pos = _samplingPositions[index]; 284 pos2 = _velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos; 285 286 glVertex3f(pos.x, pos.y, pos.z); 287 glVertex3f(pos2.x, pos2.y, pos2.z); 288 } 289 } 290 } 291 292 glEnd(); 293 glLineWidth(1.0); 283 294 } else { 284 glColor3f(_arrowColor.x, _arrowColor.y, _arrowColor.z); 285 glEnable(GL_BLEND); 286 glBlendFunc(GL_SRC_ALPHA, GL_ONE); 287 glEnable(GL_POINT_SPRITE_NV); 288 glPointSize(20); 289 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_NV); 290 291 _arrowsTex->activate(); 292 glEnable(GL_TEXTURE_2D); 293 294 glPointParameterfARB( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 0.0f ); 295 296 glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, 1.0f); 297 glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, 100.0f); 298 glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE ); 299 300 cgGLBindProgram(_particleVP); 301 cgGLBindProgram(_particleFP); 302 cgGLEnableProfile(CG_PROFILE_VP40); 303 cgGLEnableProfile(CG_PROFILE_FP40); 304 305 cgGLSetTextureParameter(_vectorParticleParam, _vectorFieldGraphicsID); 306 cgGLEnableTextureParameter(_vectorParticleParam); 307 308 //cgSetParameter1f(_mvTanHalfFOVParam, -tan(_fov * 0.5) * _screenHeight * 0.5); 309 310 cgGLSetStateMatrixParameter(_mvpParticleParam, 311 CG_GL_MODELVIEW_PROJECTION_MATRIX, 312 CG_GL_MATRIX_IDENTITY); 313 cgGLSetStateMatrixParameter(_mvParticleParam, 314 CG_GL_MODELVIEW_MATRIX, 315 CG_GL_MATRIX_IDENTITY); 316 317 glEnableClientState(GL_VERTEX_ARRAY); 318 glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vertexBufferGraphicsID); 319 glVertexPointer(3, GL_FLOAT, 0, 0); 320 //glEnableClientState(GL_COLOR_ARRAY); 321 322 // TBD.. 323 glDrawArrays(GL_POINTS, 0, _pointCount); 324 glPointSize(1); 325 glDrawArrays(GL_POINTS, 0, _pointCount); 326 327 glDisableClientState(GL_VERTEX_ARRAY); 328 329 cgGLDisableProfile(CG_PROFILE_VP40); 330 cgGLDisableProfile(CG_PROFILE_FP40); 331 332 glDepthMask(GL_TRUE); 333 334 glDisable(GL_POINT_SPRITE_NV); 335 glDisable(GL_VERTEX_PROGRAM_POINT_SIZE_NV); 336 337 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 338 glDisable(GL_BLEND); 339 _arrowsTex->deactivate(); 295 glColor3f(_arrowColor.x, _arrowColor.y, _arrowColor.z); 296 glEnable(GL_BLEND); 297 glBlendFunc(GL_SRC_ALPHA, GL_ONE); 298 glEnable(GL_POINT_SPRITE_NV); 299 glPointSize(20); 300 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_NV); 301 302 _arrowsTex->activate(); 303 glEnable(GL_TEXTURE_2D); 304 305 glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 0.0f); 306 glPointParameterfARB(GL_POINT_SIZE_MIN_ARB, 1.0f); 307 glPointParameterfARB(GL_POINT_SIZE_MAX_ARB, 100.0f); 308 glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE); 309 310 cgGLBindProgram(_particleVP); 311 cgGLBindProgram(_particleFP); 312 cgGLEnableProfile(CG_PROFILE_VP40); 313 cgGLEnableProfile(CG_PROFILE_FP40); 314 315 cgGLSetTextureParameter(_vectorParticleParam, _vectorFieldGraphicsID); 316 cgGLEnableTextureParameter(_vectorParticleParam); 317 318 //cgSetParameter1f(_mvTanHalfFOVParam, -tan(_fov * 0.5) * _screenHeight * 0.5); 319 320 cgGLSetStateMatrixParameter(_mvpParticleParam, 321 CG_GL_MODELVIEW_PROJECTION_MATRIX, 322 CG_GL_MATRIX_IDENTITY); 323 cgGLSetStateMatrixParameter(_mvParticleParam, 324 CG_GL_MODELVIEW_MATRIX, 325 CG_GL_MATRIX_IDENTITY); 326 327 glEnableClientState(GL_VERTEX_ARRAY); 328 glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vertexBufferGraphicsID); 329 glVertexPointer(3, GL_FLOAT, 0, 0); 330 //glEnableClientState(GL_COLOR_ARRAY); 331 332 // TBD.. 333 glDrawArrays(GL_POINTS, 0, _pointCount); 334 glPointSize(1); 335 336 glDisableClientState(GL_VERTEX_ARRAY); 337 338 cgGLDisableProfile(CG_PROFILE_VP40); 339 cgGLDisableProfile(CG_PROFILE_FP40); 340 341 glDepthMask(GL_TRUE); 342 343 glDisable(GL_POINT_SPRITE_NV); 344 glDisable(GL_VERTEX_PROGRAM_POINT_SIZE_NV); 345 346 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 347 glDisable(GL_BLEND); 348 _arrowsTex->deactivate(); 340 349 } 341 350 glPopMatrix(); … … 344 353 void 345 354 VelocityArrowsSlice::vectorField(unsigned int vfGraphicsID, 346 355 float xScale, float yScale, float zScale) 347 356 { 348 357 _vectorFieldGraphicsID = vfGraphicsID; … … 360 369 // vfXscale 361 370 _tickCountX = _tickCountForMinSizeAxis; 362 371 363 372 float step = _vfXscale / (_tickCountX + 1); 364 373 365 374 _tickCountY = (int)(_vfYscale/step); 366 375 _tickCountZ = (int)(_vfZscale/step); … … 394 403 // vfZscale 395 404 _tickCountZ = _tickCountForMinSizeAxis; 396 405 397 406 float step = _vfZscale / (_tickCountZ + 1); 398 407 _tickCountX = (int)(_vfXscale/step); … … 448 457 } else { 449 458 glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vertexBufferGraphicsID); 450 Vector3 * pinfo = (Vector3*)glMapBufferARB(GL_ARRAY_BUFFER, GL_WRITE_ONLY_ARB);459 Vector3 *pinfo = (Vector3 *)glMapBufferARB(GL_ARRAY_BUFFER, GL_WRITE_ONLY_ARB); 451 460 452 461 Vector3 pos; -
trunk/packages/vizservers/nanovis/VelocityArrowsSlice.h
r2835 r2857 90 90 float _slicePos; 91 91 int _axis; 92 93 unsigned int _fbo; 92 93 unsigned int _fbo; 94 94 unsigned int _tex; 95 95 96 96 CGcontext _context; 97 97 CGprogram _queryVelocityFP; … … 108 108 int _tickCountY; 109 109 int _tickCountZ; 110 110 111 111 int _pointCount; 112 112 … … 114 114 Vector3 _arrowColor; 115 115 116 bool _enabled; 116 bool _enabled; 117 117 bool _dirty; 118 118 bool _dirtySamplingPosition; … … 126 126 CGparameter _mvTanHalfFOVParam; 127 127 CGparameter _mvCurrentTimeParam; 128 128 129 129 CGprogram _particleFP; 130 130 CGparameter _vectorParticleParam; -
trunk/packages/vizservers/nanovis/Volume.cpp
r2844 r2857 69 69 } 70 70 71 id = _tex->id ;71 id = _tex->id(); 72 72 73 73 wAxis.SetRange(v0, v1); 74 74 75 75 // VOLUME 76 aspect_ratio_width = s * _tex->aspect _ratio_width;77 aspect_ratio_height = s * _tex->aspect _ratio_height;78 aspect_ratio_depth = s * _tex->aspect _ratio_depth;76 aspect_ratio_width = s * _tex->aspectRatioWidth(); 77 aspect_ratio_height = s * _tex->aspectRatioHeight(); 78 aspect_ratio_depth = s * _tex->aspectRatioDepth(); 79 79 80 80 //Add cut planes. We create 3 default cut planes facing x, y, z directions. -
trunk/packages/vizservers/nanovis/Volume.h
r2844 r2857 363 363 { 364 364 size = s; 365 aspect_ratio_width = s * _tex->aspect _ratio_width;366 aspect_ratio_height = s * _tex->aspect _ratio_height;367 aspect_ratio_depth = s * _tex->aspect _ratio_depth;365 aspect_ratio_width = s * _tex->aspectRatioWidth(); 366 aspect_ratio_height = s * _tex->aspectRatioHeight(); 367 aspect_ratio_depth = s * _tex->aspectRatioDepth(); 368 368 } 369 369 -
trunk/packages/vizservers/nanovis/imgLoaders/Image.cpp
r2831 r2857 36 36 free(_dataBuffer); 37 37 } 38 -
trunk/packages/vizservers/nanovis/imgLoaders/ImageLoaderImpl.h
r2831 r2857 8 8 { 9 9 public: 10 friend class ImageLoader;11 12 10 ImageLoaderImpl(); 13 11 14 12 virtual ~ImageLoaderImpl(); 15 13 14 virtual Image *load(const char *fileName) = 0; 15 16 friend class ImageLoader; 17 16 18 protected: 17 19 Image::ImageFormat _targetImageFormat; 18 19 public:20 virtual Image *load(const char *fileName) = 0;21 20 }; 22 21 -
trunk/packages/vizservers/nanovis/nvconf.h.in
r2724 r2857 97 97 #undef HAVE_LIBAVUTIL_AVUTIL_H 98 98 99 /* Define to 1 if you have the `highgui' library (-lhighgui). */100 #undef HAVE_LIBHIGHGUI101 102 99 /* Define to 1 if you have the `swscale' library (-lswscale). */ 103 100 #undef HAVE_LIBSWSCALE … … 111 108 /* Define to 1 if you have the <netinet/in.h> header file. */ 112 109 #undef HAVE_NETINET_IN_H 113 114 /* Define to 1 if you have the <opencv/cv.h> header file. */115 #undef HAVE_OPENCV_CV_H116 117 /* Define to 1 if you have the <opencv/highgui.h> header file. */118 #undef HAVE_OPENCV_HIGHGUI_H119 110 120 111 /* Define to 1 if you have the <Python.h> header file. */ … … 175 166 #undef PACKAGE_TARNAME 176 167 177 /* Define to the home page for this package. */178 #undef PACKAGE_URL179 180 168 /* Define to the version of this package. */ 181 169 #undef PACKAGE_VERSION -
trunk/packages/vizservers/nanovis/shaders/pointsvp.cg
r2852 r2857 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 2 3 void main(in float4 posin : POSITION, 3 4 in float4 colin : COLOR0, -
trunk/packages/vizservers/nanovis/shaders/queryvelocity.cg
r2852 r2857 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 float4 main (float3 pos : TEXCOORD0, 3 uniform sampler3D vfield 4 2 3 float4 main(float3 pos : TEXCOORD0, 4 uniform sampler3D vfield) : COLOR 5 5 { 6 6 float3 velocity = tex3D(vfield, pos).yzw * 2 - float3(1, 1, 1); -
trunk/packages/vizservers/nanovis/shaders/velocityslicefp.cg
r2852 r2857 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 2 3 #include "particle_common.cg" 3 4 -
trunk/packages/vizservers/nanovis/shaders/velocityslicevp.cg
r2852 r2857 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 2 3 #include "particle_common.cg" 4 3 5 void vpmain(in float4 posin : POSITION, 4 6 in float4 colin : COLOR0, -
trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrFilePath.h
r2841 r2857 3 3 #define VRFILEPATH_H 4 4 5 #include <vrutil/vrUtil.h>6 5 #include <string> 7 6 #include <list> 7 8 #include <vrutil/vrUtil.h> 8 9 9 10 class vrFilePath -
trunk/packages/vizservers/nanovis/vrutil/vrFilePath.cpp
r2841 r2857 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include <vrutil/vrFilePath.h>3 4 #ifdef _WIN325 #pragma warning (disable : 4996)6 #endif7 8 2 #include <string.h> 9 3 #include <stdio.h> 10 4 #include <stdlib.h> 11 12 5 #ifdef _WIN32 13 6 #include <direct.h> 14 7 #endif 8 9 #include <vrutil/vrFilePath.h> 10 11 #include "Trace.h" 15 12 16 13 std::string vrFilePath::_curDirectory; … … 18 15 19 16 static char seps[] = ";"; 17 20 18 vrFilePath::vrFilePath() 21 19 { … … 23 21 #ifdef _WIN32 24 22 if (_getcwd(buff, 255) == 0) { 25 printf("failed to get the current directory in vrFilePath::vrFilePath\n");23 ERROR("failed to get the current working directory\n"); 26 24 } 27 25 #else 28 26 if (getcwd(buff, 255) == 0) { 29 printf("failed to get the current directory in vrFilePath::vrFilePath\n");27 ERROR("failed to get the current working directory\n"); 30 28 } 31 29 #endif … … 113 111 #ifdef _WIN32 114 112 if (_chdir(iter->c_str()) == -1) { 115 printf("error: change dir (%s)", iter->c_str());113 ERROR("error: change dir (%s)", iter->c_str()); 116 114 } 117 115 #else 118 116 if (chdir(iter->c_str()) == -1) { 119 printf("error: change dir (%s)", iter->c_str());117 ERROR("error: change dir (%s)", iter->c_str()); 120 118 } 121 119 #endif … … 125 123 path = (*iter) + fileName; 126 124 127 printf("returned [%s]\n", path.c_str());125 ERROR("error: returned [%s]\n", path.c_str()); 128 126 break; 129 127 } … … 132 130 #ifdef _WIN32 133 131 if (_chdir(_curDirectory.c_str()) != -1) { 134 printf("error: change dir (%s)", _curDirectory.c_str());132 ERROR("error: change dir (%s)", _curDirectory.c_str()); 135 133 } 136 134 #else 137 135 if (chdir(_curDirectory.c_str()) != -1) { 138 printf("error: change dir (%s)", _curDirectory.c_str());136 ERROR("error: change dir (%s)", _curDirectory.c_str()); 139 137 } 140 138 #endif
Note: See TracChangeset
for help on using the changeset viewer.