/[libvob]/libvob/include/vob/LinearPrimitives.hxx
ViewVC logotype

Diff of /libvob/include/vob/LinearPrimitives.hxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by tjl, Mon Mar 10 18:15:53 2003 UTC revision 1.10 by tjl, Wed Mar 12 16:17:20 2003 UTC
# Line 54  namespace Primitives { Line 54  namespace Primitives {
54          void tr(const ZPt &from, ZPt &to) const {          void tr(const ZPt &from, ZPt &to) const {
55              to = from + vec;              to = from + vec;
56          }          }
57          void performGL() {          void performGL() const {
58              glTranslatef(vec.x, vec.y, vec.z);              glTranslatef(vec.x, vec.y, vec.z);
59          }          }
60          typedef TranslateXYZ InverseType;          typedef TranslateXYZ InverseType;
# Line 79  namespace Primitives { Line 79  namespace Primitives {
79          void tr(const ZPt &from, ZPt &to) const {          void tr(const ZPt &from, ZPt &to) const {
80              to = from * vec;              to = from * vec;
81          }          }
82          void performGL() {          void performGL() const {
83              glScalef(vec.x, vec.y, vec.z);              glScalef(vec.x, vec.y, vec.z);
84          }          }
85          typedef ScaleXYZ InverseType;          typedef ScaleXYZ InverseType;
# Line 171  namespace Primitives { Line 171  namespace Primitives {
171          void tr(const ZPt &from, ZPt &to) const {          void tr(const ZPt &from, ZPt &to) const {
172              to = from;              to = from;
173          }          }
174          void performGL() {          void performGL() const {
175          }          }
176          typedef Unit InverseType;          typedef Unit InverseType;
177          void inverse(InverseType &into) const { }          void inverse(InverseType &into) const { }
# Line 195  namespace Primitives { Line 195  namespace Primitives {
195          void tr(const ZPt &from, ZPt &to) const {          void tr(const ZPt &from, ZPt &to) const {
196              to = from;              to = from;
197          }          }
198          void performGL() {          void performGL() const {
199          }          }
200          Pt getSqSize() const { return box; }          Pt getSqSize() const { return box; }
201    
# Line 218  namespace Primitives { Line 218  namespace Primitives {
218      };      };
219      VOB_PRIMITIVETRANS_DEFINED(Box_Explicit, "box");      VOB_PRIMITIVETRANS_DEFINED(Box_Explicit, "box");
220    
221        struct RotateXYZ:
222                public PrimitiveTransform,
223                public GLPerformablePrimitiveTransform
224        {
225        public:
226            ZVec vec;
227            /** Angle, degs.
228             */
229            float a;
230            /** Sine and cosine of angle.
231             */
232            float s, c;
233    
234            void angleWasSet() {
235                s = sin(a * M_PI / 180);
236                c = cos(a * M_PI / 180);
237            }
238    
239            void tr(const ZPt &from, ZPt &to) const {
240                ZVec v(from);
241                float same = v.dot(vec);
242                ZVec para = v - same*vec;
243                float  paral = para.length();
244                para = (1/paral)*para;
245                ZVec ortho = para.crossp(vec).normalized();
246                to = ZPt( same * vec + paral * (c * para - s * ortho) );
247            }
248            virtual void performGL() const {
249                glRotatef(a, vec.x, vec.y, vec.z);
250            }
251            typedef RotateXYZ InverseType;
252            void inverse(InverseType &inv) const {
253                inv.vec = vec;
254                inv.a = -a;
255                inv.angleWasSet();
256            }
257        };
258    
259        struct RotateXYZ_Explicit :
260                public RotateXYZ,
261                public ParametrizedPrimitiveTransform
262        {
263            enum { NParams = 4 };
264            template<class Ptr> void setParams(Ptr p) {
265                vec.x = p[0];
266                vec.y = p[1];
267                vec.z = p[2];
268                vec = vec.normalized();
269                a = p[3];
270    
271                angleWasSet();
272            }
273        };
274        VOB_PRIMITIVETRANS_DEFINED(RotateXYZ_Explicit, "rotateXYZ");
275    
276      /** Affine coordinate system (in xy), offset in z.      /** Affine coordinate system (in xy), offset in z.
277       * Can't be used in HierarchicalTransform directly       * Can't be used in HierarchicalTransform directly
278       * because parameters are required.       * because parameters are required.
# Line 239  namespace Primitives { Line 294  namespace Primitives {
294              to.y += ydot.dot(from);              to.y += ydot.dot(from);
295              to.z += from.z;              to.z += from.z;
296          }          }
297          void performGL() {          void performGL() const {
298              GLfloat matrix[16] = {              GLfloat matrix[16] = {
299                  xdot.x, ydot.x, 0, 0,                  xdot.x, ydot.x, 0, 0,
300                  xdot.y, ydot.y, 0, 0,                  xdot.y, ydot.y, 0, 0,
# Line 307  namespace Primitives { Line 362  namespace Primitives {
362              to.y = y + from.y * sy;              to.y = y + from.y * sy;
363              to.z = z + from.z;              to.z = z + from.z;
364          }          }
365          void performGL() {          void performGL() const {
366              glTranslatef(x, y, z);              glTranslatef(x, y, z);
367              glScalef(sx, sy, 1);              glScalef(sx, sy, 1);
368          }          }
# Line 386  namespace Primitives { Line 441  namespace Primitives {
441    
442      VOB_PRIMITIVETRANS_DEFINED(UnitSqBox, "unitSqBox");      VOB_PRIMITIVETRANS_DEFINED(UnitSqBox, "unitSqBox");
443    
444    
445  }  }
446  }  }
447    

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26