Open Inventor Reference
SoVertexProperty.h
Go to the documentation of this file.
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
39/*
40 * Copyright (C) 1995-96 Silicon Graphics, Inc.
41 *
42 _______________________________________________________________________
43 ______________ S I L I C O N G R A P H I C S I N C . ____________
44 |
45 | $Revision: 1.1.1.1 $
46 |
47 | Description:
48 | This file defines the SoVertexProperty node class, and the
49 | SoVertexPropertyCache class.
50 |
51 | Author(s) : Alan Norton, Gavin Bell
52 |
53 ______________ S I L I C O N G R A P H I C S I N C . ____________
54 _______________________________________________________________________
55 */
56
57#ifndef _SO_VERTEX_PROPERTY
58#define _SO_VERTEX_PROPERTY
59
67
68
70class SoVBO;
71
74
193
195
197
198 public:
199
207
208 enum Binding {
216 };
217
225
226 SoEXTENDER public:
227 virtual void doAction(SoAction *action);
228 virtual void GLRender(SoGLRenderAction *action);
230 virtual void callback(SoCallbackAction *action);
231 virtual void pick(SoPickAction *action);
232
233 SoINTERNAL public:
236
237 static void initClass();
238
239 protected:
241
246
247};
248
259
261
262typedef void SoVPCacheFunc(const char *);
263
265 public:
266
268
270 { return (needFromState & sse->getRenderCaseMask())!=0; }
271
274
276 { return (generateNormals && sse->needNormals()); }
277
279 { return (generateTexCoords && sse->needTexCoords()); }
280
281 int getRenderCase(const SoShapeStyleElement *sse) const
282 { return renderCase & sse->getRenderCaseMask(); }
283
285 { return (needFromState & TEXTURE_FUNCTION_BIT) != 0; }
286
287 void sendVertex(const char *vp) const
288 { (*vertexFunc)(vp); }
289 void sendNormal(const char *np) const
290 { (*normalFunc)(np); }
291 void sendColor(const char *cp) const
292 { (*colorFunc)(cp); }
293 void sendTexCoord(const char *tcp) const
294 { (*texCoordFunc)(tcp); }
295
296 int getNumVertices() const { return numVerts; }
297 int getNumNormals() const { return numNorms; }
298 int getNumColors() const { return numColors; }
299 int getNumTexCoords() const { return numTexCoords; }
300
301 const char *getVertices(int i) const
302 { return vertexPtr + vertexStride*i; }
303 const char *getNormals(int i) const
304 { return normalPtr + normalStride*i; }
305 const char *getColors(int i) const
306 { return colorPtr + colorStride*i; }
307 const char *getTexCoords(int i) const
308 { return texCoordPtr + texCoordStride*i; }
309
310 bool colorIsInVtxProp() const {return colorIsInVP!=0;}
311
313 bool transpIsInVtxProp() const {return transpIsInVP!=0;}
314
315 int getVertexStride() const { return vertexStride; }
316 int getNormalStride() const { return normalStride; }
317 int getColorStride() const { return colorStride; }
318 int getTexCoordStride() const { return texCoordStride; }
319
321 { return (SoNormalBindingElement::Binding)normalBinding; }
322
324 { return (SoMaterialBindingElement::Binding)materialBinding; }
325
327 { return (SoTextureCoordinateBindingElement::Binding)texCoordBinding; }
328
329 void invalidate() { needFromState = ALL_FROM_STATE_BITS; }
330
331 void sendVertexAtIndex(const int32_t index);
332 void sendNormalAtIndex(const int32_t index);
333 void sendColorAtIndex(const int32_t index);
334 void sendTexCoordAtIndex(const int32_t index);
335
338
339 public:
340
343 const char *vertexPtr;
344 int vertexStride, numVerts;
346 const char *normalPtr;
347 int normalStride, numNorms;
349 const char *colorPtr;
350 int colorStride, numColors;
352 const char *texCoordPtr;
353 int texCoordStride, numTexCoords;
354
357
358 unsigned char needFromState;
359
373 SoINTERNAL public:
374 enum {
375 COLOR_BITS = 0x18,
376 PART_COLOR = 0x8,
377 FACE_COLOR = 0x10,
378 VERTEX_COLOR = 0x18,
379
380 NORMAL_BITS = 0x6,
381 PART_NORMAL = 0x2,
382 FACE_NORMAL = 0x4,
383 VERTEX_NORMAL = 0x6,
384
385 TEXCOORD_BIT = 0x1
386 };
391
392 enum {
393 TEXTURE_FUNCTION_BIT = 0x80,
394 OVERRIDE_FROM_STATE_BIT = 0x40,
395 COORD_FROM_STATE_BIT = 0x20,
396 COLOR_FROM_STATE_BITS = COLOR_BITS,
397 NORMAL_FROM_STATE_BITS = NORMAL_BITS,
398 TEXCOORD_FROM_STATE_BIT = TEXCOORD_BIT,
399 ALL_FROM_STATE_BITS = 0xFF
400 };
401 private:
402
408 unsigned char normalBinding;
409 unsigned char materialBinding;
410 unsigned char texCoordBinding;
411 unsigned char renderCase;
412 unsigned char colorIsInVP;
413 unsigned char transpIsInVP;
414};
415
416#endif /* _SO_VERTEX_PROPERTY */
417
#define SoEXTENDER
Provide inline template functions for abs, swap, min, max, and clamp.
Definition SbBasic.h:154
#define SoINTERNAL
Definition SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition SbSystem.h:77
signed int int32_t
Definition SbTypeDefs.h:43
#define SO_NODE_HEADER(className)
Non-abstract classes have everything abstract classes have, plus a way to create an instance.
Definition SoSubNode.h:170
void SoVPCacheFunc(const char *)
Description: The SoVertexPropertyCache class is a convenient way for vertex-based shapes to store inf...
Abstract base class for all actions.
Definition SoAction.h:179
Performs a generic traversal of the scene graph.
Renders a scene graph using OpenGL.
Computes bounding box of a scene.
Multiple-value field containing any number of uint32_tegers.
Definition SoMFUInt32.h:84
Multiple-value field containing any number of two-dimensional vectors.
Definition SoMFVec2f.h:83
Multiple-value field containing any number of three-dimensional vectors.
Definition SoMFVec3f.h:85
Binding
The (seemingly random) choice of values is for compatibility with Inventor 2.0 binary format files:
@ PER_VERTEX_INDEXED
One material for each vertex, indexed.
@ OVERALL
Whole object has same material.
@ PER_PART_INDEXED
One material for each part, indexed.
@ PER_VERTEX
One material for each vertex.
@ PER_FACE_INDEXED
One material for each face, indexed.
@ PER_FACE
One material for each face of object.
@ PER_PART
One material for each part of object.
Abstract base class for all database nodes.
Definition SoNode.h:103
Binding
The (seemingly random) choice of values is for compatibility with Inventor 2.0 binary format files:
Abstract base class for picking objects in a scene.
Field containing an enumerated value.
Definition SoSFEnum.h:93
This elements stores some information shapes need to quickly determine whether or not they should ren...
bool needTexCoords() const
Returns TRUE if need texture coordinates:
bool needNormals() const
Returns TRUE if need normals:
int getRenderCaseMask() const
Returns a mask that can be used by the SoVertexPropertyCache class (see SoVertexProperty....
An SoState collects and holds state while traversing a scene graph.
Definition SoState.h:82
Binding
The (seemingly random) choice of values is for compatibility with Inventor 2.0 binary format files:
SoVBO is used to manage OpenGL vertex buffer objects.
Definition SoVBO.h:52
SoTextureCoordinateBindingElement::Binding getTexCoordBinding()
bool shouldGenerateNormals(const SoShapeStyleElement *sse) const
void sendNormalAtIndex(const int32_t index)
SoVPCacheFunc * texCoordFunc
void sendColorAtIndex(const int32_t index)
void fillInColorAndTranspAvail(const SoVertexProperty *, SoState *state)
SoVPCacheFunc * vertexFunc
Tables of functions, data, and strides to increment through data.
void sendTexCoord(const char *tcp) const
void sendVertex(const char *vp) const
bool mightNeedSomethingFromState(const SoShapeStyleElement *sse) const
API used by shapes:
const char * getTexCoords(int i) const
void sendTexCoordAtIndex(const int32_t index)
int getRenderCase(const SoShapeStyleElement *sse) const
SoVertexPropertyCache()
Constructor. Initializes everything.
void sendVertexAtIndex(const int32_t index)
SoVPCacheFunc * normalFunc
bool transpIsInVtxProp() const
Indicates if non-opaque transparency is in vertex property.
void fillInCache(const SoVertexProperty *, SoState *)
SoMaterialBindingElement::Binding getMaterialBinding()
const char * getVertices(int i) const
void sendColor(const char *cp) const
const char * getNormals(int i) const
const char * getColors(int i) const
void sendNormal(const char *np) const
SoNormalBindingElement::Binding getNormalBinding()
SoVPCacheFunc * colorFunc
bool shouldGenerateTexCoords(const SoShapeStyleElement *sse) const
Vertex property node.
void putVBOsIntoState(SoState *state)
puts the VBOs into the SoGLVBOElement (MeVis ONLY)
virtual void doAction(SoAction *action)
This method performs the "typical" operation of a node for any action.
SoSFEnum materialBinding
Ignored unless orderedRGBA field set.
SoMFVec3f normal
Normal vector(s)
virtual ~SoVertexProperty()
SoSFEnum normalBinding
Ignored unless normal field set.
SoVertexProperty()
When traversed in a scene graph, sets coordinates, normals, texture coordinates, diffuse colors,...
virtual void pick(SoPickAction *action)
SoMFUInt32 orderedRGBA
Diffuse+transparency.
virtual void GLRender(SoGLRenderAction *action)
These virtual functions implement all of the actions for nodes, Most of the default implementations d...
virtual void getBoundingBox(SoGetBoundingBoxAction *action)
static void initClass()
virtual void callback(SoCallbackAction *action)
SoMFVec3f vertex
Fields:
SoMFVec2f texCoord
Texture coordinate(s)