Ignore:
Timestamp:
Mar 15, 2012 11:46:42 PM (12 years ago)
Author:
ldelgass
Message:

Remove vr3d library - texture classes were redundant. Remove last vestiges of
opencv usage in code and remove from configure - replaced by imgLoaders library
functions.

Location:
trunk/packages/vizservers/nanovis
Files:
1 deleted
34 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/Color.h

    r2844 r2857  
    3434    void getRGB(float *result);
    3535
     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
    3651    /// Limits the color to be in range of [0,1]
    3752    void clamp();
  • trunk/packages/vizservers/nanovis/Makefile.in

    r2846 r2857  
    4848VRUTIL_LIB      = $(VRUTIL_DIR)/vrutil.a
    4949VRUTIL_LIB_SPEC = $(VRUTIL_LIB)
    50 VR3D_DIR        = ./vr3d
    51 VR3D_INC_SPEC   = -I$(srcdir)/$(VR3D_DIR)/include
    52 VR3D_LIB        = $(VR3D_DIR)/vr3d.a
    53 VR3D_LIB_SPEC   = $(VR3D_LIB)
    5450R2_DIR          = ./R2
    5551R2_INC_SPEC     = -I$(srcdir)/$(R2_DIR)/include
     
    7470                $(VRMATH_LIB_SPEC) \
    7571                $(VRUTIL_LIB_SPEC) \
    76                 $(VR3D_LIB_SPEC) \
    7772                $(TCL_LIB_SPEC) \
    7873                $(CG_LIB_SPEC) \
     
    9085                $(VRMATH_INC_SPEC) \
    9186                $(VRUTIL_INC_SPEC) \
    92                 $(VR3D_INC_SPEC) \
    9387                $(TCL_INC_SPEC) \
    9488                $(FF_INC_SPEC) \
     
    217211                $(srcdir)/shaders/velocity.cg
    218212
    219 .PHONY: all install install-resources install-shaders install-nanovis clean distclean newmat11 R2 imgloaders vrmath vrutil vr3d transfer-function
    220 
    221 all: newmat11 R2 imgloaders vrmath vrutil vr3d transfer-function nanovis
     213.PHONY: all install install-resources install-shaders install-nanovis clean distclean newmat11 R2 imgloaders vrmath vrutil transfer-function
     214
     215all: newmat11 R2 imgloaders vrmath vrutil nanovis
    222216
    223217install: install-nanovis install-resources install-shaders
     
    227221vrmath:                 $(VRMATH_LIB)
    228222vrutil:                 $(VRUTIL_LIB)
    229 vr3d:                   $(VR3D_LIB)
    230223imgloaders:             $(IMG_LIB)
    231224
     
    239232        $(MAKE) -C $(VRUTIL_DIR) all
    240233
    241 $(VR3D_LIB):
    242         $(MAKE) -C $(VR3D_DIR) all
    243 
    244234$(R2_LIB):
    245235        $(MAKE) -C $(R2_DIR)/src all
     
    248238        $(MAKE) -C $(IMG_DIR) all
    249239
    250 nanovis: $(MAT_LIB) $(R2_LIB) $(IMG_LIB) $(VRMATH_LIB) $(VRUTIL_LIB) $(VR3D_LIB) $(OBJS)
     240nanovis: $(MAT_LIB) $(R2_LIB) $(IMG_LIB) $(VRMATH_LIB) $(VRUTIL_LIB) $(OBJS)
    251241        $(CXX) $(CXX_SWITCHES) -o $@ $^ $(LIBS)
    252242
     
    288278        $(MAKE) -C $(VRMATH_DIR) clean
    289279        $(MAKE) -C $(VRUTIL_DIR) clean
    290         $(MAKE) -C $(VR3D_DIR) clean
    291280        $(MAKE) -C $(R2_DIR)/src clean
    292281        $(MAKE) -C $(IMG_DIR) clean
     
    297286        $(MAKE) -C $(VRMATH_DIR) distclean
    298287        $(MAKE) -C $(VRUTIL_DIR) distclean
    299         $(MAKE) -C $(VR3D_DIR) distclean
    300288        $(MAKE) -C $(R2_DIR)/src distclean
    301289        $(MAKE) -C $(IMG_DIR) distclean
     
    307295CmdProc.o: CmdProc.cpp CmdProc.h
    308296Color.o: Color.cpp Color.h
    309 Command.o: Command.cpp dxReader.h
     297Command.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
    310298ContourLineFilter.o: ContourLineFilter.cpp ContourLineFilter.h
    311299ConvexPolygon.o: ConvexPolygon.cpp ConvexPolygon.h Vector4.h Mat4x4.h Plane.h
  • trunk/packages/vizservers/nanovis/NvColorTableShader.h

    r2836 r2857  
    3030inline void NvColorTableShader::bind(Texture2D *plane, TransferFunction *tf)
    3131{
    32     cgGLSetTextureParameter(_dataParam, plane->id);
     32    cgGLSetTextureParameter(_dataParam, plane->id());
    3333    cgGLSetTextureParameter(_tfParam, tf->id());
    3434    cgGLEnableTextureParameter(_dataParam);
  • trunk/packages/vizservers/nanovis/NvRegularVolumeShader.h

    r2837 r2857  
    11/* -*- 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
    44
    55#include "Volume.h"
     
    2727
    2828inline void
    29 NvRegularVolumeShader::bind(unsigned int tfID, Volume* volume, int sliceMode)
     29NvRegularVolumeShader::bind(unsigned int tfID, Volume *volume, int sliceMode)
    3030{
    3131    //regular cubic volume
     
    3838    cgGLEnableTextureParameter(_tf_one_volume_param);
    3939
    40     if(!sliceMode)
     40    if (!sliceMode) {
    4141        cgGLSetParameter4f(_render_param_one_volume_param,
    4242            volume->n_slices(),
     
    4444            volume->diffuse(),
    4545            volume->specular());
    46     else
     46    } else {
    4747        cgGLSetParameter4f(_render_param_one_volume_param,
    4848            0.,
     
    5050            volume->diffuse(),
    5151            volume->specular());
     52    }
    5253
    5354    cgGLSetParameter4f(_option_one_volume_param,
  • trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.h

    r2844 r2857  
    3434    cgGLSetStateMatrixParameter(_mviParam, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE);
    3535    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.);
    3740
    3841    if (!sliceMode) {
     
    5659                       0.0f);
    5760
    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());
    6063    cgGLEnableTextureParameter(_volumeAParam);
    6164    cgGLEnableTextureParameter(_volumeBParam);
  • trunk/packages/vizservers/nanovis/ParticleSystem.cpp

    r2831 r2857  
    55#include <stdlib.h>
    66#include <stdio.h>
     7#include <math.h>
    78#include <pthread.h>
    89
    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>
    1911#include <Cg/cgGL.h>
    2012
    2113#include <vrutil/vrFilePath.h>
     14#include <Image.h>
     15#include <ImageLoader.h>
     16#include <ImageLoaderFactory.h>
    2217
    2318#include <vrmath/vrMatrix4x4f.h>
     
    2722#include "ParticleSystem.h"
    2823#include "ParticleEmitter.h"
     24#include "Texture2D.h"
     25#include "Texture3D.h"
    2926#include "Trace.h"
    3027
     
    292289
    293290    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();
    299294        _vectorFieldIDs.push_back(_curVectorFieldID);
    300295    } else {
    301296        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);
    306299            _vectorFields.push_back(flow);
    307             _vectorFieldIDs.push_back(flow->getGraphicsObjectID());
     300            _vectorFieldIDs.push_back(flow->id());
    308301        }
    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");
    319307#else
    320 #ifdef notdef
    321     // TBD..
    322308    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;
    334344        } else {
    335             *(dstPixels + 3) = 255;
     345            ERROR("Couldn't find loader for arrows.bmp\n");
    336346        }
    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    }
    345350
    346351#ifdef TEST
     
    10341039    static bool firstLoad = true;
    10351040    if (this->isTimeVaryingField()) {
    1036         static float oldTime = vrGetTimeStamp();
     1041        static float oldTime = (float)clock()/(float)CLOCKS_PER_SEC;
    10371042#ifdef WANT_TRACE
    10381043        static int index = 0;
    10391044#endif
    1040         float time = vrGetTimeStamp();
     1045        float time = (float)clock()/(float)CLOCKS_PER_SEC;
    10411046        if ((time - oldTime) > 2.0) {
    10421047            if (!_queue.isEmpty()) {
    1043                 float* data = 0;
     1048                float *data = NULL;
    10441049                if (_queue.top(data)) {
    10451050#ifdef WANT_TRACE
    10461051                    float t = clock() /(float) CLOCKS_PER_SEC;
    10471052#endif
    1048                     _vectorFields[0]->updatePixels(data);
     1053                    _vectorFields[0]->update(data);
    10491054#ifdef WANT_TRACE
    10501055                    float ti = clock() / (float) CLOCKS_PER_SEC;
     
    16611666
    16621667#ifndef TEST
    1663             _arrows->bind(0);
     1668            _arrows->activate(); //_arrows->bind(0);
    16641669            glEnable(GL_TEXTURE_2D);
    16651670            //glPointParameterfARB( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f );
     
    16771682            cgSetParameter1f(_mvCurrentTimeParam, _currentTime);
    16781683            //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));
    16831688
    16841689            cgGLSetStateMatrixParameter(_mvpParticleParam,
  • trunk/packages/vizservers/nanovis/ParticleSystem.h

    r2818 r2857  
    1111#include <Cg/cg.h>
    1212
    13 #include <vr3d/vrTexture2D.h>
    14 #include <vr3d/vrTexture3D.h>
    1513#include <vrmath/vrVector3f.h>
    1614
    1715#include "ParticleEmitter.h"
    1816#include "RenderVertexArray.h"
     17#include "Texture2D.h"
     18#include "Texture3D.h"
    1919
    2020#include "CircularQueue.h"
     
    137137    // TIME SERIES
    138138    std::vector<unsigned int> _vectorFieldIDs;
    139     std::vector<vrTexture3D *> _vectorFields;
     139    std::vector<Texture3D *> _vectorFields;
    140140    unsigned int _curVectorFieldID;
    141141    float _time_series_vel_mag_min;
     
    156156    unsigned _colorBufferID;
    157157    //////////////////////////////////////////
    158     vrTexture2D *_arrows;
     158    Texture2D *_arrows;
    159159
    160160    float _camx;
  • trunk/packages/vizservers/nanovis/PlaneRenderer.cpp

    r2835 r2857  
    109109PlaneRenderer::activate_shader(int index)
    110110{
    111     cgGLSetTextureParameter(_data_param, _plane[index]->id);
     111    cgGLSetTextureParameter(_data_param, _plane[index]->id());
    112112    cgGLSetTextureParameter(_tf_param, _tf[index]->id());
    113113    cgGLEnableTextureParameter(_data_param);
  • trunk/packages/vizservers/nanovis/PointSetRenderer.cpp

    r2831 r2857  
    3030        for (unsigned int y = 0; y < image->getHeight(); ++y) {
    3131            for (unsigned int x = 0; x < image->getWidth(); ++x, bytes += 4) {
    32                 bytes[3] =  (bytes[0] == 0) ? 0 : 255;
     32                bytes[3] = (bytes[0] == 0) ? 0 : 255;
    3333            }
    3434        }
     
    4444
    4545    delete loader;
     46    delete image;
    4647    _bucketSort = new PCA::BucketSort(1024);
    4748}
  • trunk/packages/vizservers/nanovis/PointShader.cpp

    r2833 r2857  
    1313    _normal(0)
    1414{
    15     this->loadVertexProgram("pointsvp.cg", "main");
     15    loadVertexProgram("pointsvp.cg", "main");
    1616    _modelviewVP  = getNamedParameterFromVP("modelview");
    1717    _projectionVP = getNamedParameterFromVP("projection");
  • trunk/packages/vizservers/nanovis/R2/include/R2/R2FilePath.h

    r2841 r2857  
    2828
    2929    /// get R2FilePath instance
    30     static R2FilePath* getInstance();
     30    static R2FilePath *getInstance();
    3131
    3232private:
  • trunk/packages/vizservers/nanovis/R2/src/R2FilePath.cpp

    r2841 r2857  
    112112    _curDirectory = buff;
    113113}
    114 
  • trunk/packages/vizservers/nanovis/Sphere.cpp

    r2822 r2857  
    1919Sphere::Sphere(float x, float y, float z,
    2020               float r, float g, float b,
    21                float _radius,
    22                int _stack,
    23                int _slice) :
     21               float radius,
     22               int stack,
     23               int slice) :
    2424    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)
    2929{
    30     boundary = BoundBox(x-r, y-r, z-r, x+r, y+r, z+r);
    3130}
    3231
     
    3534}
    3635
    37 void 
    38 Sphere::render()
     36void
     37Sphere::draw(GLUquadric *quad)
    3938{
    40 }
     39    glColor3f(_color.r(), _color.g(), _color.b());
    4140
    42 void
    43 Sphere::draw(GLUquadric* quad)
    44 {
    45     glColor3f(color.R, color.G, color.B);
    46    
    4741    glMatrixMode(GL_MODELVIEW);
    4842    glPushMatrix();
    49     glTranslatef(location.x, location.y, location.z);
    50    
     43    glTranslatef(_location.x, _location.y, _location.z);
     44
    5145    //draw it
    52     gluSphere(quad, radius, stack, slice);
    53    
     46    gluSphere(quad, _radius, _stack, _slice);
     47
    5448    glPopMatrix();
    5549}
    5650
    57 void
    58 Sphere::set_horizontal_res(int _slice) {
    59     slice=_slice;
     51void
     52Sphere::set_horizontal_res(int slice)
     53{
     54    _slice = slice;
    6055}
    6156
    62 void
    63 Sphere::set_vertical_res(int _stack) {
    64     stack=_stack;
     57void
     58Sphere::set_vertical_res(int stack)
     59{
     60    _stack = stack;
    6561}
    66 
  • trunk/packages/vizservers/nanovis/Sphere.h

    r2837 r2857  
    1414 * ======================================================================
    1515 */
    16 
    17 #ifndef _SPHERE_H_
    18 #define _SPHERE_H_
     16#ifndef SPHERE_H
     17#define SPHERE_H
    1918
    2019#include <GL/glew.h>
     
    2928{
    3029public:
    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);
    3334
    3435    virtual ~Sphere();
    3536
    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
    3940    //display the sphere
    40     void draw(GLUquadric* q);
    41     void render();
     41    void draw(GLUquadric *q);
     42    void render()
     43    {}
    4244
    43     float radius;
    44     Color color;
    45     int stack;
    46     int slice;
     45private:
     46    float _radius;
     47    Color _color;
     48    int _stack;
     49    int _slice;
    4750};
    4851
  • trunk/packages/vizservers/nanovis/Texture1D.cpp

    r2831 r2857  
    2323
    2424Texture1D::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)
    2732{
    2833}
     
    3136                     GLuint type, GLuint interp,
    3237                     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)
    3545{
    36     this->width = width;
    37     this->type = type;
    38     this->interp_type = interp;
    39     this->n_components = numComponents;
    40 
    4146    if (data != NULL)
    4247        initialize(data);
     
    4550Texture1D::~Texture1D()
    4651{
    47     glDeleteTextures(1, &id);
     52    glDeleteTextures(1, &_id);
    4853}
    4954
    5055GLuint Texture1D::initialize(void *data)
    5156{
    52     if (gl_resource_allocated)
    53         glDeleteTextures(1, &id);
     57    if (_glResourceAllocated)
     58        glDeleteTextures(1, &_id);
    5459
    55     glGenTextures(1, &id);
     60    glGenTextures(1, &_id);
    5661
    5762    update(data);
    5863       
    59     gl_resource_allocated = true;
    60     return id;
     64    _glResourceAllocated = true;
     65    return _id;
    6166}
    6267
     
    6570    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    6671
    67     glBindTexture(GL_TEXTURE_1D, id);
     72    glBindTexture(GL_TEXTURE_1D, _id);
    6873       
    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);
    7277
    7378    GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
    7479
    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);
    7782
    7883    assert(glGetError()==0);   
     
    8186void Texture1D::activate()
    8287{
    83     glBindTexture(GL_TEXTURE_1D, id);
     88    glBindTexture(GL_TEXTURE_1D, _id);
    8489    glEnable(GL_TEXTURE_1D);
    8590}
     
    8893{
    8994    glDisable(GL_TEXTURE_1D);           
     95}
     96
     97void Texture1D::setWrapS(GLuint wrapMode)
     98{
     99    _wrapS = wrapMode;
    90100}
    91101
  • trunk/packages/vizservers/nanovis/Texture1D.h

    r2831 r2857  
    4040    void deactivate();
    4141
     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
    4254    static void check_max_size();
    4355
    4456    static void check_max_unit();
    4557
    46     int width;
     58private:
     59    int _width;
    4760
    48     int n_components;
     61    int _numComponents;
    4962
    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;
    5668};
    5769
  • trunk/packages/vizservers/nanovis/Texture2D.cpp

    r2831 r2857  
    2424
    2525Texture2D::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)
    2835{}
    2936
     
    3138                     GLuint type, GLuint interp,
    3239                     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)
    3549{
    36     this->width = width;
    37     this->height = height;
    38     this->type = type;
    39     this->interp_type = interp;
    40     this->n_components = numComponents;
    41 
    4250    if (data != NULL)
    4351        initialize(data);
     
    4654Texture2D::~Texture2D()
    4755{
    48     glDeleteTextures(1, &id);
     56    glDeleteTextures(1, &_id);
    4957}
    5058
    5159GLuint Texture2D::initialize(void *data)
    5260{
    53     if (gl_resource_allocated)
    54         glDeleteTextures(1, &id);
     61    if (_glResourceAllocated)
     62        glDeleteTextures(1, &_id);
    5563
    56     glGenTextures(1, &id);
     64    glGenTextures(1, &_id);
    5765
    5866    update(data);
    5967
    60     gl_resource_allocated = true;
    61     return id;
     68    _glResourceAllocated = true;
     69    return _id;
    6270}
    6371
    6472void Texture2D::update(void *data)
    6573{
    66     glBindTexture(GL_TEXTURE_2D, id);
     74    glBindTexture(GL_TEXTURE_2D, _id);
    6775
    6876    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    6977
    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);
    7280
    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);
    7583
    7684    //to do: add handling to more formats
    7785#ifdef NV40
    78     if (type == GL_FLOAT) {
     86    if (_type == GL_FLOAT) {
    7987        GLuint targetFormat[5] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB };
    8088        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);
    8391    } else {
    8492#endif
    8593        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);
    8896#ifdef NV40
    8997    }
    9098#endif
    9199    assert(glGetError() == 0);
    92 
    93     gl_resource_allocated = true;
    94100}
    95101
    96 void
    97 Texture2D::activate()
     102void Texture2D::activate()
    98103{
    99     glBindTexture(GL_TEXTURE_2D, id);
     104    glBindTexture(GL_TEXTURE_2D, _id);
    100105    glEnable(GL_TEXTURE_2D);
    101106}
    102107
    103 void
    104 Texture2D::deactivate()
     108void Texture2D::deactivate()
    105109{
    106110    glDisable(GL_TEXTURE_2D);           
    107111}
    108112
    109 void
    110 Texture2D::check_max_size()
     113void Texture2D::setWrapS(GLuint wrapMode)
     114{
     115    _wrapS = wrapMode;
     116}
     117
     118void Texture2D::setWrapT(GLuint wrapMode)
     119{
     120    _wrapT = wrapMode;
     121}
     122
     123void Texture2D::check_max_size()
    111124{
    112125    GLint max = 0;
     
    116129}
    117130
    118 void
    119 Texture2D::check_max_unit()
     131void Texture2D::check_max_unit()
    120132{
    121133    int max = 0;
  • trunk/packages/vizservers/nanovis/Texture2D.h

    r2831 r2857  
    4040    void deactivate();
    4141
     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
    4261    static void check_max_size();
    4362
    4463    static void check_max_unit();
    4564
    46     int width;
    47     int height;
     65private:
     66    int _width;
     67    int _height;
    4868
    49     int n_components;
     69    int _numComponents;
    5070
    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;
    5577};
    5678
  • trunk/packages/vizservers/nanovis/Texture3D.cpp

    r2831 r2857  
    2424
    2525Texture3D::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)
    2837{}
    2938
     
    3140                     GLuint type, GLuint interp,
    3241                     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)
    3553{
    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;
    3956
    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;
    4261
    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;
    5565
    5666    if (data != NULL)
     
    6070Texture3D::~Texture3D()
    6171{
    62     glDeleteTextures(1, &id);
     72    glDeleteTextures(1, &_id);
    6373}
    6474
    6575GLuint Texture3D::initialize(void *data)
    6676{
    67     if (id != 0)
    68         glDeleteTextures(1, &id);
     77    if (_glResourceAllocated)
     78        glDeleteTextures(1, &_id);
    6979
    70     glGenTextures(1, &id);
     80    glGenTextures(1, &_id);
    7181
    7282    update(data);
    73  
    74     return id;
     83
     84    _glResourceAllocated = true;
     85    return _id;
    7586}
    7687
    7788void Texture3D::update(void *data)
    7889{
    79     assert(id > 0 && id != (GLuint)-1);
    80     glBindTexture(GL_TEXTURE_3D, id);
     90    glBindTexture(GL_TEXTURE_3D, _id);
    8191
    8292    //load texture with 16 bit half floating point precision if card is 6 series NV40
     
    8595    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    8696
    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);
    90100
    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);
    93103
    94104    //to do: add handling to more formats
    95105#ifdef NV40
    96     if (type == GL_FLOAT) {
     106    if (_type == GL_FLOAT) {
    97107        GLuint targetFormat[5] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB };
    98108        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);
    102112    } else {
    103113#endif
    104114        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);
    108118#ifdef NV40
    109119    }
     
    111121
    112122    assert(glGetError()==0);
    113 
    114     gl_resource_allocated = true;
    115123}
    116124
     
    118126{
    119127    glEnable(GL_TEXTURE_3D);
    120     glBindTexture(GL_TEXTURE_3D, id);
     128    glBindTexture(GL_TEXTURE_3D, _id);
    121129}
    122130
     
    124132{
    125133    glDisable(GL_TEXTURE_3D);           
     134}
     135
     136void Texture3D::setWrapS(GLuint wrapMode)
     137{
     138    _wrapS = wrapMode;
     139}
     140
     141void Texture3D::setWrapT(GLuint wrapMode)
     142{
     143    _wrapT = wrapMode;
     144}
     145
     146void Texture3D::setWrapR(GLuint wrapMode)
     147{
     148    _wrapR = wrapMode;
    126149}
    127150
  • trunk/packages/vizservers/nanovis/Texture3D.h

    r2831 r2857  
    4040    void deactivate();
    4141
     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
    4283    static void check_max_size();
    4384
    4485    static void check_max_unit();
    4586
    46     int width;
    47     int height;
    48     int depth;
     87private:
     88    int _width;
     89    int _height;
     90    int _depth;
    4991
    50     double aspect_ratio_width;
    51     double aspect_ratio_height;
    52     double aspect_ratio_depth;
     92    double _aspectRatioWidth;
     93    double _aspectRatioHeight;
     94    double _aspectRatioDepth;
    5395
    54     int n_components;
     96    int _numComponents;
    5597
    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;
    61105};
    62106
  • trunk/packages/vizservers/nanovis/TransferFunction.cpp

    r2831 r2857  
    2727
    2828    _tex = new Texture1D(size, GL_FLOAT, GL_LINEAR, 4, data);
    29     _id = _tex->id;
     29    _id = _tex->id();
    3030}
    3131
  • trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp

    r2831 r2857  
    44#include <GL/glew.h>
    55#include <GL/gl.h>
    6 #ifdef HAVE_OPENCV_H
    7 #include <opencv/cv.h>
    8 #endif
    9 #ifdef HAVE_OPENCV_HIGHGUI_H
    10 #include <opencv/highgui.h>
    11 #endif
    126
    137#include <R2/R2FilePath.h>
     8#include <Image.h>
     9#include <ImageLoaderFactory.h>
     10#include <ImageLoader.h>
    1411
    1512#include "VelocityArrowsSlice.h"
     
    5249    _pointCount = 0;
    5350
    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    }
    9199
    92100    _arrowColor.set(1, 1, 0);
    93101
    94     TRACE("test1\n");
     102    TRACE("Leaving VelocityArrowsSlice constructor\n");
    95103}
    96104
     
    190198
    191199    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);
    193204        glVertex2f(index % _renderTargetWidth,
    194205                   index / _renderTargetHeight);
     
    214225void VelocityArrowsSlice::render()
    215226{
    216     //if (!_enabled || (_vectorFieldGraphicsID == 0)) return;   
    217     if (!_enabled) return;
     227    if (!_enabled)
     228        return;
    218229
    219230    if (_dirty) {
    220         computeSamplingTicks();
    221         queryVelocity();
    222         _dirty = false;
     231        computeSamplingTicks();
     232        queryVelocity();
     233        _dirty = false;
    223234    }
    224235
     
    228239    glTranslatef(-0.5f, -0.5f, -0.5f);
    229240    if (_renderMode == LINES) {
    230         glDisable(GL_TEXTURE_2D);
    231         glLineWidth(2.0);
    232         glColor3f(_arrowColor.x, _arrowColor.y, _arrowColor.z);
    233         glBegin(GL_LINES);
    234         Vector3 pos;
    235         Vector3 pos2;
    236         Vector3 vel(1, 0, 0);
    237         Vector3 v, v2;
    238         if (_axis == 2) {
    239             int index = 0;
    240             for (int y = 1; y <= _tickCountY; ++y) {
    241                 for (int x = 1; x <= _tickCountX; ++x, ++index) {
    242                     pos = this->_samplingPositions[index];
    243                     pos2 = this->_velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos;
    244                     glVertex3f(pos.x, pos.y, pos.z);
    245                     glVertex3f(pos2.x, pos2.y, pos2.z);
    246                     /*v = pos - pos2;
     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;
    247258                      v2.x = 1;
    248259                      v2.y = 1;
     
    252263                      y3 *= adj
    253264                      z3 *= adj
    254                     */
    255                 }
    256             }
    257         } else if (_axis == 1) {
    258             int index = 0;
    259             for (int z = 1; z <= _tickCountZ; ++z) {
    260                 for (int x = 1; x <= _tickCountX; ++x, ++index) {
    261                     pos = _samplingPositions[index];
    262                     pos2 = this->_velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos;
    263 
    264                     glVertex3f(pos.x, pos.y, pos.z);
    265                     glVertex3f(pos2.x, pos2.y, pos2.z);
    266                 }
    267             }
    268         } else if (_axis == 0) {
    269             int index = 0;
    270             for (int z = 1; z <= _tickCountZ; ++z) {
    271                 for (int y = 1; y <= _tickCountY; ++y, ++index) {
    272                     pos = _samplingPositions[index];
    273                     pos2 = this->_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         }
    280 
    281         glEnd();
    282         glLineWidth(1.0);
     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);
    283294    } 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();
    340349    }
    341350    glPopMatrix();
     
    344353void
    345354VelocityArrowsSlice::vectorField(unsigned int vfGraphicsID,
    346                                 float xScale, float yScale, float zScale)
     355                                float xScale, float yScale, float zScale)
    347356{
    348357    _vectorFieldGraphicsID = vfGraphicsID;
     
    360369            // vfXscale
    361370            _tickCountX = _tickCountForMinSizeAxis;
    362                        
     371
    363372            float step = _vfXscale / (_tickCountX + 1);
    364                        
     373
    365374            _tickCountY = (int)(_vfYscale/step);
    366375            _tickCountZ = (int)(_vfZscale/step);
     
    394403            // vfZscale
    395404            _tickCountZ = _tickCountForMinSizeAxis;
    396                        
     405
    397406            float step = _vfZscale / (_tickCountZ + 1);
    398407            _tickCountX = (int)(_vfXscale/step);
     
    448457    } else {
    449458        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);
    451460
    452461        Vector3 pos;
  • trunk/packages/vizservers/nanovis/VelocityArrowsSlice.h

    r2835 r2857  
    9090    float _slicePos;
    9191    int _axis;
    92        
    93     unsigned int _fbo; 
     92
     93    unsigned int _fbo;
    9494    unsigned int _tex;
    95        
     95
    9696    CGcontext _context;
    9797    CGprogram _queryVelocityFP;
     
    108108    int _tickCountY;
    109109    int _tickCountZ;
    110        
     110
    111111    int _pointCount;
    112112
     
    114114    Vector3 _arrowColor;
    115115
    116     bool _enabled;     
     116    bool _enabled;
    117117    bool _dirty;
    118118    bool _dirtySamplingPosition;
     
    126126    CGparameter _mvTanHalfFOVParam;
    127127    CGparameter _mvCurrentTimeParam;
    128        
     128
    129129    CGprogram _particleFP;
    130130    CGparameter _vectorParticleParam;
  • trunk/packages/vizservers/nanovis/Volume.cpp

    r2844 r2857  
    6969    }
    7070
    71     id = _tex->id;
     71    id = _tex->id();
    7272
    7373    wAxis.SetRange(v0, v1);
    7474
    7575    // 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();
    7979
    8080    //Add cut planes. We create 3 default cut planes facing x, y, z directions.
  • trunk/packages/vizservers/nanovis/Volume.h

    r2844 r2857  
    363363{
    364364    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();
    368368}
    369369
  • trunk/packages/vizservers/nanovis/imgLoaders/Image.cpp

    r2831 r2857  
    3636    free(_dataBuffer);
    3737}   
    38 
  • trunk/packages/vizservers/nanovis/imgLoaders/ImageLoaderImpl.h

    r2831 r2857  
    88{
    99public:
    10     friend class ImageLoader;
    11 
    1210    ImageLoaderImpl();
    1311
    1412    virtual ~ImageLoaderImpl();
    1513
     14    virtual Image *load(const char *fileName) = 0;
     15
     16    friend class ImageLoader;
     17
    1618protected:
    1719    Image::ImageFormat _targetImageFormat;
    18 
    19 public:
    20     virtual Image *load(const char *fileName) = 0;
    2120};
    2221
  • trunk/packages/vizservers/nanovis/nvconf.h.in

    r2724 r2857  
    9797#undef HAVE_LIBAVUTIL_AVUTIL_H
    9898
    99 /* Define to 1 if you have the `highgui' library (-lhighgui). */
    100 #undef HAVE_LIBHIGHGUI
    101 
    10299/* Define to 1 if you have the `swscale' library (-lswscale). */
    103100#undef HAVE_LIBSWSCALE
     
    111108/* Define to 1 if you have the <netinet/in.h> header file. */
    112109#undef HAVE_NETINET_IN_H
    113 
    114 /* Define to 1 if you have the <opencv/cv.h> header file. */
    115 #undef HAVE_OPENCV_CV_H
    116 
    117 /* Define to 1 if you have the <opencv/highgui.h> header file. */
    118 #undef HAVE_OPENCV_HIGHGUI_H
    119110
    120111/* Define to 1 if you have the <Python.h> header file. */
     
    175166#undef PACKAGE_TARNAME
    176167
    177 /* Define to the home page for this package. */
    178 #undef PACKAGE_URL
    179 
    180168/* Define to the version of this package. */
    181169#undef PACKAGE_VERSION
  • trunk/packages/vizservers/nanovis/shaders/pointsvp.cg

    r2852 r2857  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2
    23void main(in float4 posin : POSITION,
    34          in float4 colin : COLOR0,
  • trunk/packages/vizservers/nanovis/shaders/queryvelocity.cg

    r2852 r2857  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 float4 main (float3 pos : TEXCOORD0,
    3              uniform sampler3D vfield
    4              ) : COLOR
     2
     3float4 main(float3 pos : TEXCOORD0,
     4            uniform sampler3D vfield) : COLOR
    55{
    66    float3 velocity = tex3D(vfield, pos).yzw * 2 - float3(1, 1, 1);
  • trunk/packages/vizservers/nanovis/shaders/velocityslicefp.cg

    r2852 r2857  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2
    23#include "particle_common.cg"
    34
  • trunk/packages/vizservers/nanovis/shaders/velocityslicevp.cg

    r2852 r2857  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2
    23#include "particle_common.cg"
     4
    35void vpmain(in float4 posin : POSITION,
    46            in float4 colin : COLOR0,
  • trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrFilePath.h

    r2841 r2857  
    33#define VRFILEPATH_H
    44
    5 #include <vrutil/vrUtil.h>
    65#include <string>
    76#include <list>
     7
     8#include <vrutil/vrUtil.h>
    89
    910class vrFilePath
  • trunk/packages/vizservers/nanovis/vrutil/vrFilePath.cpp

    r2841 r2857  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #include <vrutil/vrFilePath.h>
    3 
    4 #ifdef _WIN32
    5 #pragma warning (disable : 4996)
    6 #endif
    7 
    82#include <string.h>
    93#include <stdio.h>
    104#include <stdlib.h>
    11 
    125#ifdef _WIN32
    136#include <direct.h>
    147#endif
     8
     9#include <vrutil/vrFilePath.h>
     10
     11#include "Trace.h"
    1512
    1613std::string vrFilePath::_curDirectory;
     
    1815
    1916static char seps[]  = ";";
     17
    2018vrFilePath::vrFilePath()
    2119{
     
    2321#ifdef _WIN32
    2422    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");
    2624    }
    2725#else
    2826    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");
    3028    }
    3129#endif
     
    113111#ifdef _WIN32
    114112        if (_chdir(iter->c_str()) == -1) {
    115             printf("error : change dir (%s)", iter->c_str());
     113            ERROR("error: change dir (%s)", iter->c_str());
    116114        }
    117115#else
    118116        if (chdir(iter->c_str()) == -1) {
    119             printf("error : change dir (%s)", iter->c_str());
     117            ERROR("error: change dir (%s)", iter->c_str());
    120118        }
    121119#endif
     
    125123            path = (*iter) + fileName;
    126124
    127             printf("returned [%s]\n", path.c_str());
     125            ERROR("error: returned [%s]\n", path.c_str());
    128126            break;
    129127        }
     
    132130#ifdef _WIN32
    133131    if (_chdir(_curDirectory.c_str()) != -1) {
    134         printf("error : change dir (%s)", _curDirectory.c_str());
     132        ERROR("error: change dir (%s)", _curDirectory.c_str());
    135133    }
    136134#else
    137135    if (chdir(_curDirectory.c_str()) != -1) {
    138         printf("error : change dir (%s)", _curDirectory.c_str());
     136        ERROR("error: change dir (%s)", _curDirectory.c_str());
    139137    }
    140138#endif
Note: See TracChangeset for help on using the changeset viewer.