Coin  4.0.10
Coin3D core library
Loading...
Searching...
No Matches
SoMultiTextureCoordinateElement.h
1#ifndef COIN_SOMULTITEXTURECOORDINATEELEMENT_H
2#define COIN_SOMULTITEXTURECOORDINATEELEMENT_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/elements/SoElement.h>
37#include <Inventor/elements/SoSubElement.h>
38#include <Inventor/SbVec2f.h>
39#include <Inventor/SbVec3f.h>
40#include <Inventor/SbVec4f.h>
41
42typedef const SbVec4f & SoTextureCoordinateFunctionCB(void * userdata,
43 const SbVec3f & point,
44 const SbVec3f & normal);
45
46class SoMultiTextureCoordinateElementP;
47
48class COIN_DLL_API SoMultiTextureCoordinateElement : public SoElement {
49 typedef SoElement inherited;
50
51 SO_ELEMENT_HEADER(SoMultiTextureCoordinateElement);
52public:
53 static void initClass(void);
54protected:
56
57public:
58
59 enum CoordType {
60 NONE = 0,
61 TEXGEN = 0,
62 EXPLICIT = 1,
63 FUNCTION = 2,
64 DEFAULT = 3
65 };
66
67 void init(SoState * state) override;
68
69 static void setDefault(SoState * const state, SoNode * const node, const int unit = 0);
70 static void setFunction(SoState * const state, SoNode * const node,
71 const int unit,
72 SoTextureCoordinateFunctionCB * const func,
73 void * const userdata);
74
75 static void set2(SoState * const state, SoNode * const node,
76 const int unit,
77 const int32_t numCoords, const SbVec2f * const coords);
78 static void set3(SoState * const state, SoNode * const node,
79 const int unit,
80 const int32_t numCoords, const SbVec3f * const coords);
81 static void set4(SoState * const state, SoNode * const node,
82 const int unit,
83 const int32_t numCoords, const SbVec4f * const coords);
84
85 static CoordType getType(SoState * const state, const int unit = 0);
86 virtual CoordType getType(const int unit = 0) const;
87
88 static const SoMultiTextureCoordinateElement * getInstance(SoState * const state);
89
90 const SbVec4f & get(const int unit,
91 const SbVec3f & point,
92 const SbVec3f & normal) const;
93
94 int32_t getNum(const int unit = 0) const;
95 SbBool is2D(const int unit = 0) const;
96 int32_t getDimension(const int unit = 0) const;
97
98 const SbVec2f & get2(const int unit, const int index) const;
99 const SbVec3f & get3(const int unit, const int index) const;
100 const SbVec4f & get4(const int unit, const int index) const;
101
102 const SbVec2f * getArrayPtr2(const int unit = 0) const;
103 const SbVec3f * getArrayPtr3(const int unit = 0) const;
104 const SbVec4f * getArrayPtr4(const int unit = 0) const;
105
106 class UnitData {
107 public:
108 UnitData();
109 UnitData(const UnitData & org);
110 UnitData & operator=(const UnitData & org) = default;
111
112 SbUniqueId nodeid;
113 CoordType whatKind;
114 SoTextureCoordinateFunctionCB * funcCB;
115 void * funcCBData;
116 int32_t numCoords;
117 const SbVec2f * coords2;
118 const SbVec3f * coords3;
119 const SbVec4f * coords4;
120 int coordsDimension;
121 };
122
123 void push(SoState * state) override;
124 SbBool matches(const SoElement * elem) const override;
125 SoElement * copyMatchInfo(void) const override;
126
127 // Coin-3 support
128 const SbVec4f & get(const SbVec3f & point,
129 const SbVec3f & normal) const {
130 return this->get(0, point, normal);
131 }
132
133 static void setFunction(SoState * const state,
134 SoNode * const node,
135 SoTextureCoordinateFunctionCB * const func,
136 void * const userdata) {
137 setFunction(state, node, 0, func, userdata);
138 }
139
140 static void set2(SoState * const state, SoNode * const node,
141 const int32_t numCoords, const SbVec2f * const coords) {
142 set2(state, node, 0, numCoords, coords);
143 }
144 static void set3(SoState * const state, SoNode * const node,
145 const int32_t numCoords, const SbVec3f * const coords) {
146 set3(state, node, 0, numCoords, coords);
147 }
148 static void set4(SoState * const state, SoNode * const node,
149 const int32_t numCoords, const SbVec4f * const coords) {
150 set4(state, node, 0, numCoords, coords);
151 }
152 const SbVec2f & get2(const int index) const {
153 return this->get2(0, index);
154 }
155 const SbVec3f & get3(const int index) const {
156 return this->get3(0, index);
157 }
158 const SbVec4f & get4(const int index) const {
159 return this->get4(0, index);
160 }
161
162
163protected:
164 int getMaxUnits() const;
165 UnitData & getUnitData(const int unit);
166 const UnitData & getUnitData(const int unit) const;
167 SbVec2f convert2;
168 SbVec3f convert3;
169 SbVec4f convert4;
170
171private:
172 SoMultiTextureCoordinateElementP * pimpl;
173};
174
175#endif // !COIN_SOMULTITEXTURECOORDINATEELEMENT_H
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition SbVec2f.h:49
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition SbVec3f.h:51
The SbVec4f class is a 4 dimensional vector with floating point coordinates.
Definition SbVec4f.h:49
SoElement is the abstract base class for all elements.
Definition SoElement.h:43
virtual SoElement * copyMatchInfo(void) const =0
virtual SbBool matches(const SoElement *element) const =0
Definition SoElement.cpp:609
static void initClass(void)
Definition SoElement.cpp:507
virtual void init(SoState *state)
Definition SoElement.cpp:553
virtual void push(SoState *state)
Definition SoElement.cpp:570
Definition SoMultiTextureCoordinateElement.h:106
The SoMultiTextureCoordinateElement class is yet to be documented.
Definition SoMultiTextureCoordinateElement.h:48
The SoNode class is the base class for nodes used in scene graphs.
Definition SoNode.h:56
The SoState class manages the Coin scene graph traversal state data.
Definition SoState.h:44