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

Last change on this file since 1522 was 1493, checked in by gah, 15 years ago

Changed vector id to name

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