root/OpenSceneGraph/trunk/src/osg/CoordinateSystemNode.cpp @ 13041

Revision 13041, 2.1 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • 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
14#include <osg/CoordinateSystemNode>
15#include <osg/Notify>
16
17using namespace osg;
18
19
20CoordinateSystemNode::CoordinateSystemNode()
21{
22}
23
24CoordinateSystemNode::CoordinateSystemNode(const std::string& format, const std::string& cs):
25    _format(format),
26    _cs(cs)
27{
28}
29
30CoordinateSystemNode::CoordinateSystemNode(const CoordinateSystemNode& csn,const osg::CopyOp& copyop):
31    Group(csn,copyop),
32    _format(csn._format),
33    _cs(csn._cs),
34    _ellipsoidModel(csn._ellipsoidModel)
35{
36}
37
38void CoordinateSystemNode::set(const CoordinateSystemNode& csn)
39{
40    _format = csn._format;
41    _cs = csn._cs;
42    _ellipsoidModel = csn._ellipsoidModel;
43}
44
45CoordinateFrame CoordinateSystemNode::computeLocalCoordinateFrame(const Vec3d& position) const
46{
47    if (_ellipsoidModel.valid())
48    {
49        Matrixd localToWorld;
50
51        double latitude, longitude, height;
52        _ellipsoidModel->convertXYZToLatLongHeight(position.x(),position.y(),position.z(),latitude, longitude, height);
53        _ellipsoidModel->computeLocalToWorldTransformFromLatLongHeight(latitude, longitude, 0.0f, localToWorld);
54
55        return localToWorld;
56    }
57    else
58    {
59        return Matrixd::translate(position.x(),position.y(),0.0f);
60    }
61}
62
63osg::Vec3d CoordinateSystemNode::computeLocalUpVector(const Vec3d& position) const
64{
65    if (_ellipsoidModel.valid())
66    {
67        return _ellipsoidModel->computeLocalUpVector(position.x(),position.y(),position.z());
68    }
69    else
70    {
71        return osg::Vec3d(0.0f,0.0f,1.0f);
72    }
73}
74
Note: See TracBrowser for help on using the browser.