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 #ifdef HAVE_CONFIG_H
34 #include <config.h>
35 #endif // HAVE_CONFIG_H
36
37 #ifdef HAVE_VRML97
38
39 /*!
40 \class SoVRMLNavigationInfo SoVRMLNavigationInfo.h Inventor/VRMLnodes/SoVRMLNavigationInfo.h
41 \brief The SoVRMLNavigationInfo class is used to specify avatar and viewer settings.
42
43 \ingroup VRMLnodes
44
45 \WEB3DCOPYRIGHT
46
47 \verbatim
48 NavigationInfo {
49 eventIn SFBool set_bind
50 exposedField MFFloat avatarSize [0.25, 1.6, 0.75] # [0, inf)
51 exposedField SFBool headlight TRUE
52 exposedField SFFloat speed 1.0 # [0, inf)
53 exposedField MFString type ["WALK", "ANY"]
54 exposedField SFFloat visibilityLimit 0.0 # [0, inf)
55 eventOut SFBool isBound
56 }
57 \endverbatim
58
59 The NavigationInfo node contains information describing the physical
60 characteristics of the viewer's avatar and viewing
61 model. NavigationInfo node is a bindable node (see 4.6.10, Bindable
62 children nodes:
63 http://www.web3d.org/documents/specifications/14772/V2.0/part1/concepts.html#4.6.10).
64 Thus, there exists a NavigationInfo node stack in which the top-most
65 NavigationInfo node on the stack is the currently bound
66 NavigationInfo node. The current NavigationInfo node is considered
67 to be a child of the current Viewpoint node regardless of where it
68 is initially located in the VRML file. Whenever the current
69 Viewpoint nodes changes, the current NavigationInfo node shall be
70 re-parented to it by the browser. Whenever the current
71 NavigationInfo node changes, the new NavigationInfo node shall be
72 re-parented to the current Viewpoint node by the browser. If a TRUE
73 value is sent to the set_bind eventIn of a NavigationInfo node, the
74 node is pushed onto the top of the NavigationInfo node stack. When a
75 NavigationInfo node is bound, the browser uses the fields of the
76 NavigationInfo node to set the navigation controls of its user
77 interface and the NavigationInfo node is conceptually re-parented
78 under the currently bound Viewpoint node. All subsequent scaling
79 changes to the current Viewpoint node's coordinate system
80 automatically change aspects (see below) of the NavigationInfo node
81 values used in the browser (e.g., scale changes to any ancestors'
82 transformations). A FALSE value sent to set_bind pops the
83 NavigationInfo node from the stack, results in an isBound FALSE
84 event, and pops to the next entry in the stack which shall be
85 re-parented to the current Viewpoint node. 4.6.10, Bindable children
86 nodes, has more details on binding stacks
87 (<http://www.web3d.org/documents/specifications/14772/V2.0/part1/concepts.html#4.6.10>).
88
89 The type field specifies an ordered list of navigation paradigms
90 that specify a combination of navigation types and the initial
91 navigation type. The navigation type of the currently bound
92 NavigationInfo node determines the user interface capabilities of
93 the browser. For example, if the currently bound NavigationInfo
94 node's type is "WALK", the browser shall present a WALK navigation
95 user interface paradigm (see below for description of
96 WALK). Browsers shall recognize and support at least the following
97 navigation types: "ANY", "WALK", "EXAMINE", "FLY", and "NONE".
98
99 If "ANY" does not appear in the type field list of the
100 currently bound NavigationInfo, the browser's navigation user
101 interface shall be restricted to the recognized navigation types
102 specified in the list. In this case, browsers shall not present a
103 user interface that allows the navigation type to be changed to a
104 type not specified in the list. However, if any one of the values in
105 the type field are "ANY", the browser may provide any type of
106 navigation interface, and allow the user to change the navigation
107 type dynamically. Furthermore, the first recognized type in the list
108 shall be the initial navigation type presented by the browser's user
109 interface.
110
111 ANY navigation specifies that the browser may choose the
112 navigation paradigm that best suits the content and provide a user
113 interface to allow the user to change the navigation paradigm
114 dynamically. The results are undefined if the currently bound
115 NavigationInfo's type value is "ANY" and Viewpoint transitions (see
116 SoVRMLViewpoint) are triggered by the Anchor node (see SoVRMLAnchor)
117 or the loadURL()scripting method (see 4.12.10, Browser script
118 interface:
119 (<http://www.web3d.org/documents/specifications/14772/V2.0/part1/concepts.html#4.6.10>).
120
121 WALK navigation is used for exploring a virtual world
122 on foot or in a vehicle that rests on or hovers above the ground. It
123 is strongly recommended that WALK navigation define the up vector in
124 the +Y direction and provide some form of terrain following and
125 gravity in order to produce a walking or driving experience. If the
126 bound NavigationInfo's type is "WALK", the browser shall strictly
127 support collision detection (see SoVRMLCollision).
128
129 FLY navigation is similar to WALK except that terrain following and
130 gravity may be disabled or ignored. There shall still be some notion
131 of "up" however. If the bound NavigationInfo's type is "FLY", the
132 browser shall strictly support collision detection (see 6.8,
133 Collision).
134
135 EXAMINE navigation is used for viewing individual objects and often
136 includes (but does not require) the ability to spin around the
137 object and move the viewer closer or further away.
138
139 NONE navigation disables and removes all browser-specific navigation
140 user interface forcing the user to navigate using only mechanisms
141 provided in the scene, such as Anchor nodes or scripts that include
142 loadURL().
143
144 If the NavigationInfo type is "WALK", "FLY", "EXAMINE", or "NONE" or
145 a combination of these types (i.e., "ANY" is not in the list),
146 Viewpoint transitions (see SoVRMLViewpoint) triggered by the Anchor
147 node (see SoVRMLAnchor) or the loadURL() scripting method shall be
148 implemented as a jump cut from the old Viewpoint to the new
149 Viewpoint with transition effects that shall not trigger events
150 besides the exit and enter events caused by the jump.
151
152 Browsers may create browser-specific navigation type extensions. It
153 is recommended that extended type names include a unique suffix
154 (e.g., HELICOPTER_mydomain.com) to prevent conflicts.
155
156 Viewpoint transitions (see SoVRMLViewpoint) triggered by the Anchor
157 node (see SoVRMLAnchor) or the loadURL() scripting method are
158 undefined for extended navigation types. If none of the types are
159 recognized by the browser, the default "ANY" is used. These strings
160 values are case sensitive ("any" is not equal to "ANY").
161
162 The speed field specifies the rate at which the viewer
163 travels through a scene in metres per second. Since browsers may
164 provide mechanisms to travel faster or slower, this field specifies
165 the default, average speed of the viewer when the NavigationInfo
166 node is bound. If the NavigationInfo type is EXAMINE, speed shall not affect the
167 viewer's rotational speed. Scaling in the transformation hierarchy
168 of the currently bound Viewpoint node (see above) scales the speed;
169 parent translation and rotation transformations have no effect on
170 speed. Speed shall be non-negative. Zero speed indicates that the
171 avatar's position is stationary, but its orientation and field of
172 view may still change. If the navigation type is "NONE", the speed
173 field has no effect.
174
175 The avatarSize field specifies the user's physical dimensions in the
176 world for the purpose of collision detection and terrain following.
177 It is a multi-value field allowing several dimensions to be
178 specified. The first value shall be the allowable distance between
179 the user's position and any collision geometry (as specified by a
180 Collision node ) before a collision is detected. The second shall be
181 the height above the terrain at which the browser shall maintain the
182 viewer. The third shall be the height of the tallest object over
183 which the viewer can move. This allows staircases to be built with
184 dimensions that can be ascended by viewers in all browsers. The
185 transformation hierarchy of the currently bound Viewpoint node
186 scales the avatarSize. Translations and rotations have no effect on
187 avatarSize.
188
189 For purposes of terrain following, the browser maintains a notion of
190 the down direction (down vector), since gravity is applied in the
191 direction of the down vector. This down vector shall be along the
192 negative Y-axis in the local coordinate system of the currently
193 bound Viewpoint node (i.e., the accumulation of the Viewpoint node's
194 ancestors' transformations, not including the Viewpoint node's
195 orientation field).
196
197 Geometry beyond the visibilityLimit may not be rendered. A value of
198 0.0 indicates an infinite visibility limit. The visibilityLimit
199 field is restricted to be greater than or equal to zero.
200
201 The speed, avatarSize and visibilityLimit values are all scaled by
202 the transformation being applied to the currently bound Viewpoint
203 node. If there is no currently bound Viewpoint node, the values are
204 interpreted in the world coordinate system. This allows these
205 values to be automatically adjusted when binding to a Viewpoint node
206 that has a scaling transformation applied to it without requiring a
207 new NavigationInfo node to be bound as well. The results are
208 undefined if the scale applied to the Viewpoint node is non-uniform.
209
210 The headlight field specifies whether a browser shall turn on a
211 headlight. A headlight is a directional light that always points in
212 the direction the user is looking. Setting this field to TRUE allows
213 the browser to provide a headlight, possibly with user interface
214 controls to turn it on and off. Scenes that enlist precomputed
215 lighting (e.g., radiosity solutions) can turn the headlight off. The
216 headlight shall have intensity = 1, color = (1 1 1),
217 ambientIntensity = 0.0, and direction = (0 0 -1).
218
219 It is recommended that the near clipping plane be set to one-half of
220 the collision radius as specified in the avatarSize field (setting
221 the near plane to this value prevents excessive clipping of objects
222 just above the collision volume, and also provides a region inside
223 the collision volume for content authors to include geometry
224 intended to remain fixed relative to the viewer). Such geometry
225 shall not be occluded by geometry outside of the collision volume.
226
227 */
228
229 /*!
230 \var SoMFString SoVRMLNavigationInfo::type
231 Types of viewer. Possible values are "WALK", "ANY", "EXAMINE", "FLY" and "NONE".
232 Is set to "WALK" and "ANY" by default.
233 */
234
235 /*!
236 \var SoSFFloat SoVRMLNavigationInfo::speed
237 Navigation speed. Default value is 1.0.
238 */
239
240 /*!
241 \var SoMFFloat SoVRMLNavigationInfo::avatarSize
242 Size of avatar. Default value is (0.25, 1.6, 0.75).
243 */
244
245 /*!
246 \var SoSFFloat SoVRMLNavigationInfo::visibilityLimit
247 Visibility limit. Default value is 0.0.
248 */
249
250 /*!
251 \var SoSFBool SoVRMLNavigationInfo::headlight
252 Specifies whether headlight should be enabled. Default value is TRUE.
253 */
254
255
256 #include <Inventor/VRMLnodes/SoVRMLNavigationInfo.h>
257 #include "coindefs.h"
258
259 #include <Inventor/VRMLnodes/SoVRMLMacros.h>
260
261 #include "nodes/SoSubNodeP.h"
262
263 SO_NODE_SOURCE(SoVRMLNavigationInfo);
264
265 // Doc in parent
266 void
initClass(void)267 SoVRMLNavigationInfo::initClass(void) // static
268 {
269 SO_NODE_INTERNAL_INIT_CLASS(SoVRMLNavigationInfo, SO_VRML97_NODE_TYPE);
270 }
271
272 /*!
273 Constructor.
274 */
SoVRMLNavigationInfo(void)275 SoVRMLNavigationInfo::SoVRMLNavigationInfo(void)
276 {
277 SO_VRMLNODE_INTERNAL_CONSTRUCTOR(SoVRMLNavigationInfo);
278
279 SO_VRMLNODE_ADD_EXPOSED_FIELD(type, ("WALK"));
280 this->type.setNum(2);
281 this->type.set1Value(1, "ANY");
282 this->type.setDefault(TRUE);
283
284 SO_VRMLNODE_ADD_EXPOSED_FIELD(speed, (1.0f));
285 SO_VRMLNODE_ADD_EXPOSED_FIELD(avatarSize, (0.25f));
286 this->avatarSize.setNum(3);
287 this->avatarSize.set1Value(1, 1.6f);
288 this->avatarSize.set1Value(2, 0.75f);
289 this->avatarSize.setDefault(TRUE);
290
291 SO_VRMLNODE_ADD_EXPOSED_FIELD(visibilityLimit, (0.0f));
292 SO_VRMLNODE_ADD_EXPOSED_FIELD(headlight, (TRUE));
293
294 SO_VRMLNODE_ADD_EVENT_IN(set_bind);
295 SO_VRMLNODE_ADD_EVENT_OUT(isBound);
296 }
297
298 /*!
299 Destructor.
300 */
~SoVRMLNavigationInfo()301 SoVRMLNavigationInfo::~SoVRMLNavigationInfo() // virtual, protected
302 {
303 }
304
305 // Doc in parent
306 void
GLRender(SoGLRenderAction * COIN_UNUSED_ARG (action))307 SoVRMLNavigationInfo::GLRender(SoGLRenderAction * COIN_UNUSED_ARG(action))
308 {
309 }
310
311 #endif // HAVE_VRML97
312