root/OpenSceneGraph/trunk/src/osg/NodeVisitor.cpp @ 13798

Revision 13798, 3.9 kB (checked in by robert, 3 minutes ago)

From Kristofer Tingdahl, "I and my team have gone over the code again, and we feel that we are comfortable in our current proposal for change. It goes deeper than it did before, and I explain why:

There was code in the osgViewer/Viewer.cpp and osgViewer/CompositeViewer.cpp that transformed the Y-coordinates of an event. The code in the composite viewer did however miss the touch-data of the event. I thought that it should really be the GUIEventAdapter that should know about this, and hence I added the
GUIEventAdapter::setMouseYOrientationAndUpdateCoords which is re-computing the coordinates. First I simply added a boolean to the setMouseYOrientation function:

setMouseYOrientation( MouseYOrientation, bool updatecooreds=false );

but then the serializer complained.

This function is called from both the Viewer and the CompositeViewer?. We have not tested from the viewer, but I cannot see it would not work from visual inspection.

The other change is in MultiTouchTrackballManipulator::handleMultiTouchDrag. I have removed the normalisation. The reason for that is that it normalised into screen coordinates from 0,0 to 1,1. The problem with that is that if you have a pinch event and you keep the distance say 300 pixels between your fingers, these 300 pixels represent 0.20 of the screen in the horizontal domain, but 0.3 of the screen in the vertical domain. A rotation of the pinch-fingers will hence result in a zoom in, as the normalised distance is changing between them.

A consequence of this is that I have changed the pan-code to use the same algorithm as the middle-mouse-pan.

The rest of it is very similar from previous revision, and there has been some fine-tuning here and there.

"

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13#include <osg/NodeVisitor>
14
15#include <osg/Billboard>
16#include <osg/ClearNode>
17#include <osg/ClipNode>
18#include <osg/CoordinateSystemNode>
19#include <osg/Geode>
20#include <osg/Group>
21#include <osg/LightSource>
22#include <osg/LOD>
23#include <osg/MatrixTransform>
24#include <osg/OccluderNode>
25#include <osg/OcclusionQueryNode>
26#include <osg/PagedLOD>
27#include <osg/PositionAttitudeTransform>
28#include <osg/Projection>
29#include <osg/ProxyNode>
30#include <osg/Sequence>
31#include <osg/Switch>
32#include <osg/TexGenNode>
33#include <osg/Transform>
34#include <osg/Camera>
35#include <osg/CameraView>
36
37#include <stdlib.h>
38
39using namespace osg;
40
41NodeVisitor::NodeVisitor(TraversalMode tm):
42    Object(true)
43{
44    _visitorType = NODE_VISITOR;
45    _traversalNumber = osg::UNINITIALIZED_FRAME_NUMBER;
46
47    _traversalMode = tm;
48    _traversalMask = 0xffffffff;
49    _nodeMaskOverride = 0x0;
50}
51
52NodeVisitor::NodeVisitor(VisitorType type,TraversalMode tm):
53    Object(true)
54{
55    _visitorType = type;
56    _traversalNumber = osg::UNINITIALIZED_FRAME_NUMBER;
57
58    _traversalMode = tm;
59    _traversalMask = 0xffffffff;
60    _nodeMaskOverride = 0x0;
61}
62
63NodeVisitor::NodeVisitor(const NodeVisitor& nv, const osg::CopyOp& copyop):
64    Object(nv, copyop),
65    _visitorType(nv._visitorType),
66    _traversalNumber(nv._traversalNumber),
67    _traversalMode(nv._traversalMode),
68    _traversalMask(nv._traversalMask),
69    _nodeMaskOverride(nv._nodeMaskOverride)
70{
71}
72
73NodeVisitor::~NodeVisitor()
74{
75    // if (_traversalVisitor) detach from _traversalVisitor;
76}
77
78void NodeVisitor::apply(Node& node)
79{
80    traverse(node);
81}
82
83void NodeVisitor::apply(Geode& node)
84{
85    apply(static_cast<Node&>(node));
86}
87
88void NodeVisitor::apply(Billboard& node)
89{
90    apply(static_cast<Geode&>(node));
91}
92
93void NodeVisitor::apply(Group& node)
94{
95    apply(static_cast<Node&>(node));
96}
97
98void NodeVisitor::apply(ProxyNode& node)
99{
100    apply(static_cast<Group&>(node));
101}
102
103void NodeVisitor::apply(Projection& node)
104{
105    apply(static_cast<Group&>(node));
106}
107
108void NodeVisitor::apply(CoordinateSystemNode& node)
109{
110    apply(static_cast<Group&>(node));
111}
112
113void NodeVisitor::apply(ClipNode& node)
114{
115    apply(static_cast<Group&>(node));
116}
117
118void NodeVisitor::apply(TexGenNode& node)
119{
120    apply(static_cast<Group&>(node));
121}
122
123void NodeVisitor::apply(LightSource& node)
124{
125    apply(static_cast<Group&>(node));
126}
127
128void NodeVisitor::apply(Transform& node)
129{
130    apply(static_cast<Group&>(node));
131}
132
133void NodeVisitor::apply(Camera& node)
134{
135    apply(static_cast<Transform&>(node));
136}
137
138void NodeVisitor::apply(CameraView& node)
139{
140    apply(static_cast<Transform&>(node));
141}
142
143void NodeVisitor::apply(MatrixTransform& node)
144{
145    apply(static_cast<Transform&>(node));
146}
147
148void NodeVisitor::apply(PositionAttitudeTransform& node)
149{
150    apply(static_cast<Transform&>(node));
151}
152
153void NodeVisitor::apply(Switch& node)
154{
155    apply(static_cast<Group&>(node));
156}
157
158void NodeVisitor::apply(Sequence& node)
159{
160    apply(static_cast<Group&>(node));
161}
162
163void NodeVisitor::apply(LOD& node)
164{
165    apply(static_cast<Group&>(node));
166}
167
168void NodeVisitor::apply(PagedLOD& node)
169{
170    apply(static_cast<LOD&>(node));
171}
172
173void NodeVisitor::apply(ClearNode& node)
174{
175    apply(static_cast<Group&>(node));
176}
177
178void NodeVisitor::apply(OccluderNode& node)
179{
180    apply(static_cast<Group&>(node));
181}
182
183void NodeVisitor::apply(OcclusionQueryNode& node)
184{
185    apply(static_cast<Group&>(node));
186}
Note: See TracBrowser for help on using the browser.