1 /**************************************************************************\
2  * Copyright (c) Kongsberg Oil & Gas Technologies AS
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  *
12  * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * Neither the name of the copyright holder nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 \**************************************************************************/
32 
33 /*!
34   \class SoBumpMapCoordinateElement Inventor/elements/SoBumpMapCoordinateElement.h
35   \brief The SoBumpMapCoordinateElement class is yet to be documented.
36 
37   \ingroup elements
38 
39   FIXME: write doc.
40 */
41 
42 #include <Inventor/elements/SoBumpMapCoordinateElement.h>
43 
44 #include <cassert>
45 
46 #include <Inventor/errors/SoDebugError.h>
47 #include <Inventor/nodes/SoNode.h>
48 
49 #include "tidbitsp.h"
50 #include "SbBasicP.h"
51 
52 /*!
53   \fn SoBumpMapCoordinateElement::numcoords
54 
55   FIXME: write doc.
56 */
57 
58 /*!
59   \fn SoBumpMapCoordinateElement::coords
60 
61   FIXME: write doc.
62 */
63 
64 
65 SO_ELEMENT_SOURCE(SoBumpMapCoordinateElement);
66 
67 /*!
68   This static method initializes static data for the
69   SoBumpMapCoordinateElement class.
70 */
71 
72 void
initClass(void)73 SoBumpMapCoordinateElement::initClass(void)
74 {
75   SO_ELEMENT_INIT_CLASS(SoBumpMapCoordinateElement, inherited);
76 }
77 
78 /*!
79   The destructor.
80 */
81 
~SoBumpMapCoordinateElement(void)82 SoBumpMapCoordinateElement::~SoBumpMapCoordinateElement(void)
83 {
84 }
85 
86 //! FIXME: write doc.
87 
88 void
init(SoState * state)89 SoBumpMapCoordinateElement::init(SoState * state)
90 {
91   inherited::init(state);
92   this->numcoords = 0;
93   this->coords = NULL;
94 }
95 
96 //! FIXME: write doc.
97 
98 void
set(SoState * state,SoNode * node,const int32_t numcoords,const SbVec2f * coords)99 SoBumpMapCoordinateElement::set(SoState * state,
100                                 SoNode * node,
101                                 const int32_t numcoords,
102                                 const SbVec2f * coords)
103 {
104   SoBumpMapCoordinateElement * elem = coin_assert_cast<SoBumpMapCoordinateElement *>
105     (SoReplacedElement::getElement(state, classStackIndex, node));
106   elem->coords = coords;
107   elem->numcoords = numcoords;
108 }
109 
110 //! FIXME: write doc.
111 
112 const SbVec2f &
get(const int index) const113 SoBumpMapCoordinateElement::get(const int index) const
114 {
115   assert(index >= 0 && index < this->numcoords);
116   return this->coords[index];
117 }
118 
119 
120 //! FIXME: write doc.
121 
122 const SoBumpMapCoordinateElement *
getInstance(SoState * state)123 SoBumpMapCoordinateElement::getInstance(SoState * state)
124 {
125   return coin_assert_cast<const SoBumpMapCoordinateElement *>
126     (getConstElement(state, classStackIndex));
127 }
128 
129 //! FIXME: write doc.
130 
131 int32_t
getNum(void) const132 SoBumpMapCoordinateElement::getNum(void) const
133 {
134   return this->numcoords;
135 }
136 
137 //! FIXME: write doc.
138 
139 const SbVec2f *
getArrayPtr(void) const140 SoBumpMapCoordinateElement::getArrayPtr(void) const
141 {
142   return this->coords;
143 }
144