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 SoBumpMapCoordinate SoBumpMapCoordinate.h Inventor/nodes/SoBumpMapCoordinate.h
35   \brief The SoBumpMapCoordinate class is a node for providing bump map coordinates to shape nodes.
36 
37   \ingroup nodes
38 
39   When encountering nodes of this type during traversal, the
40   coordinates it contains will be put on the state stack for later use
41   by shape nodes. The bump map coordinates can be used to specify
42   explicit coordinates for a bump map. The SoBumpMap node is used to
43   specify a bump map for the shape nodes.
44 
45   Note that an SoBumpMapCoordinate node will \e replace the bump map
46   coordinates already present in the state (if any).
47 
48   Also note that since the indexed shape nodes have no
49   bumpMapCoordIndex field, the textureCoordIndex field will be used
50   for selecting bump map coordinate indices. You can set the bump map
51   coordinate binding using the SoTextureCoordinateBinding node. Bump
52   map coordinates must therefore have the same binding as the texture
53   coordinates for texture unit 0.
54 
55   If you supply no bump map coordinates for a shape, the texture
56   coordinates for texture unit 0 will be used.
57 
58   <b>FILE FORMAT/DEFAULTS:</b>
59   \code
60     BumpMapCoordinate {
61         point [  ]
62     }
63   \endcode
64 
65   \since Coin 2.2
66 */
67 
68 #include <Inventor/nodes/SoBumpMapCoordinate.h>
69 
70 #include <Inventor/actions/SoGLRenderAction.h>
71 #include <Inventor/actions/SoCallbackAction.h>
72 #include <Inventor/actions/SoRayPickAction.h>
73 #include <Inventor/elements/SoBumpMapCoordinateElement.h>
74 
75 #include "nodes/SoSubNodeP.h"
76 
77 /*!
78   \var SoMFVec3f SoBumpMapCoordinate::point
79   Set of 2D points. Contains no points by default.
80 */
81 
82 
83 // *************************************************************************
84 
85 SO_NODE_SOURCE(SoBumpMapCoordinate);
86 
87 /*!
88   Constructor.
89 */
SoBumpMapCoordinate(void)90 SoBumpMapCoordinate::SoBumpMapCoordinate(void)
91 {
92   SO_NODE_INTERNAL_CONSTRUCTOR(SoBumpMapCoordinate);
93 
94   SO_NODE_ADD_FIELD(point, (0.0f, 0.0f));
95   this->point.setNum(0);
96   this->point.setDefault(TRUE);
97 }
98 
99 /*!
100   Destructor.
101 */
~SoBumpMapCoordinate()102 SoBumpMapCoordinate::~SoBumpMapCoordinate()
103 {
104 }
105 
106 // Doc from superclass.
107 void
initClass(void)108 SoBumpMapCoordinate::initClass(void)
109 {
110   SO_NODE_INTERNAL_INIT_CLASS(SoBumpMapCoordinate, SO_FROM_COIN_2_2);
111 
112   SO_ENABLE(SoGLRenderAction, SoBumpMapCoordinateElement);
113   SO_ENABLE(SoCallbackAction, SoBumpMapCoordinateElement);
114   SO_ENABLE(SoPickAction, SoBumpMapCoordinateElement);
115 }
116 
117 // Doc from superclass.
118 void
doAction(SoAction * action)119 SoBumpMapCoordinate::doAction(SoAction * action)
120 {
121   SoBumpMapCoordinateElement::set(action->getState(), this,
122                                   point.getNum(), point.getValues(0));
123 }
124 
125 // Doc from superclass.
126 void
GLRender(SoGLRenderAction * action)127 SoBumpMapCoordinate::GLRender(SoGLRenderAction * action)
128 {
129   SoBumpMapCoordinateElement::set(action->getState(), this,
130                                   point.getNum(), point.getValues(0));
131 }
132 
133 // Doc from superclass.
134 void
callback(SoCallbackAction * action)135 SoBumpMapCoordinate::callback(SoCallbackAction * action)
136 {
137   SoBumpMapCoordinate::doAction((SoAction*)action);
138 }
139 
140 // Doc from superclass.
141 void
pick(SoPickAction * action)142 SoBumpMapCoordinate::pick(SoPickAction * action)
143 {
144   SoBumpMapCoordinate::doAction((SoAction*) action);
145 }
146