source: trunk/packages/vizservers/nanovis/VelocityArrowsSlice.h @ 2798

Last change on this file since 2798 was 2798, checked in by ldelgass, 12 years ago

Add emacs mode magic line in preparation for indentation cleanup

  • Property svn:eol-style set to native
File size: 3.6 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2#ifndef VELOCITY_ARROW_SLICE_H
3#define VELOCITY_ARROW_SLICE_H 1
4
5#include <Cg/cg.h>
6#include <Cg/cgGL.h>
7#include <vector>
8
9#define USE_NANOVIS_LIB
10
11#ifdef USE_NANOVIS_LIB
12#include "Texture2D.h"
13#include "Vector3.h"
14#else
15#include <vr3d/vrTexture2D.h>
16
17typedef vrTexture2D Texture2D;
18
19class Vector3 {
20public :
21        float x, y, z;
22        Vector3() : x(0.0f), y(0.0f), z(0.0f) {}
23        Vector3(float x1, float y1, float z1) : x(x1), y(y1), z(z1) {}
24        Vector3 operator*(float scale)
25        {
26                Vector3 vec;
27                vec.x = x * scale;
28                vec.y = y * scale;
29                vec.z = z * scale;
30                return vec;
31        }
32    Vector3 scale(const Vector3& scale)
33    {
34        Vector3 vec;
35        vec.x = x * scale.x;
36        vec.y = y * scale.y;
37        vec.z = z * scale.z;
38            return vec;
39    }
40
41        Vector3 operator*(const Vector3& scale)
42        {
43                Vector3 vec;
44                vec.x = x * scale.x;
45                vec.y = y * scale.y;
46                vec.z = z * scale.z;
47                return vec;
48
49        }
50        friend Vector3 operator+(const Vector3& value1, const Vector3& value2);
51
52    void set(float x1, float y1, float z1)
53    {
54        x = x1; y = y1; z = z1;
55    }
56};
57
58inline Vector3 operator+(const Vector3& value1, const Vector3& value2)
59{
60        return Vector3(value1.x + value2.x, value1.y + value2.y, value1.z + value2.z);
61}
62
63#endif
64
65
66class VelocityArrowsSlice {
67public :
68        enum RenderMode {
69                LINES,
70                GLYPHES,
71        };
72private :
73        unsigned int _vectorFieldGraphicsID;
74        float _vfXscale;
75        float _vfYscale;
76        float _vfZscale;
77        float _slicePos;
78        int _axis;
79       
80        unsigned int _fbo;     
81    unsigned int _tex;
82       
83        CGcontext _context;
84        CGprogram _queryVelocityFP;
85        CGparameter _qvVectorFieldParam;
86
87        int _renderTargetWidth;
88        int _renderTargetHeight;
89        Vector3* _velocities;
90        std::vector<Vector3> _samplingPositions;
91        Vector3 _projectionVector;
92
93        int _tickCountForMinSizeAxis;
94        int _tickCountX;
95        int _tickCountY;
96        int _tickCountZ;
97       
98        int _pointCount;
99
100        Vector3 _maxVelocityScale;
101        Vector3 _arrowColor;
102
103        bool _enabled; 
104        bool _dirty;
105        bool _dirtySamplingPosition;
106        bool _dirtyRenderTarget;
107
108        unsigned int _vertexBufferGraphicsID;
109
110        CGprogram _particleVP;
111        CGparameter _mvpParticleParam;
112        CGparameter _mvParticleParam;
113        CGparameter _mvTanHalfFOVParam;
114        CGparameter _mvCurrentTimeParam;
115       
116        CGprogram _particleFP;
117        CGparameter _vectorParticleParam;
118
119        Texture2D* _arrowsTex;
120
121        RenderMode _renderMode;
122private :
123        void createRenderTarget();
124        void computeSamplingTicks();
125public :
126        VelocityArrowsSlice();
127        ~VelocityArrowsSlice();
128
129        void vectorField(unsigned int vfGraphicsID, float xScale, float yScale, float zScale);
130        void axis(int axis);
131        int axis() const;
132        void slicePos(float pos);
133        float slicePos() const;
134        void queryVelocity();
135        void render();
136    void enabled(bool enabled) {
137        _enabled = enabled;
138    }
139    bool enabled(void) const {
140        return _enabled;
141    }
142    void tickCountForMinSizeAxis(int tickCount);
143    int tickCountForMinSizeAxis() const;
144    void arrowColor(const Vector3& color);
145    void renderMode(RenderMode mode);
146    RenderMode renderMode() const;
147};
148
149inline int VelocityArrowsSlice::axis() const
150{
151        return _axis;
152}
153
154inline float VelocityArrowsSlice::slicePos() const
155{
156        return _slicePos;
157}
158
159
160inline int VelocityArrowsSlice::tickCountForMinSizeAxis() const
161{
162        return _tickCountForMinSizeAxis;
163}
164
165inline void VelocityArrowsSlice::arrowColor(const Vector3& color)
166{
167    _arrowColor = color;
168}
169
170inline void VelocityArrowsSlice::renderMode(VelocityArrowsSlice::RenderMode mode)
171{
172        _renderMode = mode;
173        _dirty = true;
174}
175
176inline VelocityArrowsSlice::RenderMode VelocityArrowsSlice::renderMode() const
177{
178        return _renderMode;
179}
180 
181#endif /* VELOCITY_ARROW_SLICE_H */
Note: See TracBrowser for help on using the repository browser.