| 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 | /* |
| 38 | * Copyright (C) 1990,91 Silicon Graphics, Inc. |
| 39 | * |
| 40 | _______________________________________________________________________ |
| 41 | ______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 42 | | |
| 43 | | $Revision: 1.1.1.1 $ |
| 44 | | |
| 45 | | Classes: |
| 46 | | SoVertexShape |
| 47 | | |
| 48 | | Author(s) : Paul S. Strauss |
| 49 | | |
| 50 | ______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 51 | _______________________________________________________________________ |
| 52 | */ |
| 53 | |
| 54 | #include <Inventor/caches/SoNormalCache.h>cxx . . $ `<file>/lib/database/include/Inventor/caches/SoNormalCache.h`/ |
| 55 | #include <Inventor/elements/SoCoordinateElement.h>cxx . . $ `<file>/lib/database/include/Inventor/elements/SoCoordinateElement.h`/ |
| 56 | #include <Inventor/elements/SoCreaseAngleElement.h>cxx . . $ `<file>/lib/database/include/Inventor/elements/SoCreaseAngleElement.h`/ |
| 57 | #include <Inventor/elements/SoShapeHintsElement.h>cxx . . $ `<file>/lib/database/include/Inventor/elements/SoShapeHintsElement.h`/ |
| 58 | #include <Inventor/nodes/SoVertexShape.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoVertexShape.h`/ |
| 59 | #include <Inventor/elements/SoDrawStyleElement.h>cxx . . $ `<file>/lib/database/include/Inventor/elements/SoDrawStyleElement.h`/ |
| 60 | #include <Inventor/elements/SoComplexityTypeElement.h>cxx . . $ `<file>/lib/database/include/Inventor/elements/SoComplexityTypeElement.h`/ |
| 61 | #include <Inventor/actions/SoGLRenderAction.h>cxx . . $ `<file>/lib/database/include/Inventor/actions/SoGLRenderAction.h`/ |
| 62 | |
| 63 | SO_NODE_ABSTRACT_SOURCEcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:245:9`!(SoVertexShape); |
| 64 | |
| 65 | //////////////////////////////////////////////////////////////////////// |
| 66 | // |
| 67 | // Description: |
| 68 | // Constructor |
| 69 | // |
| 70 | // Use: protected |
| 71 | |
| 72 | SoVertexShapecxx . . $ SoVertexShape#::SoVertexShapecxx . . $ SoVertexShape#SoVertexShape(49f6e7a06ebc5aa8).() |
| 73 | // |
| 74 | //////////////////////////////////////////////////////////////////////// |
| 75 | { |
| 76 | SO_NODE_CONSTRUCTORcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:309:9`!(SoVertexShape); |
| 77 | SO_NODE_ADD_FIELDcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:346:9`!(vertexProperty, (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)); |
| 78 | |
| 79 | normalCachecxx . . $ SoVertexShape#normalCache. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 80 | } |
| 81 | |
| 82 | //////////////////////////////////////////////////////////////////////// |
| 83 | // |
| 84 | // Description: |
| 85 | // Destructor |
| 86 | // |
| 87 | // Use: private |
| 88 | |
| 89 | SoVertexShapecxx . . $ SoVertexShape#::~cxx . . $ SoVertexShape#`~SoVertexShape`(49f6e7a06ebc5aa8).SoVertexShapecxx . . $ SoVertexShape#() |
| 90 | // |
| 91 | //////////////////////////////////////////////////////////////////////// |
| 92 | { |
| 93 | if (normalCachecxx . . $ SoVertexShape#normalCache. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 94 | delete normalCachecxx . . $ SoVertexShape#normalCache.; |
| 95 | } |
| 96 | |
| 97 | //////////////////////////////////////////////////////////////////////// |
| 98 | // |
| 99 | // Description: |
| 100 | // Subclasses may define this method to generate normals to use |
| 101 | // when the normal binding is DEFAULT and there aren't enough |
| 102 | // normals in the state. This should use the given SoNormalBundle |
| 103 | // to generate the normals. Returns TRUE if normals were generated. |
| 104 | // |
| 105 | // The default method returns TRUE. |
| 106 | // |
| 107 | // Use: extender, virtual |
| 108 | |
| 109 | SbBoolcxx . . $ SbBool# |
| 110 | SoVertexShapecxx . . $ SoVertexShape#::generateDefaultNormalscxx . . $ SoVertexShape#generateDefaultNormals(3b414e6c11576c1).(SoStatecxx . . $ SoState# *, SoNormalBundlecxx . . $ SoNormalBundle# *) |
| 111 | // |
| 112 | //////////////////////////////////////////////////////////////////////// |
| 113 | { |
| 114 | return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 115 | } |
| 116 | |
| 117 | //////////////////////////////////////////////////////////////////////// |
| 118 | // |
| 119 | // Description: |
| 120 | // Sets up a cache to hold normals. This assumes the cache depends |
| 121 | // on only the current coordinates, shape hints, and crease angle. |
| 122 | // |
| 123 | // Use: protected |
| 124 | |
| 125 | void |
| 126 | SoVertexShapecxx . . $ SoVertexShape#::setNormalCachecxx . . $ SoVertexShape#setNormalCache(eb708fc4347dc948).(SoStatecxx . . $ SoState# *state, |
| 127 | int numNormals, const SbVec3fcxx . . $ SbVec3f# *normals) |
| 128 | // |
| 129 | //////////////////////////////////////////////////////////////////////// |
| 130 | { |
| 131 | if (normalCachecxx . . $ SoVertexShape#normalCache. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 132 | normalCachecxx . . $ SoVertexShape#normalCache.->unrefcxx . . $ SoCache#unref(10e5c4d2a7f63e3e).(); |
| 133 | |
| 134 | normalCachecxx . . $ SoVertexShape#normalCache. = new SoNormalCachecxx . . $ SoNormalCache#(state); |
| 135 | normalCachecxx . . $ SoVertexShape#normalCache.->refcxx . . $ SoCache#ref(49f6e7a06ebc5aa8).(); |
| 136 | |
| 137 | normalCachecxx . . $ SoVertexShape#normalCache.->setcxx . . $ SoNormalCache#set(66b4309e4be2cede).(numNormals, normals); |
| 138 | |
| 139 | // Set up the dependencies |
| 140 | #define ADD_DEPENDENCYcxx . . $ `lib/database/src/so/nodes/SoVertexShape.c++:140:9`!(elt) \ |
| 141 | normalCache->addElement(state->getConstElement(elt::getClassStackIndex())) |
| 142 | |
| 143 | ADD_DEPENDENCYcxx . . $ `lib/database/src/so/nodes/SoVertexShape.c++:140:9`!(SoCoordinateElement); |
| 144 | ADD_DEPENDENCYcxx . . $ `lib/database/src/so/nodes/SoVertexShape.c++:140:9`!(SoCreaseAngleElement); |
| 145 | ADD_DEPENDENCYcxx . . $ `lib/database/src/so/nodes/SoVertexShape.c++:140:9`!(SoShapeHintsElement); |
| 146 | |
| 147 | #undef ADD_DEPENDENCYcxx . . $ `lib/database/src/so/nodes/SoVertexShape.c++:140:9`! |
| 148 | } |
| 149 | |
| 150 | //////////////////////////////////////////////////////////////////////// |
| 151 | // |
| 152 | // Description: |
| 153 | // Passes on notification after invalidating any caches. |
| 154 | // |
| 155 | // Use: internal |
| 156 | |
| 157 | void |
| 158 | SoVertexShapecxx . . $ SoVertexShape#::notifycxx . . $ SoVertexShape#notify(f43de791d8d2eb5a).(SoNotListcxx . . $ SoNotList# *list) |
| 159 | // |
| 160 | //////////////////////////////////////////////////////////////////////// |
| 161 | { |
| 162 | // Destroy cache, if present |
| 163 | if (normalCachecxx . . $ SoVertexShape#normalCache. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 164 | normalCachecxx . . $ SoVertexShape#normalCache.->unrefcxx . . $ SoCache#unref(10e5c4d2a7f63e3e).(); |
| 165 | normalCachecxx . . $ SoVertexShape#normalCache. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 166 | } |
| 167 | vpCachecxx . . $ SoVertexShape#vpCache..invalidatecxx . . $ SoVertexPropertyCache#invalidate(49f6e7a06ebc5aa8).(); |
| 168 | |
| 169 | // Then do the usual stuff |
| 170 | SoShapecxx . . $ SoShape#::notifycxx . . $ SoNode#notify(f43de791d8d2eb5a).(list); |
| 171 | } |
| 172 | |
| 173 | //////////////////////////////////////////////////////////////////////// |
| 174 | // |
| 175 | // Description: |
| 176 | // Returns TRUE if the shape should be rendered now. Does more then |
| 177 | // the method in SoShape, because of possible transparency in vertex |
| 178 | // property node. |
| 179 | // |
| 180 | // Use: protected |
| 181 | // |
| 182 | ////////////////////////////////////////////////////////////////////////// |
| 183 | SbBoolcxx . . $ SbBool# |
| 184 | SoVertexShapecxx . . $ SoVertexShape#::shouldGLRendercxx . . $ SoVertexShape#shouldGLRender(446ea20fc76c7af1).(SoGLRenderActioncxx . . $ SoGLRenderAction# *action) |
| 185 | // |
| 186 | //////////////////////////////////////////////////////////////////////// |
| 187 | { |
| 188 | |
| 189 | // Check if the shape is invisible |
| 190 | if (SoDrawStyleElementcxx . . $ SoDrawStyleElement#::getcxx . . $ SoDrawStyleElement#get(81be143f98f0d7a8).(action->getStatecxx . . $ SoAction#getState(5c8eb8fe6550a03).()) == |
| 191 | SoDrawStyleElementcxx . . $ SoDrawStyleElement#::INVISIBLEcxx . . $ SoDrawStyleElement#INVISIBLE.) |
| 192 | return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 193 | |
| 194 | // If the shape is transparent and transparent objects are being |
| 195 | // delayed, don't render now |
| 196 | // if there is transparency in the vertex property node, the object is |
| 197 | // transparent. If there are no colors in the vertexProperty node, |
| 198 | // we have to check the state. |
| 199 | if (!vpCachecxx . . $ SoVertexShape#vpCache..colorIsInVtxPropcxx . . $ SoVertexPropertyCache#colorIsInVtxProp(455f465bc33b4cdf).()){ |
| 200 | if (action->handleTransparencycxx . . $ SoGLRenderAction#handleTransparency(7864480464b09eea).()) |
| 201 | return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 202 | } |
| 203 | else if (vpCachecxx . . $ SoVertexShape#vpCache..transpIsInVtxPropcxx . . $ SoVertexPropertyCache#transpIsInVtxProp(455f465bc33b4cdf).()){ |
| 204 | if (action->handleTransparencycxx . . $ SoGLRenderAction#handleTransparency(7864480464b09eea).(TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!)) |
| 205 | return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 206 | } |
| 207 | else |
| 208 | SoLazyElementcxx . . $ SoLazyElement#::setBlendingcxx . . $ SoLazyElement#setBlending(47a371b7b9daa722).(action->getStatecxx . . $ SoAction#getState(5c8eb8fe6550a03).(), FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); |
| 209 | |
| 210 | // If the current complexity is BOUNDING_BOX, just render the |
| 211 | // cuboid surrounding the shape and tell the shape to stop |
| 212 | if (SoComplexityTypeElementcxx . . $ SoComplexityTypeElement#::getcxx . . $ SoComplexityTypeElement#get(f065841ab22bd7f0).(action->getStatecxx . . $ SoAction#getState(5c8eb8fe6550a03).()) == |
| 213 | SoComplexityTypeElementcxx . . $ SoComplexityTypeElement#::BOUNDING_BOXcxx . . $ SoComplexityTypeElement#BOUNDING_BOX.) { |
| 214 | GLRenderBoundingBoxcxx . . $ SoShape#GLRenderBoundingBox(5c806c737f468e18).(action); |
| 215 | return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 216 | } |
| 217 | |
| 218 | // Otherwise, go ahead and render the object |
| 219 | return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 220 | } |