Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
InterleavedArraysShape.h
Go to the documentation of this file.
1 #ifndef INTERLEAVEDARRAYSSHAPE_H
2 #define INTERLEAVEDARRAYSSHAPE_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <Inventor/nodes/SoSubNode.h>
37 #include <Inventor/nodes/SoVertexShape.h>
38 #include <Inventor/fields/SoMFInt32.h>
39 #include <Inventor/fields/SoSFEnum.h>
40 
41 class SoPickedPoint;
42 
43 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
44 #include <SoWinLeaveScope.h>
45 #endif // win
46 
47 #include <SmallChange/basic.h>
48 
49 class SMALLCHANGE_DLL_API InterleavedArraysShape : public SoVertexShape {
50  typedef SoShape inherited;
51 
53 
54  public:
55  static void initClass(void);
57 
58  enum Type {
63  TRIANGLE_STRIP,
64  QUAD_STRIP
65  };
66 
69 
70  virtual void GLRender(SoGLRenderAction * action);
71  virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
72  virtual void rayPick(SoRayPickAction * action);
73 
74 protected:
75  virtual void notify(SoNotList * nl);
76  virtual ~InterleavedArraysShape();
77  virtual void generatePrimitives(SoAction * action);
78  virtual void computeBBox(SoAction * action, SbBox3f & box, SbVec3f & center);
79 
80 private:
81  enum Binding {
82  OVERALL,
83  PER_VERTEX
84  };
85 
86  SbBool shouldIncrementFaceIndex(Type type, int i) const;
87  SoPickedPoint * tryPickTriangle(SoRayPickAction * action,
88  const SbVec3f * vertices,
89  int v0, int v1, int v2,
90  SbVec3f & barycentric);
91 
92  Binding findMaterialBinding(SoState * state) const;
93  Binding findNormalBinding(SoState * state) const;
94  void enableArrays(SoGLRenderAction * action, SbBool normals, SbBool colors, SbBool texcoords);
95  void disableArrays(SoGLRenderAction * action, SbBool normals, SbBool colors, SbBool texcoords);
96  void createVBO(uint32_t contextid);
97  void createIndexVBO(uint32_t contextid);
98  class Pimpl;
99  Pimpl * pimpl;
100  class VBO;
101 };
102 
103 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
104 #include <SoWinEnterScope.h>
105 #endif // win
106 
107 #endif // INTERLEAVEDARRAYSSHAPE_H
#define SO_NODE_HEADER(classname)
virtual void GLRender(SoGLRenderAction *action)
SoSFEnum type
Definition: InterleavedArraysShape.h:67
virtual void notify(SoNotList *nl)
SoMFInt32 vertexIndex
Definition: InterleavedArraysShape.h:68
Definition: InterleavedArraysShape.h:61
Type
Definition: InterleavedArraysShape.h:58
Definition: InterleavedArraysShape.h:60
Definition: InterleavedArraysShape.h:59
virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action)
static void initClass(void)
virtual void generatePrimitives(SoAction *action)=0
virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center)=0
Definition: InterleavedArraysShape.h:62
The InterleavedArraysShape class is used to render static geometry very fast.
Definition: InterleavedArraysShape.h:49
virtual void rayPick(SoRayPickAction *action)