Coin: SoPrimitiveVertexCache.h Source File

| Coin3D is Free Software, published under the BSD 3-clause license. | https://coin3d.github.io https://www.kongsberg.com/en/kogt/

SoPrimitiveVertexCache.h
1#ifndef COIN_SOPRIMITIVEVERTEXCACHE_H
2#define COIN_SOPRIMITIVEVERTEXCACHE_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/caches/SoCache.h>
37#include <Inventor/system/gl.h>
38#include <Inventor/SbVec3f.h>
39#include <Inventor/SbVec4f.h>
40#include <Inventor/SbVec2f.h>
41#include <Inventor/tools/SbPimplPtr.h>
42
43class SoPrimitiveVertexCacheP;
44class SoPrimitiveVertex;
45class SoPointDetail;
46class SoState;
47
48 class COIN_DLL_API SoPrimitiveVertexCache : public SoCache {
49 typedef SoCache inherited;
50public:
51 SoPrimitiveVertexCache(SoState * state);
52 virtual ~SoPrimitiveVertexCache();
53
54 enum Arrays {
55 NORMAL = 0x01,
56 TEXCOORD = 0x02,
57 COLOR = 0x04,
58 ALL = (NORMAL|TEXCOORD|COLOR)
59 };
60
61 virtual SbBool isValid(const SoState * state) const;
62 void close(SoState * state);
63
64 void renderTriangles(SoState * state, const int arrays = ALL) const;
65 void renderLines(SoState * state, const int arrays = ALL) const;
66 void renderPoints(SoState * state, const int array = ALL) const;
67
68 void addTriangle(const SoPrimitiveVertex * v0,
69 const SoPrimitiveVertex * v1,
70 const SoPrimitiveVertex * v2,
71 const int * pointdetailidx = NULL);
72 void addLine(const SoPrimitiveVertex * v0,
73 const SoPrimitiveVertex * v1);
74 void addPoint(const SoPrimitiveVertex * v);
75
76 int getNumVertices(void) const;
77 const SbVec3f * getVertexArray(void) const;
78 const SbVec3f * getNormalArray(void) const;
79 const SbVec4f * getTexCoordArray(void) const;
80 const SbVec2f * getBumpCoordArray(void) const;
81 const uint8_t * getColorArray(void) const;
82
83 int getNumTriangleIndices(void) const;
84 const GLint * getTriangleIndices(void) const;
85 int32_t getTriangleIndex(const int idx) const;
86
87 SbBool colorPerVertex(void) const;
88 const SbVec4f * getMultiTextureCoordinateArray(const int unit) const;
89
90 int getNumLineIndices(void) const;
91 const GLint * getLineIndices(void) const;
92
93 int getNumPointIndices(void) const;
94 const GLint * getPointIndices(void) const;
95
96 void fit(void);
97 void depthSortTriangles(SoState * state);
98
99private:
100 SbPimplPtr<SoPrimitiveVertexCacheP> pimpl;
101
102 SoPrimitiveVertexCache(const SoPrimitiveVertexCache & rhs); // N/A
103 SoPrimitiveVertexCache & operator = (const SoPrimitiveVertexCache & rhs); // N/A
104
105};
106
107#endif // COIN_SOPRIMITIVEVERTEXCACHE_H
SbPimplPtr
Definition SbPimplPtr.h:55
SbVec2f
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition SbVec2f.h:49
SbVec3f
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition SbVec3f.h:51
SbVec4f
The SbVec4f class is a 4 dimensional vector with floating point coordinates.
Definition SbVec4f.h:49
SoCache::SoCache
SoCache(SoState *const state)
Definition SoCache.cpp:153
SoCache::isValid
virtual SbBool isValid(const SoState *state) const
Definition SoCache.cpp:257
SoPointDetail
The SoPointDetail class is for storing detailed information for a single 3D point.
Definition SoPointDetail.h:38
SoPrimitiveVertexCache::SoPrimitiveVertexCache
SoPrimitiveVertexCache(SoState *state)
Definition SoPrimitiveVertexCache.cpp:249
SoPrimitiveVertexCache::close
void close(SoState *state)
Definition SoPrimitiveVertexCache.cpp:341
SoPrimitiveVertex
The SoPrimitiveVertex class represents a single vertex of a generated primitive.
Definition SoPrimitiveVertex.h:43
SoState
The SoState class manages the Coin scene graph traversal state data.
Definition SoState.h:44