source: trunk/packages/vizservers/nanovis/NvLIC.cpp @ 3452

Last change on this file since 3452 was 3452, checked in by ldelgass, 11 years ago

Remove XINETD define from nanovis. We only support server mode now, no glut
interaction loop with mouse/keyboard handlers. Fixes for trace logging to make
output closer to vtkvis: inlcude function name for trace messages, remove
newlines from format strings in macros since newlines get added by syslog.

  • Property svn:eol-style set to native
File size: 15.2 KB
RevLine 
[2798]1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
[587]2/*
3 * ----------------------------------------------------------------------
4 * NvLIC.h: line integral convolution class
5 *
6 * ======================================================================
[851]7 *  AUTHOR:  Insoo Woo <iwoo@purdue.edu, Wei Qiao <qiaow@purdue.edu>
[587]8 *           Purdue Rendering and Perceptualization Lab (PURPL)
9 *
[3177]10 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
[587]11 *
12 *  See the file "license.terms" for information on usage and
13 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 * ======================================================================
15 */
16#include <stdlib.h>
17#include <math.h>
18#include <assert.h>
19
[2967]20#include "nanovis.h"
21#include "define.h"
[2831]22
[587]23#include "NvLIC.h"
[2870]24#include "NvShader.h"
[2831]25#include "Trace.h"
[587]26
[2847]27#define NPN 256   //resolution of background pattern
28#define DM ((float) (1.0/(NMESH-1.0))) //distance in world coords between mesh lines
29#define SCALE 3.0 //scale for background pattern. small value -> fine texture
30
[2920]31NvLIC::NvLIC(int size, int width, int height, int axis,
[2951]32             float offset) :
[2920]33    _width(width),
34    _height(height),
35    _size(size),
36    _scale(1.0f, 1.0f, 1.0f),
37    _origin(0, 0, 0),
38    _offset(offset),
39    _axis(axis),
40    _iframe(0),
41    _Npat(64),
42    _alpha((int)0.12*255),
43    _tmax(NPIX/(SCALE*NPN)),
44    _dmax(SCALE/NPIX),
45    _max(1.0f),
46    _disListID(0),
[1515]47    _vectorFieldId(0),
[851]48    _activate(false)
[587]49{
[2920]50    _sliceVector = new float[_size*_size*4];
51    memset(_sliceVector, 0, sizeof(float) * _size * _size * 4);
[1370]52
[2920]53    int fboOrig;
54    glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &fboOrig);
[587]55
[851]56    //initialize the pattern texture
[2920]57    glGenTextures(1, &_patternTex);
58    glBindTexture(GL_TEXTURE_2D, _patternTex);
[1431]59    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
60    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
[2967]61    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
62    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
[851]63    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
[587]64
[2920]65    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, NPN, NPN, 0,
66                 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
67
[851]68    //initialize frame buffer objects
69    //render buffer for projecting 3D velocity onto a 2D plane
[2920]70    glGenFramebuffersEXT(1, &_velFbo);
71    glGenTextures(1, &_sliceVectorTex);
[587]72
[2920]73    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _velFbo);
[587]74
[2920]75    glBindTexture(GL_TEXTURE_RECTANGLE_ARB, _sliceVectorTex);
[2884]76    glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
77    glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
[2920]78    glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
79    glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
[587]80
[2920]81    glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA32F_ARB, _size, _size,
82                 0, GL_RGBA, GL_FLOAT, NULL);
[851]83
84    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
[2920]85                              GL_TEXTURE_RECTANGLE_ARB, _sliceVectorTex, 0);
[587]86
[851]87    //render buffer for the convolution
[2920]88    glGenFramebuffersEXT(1, &_fbo);
89    glGenTextures(1, &_colorTex);
[587]90
[2920]91    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fbo);
[587]92
[851]93    //initialize color texture for lic
[2920]94    glBindTexture(GL_TEXTURE_2D, _colorTex);
95    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
96    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
97    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
[851]98
[2920]99    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, _width, _height, 0,
100                 GL_RGB, GL_UNSIGNED_BYTE, NULL);
[851]101
[2920]102    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
103                              GL_TEXTURE_2D, _colorTex, 0);
[587]104
[851]105    // Check framebuffer completeness at the end of initialization.
106    CHECK_FRAMEBUFFER_STATUS();
[587]107
[2920]108    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig);
[587]109
[2920]110    _renderVelShader = new NvShader();
111    _renderVelShader->loadFragmentProgram("render_vel.cg", "main");
[2847]112
[2920]113    makePatterns();
[587]114}
115
[851]116NvLIC::~NvLIC()
117{
[2920]118    glDeleteTextures(1, &_patternTex);
119    glDeleteTextures(1, &_magTex);
[1481]120
[2920]121    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _velFbo);
122    glDeleteTextures(1, &_sliceVectorTex);
[587]123
[2920]124    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fbo);
125    glDeleteTextures(1, &_colorTex);
[587]126
[2920]127    GLuint buffers[2] = {_velFbo, _fbo};
[851]128    glDeleteFramebuffersEXT(2, buffers);
[587]129
[2920]130    glDeleteLists(_disListID, _Npat);
[851]131
[2920]132    delete _renderVelShader;
133
134    delete [] _sliceVector;
[587]135}
136
[984]137void
[2920]138NvLIC::makePatterns()
[587]139{
[3452]140    TRACE("Enter");
141
[2920]142    if (_disListID > 0) {
143        glDeleteLists(_disListID, _Npat);
[1510]144    }
[2920]145    _disListID = glGenLists(_Npat);
[2847]146
[3452]147    TRACE("DisplayList : %d", _disListID);
[2847]148
[984]149    int lut[256];
150    int phase[NPN][NPN];
151    GLubyte pat[NPN][NPN][4];
152    int i, j, k, t;
[2847]153
[984]154    for (i = 0; i < 256; i++) {
[1028]155        lut[i] = i < 127 ? 0 : 255;
[984]156    }
157    for (i = 0; i < NPN; i++) {
[1028]158        for (j = 0; j < NPN; j++) {
[2847]159            phase[i][j] = rand() >> 8;
[851]160        }
[984]161    }
[2920]162    for (k = 0; k < _Npat; k++) {
163        t = (k << 8) / _Npat;
[1028]164        for (i = 0; i < NPN; i++) {
165            for (j = 0; j < NPN; j++) {
166                pat[i][j][0] = pat[i][j][1] = pat[i][j][2] =
167                    lut[(t + phase[i][j]) % 255];
[2920]168                pat[i][j][3] = _alpha;
[1028]169            }
170        }
[2920]171        glNewList(_disListID + k, GL_COMPILE);
172        glBindTexture(GL_TEXTURE_2D, _patternTex);
173        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, NPN, NPN, 0,
174                     GL_RGBA, GL_UNSIGNED_BYTE, pat);
[1028]175        glEndList();
[984]176    }
[2847]177
[2920]178    glBindTexture(GL_TEXTURE_2D, _patternTex);
179    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, NPN, NPN, 0,
[1028]180                 GL_RGBA, GL_UNSIGNED_BYTE, pat);
[3452]181
182    TRACE("Leave");
[587]183}
184
[2920]185void NvLIC::makeMagnitudes()
[587]186{
[851]187    GLubyte mag[NMESH][NMESH][4];
[587]188
[2847]189    //read vector field
190    for (int i = 0; i < NMESH; i++) {
191        for (int j = 0; j < NMESH; j++) {
192            float x = DM*i;
193            float y = DM*j;
194 
[1028]195            float magnitude = sqrt(x*x+y*y)/1.414;
[2847]196
[1028]197            //from green to red
[2847]198            GLubyte r = (GLubyte)floor(magnitude*255);
[1028]199            GLubyte g = 0;
200            GLubyte b = 255 - r;
201            GLubyte a = 122;
[2847]202
[1028]203            mag[i][j][0] = r;
204            mag[i][j][1] = g;
205            mag[i][j][2] = b;
206            mag[i][j][3] = a;
[851]207        }
[587]208    }
[2920]209    glGenTextures(1, &_magTex);
210    glBindTexture(GL_TEXTURE_2D, _magTex);
[851]211    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
212    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
213    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
214    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
215    //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
[1028]216    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, NMESH, NMESH, 0, GL_RGBA,
217                 GL_UNSIGNED_BYTE, mag);
[851]218    glBindTexture(GL_TEXTURE_2D, 0);
[587]219}
220
[1028]221void
[2920]222NvLIC::getSlice()
[851]223{
[2920]224    int fboOrig;
225    glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &fboOrig);
[587]226
[2920]227    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _velFbo);
228
229    glPushAttrib(GL_VIEWPORT_BIT | GL_ENABLE_BIT);
230
[851]231    glClear(GL_COLOR_BUFFER_BIT);
[2920]232    glDisable(GL_DEPTH_TEST);
233    glDisable(GL_BLEND);
[587]234
[2920]235    glViewport(0, 0, _size, _size);
[851]236    glMatrixMode(GL_PROJECTION);
[2920]237    glPushMatrix();
[851]238    glLoadIdentity();
[2920]239    gluOrtho2D(0, _size, 0, _size);
[851]240    glMatrixMode(GL_MODELVIEW);
[2920]241    glPushMatrix();
[851]242    glLoadIdentity();
[587]243
[851]244    glEnable(GL_TEXTURE_3D);
[1515]245    glBindTexture(GL_TEXTURE_3D, _vectorFieldId);
[587]246
[2920]247    _renderVelShader->bind();
[2967]248    _renderVelShader->setFPTextureParameter("vel_tex", _vectorFieldId);
249    _renderVelShader->setFPParameter1f("timestep", 0.0005);
250    _renderVelShader->setFPParameter1f("vmax", _max > 100.0 ? 100.0 : _max);
[851]251
[2967]252    switch (_axis) {
253    case 0:
254        _renderVelShader->setFPParameter3f("projection_vector", 0., 1., 1.);
255        break;
256    case 1:
257        _renderVelShader->setFPParameter3f("projection_vector", 1., 0., 1.);
258        break;
259    default:
260    case 2:
261        _renderVelShader->setFPParameter3f("projection_vector", 1., 1., 0.);
262        break;
263    }
264
[851]265    glBegin(GL_QUADS);
[1028]266    {
[2920]267        switch (_axis) {
[2967]268        case 0:
[2951]269            glTexCoord3f(_offset, 0., 0.); glVertex2f(0.,    0.);
270            glTexCoord3f(_offset, 1., 0.); glVertex2f(_size, 0.);
271            glTexCoord3f(_offset, 1., 1.); glVertex2f(_size, _size);
272            glTexCoord3f(_offset, 0., 1.); glVertex2f(0.,    _size);
[2967]273            break;
274        case 1:
[2951]275            glTexCoord3f(0., _offset, 0.); glVertex2f(0.,    0.);
276            glTexCoord3f(1., _offset, 0.); glVertex2f(_size, 0.);
277            glTexCoord3f(1., _offset, 1.); glVertex2f(_size, _size);
278            glTexCoord3f(0., _offset, 1.); glVertex2f(0.,    _size);
[2967]279            break;
280        case 2:
[2951]281            glTexCoord3f(0., 0., _offset); glVertex2f(0.,    0.);
282            glTexCoord3f(1., 0., _offset); glVertex2f(_size, 0.);
283            glTexCoord3f(1., 1., _offset); glVertex2f(_size, _size);
284            glTexCoord3f(0., 1., _offset); glVertex2f(0.,    _size);
[2920]285            break;
286        }
[1028]287    }
[851]288    glEnd();
[2847]289
[2967]290    _renderVelShader->disableFPTextureParameter("vel_tex");
[2920]291    _renderVelShader->unbind();
[2847]292
[851]293    glBindTexture(GL_TEXTURE_3D, 0);
294    glDisable(GL_TEXTURE_3D);
295
296    //read the vectors
[2920]297    glReadPixels(0, 0, _size, _size, GL_RGBA, GL_FLOAT, _sliceVector);
[851]298
[2920]299    int lim = _size * _size * 4;
300    float *v = _sliceVector;
[1028]301    for (int i = 0; i < lim; ++i) {
302        if (isnan(*v)) {
303            *v = 0.0f;   
304        }
[851]305        ++v;
306    }
[2920]307
308    glMatrixMode(GL_PROJECTION);
309    glPopMatrix();
310    glMatrixMode(GL_MODELVIEW);
311    glPopMatrix();
312
313    glPopAttrib();
314
315    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig);
[587]316}
317
318//line integral convolution
[1028]319void
320NvLIC::convolve()
[851]321{
[1515]322    if (_vectorFieldId == 0) {
[2920]323        return;
[1431]324    }
[1370]325
[851]326    int   i, j;
327    float x1, x2, y, px, py;
[2847]328
[2920]329    int fboOrig;
330    glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &fboOrig);
[2847]331
[2920]332    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fbo);
333
334    glPushAttrib(GL_VIEWPORT_BIT | GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
335
[851]336    glMatrixMode(GL_PROJECTION);
[2920]337    glPushMatrix();
338    glLoadIdentity();
[1429]339
[851]340    glViewport(0, 0, (GLsizei) NPIX, (GLsizei) NPIX);
341    //glTranslatef(-1.0, -1.0, 0.0);
342    //glScalef(2.0, 2.0, 1.0);
343    glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -10.0f, 10.0f);
[2847]344
[851]345    glMatrixMode(GL_MODELVIEW);
[2920]346    glPushMatrix();
347    glLoadIdentity();
[2847]348
[2920]349    glClear(GL_COLOR_BUFFER_BIT);
350    //glDepthMask(GL_FALSE);
351    glDisable(GL_DEPTH_TEST);
352    glDisable(GL_LIGHTING);
353    glDisable(GL_ALPHA_TEST);
[2847]354
[2920]355    //_sa = 0.010*cos(_iframe*2.0*M_PI/200.0);
[851]356    glEnable(GL_TEXTURE_2D);
[2920]357    glBindTexture(GL_TEXTURE_2D, _patternTex);
358    _sa = 0.01;
[2847]359 
[2920]360    glColor4f(1, 1, 1, 1);
[1028]361    for (i = 0; i < NMESH-1; i++) {
[851]362        x1 = DM*i; x2 = x1 + DM;
363        glBegin(GL_QUAD_STRIP);
364        for (j = 0; j < NMESH-1; j++) {
[1028]365            y = DM*j;
[2967]366            glTexCoord2f(x1, y);
[2920]367            getVelocity(x1, y, &px, &py);
[1028]368            glVertex2f(px, py);
[2920]369
[2967]370            glTexCoord2f(x2, y);
371            getVelocity(x2, y, &px, &py);
[1028]372            glVertex2f(px, py);
[851]373        }
374        glEnd();
[1028]375    }
[2920]376    _iframe = _iframe + 1;
[2847]377
378    glEnable(GL_BLEND);
379
[851]380    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
[2847]381
[851]382    glEnable(GL_TEXTURE_2D);
[2920]383    glCallList(_iframe % _Npat + _disListID);
[2967]384    glBegin(GL_QUADS);
[1028]385    {
[2920]386        glTexCoord2f(0.0,   0.0);   glVertex2f(0.0, 0.0);
387        glTexCoord2f(_tmax, 0.0);   glVertex2f(1.0, 0.0);
388        glTexCoord2f(_tmax, _tmax); glVertex2f(1.0, 1.0);
[2967]389        glTexCoord2f(0.0,   _tmax); glVertex2f(0.0, 1.0);
[1028]390    }
[2967]391    glEnd();
[851]392    glDisable(GL_TEXTURE_2D);
[2847]393
[1028]394    /*
395    //inject dye
396    glDisable(GL_TEXTURE_2D);
397    glColor4f(1.,0.8,0.,1.);
398    glBegin(GL_QUADS);
399    glVertex2d(0.6, 0.6);
400    glVertex2d(0.6, 0.62);
401    glVertex2d(0.62, 0.62);
402    glVertex2d(0.62, 0.6);
403    glEnd();
404    */
[2847]405
[1028]406    glDisable(GL_BLEND);
407    glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, NPIX, NPIX, 0);
[2847]408
[1028]409    /*
410    //blend magnitude texture
[2920]411    glBindTexture(GL_TEXTURE_2D, _magTex);
[1028]412    glEnable(GL_TEXTURE_2D);
413    glEnable(GL_BLEND);
414    glBegin(GL_QUADS);
415    glTexCoord2f(0.0,  0.0);  glVertex2f(0.0, 0.0);
416    glTexCoord2f(0.0,  1.0); glVertex2f(0.0, 1.);
417    glTexCoord2f(1.0, 1.0);  glVertex2f(1., 1.);
418    glTexCoord2f(1.0, 0.0); glVertex2f(1., 0.0);
419    glEnd();
420    */
[851]421
[2920]422    glMatrixMode(GL_PROJECTION);
[851]423    glPopMatrix();
424    glMatrixMode(GL_MODELVIEW);
[2920]425    glPopMatrix();
[587]426
[2920]427    glPopAttrib();
428
429    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig);
[2837]430}
[587]431
[1028]432void
[2920]433NvLIC::render()
[851]434{
[1515]435    if (_vectorFieldId == 0) {
[2920]436        return;
[1431]437    }
[1370]438
[2920]439    //draw line integral convolution quad
440
441    glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
442    glBindTexture(GL_TEXTURE_2D, _colorTex);
[1028]443    glEnable(GL_TEXTURE_2D);
[2920]444    //glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
445    //glEnable(GL_LIGHTING);
446    glDisable(GL_LIGHTING);
[1028]447    glEnable(GL_DEPTH_TEST);
[2847]448
[2920]449    glMatrixMode(GL_MODELVIEW);
[1028]450    glPushMatrix();
[2847]451
[2920]452    glTranslatef(_origin.x, _origin.y, _origin.z);
[2967]453    glScalef(_scale.x, _scale.y, _scale.z);
[2847]454
[2920]455    glColor4f(1, 1, 1, 1);
[1028]456    glBegin(GL_QUADS);
[2920]457    switch (_axis) {
[1311]458    case 0:
[2920]459        glNormal3f(1, 0, 0);
[2951]460        glTexCoord2f(0, 0); glVertex3f(_offset, 0, 0);
461        glTexCoord2f(1, 0); glVertex3f(_offset, 1, 0);
462        glTexCoord2f(1, 1); glVertex3f(_offset, 1, 1);
463        glTexCoord2f(0, 1); glVertex3f(_offset, 0, 1);
[2920]464        break;
[1311]465    case 1:
[2920]466        glNormal3f(0, 1, 0);
[2951]467        glTexCoord2f(0, 0); glVertex3f(0, _offset, 0);
468        glTexCoord2f(1, 0); glVertex3f(1, _offset, 0);
469        glTexCoord2f(1, 1); glVertex3f(1, _offset, 1);
470        glTexCoord2f(0, 1); glVertex3f(0, _offset, 1);
[2920]471        break;
[1311]472    case 2:
[2920]473        glNormal3f(0, 0, 1);
[2951]474        glTexCoord2f(0, 0); glVertex3f(0, 0, _offset);
475        glTexCoord2f(1, 0); glVertex3f(1, 0, _offset);
476        glTexCoord2f(1, 1); glVertex3f(1, 1, _offset);
477        glTexCoord2f(0, 1); glVertex3f(0, 1, _offset);
[2920]478        break;
[1028]479    }
480    glEnd();
[2847]481
[1028]482    glPopMatrix();
[2847]483
[2920]484    glBindTexture(GL_TEXTURE_2D, 0);
[2847]485
[2920]486    glPopAttrib();
[1028]487}
[851]488
[1028]489void
[2920]490NvLIC::setVectorField(unsigned int texID, const Vector3& origin,
491                      float scaleX, float scaleY, float scaleZ, float max)
[851]492{
[3452]493    TRACE("NvLIC: vector field is assigned [%d]", texID);
[1515]494    _vectorFieldId = texID;
[2920]495    _origin = origin;
496    _scale = Vector3(scaleX, scaleY, scaleZ);
497    _max = max;
[1370]498
[2920]499    makePatterns();
[2847]500
[2920]501    getSlice();
[851]502}
503
[1028]504void
[2920]505NvLIC::getVelocity(float x, float y, float *px, float *py)
[587]506{
[851]507   float vx, vy, r;
[587]508
[2920]509   int xi = (int)(x*_size);
510   int yi = (int)(y*_size);
[587]511
[1984]512    //TRACE("(xi yi) = (%d %d), ", xi, yi);
[2967]513   switch (_axis) {
514   case 0:
515       vx = _sliceVector[4 * (xi+yi*_size)+2];
516       vy = _sliceVector[4 * (xi+yi*_size)+1];
517       break;
518   case 1:
519       vx = _sliceVector[4 * (xi+yi*_size)];
520       vy = _sliceVector[4 * (xi+yi*_size)+2];
521       break;
522   case 2:
523   default:
524       vx = _sliceVector[4 * (xi+yi*_size)];
525       vy = _sliceVector[4 * (xi+yi*_size)+1];
526       break;
527   }
[587]528   r  = vx*vx + vy*vy;
[851]529
[1984]530    //TRACE("(vx vx) = (%f %f), r=%f, ", vx, vy, r);
[2920]531   if (r > (_dmax * _dmax)) {
[2847]532      r  = sqrt(r);
[2920]533      vx *= _dmax/r;
534      vy *= _dmax/r;
[587]535   }
[851]536
[2847]537   *px = x + vx;
[587]538   *py = y + vy;
[851]539
[3452]540    //TRACE("vel %f %f -> %f %f, (dmax = %f)", x, y, *px, *py, dmax);
[587]541}
542
[1028]543void
[2951]544NvLIC::setOffset(float offset)
[587]545{
[2951]546    _offset = offset;
[2920]547    getSlice();
[587]548}
[1311]549
[2920]550void NvLIC::setAxis(int axis)
[1311]551{
[2920]552    _axis = axis;
[1311]553}
554
[1370]555void NvLIC::reset()
556{
[2920]557    makePatterns();
[1370]558}
Note: See TracBrowser for help on using the repository browser.