| 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 <Inventor/SoPrimitiveVertex.h>cxx . . $ `<file>/lib/database/include/Inventor/SoPrimitiveVertex.h`/ |
| 38 | #include <Inventor/actions/SoCallbackAction.h>cxx . . $ `<file>/lib/database/include/Inventor/actions/SoCallbackAction.h`/ |
| 39 | #include <Inventor/nodes/SoCoordinate3.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoCoordinate3.h`/ |
| 40 | #include <Inventor/nodes/SoIndexedShape.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoIndexedShape.h`/ |
| 41 | #include <Inventor/nodes/SoMaterialBinding.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoMaterialBinding.h`/ |
| 42 | #include <Inventor/nodes/SoNormal.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoNormal.h`/ |
| 43 | #include <Inventor/nodes/SoNormalBinding.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoNormalBinding.h`/ |
| 44 | #include <Inventor/nodes/SoShape.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoShape.h`/ |
| 45 | #include <Inventor/nodes/SoTextureCoordinate2.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoTextureCoordinate2.h`/ |
| 46 | #include <Inventor/nodes/SoTextureCoordinateBinding.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoTextureCoordinateBinding.h`/ |
| 47 | |
| 48 | #include "IfFlattener.h"cxx . . $ `<file>/apps/tools/ivfix/IfFlattener.h`/ |
| 49 | #include "IfHolder.h"cxx . . $ `<file>/apps/tools/ivfix/IfHolder.h`/ |
| 50 | |
| 51 | ///////////////////////////////////////////////////////////////////////////// |
| 52 | // |
| 53 | // Constructor. Initializes data structures. |
| 54 | // |
| 55 | ///////////////////////////////////////////////////////////////////////////// |
| 56 | |
| 57 | IfFlattenercxx . . $ IfFlattener#::IfFlattenercxx . . $ IfFlattener#IfFlattener(49f6e7a06ebc5aa8).() |
| 58 | { |
| 59 | holdercxx . . $ IfFlattener#holder. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 60 | |
| 61 | numVertscxx . . $ IfFlattener#numVerts. = 0; |
| 62 | numMtlIndicescxx . . $ IfFlattener#numMtlIndices. = 0; |
| 63 | } |
| 64 | |
| 65 | ///////////////////////////////////////////////////////////////////////////// |
| 66 | // |
| 67 | // Destructor. |
| 68 | // |
| 69 | ///////////////////////////////////////////////////////////////////////////// |
| 70 | |
| 71 | IfFlattenercxx . . $ IfFlattener#::~cxx . . $ IfFlattener#`~IfFlattener`(49f6e7a06ebc5aa8).IfFlattenercxx . . $ IfFlattener#() |
| 72 | { |
| 73 | } |
| 74 | |
| 75 | ///////////////////////////////////////////////////////////////////////////// |
| 76 | // |
| 77 | // This function assumes that everything under the given root can be |
| 78 | // treated as a big bag o' triangles. It will store coordinates, |
| 79 | // normals, texture coordinates, and material indices for these |
| 80 | // triangles in the IfHolder's nodes. |
| 81 | // |
| 82 | ///////////////////////////////////////////////////////////////////////////// |
| 83 | |
| 84 | void |
| 85 | IfFlattenercxx . . $ IfFlattener#::flattencxx . . $ IfFlattener#flatten(405e200fcf6cafee).(IfHoldercxx . . $ IfHolder# *_holder) |
| 86 | { |
| 87 | holdercxx . . $ IfFlattener#holder. = _holder; |
| 88 | |
| 89 | // Assume that we will find lots of triangles. We'll clean up |
| 90 | // later if there are fewer. Fields will start out with this many |
| 91 | // entries. We double this size whenever we run out of space. When |
| 92 | // we're done, we shrink the fields down to the amount used. |
| 93 | coordValscxx . . $ IfFlattener#coordVals. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 94 | normalValscxx . . $ IfFlattener#normalVals. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 95 | texCoordValscxx . . $ IfFlattener#texCoordVals. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 96 | mtlIndexValscxx . . $ IfFlattener#mtlIndexVals. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 97 | fieldSizecxx . . $ IfFlattener#fieldSize. = 20000; |
| 98 | expandFieldscxx . . $ IfFlattener#expandFields(49f6e7a06ebc5aa8).(); |
| 99 | |
| 100 | // We'll apply a callback action to produce triangles from all shapes |
| 101 | SoCallbackActioncxx . . $ SoCallbackAction# cbacxx . . $ SoCallbackAction#SoCallbackAction(49f6e7a06ebc5aa8).; |
| 102 | |
| 103 | // Set up a callback to call before and after shape is traversed |
| 104 | cba.addPreCallbackcxx . . $ SoCallbackAction#addPreCallback(1d0ccca0114e1b6f).(SoShapecxx . . $ SoShape#::getClassTypeIdcxx . . $ SoShape#getClassTypeId(c00c150378d2b968).(), preShapeCBcxx . . $ IfFlattener#preShapeCB(6eea413111466577)., this); |
| 105 | cba.addPostCallbackcxx . . $ SoCallbackAction#addPostCallback(1d0ccca0114e1b6f).(SoShapecxx . . $ SoShape#::getClassTypeIdcxx . . $ SoShape#getClassTypeId(c00c150378d2b968).(), postShapeCBcxx . . $ IfFlattener#postShapeCB(6eea413111466577)., this); |
| 106 | |
| 107 | // Set up a callback to call when a shape is traversed |
| 108 | cba.addTriangleCallbackcxx . . $ SoCallbackAction#addTriangleCallback(7698ee1e5e3e2f0d).(SoShapecxx . . $ SoShape#::getClassTypeIdcxx . . $ SoShape#getClassTypeId(c00c150378d2b968).(), triangleCBcxx . . $ IfFlattener#triangleCB(b8d71376c8e60307)., this); |
| 109 | |
| 110 | // Traverse the graph, adding to the data structures |
| 111 | cba.applycxx . . $ SoAction#apply(da6c7544ccee32bd).(holdercxx . . $ IfFlattener#holder.->origRootcxx . . $ IfHolder#origRoot.); |
| 112 | |
| 113 | // Finish editing |
| 114 | holdercxx . . $ IfFlattener#holder.->coordscxx . . $ IfHolder#coords.->pointcxx . . $ SoCoordinate3#point..finishEditingcxx . . $ SoMFVec3f#finishEditing(49f6e7a06ebc5aa8).(); |
| 115 | holdercxx . . $ IfFlattener#holder.->triSetcxx . . $ IfHolder#triSet.->materialIndexcxx . . $ SoIndexedShape#materialIndex..finishEditingcxx . . $ SoMFInt32#finishEditing(49f6e7a06ebc5aa8).(); |
| 116 | if (holdercxx . . $ IfFlattener#holder.->doNormalscxx . . $ IfHolder#doNormals.) |
| 117 | holdercxx . . $ IfFlattener#holder.->normalscxx . . $ IfHolder#normals.->vectorcxx . . $ SoNormal#vector..finishEditingcxx . . $ SoMFVec3f#finishEditing(49f6e7a06ebc5aa8).(); |
| 118 | if (holdercxx . . $ IfFlattener#holder.->doTexCoordscxx . . $ IfHolder#doTexCoords.) |
| 119 | holdercxx . . $ IfFlattener#holder.->texCoordscxx . . $ IfHolder#texCoords.->pointcxx . . $ SoTextureCoordinate2#point..finishEditingcxx . . $ SoMFVec2f#finishEditing(49f6e7a06ebc5aa8).(); |
| 120 | |
| 121 | // Process the resulting structures to produce a graph |
| 122 | createGraphcxx . . $ IfFlattener#createGraph(49f6e7a06ebc5aa8).(); |
| 123 | } |
| 124 | |
| 125 | ///////////////////////////////////////////////////////////////////////////// |
| 126 | // |
| 127 | // Expands the fields in the nodes to contain fieldSize entries. |
| 128 | // |
| 129 | ///////////////////////////////////////////////////////////////////////////// |
| 130 | |
| 131 | void |
| 132 | IfFlattenercxx . . $ IfFlattener#::expandFieldscxx . . $ IfFlattener#expandFields(49f6e7a06ebc5aa8).() |
| 133 | { |
| 134 | // If already editing the fields, stop! |
| 135 | if (coordValscxx . . $ IfFlattener#coordVals. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 136 | holdercxx . . $ IfFlattener#holder.->coordscxx . . $ IfHolder#coords.->pointcxx . . $ SoCoordinate3#point..finishEditingcxx . . $ SoMFVec3f#finishEditing(49f6e7a06ebc5aa8).(); |
| 137 | holdercxx . . $ IfFlattener#holder.->triSetcxx . . $ IfHolder#triSet.->materialIndexcxx . . $ SoIndexedShape#materialIndex..finishEditingcxx . . $ SoMFInt32#finishEditing(49f6e7a06ebc5aa8).(); |
| 138 | if (holdercxx . . $ IfFlattener#holder.->doNormalscxx . . $ IfHolder#doNormals.) |
| 139 | holdercxx . . $ IfFlattener#holder.->normalscxx . . $ IfHolder#normals.->vectorcxx . . $ SoNormal#vector..finishEditingcxx . . $ SoMFVec3f#finishEditing(49f6e7a06ebc5aa8).(); |
| 140 | if (holdercxx . . $ IfFlattener#holder.->doTexCoordscxx . . $ IfHolder#doTexCoords.) |
| 141 | holdercxx . . $ IfFlattener#holder.->texCoordscxx . . $ IfHolder#texCoords.->pointcxx . . $ SoTextureCoordinate2#point..finishEditingcxx . . $ SoMFVec2f#finishEditing(49f6e7a06ebc5aa8).(); |
| 142 | } |
| 143 | |
| 144 | // Increase the size |
| 145 | holdercxx . . $ IfFlattener#holder.->coordscxx . . $ IfHolder#coords.->pointcxx . . $ SoCoordinate3#point..setNumcxx . . $ SoMField#setNum(d4f767463ce0a6b3).(fieldSizecxx . . $ IfFlattener#fieldSize.); |
| 146 | if (holdercxx . . $ IfFlattener#holder.->doNormalscxx . . $ IfHolder#doNormals.) |
| 147 | holdercxx . . $ IfFlattener#holder.->normalscxx . . $ IfHolder#normals.->vectorcxx . . $ SoNormal#vector..setNumcxx . . $ SoMField#setNum(d4f767463ce0a6b3).(fieldSizecxx . . $ IfFlattener#fieldSize.); |
| 148 | if (holdercxx . . $ IfFlattener#holder.->doTexCoordscxx . . $ IfHolder#doTexCoords.) |
| 149 | holdercxx . . $ IfFlattener#holder.->texCoordscxx . . $ IfHolder#texCoords.->pointcxx . . $ SoTextureCoordinate2#point..setNumcxx . . $ SoMField#setNum(d4f767463ce0a6b3).(fieldSizecxx . . $ IfFlattener#fieldSize.); |
| 150 | holdercxx . . $ IfFlattener#holder.->triSetcxx . . $ IfHolder#triSet.->coordIndexcxx . . $ SoIndexedShape#coordIndex..setNumcxx . . $ SoMField#setNum(d4f767463ce0a6b3).(fieldSizecxx . . $ IfFlattener#fieldSize.); |
| 151 | holdercxx . . $ IfFlattener#holder.->triSetcxx . . $ IfHolder#triSet.->materialIndexcxx . . $ SoIndexedShape#materialIndex..setNumcxx . . $ SoMField#setNum(d4f767463ce0a6b3).(fieldSizecxx . . $ IfFlattener#fieldSize.); |
| 152 | |
| 153 | // Start editing (again, maybe) |
| 154 | coordValscxx . . $ IfFlattener#coordVals. = holdercxx . . $ IfFlattener#holder.->coordscxx . . $ IfHolder#coords.->pointcxx . . $ SoCoordinate3#point..startEditingcxx . . $ SoMFVec3f#startEditing(d7218d170b8c46e1).(); |
| 155 | mtlIndexValscxx . . $ IfFlattener#mtlIndexVals. = holdercxx . . $ IfFlattener#holder.->triSetcxx . . $ IfHolder#triSet.->materialIndexcxx . . $ SoIndexedShape#materialIndex..startEditingcxx . . $ SoMFInt32#startEditing(a7741f82f5fc3640).(); |
| 156 | if (holdercxx . . $ IfFlattener#holder.->doNormalscxx . . $ IfHolder#doNormals.) |
| 157 | normalValscxx . . $ IfFlattener#normalVals. = holdercxx . . $ IfFlattener#holder.->normalscxx . . $ IfHolder#normals.->vectorcxx . . $ SoNormal#vector..startEditingcxx . . $ SoMFVec3f#startEditing(d7218d170b8c46e1).(); |
| 158 | if (holdercxx . . $ IfFlattener#holder.->doTexCoordscxx . . $ IfHolder#doTexCoords.) |
| 159 | texCoordValscxx . . $ IfFlattener#texCoordVals. = holdercxx . . $ IfFlattener#holder.->texCoordscxx . . $ IfHolder#texCoords.->pointcxx . . $ SoTextureCoordinate2#point..startEditingcxx . . $ SoMFVec2f#startEditing(8881486cd4924579).(); |
| 160 | } |
| 161 | |
| 162 | ///////////////////////////////////////////////////////////////////////////// |
| 163 | // |
| 164 | // Prepares to process the triangles making up a shape. |
| 165 | // |
| 166 | ///////////////////////////////////////////////////////////////////////////// |
| 167 | |
| 168 | void |
| 169 | IfFlattenercxx . . $ IfFlattener#::prepareForShapecxx . . $ IfFlattener#prepareForShape(82760482a1765606).(SoCallbackActioncxx . . $ SoCallbackAction# *cba, const SoShapecxx . . $ SoShape# *) |
| 170 | { |
| 171 | // Get the current model matrix so we can transform the |
| 172 | // coordinates and normals |
| 173 | pointMatrixcxx . . $ IfFlattener#pointMatrix. =cxx . . $ SbMatrix#`operator=`(5bda0b2cfca989a9). cba->getModelMatrixcxx . . $ SoCallbackAction#getModelMatrix(be5ea7cb167a549e).(); |
| 174 | if (holdercxx . . $ IfFlattener#holder.->doNormalscxx . . $ IfHolder#doNormals.) |
| 175 | normalMatrixcxx . . $ IfFlattener#normalMatrix. =cxx . . $ SbMatrix#`operator=`(5bda0b2cfca989a9). pointMatrixcxx . . $ IfFlattener#pointMatrix..inversecxx . . $ SbMatrix#inverse(467bf55909e615bd).().transposecxx . . $ SbMatrix#transpose(467bf55909e615bd).(); |
| 176 | if (holdercxx . . $ IfFlattener#holder.->doTexCoordscxx . . $ IfHolder#doTexCoords.) |
| 177 | textureMatrixcxx . . $ IfFlattener#textureMatrix. =cxx . . $ SbMatrix#`operator=`(5bda0b2cfca989a9). cba->getTextureMatrixcxx . . $ SoCallbackAction#getTextureMatrix(be5ea7cb167a549e).(); |
| 178 | } |
| 179 | |
| 180 | ///////////////////////////////////////////////////////////////////////////// |
| 181 | // |
| 182 | // Adds a triangle generated by the current shape. |
| 183 | // |
| 184 | ///////////////////////////////////////////////////////////////////////////// |
| 185 | |
| 186 | void |
| 187 | IfFlattenercxx . . $ IfFlattener#::addTrianglecxx . . $ IfFlattener#addTriangle(25ef73422bd23fe).(SoCallbackActioncxx . . $ SoCallbackAction# *, const SoPrimitiveVertexcxx . . $ SoPrimitiveVertex# *verts[3]) |
| 188 | { |
| 189 | // Make sure there's enough room in the fields |
| 190 | if (numMtlIndicescxx . . $ IfFlattener#numMtlIndices. + 4 >= fieldSizecxx . . $ IfFlattener#fieldSize.) { |
| 191 | fieldSizecxx . . $ IfFlattener#fieldSize. *= 2; |
| 192 | expandFieldscxx . . $ IfFlattener#expandFields(49f6e7a06ebc5aa8).(); |
| 193 | } |
| 194 | |
| 195 | // For each of the three vertices |
| 196 | for (int i = 0; i < 3; i++) { |
| 197 | |
| 198 | addCoordinatecxx . . $ IfFlattener#addCoordinate(65a601b9d70571d6).(verts[i]->getPointcxx . . $ SoPrimitiveVertex#getPoint(b5c384c15c94bb12).()); |
| 199 | |
| 200 | if (holdercxx . . $ IfFlattener#holder.->doNormalscxx . . $ IfHolder#doNormals.) |
| 201 | addNormalcxx . . $ IfFlattener#addNormal(65a601b9d70571d6).(verts[i]->getNormalcxx . . $ SoPrimitiveVertex#getNormal(b5c384c15c94bb12).()); |
| 202 | |
| 203 | if (holdercxx . . $ IfFlattener#holder.->doTexCoordscxx . . $ IfHolder#doTexCoords.) |
| 204 | addTextureCoordinatecxx . . $ IfFlattener#addTextureCoordinate(5e0c53605d9ff01c).(verts[i]->getTextureCoordscxx . . $ SoPrimitiveVertex#getTextureCoords(561ae990c1ef2aee).()); |
| 205 | |
| 206 | addMaterialIndexcxx . . $ IfFlattener#addMaterialIndex(d4f767463ce0a6b3).(verts[i]->getMaterialIndexcxx . . $ SoPrimitiveVertex#getMaterialIndex(455f465bc33b4cdf).()); |
| 207 | |
| 208 | numVertscxx . . $ IfFlattener#numVerts.++; |
| 209 | numMtlIndicescxx . . $ IfFlattener#numMtlIndices.++; |
| 210 | } |
| 211 | |
| 212 | // Add a material index to skip (for the end-of-triangle marker) |
| 213 | addMaterialIndexcxx . . $ IfFlattener#addMaterialIndex(d4f767463ce0a6b3).(-1); |
| 214 | numMtlIndicescxx . . $ IfFlattener#numMtlIndices.++; |
| 215 | } |
| 216 | |
| 217 | ///////////////////////////////////////////////////////////////////////////// |
| 218 | // |
| 219 | // Finishes processing of the current shape. |
| 220 | // |
| 221 | ///////////////////////////////////////////////////////////////////////////// |
| 222 | |
| 223 | void |
| 224 | IfFlattenercxx . . $ IfFlattener#::finishShapecxx . . $ IfFlattener#finishShape(82760482a1765606).(SoCallbackActioncxx . . $ SoCallbackAction# *, const SoShapecxx . . $ SoShape# *) |
| 225 | { |
| 226 | } |
| 227 | |
| 228 | ///////////////////////////////////////////////////////////////////////////// |
| 229 | // |
| 230 | // Adds a point to the list of coordinates. |
| 231 | // |
| 232 | ///////////////////////////////////////////////////////////////////////////// |
| 233 | |
| 234 | void |
| 235 | IfFlattenercxx . . $ IfFlattener#::addCoordinatecxx . . $ IfFlattener#addCoordinate(65a601b9d70571d6).(const SbVec3fcxx . . $ SbVec3f# &point) |
| 236 | { |
| 237 | SbVec3fcxx . . $ SbVec3f# transformedPointcxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).; |
| 238 | pointMatrixcxx . . $ IfFlattener#pointMatrix..multVecMatrixcxx . . $ SbMatrix#multVecMatrix(f4e74898890c8c54).(point, transformedPoint); |
| 239 | coordValscxx . . $ IfFlattener#coordVals.[numVertscxx . . $ IfFlattener#numVerts.] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). transformedPoint; |
| 240 | } |
| 241 | |
| 242 | ///////////////////////////////////////////////////////////////////////////// |
| 243 | // |
| 244 | // Adds a normal to the list of normals. |
| 245 | // |
| 246 | ///////////////////////////////////////////////////////////////////////////// |
| 247 | |
| 248 | void |
| 249 | IfFlattenercxx . . $ IfFlattener#::addNormalcxx . . $ IfFlattener#addNormal(65a601b9d70571d6).(const SbVec3fcxx . . $ SbVec3f# &normal) |
| 250 | { |
| 251 | SbVec3fcxx . . $ SbVec3f# transformedNormalcxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).; |
| 252 | normalMatrixcxx . . $ IfFlattener#normalMatrix..multDirMatrixcxx . . $ SbMatrix#multDirMatrix(f4e74898890c8c54).(normal, transformedNormal); |
| 253 | transformedNormal.normalizecxx . . $ SbVec3f#normalize(9b8c9e39889c762c).(); |
| 254 | normalValscxx . . $ IfFlattener#normalVals.[numVertscxx . . $ IfFlattener#numVerts.] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). transformedNormal; |
| 255 | } |
| 256 | |
| 257 | ///////////////////////////////////////////////////////////////////////////// |
| 258 | // |
| 259 | // Adds a material index to the list of indices. |
| 260 | // |
| 261 | ///////////////////////////////////////////////////////////////////////////// |
| 262 | |
| 263 | void |
| 264 | IfFlattenercxx . . $ IfFlattener#::addMaterialIndexcxx . . $ IfFlattener#addMaterialIndex(d4f767463ce0a6b3).(int materialIndex) |
| 265 | { |
| 266 | mtlIndexValscxx . . $ IfFlattener#mtlIndexVals.[numMtlIndicescxx . . $ IfFlattener#numMtlIndices.] = materialIndex; |
| 267 | } |
| 268 | |
| 269 | ///////////////////////////////////////////////////////////////////////////// |
| 270 | // |
| 271 | // Adds a texture coordinate to the list. |
| 272 | // |
| 273 | ///////////////////////////////////////////////////////////////////////////// |
| 274 | |
| 275 | void |
| 276 | IfFlattenercxx . . $ IfFlattener#::addTextureCoordinatecxx . . $ IfFlattener#addTextureCoordinate(5e0c53605d9ff01c).(const SbVec4fcxx . . $ SbVec4f# &texCoord) |
| 277 | { |
| 278 | // Ignore everything except S and T |
| 279 | SbVec3fcxx . . $ SbVec3f# stTexCoordcxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(texCoord[cxx . . $ SbVec4f#`operator[]`(c60a38c584b9a5cc).0], texCoord[cxx . . $ SbVec4f#`operator[]`(c60a38c584b9a5cc).1], 0.0); |
| 280 | |
| 281 | SbVec3fcxx . . $ SbVec3f# transformedTexCoordcxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).; |
| 282 | textureMatrixcxx . . $ IfFlattener#textureMatrix..multVecMatrixcxx . . $ SbMatrix#multVecMatrix(f4e74898890c8c54).(stTexCoord, transformedTexCoord); |
| 283 | |
| 284 | SbVec2fcxx . . $ SbVec2f# tcxx . . $ SbVec2f#SbVec2f(5102ef758adc0ae7).(transformedTexCoord[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).0], transformedTexCoord[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).1]); |
| 285 | texCoordValscxx . . $ IfFlattener#texCoordVals.[numVertscxx . . $ IfFlattener#numVerts.] =cxx . . $ SbVec2f#`operator=`(55af37c201462dc0). t; |
| 286 | } |
| 287 | |
| 288 | ///////////////////////////////////////////////////////////////////////////// |
| 289 | // |
| 290 | // Processes the resulting structures to produce a graph. |
| 291 | // |
| 292 | ///////////////////////////////////////////////////////////////////////////// |
| 293 | |
| 294 | void |
| 295 | IfFlattenercxx . . $ IfFlattener#::createGraphcxx . . $ IfFlattener#createGraph(49f6e7a06ebc5aa8).() |
| 296 | { |
| 297 | // The coordinates, normals, and texture coordinates should |
| 298 | // already be set. All we need to do here is set up the |
| 299 | // indices in the SoIndexedShape. |
| 300 | int numTris = numVertscxx . . $ IfFlattener#numVerts. / 3; |
| 301 | holdercxx . . $ IfFlattener#holder.->triSetcxx . . $ IfHolder#triSet.->coordIndexcxx . . $ SoIndexedShape#coordIndex..setNumcxx . . $ SoMField#setNum(d4f767463ce0a6b3).(numTris * 4); |
| 302 | int32_t *cindex = holdercxx . . $ IfFlattener#holder.->triSetcxx . . $ IfHolder#triSet.->coordIndexcxx . . $ SoIndexedShape#coordIndex..startEditingcxx . . $ SoMFInt32#startEditing(a7741f82f5fc3640).(); |
| 303 | int ci = 0, v = 0; |
| 304 | for (int t = 0; t < numTris; t++) { |
| 305 | cindex[ci++] = v++; |
| 306 | cindex[ci++] = v++; |
| 307 | cindex[ci++] = v++; |
| 308 | cindex[ci++] = -1; |
| 309 | } |
| 310 | holdercxx . . $ IfFlattener#holder.->triSetcxx . . $ IfHolder#triSet.->coordIndexcxx . . $ SoIndexedShape#coordIndex..finishEditingcxx . . $ SoMFInt32#finishEditing(49f6e7a06ebc5aa8).(); |
| 311 | |
| 312 | // The normal and texture coordinate indices start out the same as |
| 313 | // the coordinate indices |
| 314 | if (holdercxx . . $ IfFlattener#holder.->doNormalscxx . . $ IfHolder#doNormals.) |
| 315 | holdercxx . . $ IfFlattener#holder.->triSetcxx . . $ IfHolder#triSet.->normalIndexcxx . . $ SoIndexedShape#normalIndex. =cxx . . $ SoMFInt32#`operator=`(3f2d52d2d6f9a9fd). holdercxx . . $ IfFlattener#holder.->triSetcxx . . $ IfHolder#triSet.->coordIndexcxx . . $ SoIndexedShape#coordIndex.; |
| 316 | if (holdercxx . . $ IfFlattener#holder.->doTexCoordscxx . . $ IfHolder#doTexCoords.) |
| 317 | holdercxx . . $ IfFlattener#holder.->triSetcxx . . $ IfHolder#triSet.->textureCoordIndexcxx . . $ SoIndexedShape#textureCoordIndex. =cxx . . $ SoMFInt32#`operator=`(3f2d52d2d6f9a9fd). holdercxx . . $ IfFlattener#holder.->triSetcxx . . $ IfHolder#triSet.->coordIndexcxx . . $ SoIndexedShape#coordIndex.; |
| 318 | |
| 319 | // Decrease the sizes of the fields if there is any extra space |
| 320 | if (numVertscxx . . $ IfFlattener#numVerts. < fieldSizecxx . . $ IfFlattener#fieldSize.) { |
| 321 | holdercxx . . $ IfFlattener#holder.->coordscxx . . $ IfHolder#coords.->pointcxx . . $ SoCoordinate3#point..setNumcxx . . $ SoMField#setNum(d4f767463ce0a6b3).(numVertscxx . . $ IfFlattener#numVerts.); |
| 322 | if (holdercxx . . $ IfFlattener#holder.->doNormalscxx . . $ IfHolder#doNormals.) |
| 323 | holdercxx . . $ IfFlattener#holder.->normalscxx . . $ IfHolder#normals.->vectorcxx . . $ SoNormal#vector..setNumcxx . . $ SoMField#setNum(d4f767463ce0a6b3).(numVertscxx . . $ IfFlattener#numVerts.); |
| 324 | if (holdercxx . . $ IfFlattener#holder.->doTexCoordscxx . . $ IfHolder#doTexCoords.) |
| 325 | holdercxx . . $ IfFlattener#holder.->texCoordscxx . . $ IfHolder#texCoords.->pointcxx . . $ SoTextureCoordinate2#point..setNumcxx . . $ SoMField#setNum(d4f767463ce0a6b3).(numVertscxx . . $ IfFlattener#numVerts.); |
| 326 | } |
| 327 | if (numMtlIndicescxx . . $ IfFlattener#numMtlIndices. < fieldSizecxx . . $ IfFlattener#fieldSize.) |
| 328 | holdercxx . . $ IfFlattener#holder.->triSetcxx . . $ IfHolder#triSet.->materialIndexcxx . . $ SoIndexedShape#materialIndex..setNumcxx . . $ SoMField#setNum(d4f767463ce0a6b3).(numMtlIndicescxx . . $ IfFlattener#numMtlIndices.); |
| 329 | |
| 330 | // Assume that the normals, materials, and texture coordinates are |
| 331 | // bound per vertex, using the indices |
| 332 | if (holdercxx . . $ IfFlattener#holder.->doNormalscxx . . $ IfHolder#doNormals.) |
| 333 | holdercxx . . $ IfFlattener#holder.->normalBindingcxx . . $ IfHolder#normalBinding.->valuecxx . . $ SoNormalBinding#value. =cxx . . $ SoSFEnum#`operator=`(7864480464b09eea). SoNormalBindingcxx . . $ SoNormalBinding#::PER_VERTEX_INDEXEDcxx . . $ SoNormalBinding#PER_VERTEX_INDEXED.; |
| 334 | holdercxx . . $ IfFlattener#holder.->materialBindingcxx . . $ IfHolder#materialBinding.->valuecxx . . $ SoMaterialBinding#value. =cxx . . $ SoSFEnum#`operator=`(7864480464b09eea). SoMaterialBindingcxx . . $ SoMaterialBinding#::PER_VERTEX_INDEXEDcxx . . $ SoMaterialBinding#PER_VERTEX_INDEXED.; |
| 335 | if (holdercxx . . $ IfFlattener#holder.->doTexCoordscxx . . $ IfHolder#doTexCoords.) |
| 336 | holdercxx . . $ IfFlattener#holder.->texCoordBindingcxx . . $ IfHolder#texCoordBinding.->valuecxx . . $ SoTextureCoordinateBinding#value. =cxx . . $ SoSFEnum#`operator=`(7864480464b09eea). |
| 337 | SoTextureCoordinateBindingcxx . . $ SoTextureCoordinateBinding#::PER_VERTEX_INDEXEDcxx . . $ SoTextureCoordinateBinding#PER_VERTEX_INDEXED.; |
| 338 | } |