| 1 | /* |
| 2 | * |
| 3 | * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * Further, this software is distributed without any warranty that it is |
| 16 | * free of the rightful claim of any third person regarding infringement |
| 17 | * or the like. Any license provided herein, whether implied or |
| 18 | * otherwise, applies only to this software file. Patent licenses, if |
| 19 | * any, provided herein do not apply to combinations of this program with |
| 20 | * other software, or any other product whatsoever. |
| 21 | * |
| 22 | * You should have received a copy of the GNU Lesser General Public |
| 23 | * License along with this library; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | * |
| 26 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 27 | * Mountain View, CA 94043, or: |
| 28 | * |
| 29 | * http://www.sgi.com |
| 30 | * |
| 31 | * For further information regarding this notice, see: |
| 32 | * |
| 33 | * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 34 | * |
| 35 | */ |
| 36 | |
| 37 | #include "../SoAddPrefix.h"cxx . . $ `<file>/lib/database/src/so/nodes/nurbs/SoAddPrefix.h`/ |
| 38 | #include "mymath.h"cxx . . $ `<file>/lib/database/src/so/nodes/nurbs/head/mymath.h`/ |
| 39 | #include "mystdlib.h"cxx . . $ `<file>/lib/database/src/so/nodes/nurbs/head/mystdlib.h`/ |
| 40 | #include "gl4base.h"cxx . . $ `<file>/lib/database/src/so/nodes/nurbs/clients/gl4base.h`/ |
| 41 | |
| 42 | _SoNurbsGL4Basecxx . . $ _SoNurbsGL4Base#::_SoNurbsGL4Basecxx . . $ _SoNurbsGL4Base#_SoNurbsGL4Base(f514e69759288748).( |
| 43 | _SoNurbsBasicCurveEvaluatorcxx . . $ _SoNurbsBasicCurveEvaluator#& curveEvaluator, |
| 44 | _SoNurbsBasicSurfaceEvaluatorcxx . . $ _SoNurbsBasicSurfaceEvaluator#& surfaceEvaluator ) |
| 45 | : _SoNurbsNurbsTessellatorcxx . . $ _SoNurbsNurbsTessellator#_SoNurbsNurbsTessellator(f514e69759288748).( curveEvaluator, surfaceEvaluator ) |
| 46 | { |
| 47 | redefineMapscxx . . $ _SoNurbsNurbsTessellator#redefineMaps(49f6e7a06ebc5aa8).(); |
| 48 | defineMapcxx . . $ _SoNurbsNurbsTessellator#defineMap(1accef8d191cd3cf).( N_C4Dcxx . . $ `lib/database/src/so/nodes/nurbs/clients/gl4types.h:45:9`!, 0, 4 ); |
| 49 | defineMapcxx . . $ _SoNurbsNurbsTessellator#defineMap(1accef8d191cd3cf).( N_C4DRcxx . . $ `lib/database/src/so/nodes/nurbs/clients/gl4types.h:46:9`!, 1, 5 ); |
| 50 | defineMapcxx . . $ _SoNurbsNurbsTessellator#defineMap(1accef8d191cd3cf).( N_T2Dcxx . . $ `lib/database/src/so/nodes/nurbs/clients/gl4types.h:43:9`!, 0, 2 ); |
| 51 | defineMapcxx . . $ _SoNurbsNurbsTessellator#defineMap(1accef8d191cd3cf).( N_T2DRcxx . . $ `lib/database/src/so/nodes/nurbs/clients/gl4types.h:44:9`!, 1, 3 ); |
| 52 | defineMapcxx . . $ _SoNurbsNurbsTessellator#defineMap(1accef8d191cd3cf).( N_V3Dcxx . . $ `lib/database/src/so/nodes/nurbs/clients/gl4types.h:41:9`!, 0, 3 ); |
| 53 | defineMapcxx . . $ _SoNurbsNurbsTessellator#defineMap(1accef8d191cd3cf).( N_V3DRcxx . . $ `lib/database/src/so/nodes/nurbs/clients/gl4types.h:42:9`!, 1, 4 ); |
| 54 | |
| 55 | makingGLobjcxx . . $ _SoNurbsGL4Base#makingGLobj. = 0; |
| 56 | needMatricescxx . . $ _SoNurbsGL4Base#needMatrices. = 0; |
| 57 | } |
| 58 | |
| 59 | void |
| 60 | _SoNurbsGL4Basecxx . . $ _SoNurbsGL4Base#::makeGLobjcxx . . $ _SoNurbsGL4Base#makeGLobj(d4f767463ce0a6b3).( int n ) |
| 61 | { |
| 62 | makingGLobjcxx . . $ _SoNurbsGL4Base#makingGLobj. = 1; |
| 63 | objnumcxx . . $ _SoNurbsGL4Base#objnum. = n; |
| 64 | } |
| 65 | |
| 66 | void |
| 67 | _SoNurbsGL4Basecxx . . $ _SoNurbsGL4Base#::gl4samplingmodecxx . . $ _SoNurbsGL4Base#gl4samplingmode(49f6e7a06ebc5aa8).( void ) |
| 68 | { |
| 69 | needMatricescxx . . $ _SoNurbsGL4Base#needMatrices. = 1; |
| 70 | } |
| 71 | |
| 72 | void |
| 73 | _SoNurbsGL4Basecxx . . $ _SoNurbsGL4Base#::bgnrendercxx . . $ _SoNurbsGL4Base#bgnrender(49f6e7a06ebc5aa8).( void ) |
| 74 | { |
| 75 | if( needMatricescxx . . $ _SoNurbsGL4Base#needMatrices. ) loadGLMatricescxx . . $ _SoNurbsGL4Base#loadGLMatrices(49f6e7a06ebc5aa8).(); |
| 76 | // if( makingGLobj ) { |
| 77 | // if( ::isobj( objnum ) ) ::delobj( objnum ); |
| 78 | // ::makeobj( objnum ); |
| 79 | // } |
| 80 | } |
| 81 | |
| 82 | void |
| 83 | _SoNurbsGL4Basecxx . . $ _SoNurbsGL4Base#::endrendercxx . . $ _SoNurbsGL4Base#endrender(49f6e7a06ebc5aa8).( void ) |
| 84 | { |
| 85 | // if( makingGLobj ) |
| 86 | // ::closeobj( ); |
| 87 | } |
| 88 | |
| 89 | void |
| 90 | _SoNurbsGL4Basecxx . . $ _SoNurbsGL4Base#::loadGLMatricescxx . . $ _SoNurbsGL4Base#loadGLMatrices(49f6e7a06ebc5aa8).( void ) |
| 91 | { |
| 92 | float vmat[4][4]; |
| 93 | grabGLMatrixcxx . . $ _SoNurbsGL4Base#grabGLMatrix(9fb3ef344050b01e).( vmat ); |
| 94 | loadCullingMatrixcxx . . $ _SoNurbsGL4Base#loadCullingMatrix(9fb3ef344050b01e).( vmat ); |
| 95 | loadSamplingMatrixcxx . . $ _SoNurbsGL4Base#loadSamplingMatrix(9fb3ef344050b01e).( vmat ); |
| 96 | } |
| 97 | |
| 98 | void |
| 99 | _SoNurbsGL4Basecxx . . $ _SoNurbsGL4Base#::errorHandlercxx . . $ _SoNurbsGL4Base#errorHandler(d4f767463ce0a6b3).( int ) |
| 100 | { |
| 101 | // ::fprintf( stderr, "Error: %s\n", nurbserror[msg] ); |
| 102 | } |
| 103 | |
| 104 | /*-------------------------------------------------------------------------- |
| 105 | * grabGLMatrix |
| 106 | *-------------------------------------------------------------------------- |
| 107 | */ |
| 108 | |
| 109 | void |
| 110 | _SoNurbsGL4Basecxx . . $ _SoNurbsGL4Base#::grabGLMatrixcxx . . $ _SoNurbsGL4Base#grabGLMatrix(9fb3ef344050b01e).( float [4][4] ) |
| 111 | { |
| 112 | // long matmmode = getmmode(); |
| 113 | // if( matmmode != MSINGLE ) { |
| 114 | // ::mmode( MVIEWING ); |
| 115 | // float nmat[4][4]; |
| 116 | // ::getmatrix( nmat ); /* get viewing matrix */ |
| 117 | // ::mmode( MPROJECTION ); |
| 118 | // float pmat[4][4]; |
| 119 | // ::getmatrix( pmat ); /* get projection matrix */ |
| 120 | // multmatrix4d( vmat, nmat, pmat ); |
| 121 | // } else { |
| 122 | // ::getmatrix( vmat ); /* get combined matrix */ |
| 123 | // } |
| 124 | // ::mmode( (short) matmmode ); |
| 125 | } |
| 126 | |
| 127 | void |
| 128 | _SoNurbsGL4Basecxx . . $ _SoNurbsGL4Base#::loadSamplingMatrixcxx . . $ _SoNurbsGL4Base#loadSamplingMatrix(9fb3ef344050b01e).( float [4][4] ) |
| 129 | { |
| 130 | // short llx, urx, lly, ury; |
| 131 | // ::getviewport( &llx, &urx, &lly, &ury ); |
| 132 | |
| 133 | /* rescale the mapping to correspond to pixels in x/y */ |
| 134 | /* |
| 135 | REAL xsize = 0.5 * (REAL) (urx - llx); |
| 136 | REAL ysize = 0.5 * (REAL) (ury - lly); |
| 137 | |
| 138 | INREAL smat[4][4]; |
| 139 | smat[0][0] = vmat[0][0] * xsize; |
| 140 | smat[1][0] = vmat[1][0] * xsize; |
| 141 | smat[2][0] = vmat[2][0] * xsize; |
| 142 | smat[3][0] = vmat[3][0] * xsize; |
| 143 | |
| 144 | smat[0][1] = vmat[0][1] * ysize; |
| 145 | smat[1][1] = vmat[1][1] * ysize; |
| 146 | smat[2][1] = vmat[2][1] * ysize; |
| 147 | smat[3][1] = vmat[3][1] * ysize; |
| 148 | |
| 149 | smat[0][2] = 0.0; |
| 150 | smat[1][2] = 0.0; |
| 151 | smat[2][2] = 0.0; |
| 152 | smat[3][2] = 0.0; |
| 153 | |
| 154 | smat[0][3] = vmat[0][3]; |
| 155 | smat[1][3] = vmat[1][3]; |
| 156 | smat[2][3] = vmat[2][3]; |
| 157 | smat[3][3] = vmat[3][3]; |
| 158 | |
| 159 | const long rstride = sizeof( smat[0]) / sizeof(smat[0][0]); |
| 160 | const long cstride = 1; |
| 161 | |
| 162 | setnurbsproperty( N_V3D, N_SAMPLINGMATRIX, &smat[0][0], rstride, cstride ); |
| 163 | setnurbsproperty( N_V3DR, N_SAMPLINGMATRIX, &smat[0][0], rstride, cstride ); |
| 164 | */ |
| 165 | } |
| 166 | |
| 167 | void |
| 168 | _SoNurbsGL4Basecxx . . $ _SoNurbsGL4Base#::loadCullingMatrixcxx . . $ _SoNurbsGL4Base#loadCullingMatrix(9fb3ef344050b01e).( float vmat[4][4] ) |
| 169 | { |
| 170 | INREALcxx . . $ `lib/database/src/so/nodes/nurbs/head/types.h:46:9`! cmat[4][4]; |
| 171 | |
| 172 | cmat[0][0] = vmat[0][0]; |
| 173 | cmat[0][1] = vmat[0][1]; |
| 174 | cmat[0][2] = vmat[0][2]; |
| 175 | cmat[0][3] = vmat[0][3]; |
| 176 | |
| 177 | cmat[1][0] = vmat[1][0]; |
| 178 | cmat[1][1] = vmat[1][1]; |
| 179 | cmat[1][2] = vmat[1][2]; |
| 180 | cmat[1][3] = vmat[1][3]; |
| 181 | |
| 182 | cmat[2][0] = vmat[2][0]; |
| 183 | cmat[2][1] = vmat[2][1]; |
| 184 | cmat[2][2] = vmat[2][2]; |
| 185 | cmat[2][3] = vmat[2][3]; |
| 186 | |
| 187 | cmat[3][0] = vmat[3][0]; |
| 188 | cmat[3][1] = vmat[3][1]; |
| 189 | cmat[3][2] = vmat[3][2]; |
| 190 | cmat[3][3] = vmat[3][3]; |
| 191 | |
| 192 | // const long rstride = sizeof( cmat[0]) / sizeof(cmat[0][0]); |
| 193 | // const long cstride = 1; |
| 194 | |
| 195 | // setnurbsproperty( N_V3D, N_CULLINGMATRIX, &cmat[0][0], rstride, cstride ); |
| 196 | // setnurbsproperty( N_V3DR, N_CULLINGMATRIX, &cmat[0][0], rstride, cstride ); |
| 197 | } |
| 198 | |
| 199 | /*--------------------------------------------------------------------- |
| 200 | * A = B * MAT ; transform a 4d vector through a 4x4 matrix |
| 201 | *--------------------------------------------------------------------- |
| 202 | */ |
| 203 | void |
| 204 | _SoNurbsGL4Basecxx . . $ _SoNurbsGL4Base#::transform4dcxx . . $ _SoNurbsGL4Base#transform4d(f8d5765aeee8bc35).( float A[4], float B[4], float mat[4][4] ) |
| 205 | { |
| 206 | |
| 207 | A[0] = B[0]*mat[0][0] + B[1]*mat[1][0] + B[2]*mat[2][0] + B[3]*mat[3][0]; |
| 208 | A[1] = B[0]*mat[0][1] + B[1]*mat[1][1] + B[2]*mat[2][1] + B[3]*mat[3][1]; |
| 209 | A[2] = B[0]*mat[0][2] + B[1]*mat[1][2] + B[2]*mat[2][2] + B[3]*mat[3][2]; |
| 210 | A[3] = B[0]*mat[0][3] + B[1]*mat[1][3] + B[2]*mat[2][3] + B[3]*mat[3][3]; |
| 211 | } |
| 212 | |
| 213 | /*--------------------------------------------------------------------- |
| 214 | * new = [left][right] ; multiply two matrices together |
| 215 | *--------------------------------------------------------------------- |
| 216 | */ |
| 217 | void |
| 218 | _SoNurbsGL4Basecxx . . $ _SoNurbsGL4Base#::multmatrix4dcxx . . $ _SoNurbsGL4Base#multmatrix4d(893694c8b8ecb2b3). ( float n[4][4], float left[4][4], float right[4][4] ) |
| 219 | { |
| 220 | transform4dcxx . . $ _SoNurbsGL4Base#transform4d(f8d5765aeee8bc35). (n[0],left[0],right); |
| 221 | transform4dcxx . . $ _SoNurbsGL4Base#transform4d(f8d5765aeee8bc35). (n[1],left[1],right); |
| 222 | transform4dcxx . . $ _SoNurbsGL4Base#transform4d(f8d5765aeee8bc35). (n[2],left[2],right); |
| 223 | transform4dcxx . . $ _SoNurbsGL4Base#transform4d(f8d5765aeee8bc35). (n[3],left[3],right); |
| 224 | } |
| 225 | |
| 226 |