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 SoAudioRenderAction SoAudioRenderAction.h Inventor/actions/SoAudioRenderAction.h
35 \brief The SoAudioRenderAction class renders the aural parts of the scene graph.
36
37 \ingroup actions
38
39 Applying this method at a root node for a scene graph, path or
40 pathlist will render all sound-related nodes contained within that instance to
41 the current SoAudioDevice.
42 */
43
44
45 #include <Inventor/actions/SoAudioRenderAction.h>
46
47 #ifdef HAVE_CONFIG_H
48 #include <config.h>
49 #endif // HAVE_CONFIG_H
50
51 #include <Inventor/elements/SoModelMatrixElement.h>
52 #include <Inventor/elements/SoCoordinateElement.h>
53 #include <Inventor/elements/SoSwitchElement.h>
54 #include <Inventor/elements/SoUnitsElement.h>
55 #include <Inventor/elements/SoFocalDistanceElement.h>
56 #include <Inventor/elements/SoProjectionMatrixElement.h>
57 #include <Inventor/elements/SoViewVolumeElement.h>
58 #include <Inventor/elements/SoViewingMatrixElement.h>
59 #include <Inventor/elements/SoSoundElement.h>
60 #include <Inventor/nodes/SoCoordinate3.h>
61 #include <Inventor/nodes/SoCoordinate4.h>
62 #include <Inventor/nodes/SoGroup.h>
63 #include <Inventor/nodes/SoTransform.h>
64 #include <Inventor/nodes/SoSeparator.h>
65 #include <Inventor/nodes/SoListener.h>
66
67 #ifdef HAVE_VRML97
68 #include <Inventor/VRMLnodes/SoVRMLSound.h>
69 #include <Inventor/VRMLnodes/SoVRMLAudioClip.h>
70 #endif // HAVE_VRML97
71
72 #include "SbBasicP.h"
73 #include "actions/SoSubActionP.h"
74
75 class SoAudioRenderActionP
76 {
77 public:
78 };
79
80 SO_ACTION_SOURCE(SoAudioRenderAction);
81
initClass()82 void SoAudioRenderAction::initClass()
83 {
84 SO_ACTION_INTERNAL_INIT_CLASS(SoAudioRenderAction, SoAction);
85
86 SO_ENABLE(SoAudioRenderAction, SoModelMatrixElement);
87 SO_ENABLE(SoAudioRenderAction, SoSwitchElement);
88 SO_ENABLE(SoAudioRenderAction, SoUnitsElement);
89
90 SO_ENABLE(SoAudioRenderAction, SoFocalDistanceElement);
91 SO_ENABLE(SoAudioRenderAction, SoProjectionMatrixElement);
92 SO_ENABLE(SoAudioRenderAction, SoViewVolumeElement);
93 SO_ENABLE(SoAudioRenderAction, SoViewingMatrixElement);
94
95 SO_ENABLE(SoAudioRenderAction, SoSoundElement);
96 }
97
SoAudioRenderAction()98 SoAudioRenderAction::SoAudioRenderAction()
99 {
100 SO_ACTION_CONSTRUCTOR(SoAudioRenderAction);
101 }
102
~SoAudioRenderAction()103 SoAudioRenderAction::~SoAudioRenderAction()
104 {
105 }
106
beginTraversal(SoNode * node)107 void SoAudioRenderAction::beginTraversal(SoNode *node)
108 {
109 traverse(node);
110 }
111
callDoAction(SoAction * action,SoNode * node)112 void SoAudioRenderAction::callDoAction(SoAction *action, SoNode *node)
113 {
114 node->doAction(action);
115 }
116
callAudioRender(SoAction * action,SoNode * node)117 void SoAudioRenderAction::callAudioRender(SoAction *action, SoNode *node)
118 {
119 SoAudioRenderAction * audioRenderAction = coin_assert_cast<SoAudioRenderAction *>(action);
120
121 if (node->isOfType(SoListener::getClassTypeId())) {
122 SoListener *listener;
123 listener = coin_assert_cast<SoListener *>(node);
124 listener->audioRender(audioRenderAction);
125 }
126 #ifdef HAVE_VRML97
127 else if (node->isOfType(SoVRMLSound::getClassTypeId())) {
128 SoVRMLSound *sound;
129 sound = coin_assert_cast<SoVRMLSound *>(node);
130 sound->audioRender(audioRenderAction);
131 }
132 else if (node->isOfType(SoVRMLAudioClip::getClassTypeId())) {
133 SoVRMLAudioClip *clip;
134 clip = coin_assert_cast<SoVRMLAudioClip *>(node);
135 clip->audioRender(audioRenderAction);
136 }
137 #endif // HAVE_VRML97
138 }
139
140 /*
141 FIXME 20021101 thammer: remember to override invalidateState if we
142 keep an internal state at all. Called from
143 SoSceneManager.setAudioRenderAction
144 */
145