Coin  4.0.10
Coin3D core library
Loading...
Searching...
No Matches
SoGLMultiTextureCoordinateElement.h
1#ifndef COIN_SOGLMULTITEXTURECOORDINATEELEMENT_H
2#define COIN_SOGLMULTITEXTURECOORDINATEELEMENT_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/SoMultiTextureCoordinateElement.h>
37
38class SoGLMultiTextureCoordinateElementP;
39typedef void SoTexCoordTexgenCB(void * data);
40
43
44 SO_ELEMENT_HEADER(SoGLMultiTextureCoordinateElement);
45public:
46 static void initClass(void);
47protected:
49
50public:
51 void init(SoState * state) override;
52 void push(SoState * state) override;
53 void pop(SoState * state, const SoElement * prevTopElement) override;
54
55 static void setTexGen(SoState * const state, SoNode * const node,
56 const int unit,
57 SoTexCoordTexgenCB * const texgenFunc,
58 void * const texgenData = NULL,
59 SoTextureCoordinateFunctionCB * const func = NULL,
60 void * const funcData = NULL);
61
62 CoordType getType(const int unit = 0) const override;
63
64 static const SoGLMultiTextureCoordinateElement * getInstance(SoState * const state);
65
66 void send(const int unit, const int index) const;
67 void send(const int unit, const int index, const SbVec3f &c, const SbVec3f &n) const;
68
69 class GLUnitData {
70 public:
71 GLUnitData() : texgenCB(NULL), texgenData(NULL) {}
72 GLUnitData(const GLUnitData & org) : texgenCB(org.texgenCB), texgenData(org.texgenData) {}
73 SoTexCoordTexgenCB * texgenCB;
74 void * texgenData;
75 };
76
77 void initRender(const SbBool * enabled, const int maxenabled) const;
78
79 // Coin-3 support
80 void send(const int index) const {
81 for (int i = 0; i <= this->multimax; i++) {
82 if (this->multienabled[i]) {
83 this->send(i, index);
84 }
85 }
86 }
87 void send(const int index, const SbVec3f &c, const SbVec3f &n) const {
88 for (int i = 0; i <= this->multimax; i++) {
89 if (this->multienabled[i]) {
90 this->send(i, index, c, n);
91 }
92 }
93 }
94 void initMulti(SoState * state) const;
95 static void setTexGen(SoState * const state, SoNode * const node,
96 SoTexCoordTexgenCB * const texgenFunc,
97 void * const texgenData = NULL,
98 SoTextureCoordinateFunctionCB * const func = NULL,
99 void * const funcData = NULL) {
100 setTexGen(state, node, 0, texgenFunc, texgenData, func, funcData);
101 }
102
103protected:
104 virtual void setElt(const int unit,
105 SoTexCoordTexgenCB *func,
106 void *data = NULL);
107
108private:
109 void doCallback(const int unit) const;
110 SoGLMultiTextureCoordinateElementP * pimpl;
111 mutable const SbBool * multienabled;
112 mutable int multimax;
113};
114
115#endif // !COIN_SOGLMULTITEXTURECOORDINATEELEMENT_H
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition SbVec3f.h:51
SoElement is the abstract base class for all elements.
Definition SoElement.h:43
virtual void pop(SoState *state, const SoElement *prevTopElement)
Definition SoElement.cpp:585
Definition SoGLMultiTextureCoordinateElement.h:69
The SoGLMultiTextureCoordinateElement class stores the current gltexture coordinates for several unit...
Definition SoGLMultiTextureCoordinateElement.h:41
The SoMultiTextureCoordinateElement class is yet to be documented.
Definition SoMultiTextureCoordinateElement.h:48
static CoordType getType(SoState *const state, const int unit=0)
Definition SoMultiTextureCoordinateElement.cpp:409
static const SoMultiTextureCoordinateElement * getInstance(SoState *const state)
FIXME: write doc.
Definition SoMultiTextureCoordinateElement.cpp:271
void push(SoState *state) override
Definition SoMultiTextureCoordinateElement.cpp:507
static void initClass(void)
Definition SoMultiTextureCoordinateElement.cpp:101
void init(SoState *state) override
FIXME: write doc.
Definition SoMultiTextureCoordinateElement.cpp:431
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