| 1 | /**************************************************************************** |
| 2 | * VCGLib o o * |
| 3 | * Visual and Computer Graphics Library o o * |
| 4 | * _ O _ * |
| 5 | * Copyright(C) 2004 \/)\/ * |
| 6 | * Visual Computing Lab /\/| * |
| 7 | * ISTI - Italian National Research Council | * |
| 8 | * \ * |
| 9 | * All rights reserved. * |
| 10 | * * |
| 11 | * This program is free software; you can redistribute it and/or modify * |
| 12 | * it under the terms of the GNU General Public License as published by * |
| 13 | * the Free Software Foundation; either version 2 of the License, or * |
| 14 | * (at your option) any later version. * |
| 15 | * * |
| 16 | * This program is distributed in the hope that it will be useful, * |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 19 | * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * |
| 20 | * for more details. * |
| 21 | * * |
| 22 | ****************************************************************************/ |
| 23 | /**************************************************************************** |
| 24 | History |
| 25 | |
| 26 | $Log: math.h,v $ |
| 27 | Revision 1.11 2006/10/09 19:56:09 cignoni |
| 28 | Removed the default use of the OpenGL transpose extension. Added two method for direct (non transposed) matrix multiplication and getting |
| 29 | |
| 30 | Revision 1.10 2006/02/13 13:05:05 cignoni |
| 31 | Removed glew inclusion |
| 32 | |
| 33 | Revision 1.9 2004/09/30 00:48:07 ponchio |
| 34 | <gl/glew.h> -> <GL/glew.h> |
| 35 | |
| 36 | Revision 1.8 2004/09/28 14:04:36 ganovelli |
| 37 | glGet added |
| 38 | |
| 39 | Revision 1.7 2004/07/13 15:55:57 cignoni |
| 40 | Added test on presence of glTranspose extension (for old hw support) |
| 41 | |
| 42 | Revision 1.6 2004/05/26 15:12:39 cignoni |
| 43 | Removed inclusion of gl extension stuff |
| 44 | |
| 45 | Revision 1.5 2004/05/12 20:54:55 ponchio |
| 46 | *** empty log message *** |
| 47 | |
| 48 | Revision 1.4 2004/05/12 13:07:47 ponchio |
| 49 | Added #include <glew.h> |
| 50 | |
| 51 | Revision 1.3 2004/05/04 23:36:23 cignoni |
| 52 | remove include of gl and added glextgension exploiting, |
| 53 | |
| 54 | Revision 1.2 2004/04/07 10:47:03 cignoni |
| 55 | inlined functions for avoid multiple linking errors |
| 56 | |
| 57 | Revision 1.1 2004/03/31 15:27:17 ponchio |
| 58 | *** empty log message *** |
| 59 | |
| 60 | |
| 61 | ****************************************************************************/ |
| 62 | |
| 63 | #ifndef VCG_GL_MATH_H |
| 64 | #define VCG_GL_MATH_Hcxx . . $ `vcg/wrap/gl/math.h:64:9`! |
| 65 | |
| 66 | // Please note that this file assume that you have already included your |
| 67 | // gl-extension wrapping utility, and that therefore all the extension symbol are already defined. |
| 68 | |
| 69 | #include <vcg/math/matrix44.h>cxx . . $ `<file>/vcg/vcg/math/matrix44.h`/ |
| 70 | #include <vcg/math/similarity.h>cxx . . $ `<file>/vcg/vcg/math/similarity.h`/ |
| 71 | //#include <GL/glew.h> // please do not include it! |
| 72 | |
| 73 | |
| 74 | namespace vcgcxx . . $ vcg/ { |
| 75 | |
| 76 | inline void glMultMatrixEcxx . . $ vcg/glMultMatrixE(d6fcb610a9d9294f).(const Matrix44fcxx . . $ vcg/Matrix44f# &matrix) { |
| 77 | //glMultMatrixf((const GLfloat *)(matrix[0])); |
| 78 | if(glMultTransposeMatrixfcxx . . $ `<external>/18396878532286971346/glew.h:1450:9`!) glMultTransposeMatrixfcxx . . $ `<external>/18396878532286971346/glew.h:1450:9`!((const GLfloat *)(matrix[cxx . . $ vcg/Matrix44#`operator[]`(a8bee47fb301c1de).0])); |
| 79 | else { |
| 80 | Matrix44fcxx . . $ vcg/Matrix44f# tmpcxx . . $ vcg/Matrix44#Matrix44(4a202868f936a31e).(matrix); |
| 81 | Transposecxx . . $ vcg/Transpose(24a89560d95dde74).(tmp); |
| 82 | glMultMatrixf((const GLfloat *)(tmp[cxx . . $ vcg/Matrix44#`operator[]`(72482124cd0e1400).0])); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | inline void glMultMatrixcxx . . $ vcg/glMultMatrix(d6fcb610a9d9294f).(const Matrix44fcxx . . $ vcg/Matrix44f# &matrix) { |
| 87 | Matrix44fcxx . . $ vcg/Matrix44f# tmpcxx . . $ vcg/Matrix44#Matrix44(4a202868f936a31e).(matrix); |
| 88 | Transposecxx . . $ vcg/Transpose(24a89560d95dde74).(tmp); |
| 89 | glMultMatrixf((const GLfloat *)(tmp[cxx . . $ vcg/Matrix44#`operator[]`(72482124cd0e1400).0])); |
| 90 | } |
| 91 | |
| 92 | inline void glMultMatrixEcxx . . $ vcg/glMultMatrixE(f2804d0e7630b327).(const Matrix44dcxx . . $ vcg/Matrix44d# &matrix) { |
| 93 | if(glMultTransposeMatrixdcxx . . $ `<external>/18396878532286971346/glew.h:1449:9`!) glMultTransposeMatrixdcxx . . $ `<external>/18396878532286971346/glew.h:1449:9`!((const GLdouble *)(matrix[cxx . . $ vcg/Matrix44#`operator[]`(a8bee47fb301c1de).0])); |
| 94 | else { |
| 95 | Matrix44dcxx . . $ vcg/Matrix44d# tmpcxx . . $ vcg/Matrix44#Matrix44(4a202868f936a31e).(matrix); |
| 96 | Transposecxx . . $ vcg/Transpose(24a89560d95dde74).(tmp); |
| 97 | glMultMatrixd((const GLdouble *)(tmp[cxx . . $ vcg/Matrix44#`operator[]`(72482124cd0e1400).0])); |
| 98 | } |
| 99 | } |
| 100 | inline void glMultMatrixcxx . . $ vcg/glMultMatrix(f2804d0e7630b327).(const Matrix44dcxx . . $ vcg/Matrix44d# &matrix) { |
| 101 | Matrix44dcxx . . $ vcg/Matrix44d# tmpcxx . . $ vcg/Matrix44#Matrix44(4a202868f936a31e).(matrix); |
| 102 | Transposecxx . . $ vcg/Transpose(24a89560d95dde74).(tmp); |
| 103 | glMultMatrixd((const GLdouble *)(tmp[cxx . . $ vcg/Matrix44#`operator[]`(72482124cd0e1400).0])); |
| 104 | } |
| 105 | |
| 106 | inline void glMultMatrixDirectcxx . . $ vcg/glMultMatrixDirect(d6fcb610a9d9294f).(const Matrix44fcxx . . $ vcg/Matrix44f# &matrix) { |
| 107 | glMultMatrixf((const GLfloat *)(matrix[cxx . . $ vcg/Matrix44#`operator[]`(a8bee47fb301c1de).0])); |
| 108 | } |
| 109 | |
| 110 | inline void glMultMatrixDirectcxx . . $ vcg/glMultMatrixDirect(f2804d0e7630b327).(const Matrix44dcxx . . $ vcg/Matrix44d# &matrix) { |
| 111 | glMultMatrixd((const GLdouble *)(matrix[cxx . . $ vcg/Matrix44#`operator[]`(a8bee47fb301c1de).0])); |
| 112 | } |
| 113 | |
| 114 | inline void glMultMatrixcxx . . $ vcg/glMultMatrix(878e1db0f3b7a82c).(const Similarityfcxx . . $ vcg/Similarityf# &s) { |
| 115 | glTranslatef(s.tracxx . . $ vcg/Similarity#tra.[cxx . . $ vcg/Point3#`operator[]`(e2681f9bb6b2f357).0], s.tracxx . . $ vcg/Similarity#tra.[cxx . . $ vcg/Point3#`operator[]`(e2681f9bb6b2f357).1], s.tracxx . . $ vcg/Similarity#tra.[cxx . . $ vcg/Point3#`operator[]`(e2681f9bb6b2f357).2]); |
| 116 | glScalef(s.scacxx . . $ vcg/Similarity#sca., s.scacxx . . $ vcg/Similarity#sca., s.scacxx . . $ vcg/Similarity#sca.); |
| 117 | float alpha; |
| 118 | Point3fcxx . . $ vcg/Point3f# axiscxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).; |
| 119 | s.rotcxx . . $ vcg/Similarity#rot..ToAxiscxx . . $ vcg/Quaternion#ToAxis(58dadbe07da77e7a).(alpha, axis); |
| 120 | glRotatef(mathcxx . . $ vcg/math/::ToDegcxx . . $ vcg/math/ToDeg(b9cd5987e7aec515).(alpha), axis[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).0], axis[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).1], axis[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).2]); |
| 121 | |
| 122 | } |
| 123 | |
| 124 | inline void glMultMatrixcxx . . $ vcg/glMultMatrix(93674a9c63b6404).(const Similaritydcxx . . $ vcg/Similarityd# &s) { |
| 125 | glTranslated(s.tracxx . . $ vcg/Similarity#tra.[cxx . . $ vcg/Point3#`operator[]`(e2681f9bb6b2f357).0], s.tracxx . . $ vcg/Similarity#tra.[cxx . . $ vcg/Point3#`operator[]`(e2681f9bb6b2f357).1], s.tracxx . . $ vcg/Similarity#tra.[cxx . . $ vcg/Point3#`operator[]`(e2681f9bb6b2f357).2]); |
| 126 | double alpha; |
| 127 | Point3dcxx . . $ vcg/Point3d# axiscxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).; |
| 128 | s.rotcxx . . $ vcg/Similarity#rot..ToAxiscxx . . $ vcg/Quaternion#ToAxis(58dadbe07da77e7a).(alpha, axis); |
| 129 | glRotated(mathcxx . . $ vcg/math/::ToDegcxx . . $ vcg/math/ToDeg(569b37c916856981).(alpha), axis[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).0], axis[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).1], axis[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).2]); |
| 130 | glScaled(s.scacxx . . $ vcg/Similarity#sca., s.scacxx . . $ vcg/Similarity#sca., s.scacxx . . $ vcg/Similarity#sca.); |
| 131 | } |
| 132 | |
| 133 | inline void glGetvcxx . . $ vcg/glGetv(56eefd26a777774).(const GLenum pname, Matrix44fcxx . . $ vcg/Matrix44f# & m){ |
| 134 | glGetFloatv(pname,&m[cxx . . $ vcg/Matrix44#`operator[]`(72482124cd0e1400).0][0]); |
| 135 | Transposecxx . . $ vcg/Transpose(24a89560d95dde74).(m); |
| 136 | } |
| 137 | |
| 138 | inline void glGetvcxx . . $ vcg/glGetv(dae5f9b1e1c6bf85).(const GLenum pname, Matrix44dcxx . . $ vcg/Matrix44d# & m){ |
| 139 | glGetDoublev(pname,&m[cxx . . $ vcg/Matrix44#`operator[]`(72482124cd0e1400).0][0]); |
| 140 | Transposecxx . . $ vcg/Transpose(24a89560d95dde74).(m); |
| 141 | } |
| 142 | |
| 143 | inline void glGetDirectvcxx . . $ vcg/glGetDirectv(56eefd26a777774).(const GLenum pname, Matrix44fcxx . . $ vcg/Matrix44f# & m){ |
| 144 | glGetFloatv(pname,&m[cxx . . $ vcg/Matrix44#`operator[]`(72482124cd0e1400).0][0]); |
| 145 | } |
| 146 | |
| 147 | inline void glGetDirecvcxx . . $ vcg/glGetDirecv(dae5f9b1e1c6bf85).(const GLenum pname, Matrix44dcxx . . $ vcg/Matrix44d# & m){ |
| 148 | glGetDoublev(pname,&m[cxx . . $ vcg/Matrix44#`operator[]`(72482124cd0e1400).0][0]); |
| 149 | } |
| 150 | |
| 151 | |
| 152 | }//namespace |
| 153 | #endif |