Debian Codegraph @

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

raw
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 | SoNormalBinding
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/SoGLRenderAction.h>
55 #include <Inventor/actions/SoCallbackAction.h>
56 #include <Inventor/actions/SoPickAction.h>
57 #include <Inventor/nodes/SoNormalBinding.h>
58
59 SO_NODE_SOURCE(SoNormalBinding);
60
61 ////////////////////////////////////////////////////////////////////////
62 //
63 // Description:
64 // Constructor
65 //
66 // Use: public
67
68 SoNormalBinding::SoNormalBinding()
69 //
70 ////////////////////////////////////////////////////////////////////////
71 {
72 SO_NODE_CONSTRUCTOR(SoNormalBinding);
73 SO_NODE_ADD_FIELD(value, (SoNormalBindingElement::getDefault()));
74
75 // Set up static info for enumerated type field
76 SO_NODE_DEFINE_ENUM_VALUE(Binding, OVERALL);
77 SO_NODE_DEFINE_ENUM_VALUE(Binding, PER_PART);
78 SO_NODE_DEFINE_ENUM_VALUE(Binding, PER_PART_INDEXED);
79 SO_NODE_DEFINE_ENUM_VALUE(Binding, PER_FACE);
80 SO_NODE_DEFINE_ENUM_VALUE(Binding, PER_FACE_INDEXED);
81 SO_NODE_DEFINE_ENUM_VALUE(Binding, PER_VERTEX);
82 SO_NODE_DEFINE_ENUM_VALUE(Binding, PER_VERTEX_INDEXED);
83
84 // And obsolete bindings:
85 if (firstInstance) {
86 fieldData->addEnumValue("Binding", "DEFAULT", 0);
87 fieldData->addEnumValue("Binding", "NONE", 1);
88 }
89
90 // Set up info in enumerated type field
91 SO_NODE_SET_SF_ENUM_TYPE(value, Binding);
92
93 isBuiltIn = TRUE;
94 }
95
96 ////////////////////////////////////////////////////////////////////////
97 //
98 // Description:
99 // Destructor
100 //
101 // Use: private
102
103 SoNormalBinding::~SoNormalBinding()
104 //
105 ////////////////////////////////////////////////////////////////////////
106 {
107 }
108
109 ////////////////////////////////////////////////////////////////////////
110 //
111 // Description:
112 // Handles most actions.
113 //
114 // Use: extender
115
116 void
117 SoNormalBinding::doAction(SoAction *action)
118
119 //
120 ////////////////////////////////////////////////////////////////////////
121 {
122 if (! value.isIgnored()) {
123 SoNormalBindingElement::set(action->getState(),
124 (SoNormalBindingElement::Binding)value.getValue());
125 }
126 }
127
128 ////////////////////////////////////////////////////////////////////////
129 //
130 // Description:
131 // Override read to translate obsolete bindings
132 //
133 // Use: extender
134
135 SbBool
136 SoNormalBinding::readInstance(SoInput *in, unsigned short flags)
137 //
138 ////////////////////////////////////////////////////////////////////////
139 {
140 SbBool result = SoNode::readInstance(in, flags);
141
142 // Deal with obsolete bindings:
143 int b = value.getValue();
144 if (b == 0 || b == 1) value = PER_VERTEX_INDEXED;
145
146 return result;
147 }
148
149 ////////////////////////////////////////////////////////////////////////
150 //
151 // Description:
152 // Does callback action thing.
153 //
154 // Use: extender
155
156 void
157 SoNormalBinding::callback(SoCallbackAction *action)
158 //
159 ////////////////////////////////////////////////////////////////////////
160 {
161 SoNormalBinding::doAction(action);
162 }
163
164 ////////////////////////////////////////////////////////////////////////
165 //
166 // Description:
167 // Does GL render action.
168 //
169 // Use: extender
170
171 void
172 SoNormalBinding::GLRender(SoGLRenderAction *action)
173 //
174 ////////////////////////////////////////////////////////////////////////
175 {
176 SoNormalBinding::doAction(action);
177 }
178
179 ////////////////////////////////////////////////////////////////////////
180 //
181 // Description:
182 // Does pick action...
183 //
184 // Use: extender
185
186 void
187 SoNormalBinding::pick(SoPickAction *action)
188 //
189 ////////////////////////////////////////////////////////////////////////
190 {
191 SoNormalBinding::doAction(action);
192 }