earth rotation

classic Classic list List threaded Threaded
4 messages Options
cxh860315 cxh860315
Reply | Threaded
Open this post in threaded view
|

earth rotation

Dear ereryone, I want to realize the earth rotation around itself, i use callback way to realize,but no success. I can see other model rotate, but the earth did not rotate.  I Think the earth should rotate, only because the imagelayer and ElevationLayer do not rotate,so cannot see earth rotate. i do not know how to solve the problem.hoping for your help.Any idea is welcome. Thanks very much. The below is  the main code.

I uese OSGEARTH 2.10,OSG3.6.5,visual studio 2013.

m_pmap = new osgEarth::Map(m_mapOpts);
m_pmapNode = new osgEarth::MapNode(m_pmap);

mt = new osg::MatrixTransform();
mt->addChild(m_pmapNode.get());
m_pearthGroupNode->addChild(mt);
mt->setUpdateCallback(new simpleCallBack());

class simpleCallBack :public osg::NodeCallback
        {
        public:
                simpleCallBack() :_angle(0)
                {
                }

                virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
                {
                        osg::ref_ptr<osg::MatrixTransform> mt = dynamic_cast<osg::MatrixTransform>*(node);
                        osg::Matrix mx;
                        mx.makeRotate(_angle, osg::Vec3(0.0, 1.0, 0.0));
                        mt->setMatrix(mx);
                        _angle += 0.1;
                        traverse(node, nv);
                }

        public:
                double _angle;
        };
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: earth rotation

Are you using the EarthManipulator camera manipulator? If so, it will probably position itself over the same point on the earth regardless of the MatrixTransform.
Glenn Waldron / Pelican Mapping
cxh860315 cxh860315
Reply | Threaded
Open this post in threaded view
|

Re: earth rotation

Thank you very much for your quick reply.
Yes,I use the EarthManipulator camera manipulator. when I use the camera way to control rotation,the sky can rotate,too. I only want to rotate the earth. Could you give me some suggestions? Thanks.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: earth rotation

The EarthManipulator (EM) always locks the camera on a map location. That map location is the same regardless of whether you rotate the earth.

So you either need to disable the EM, or you need to move your camera in the opposite direction as you rotate.
Glenn Waldron / Pelican Mapping