Debian Codegraph @

lib/database/src/so/nodes/SoMaterial.c++

raw symbols SCIP
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.2 $
44 |
45 | Classes:
46 | SoMaterial
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/actions/SoCallbackAction.h>cxx . . $ `<file>/lib/database/include/Inventor/actions/SoCallbackAction.h`/
55 #include <Inventor/actions/SoGLRenderAction.h>cxx . . $ `<file>/lib/database/include/Inventor/actions/SoGLRenderAction.h`/
56 #include <Inventor/elements/SoGLLazyElement.h>cxx . . $ `<file>/lib/database/include/Inventor/elements/SoGLLazyElement.h`/
57 #include <Inventor/elements/SoOverrideElement.h>cxx . . $ `<file>/lib/database/include/Inventor/elements/SoOverrideElement.h`/
58 #include <Inventor/nodes/SoMaterial.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoMaterial.h`/
59
60 SO_NODE_SOURCEcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:241:9`!(SoMaterial);
61
62 ////////////////////////////////////////////////////////////////////////
63 //
64 // Description:
65 // Constructor
66 //
67 // Use: public
68
69 SoMaterialcxx . . $ SoMaterial#::SoMaterialcxx . . $ SoMaterial#SoMaterial(49f6e7a06ebc5aa8).()
70 //
71 ////////////////////////////////////////////////////////////////////////
72 {
73 SO_NODE_CONSTRUCTORcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:309:9`!(SoMaterial);
74
75 SO_NODE_ADD_FIELDcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:346:9`!(ambientColor, (SoLazyElement::getDefaultAmbient()));
76 SO_NODE_ADD_FIELDcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:346:9`!(diffuseColor, (SoLazyElement::getDefaultDiffuse()));
77 SO_NODE_ADD_FIELDcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:346:9`!(specularColor,(SoLazyElement::getDefaultSpecular()));
78 SO_NODE_ADD_FIELDcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:346:9`!(emissiveColor,(SoLazyElement::getDefaultEmissive()));
79 SO_NODE_ADD_FIELDcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:346:9`!(shininess, (SoLazyElement::getDefaultShininess()));
80 SO_NODE_ADD_FIELDcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:346:9`!(transparency, (SoLazyElement::getDefaultTransparency()));
81 isBuiltIncxx . . $ SoFieldContainer#isBuiltIn. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
82 colorPackercxx . . $ SoMaterial#colorPacker. = new SoColorPackercxx . . $ SoColorPacker#SoColorPacker(49f6e7a06ebc5aa8).;
83 }
84
85 ////////////////////////////////////////////////////////////////////////
86 //
87 // Description:
88 // This initializes the SoMaterial class.
89 //
90 // Use: internal
91
92 void
93 SoMaterialcxx . . $ SoMaterial#::initClasscxx . . $ SoMaterial#initClass(49f6e7a06ebc5aa8).()
94 //
95 ////////////////////////////////////////////////////////////////////////
96 {
97 SO__NODE_INIT_CLASScxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:255:9`!(SoMaterial, "Material", SoNode);
98
99 // Enable elements:
100 SO_ENABLEcxx . . $ `lib/database/include/Inventor/actions/SoAction.h:436:9`!(SoCallbackAction, SoLazyElement);
101 SO_ENABLEcxx . . $ `lib/database/include/Inventor/actions/SoAction.h:436:9`!(SoGLRenderAction, SoGLLazyElement);
102 }
103 ////////////////////////////////////////////////////////////////////////
104 //
105 // Description:
106 // Destructor (necessary since inline destructor is too complex)
107 //
108 // Use: private
109
110 SoMaterialcxx . . $ SoMaterial#::~cxx . . $ SoMaterial#`~SoMaterial`(49f6e7a06ebc5aa8).SoMaterialcxx . . $ SoMaterial#()
111 //
112 ////////////////////////////////////////////////////////////////////////
113 {
114 delete colorPackercxx . . $ SoMaterial#colorPacker.;
115 }
116
117 ////////////////////////////////////////////////////////////////////////
118 //
119 // Description:
120 // Performs accumulation of state for actions.
121 //
122 // Use: extender
123
124 void
125 SoMaterialcxx . . $ SoMaterial#::doActioncxx . . $ SoMaterial#doAction(967167263c8a77b7).(SoActioncxx . . $ SoAction# *action)
126 //
127 ////////////////////////////////////////////////////////////////////////
128 {
129 SoStatecxx . . $ SoState# *state = action->getStatecxx . . $ SoAction#getState(5c8eb8fe6550a03).();
130 register uint32_tcxx . . $ uint32_t# bitmask = 0;
131
132 // Set all non-ignored components
133
134 if (! ambientColorcxx . . $ SoMaterial#ambientColor..isIgnoredcxx . . $ SoField#isIgnored(455f465bc33b4cdf).() && ambientColorcxx . . $ SoMaterial#ambientColor..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).() > 0
135 && ! SoOverrideElementcxx . . $ SoOverrideElement#::getAmbientColorOverridecxx . . $ SoOverrideElement#getAmbientColorOverride(fec557bbb5044c9b).(state)) {
136 if (isOverridecxx . . $ SoNode#isOverride(455f465bc33b4cdf).()) {
137 SoOverrideElementcxx . . $ SoOverrideElement#::setAmbientColorOverridecxx . . $ SoOverrideElement#setAmbientColorOverride(2ed35df5b93ae4e2).(state, this, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!);
138 }
139 bitmask |= SoLazyElementcxx . . $ SoLazyElement#::AMBIENT_MASKcxx . . $ SoLazyElement#AMBIENT_MASK.;
140 }
141
142 if (! diffuseColorcxx . . $ SoMaterial#diffuseColor..isIgnoredcxx . . $ SoField#isIgnored(455f465bc33b4cdf).() && diffuseColorcxx . . $ SoMaterial#diffuseColor..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).() > 0
143 && ! SoOverrideElementcxx . . $ SoOverrideElement#::getDiffuseColorOverridecxx . . $ SoOverrideElement#getDiffuseColorOverride(fec557bbb5044c9b).(state)) {
144 if (isOverridecxx . . $ SoNode#isOverride(455f465bc33b4cdf).()) {
145 SoOverrideElementcxx . . $ SoOverrideElement#::setDiffuseColorOverridecxx . . $ SoOverrideElement#setDiffuseColorOverride(2ed35df5b93ae4e2).(state, this, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!);
146 // Diffuse color and transparency share override state
147 if (! transparencycxx . . $ SoMaterial#transparency..isIgnoredcxx . . $ SoField#isIgnored(455f465bc33b4cdf).() && transparencycxx . . $ SoMaterial#transparency..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).() > 0)
148 bitmask |= SoLazyElementcxx . . $ SoLazyElement#::TRANSPARENCY_MASKcxx . . $ SoLazyElement#TRANSPARENCY_MASK.;
149 }
150 bitmask |= SoLazyElementcxx . . $ SoLazyElement#::DIFFUSE_MASKcxx . . $ SoLazyElement#DIFFUSE_MASK.;
151 }
152
153 if (! transparencycxx . . $ SoMaterial#transparency..isIgnoredcxx . . $ SoField#isIgnored(455f465bc33b4cdf).() && transparencycxx . . $ SoMaterial#transparency..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).() > 0
154 && ! SoOverrideElementcxx . . $ SoOverrideElement#::getTransparencyOverridecxx . . $ SoOverrideElement#getTransparencyOverride(fec557bbb5044c9b).(state)) {
155 if (isOverridecxx . . $ SoNode#isOverride(455f465bc33b4cdf).()) {
156 SoOverrideElementcxx . . $ SoOverrideElement#::setTransparencyOverridecxx . . $ SoOverrideElement#setTransparencyOverride(2ed35df5b93ae4e2).(state, this, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!);
157 // Diffuse color and transparency share override state
158 if (! diffuseColorcxx . . $ SoMaterial#diffuseColor..isIgnoredcxx . . $ SoField#isIgnored(455f465bc33b4cdf).() && diffuseColorcxx . . $ SoMaterial#diffuseColor..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).() > 0)
159 bitmask |= SoLazyElementcxx . . $ SoLazyElement#::DIFFUSE_MASKcxx . . $ SoLazyElement#DIFFUSE_MASK.;
160 }
161 bitmask |= SoLazyElementcxx . . $ SoLazyElement#::TRANSPARENCY_MASKcxx . . $ SoLazyElement#TRANSPARENCY_MASK.;
162 }
163 if (! specularColorcxx . . $ SoMaterial#specularColor..isIgnoredcxx . . $ SoField#isIgnored(455f465bc33b4cdf).() && specularColorcxx . . $ SoMaterial#specularColor..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).() > 0
164 && ! SoOverrideElementcxx . . $ SoOverrideElement#::getSpecularColorOverridecxx . . $ SoOverrideElement#getSpecularColorOverride(fec557bbb5044c9b).(state)) {
165 if (isOverridecxx . . $ SoNode#isOverride(455f465bc33b4cdf).()) {
166 SoOverrideElementcxx . . $ SoOverrideElement#::setSpecularColorOverridecxx . . $ SoOverrideElement#setSpecularColorOverride(2ed35df5b93ae4e2).(state, this, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!);
167 }
168 bitmask |= SoLazyElementcxx . . $ SoLazyElement#::SPECULAR_MASKcxx . . $ SoLazyElement#SPECULAR_MASK.;
169 }
170
171 if (! emissiveColorcxx . . $ SoMaterial#emissiveColor..isIgnoredcxx . . $ SoField#isIgnored(455f465bc33b4cdf).() && emissiveColorcxx . . $ SoMaterial#emissiveColor..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).() > 0
172 && ! SoOverrideElementcxx . . $ SoOverrideElement#::getEmissiveColorOverridecxx . . $ SoOverrideElement#getEmissiveColorOverride(fec557bbb5044c9b).(state)) {
173 if (isOverridecxx . . $ SoNode#isOverride(455f465bc33b4cdf).()) {
174 SoOverrideElementcxx . . $ SoOverrideElement#::setEmissiveColorOverridecxx . . $ SoOverrideElement#setEmissiveColorOverride(2ed35df5b93ae4e2).(state, this, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!);
175 }
176 bitmask |= SoLazyElementcxx . . $ SoLazyElement#::EMISSIVE_MASKcxx . . $ SoLazyElement#EMISSIVE_MASK.;
177 }
178
179 if (! shininesscxx . . $ SoMaterial#shininess..isIgnoredcxx . . $ SoField#isIgnored(455f465bc33b4cdf).() && shininesscxx . . $ SoMaterial#shininess..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).() > 0
180 && ! SoOverrideElementcxx . . $ SoOverrideElement#::getShininessOverridecxx . . $ SoOverrideElement#getShininessOverride(fec557bbb5044c9b).(state)) {
181 if (isOverridecxx . . $ SoNode#isOverride(455f465bc33b4cdf).()) {
182 SoOverrideElementcxx . . $ SoOverrideElement#::setShininessOverridecxx . . $ SoOverrideElement#setShininessOverride(2ed35df5b93ae4e2).(state, this, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!);
183 }
184 bitmask |= SoLazyElementcxx . . $ SoLazyElement#::SHININESS_MASKcxx . . $ SoLazyElement#SHININESS_MASK.;
185 }
186 SoLazyElementcxx . . $ SoLazyElement#::setMaterialscxx . . $ SoLazyElement#setMaterials(c5dfc45b36609ae5).(state, this, bitmask, colorPackercxx . . $ SoMaterial#colorPacker.,
187 diffuseColorcxx . . $ SoMaterial#diffuseColor., transparencycxx . . $ SoMaterial#transparency., ambientColorcxx . . $ SoMaterial#ambientColor.,
188 emissiveColorcxx . . $ SoMaterial#emissiveColor., specularColorcxx . . $ SoMaterial#specularColor., shininesscxx . . $ SoMaterial#shininess.);
189
190 }
191
192 ////////////////////////////////////////////////////////////////////////
193 //
194 // Description:
195 // Method for callback action
196 //
197 // Use: extender
198
199 void
200 SoMaterialcxx . . $ SoMaterial#::callbackcxx . . $ SoMaterial#callback(425635c2081b81c8).(SoCallbackActioncxx . . $ SoCallbackAction# *action)
201 //
202 ////////////////////////////////////////////////////////////////////////
203 {
204 SoMaterialcxx . . $ SoMaterial#::doActioncxx . . $ SoMaterial#doAction(967167263c8a77b7).(action);
205 }
206
207 ////////////////////////////////////////////////////////////////////////
208 //
209 // Description:
210 // Method for GL rendering
211 //
212 // Use: extender
213
214 void
215 SoMaterialcxx . . $ SoMaterial#::GLRendercxx . . $ SoMaterial#GLRender(5c806c737f468e18).(SoGLRenderActioncxx . . $ SoGLRenderAction# *action)
216 //
217 ////////////////////////////////////////////////////////////////////////
218 {
219 SoMaterialcxx . . $ SoMaterial#::doActioncxx . . $ SoMaterial#doAction(967167263c8a77b7).(action);
220
221 // If there's only one color, we might as well send it now. This
222 // prevents cache dependencies in some cases that were
223 // specifically optimized for Inventor 2.0.
224 if (diffuseColorcxx . . $ SoMaterial#diffuseColor..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).() == 1 && !diffuseColorcxx . . $ SoMaterial#diffuseColor..isIgnoredcxx . . $ SoField#isIgnored(455f465bc33b4cdf).())
225 SoGLLazyElementcxx . . $ SoGLLazyElement#::sendAllMaterialcxx . . $ SoGLLazyElement#sendAllMaterial(10e5c4d2a7f63e3e).(action->getStatecxx . . $ SoAction#getState(5c8eb8fe6550a03).());
226 }