Changeset 4973 for geovis


Ignore:
Timestamp:
Jan 31, 2015 11:27:43 PM (6 years ago)
Author:
ldelgass
Message:

First pass at protocol to set ephemeris time (currently uses server local time)

Location:
geovis/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • geovis/trunk/Renderer.cpp

    r4957 r4973  
    736736        skyOpts.atmosphericLighting() = true;
    737737        skyOpts.exposure() = 3.0;
    738         osgEarth::Util::SkyNode *sky = osgEarth::Util::SkyNode::create(skyOpts, mapNode);
    739         sky->addChild(mapNode);
    740         sky->attach(_viewer.get(), 0);
    741         _sceneRoot = sky;
     738        _skyNode = osgEarth::Util::SkyNode::create(skyOpts, mapNode);
     739        _skyNode->addChild(mapNode);
     740        _skyNode->attach(_viewer.get(), 0);
     741        _sceneRoot = _skyNode;
    742742#else
    743743        _sceneRoot = new osg::Group();
     
    745745
    746746        TRACE("Creating SkyNode");
    747         osgEarth::Util::SkyNode *sky = new osgEarth::Util::SkyNode(map);
    748         _sceneRoot->addChild(sky);
    749         sky->setAmbientBrightness(0.2f);
    750         sky->setDateTime(now);
    751         sky->attach(_viewer.get(), 0);
     747        _skyNode = new osgEarth::Util::SkyNode(map);
     748        _sceneRoot->addChild(_skyNode.get());
     749        _skyNode->setAmbientBrightness(0.2f);
     750        _skyNode->setDateTime(now);
     751        _skyNode->attach(_viewer.get(), 0);
    752752#endif
    753753    } else {
     
    811811        }
    812812        _verticalScale->setScale(scale);
     813        _needsRedraw = true;
     814    }
     815}
     816
     817void Renderer::setEphemerisTime(int year, int month, int day, double hours)
     818{
     819    if (_skyNode.valid()) {
     820        osgEarth::DateTime time(year, month, day, hours);
     821        _skyNode->setDateTime(time);
    813822        _needsRedraw = true;
    814823    }
  • geovis/trunk/Renderer.h

    r4957 r4973  
    2222#include <osgUtil/IncrementalCompileOperation>
    2323
     24#include <osgEarth/Version>
    2425#include <osgEarth/StringUtils>
    2526#include <osgEarth/Map>
     
    3334#include <osgEarthAnnotation/AnnotationNode>
    3435#include <osgEarthAnnotation/FeatureNode>
     36#if OSGEARTH_MIN_VERSION_REQUIRED(2, 5, 1)
     37#include <osgEarthUtil/Sky>
     38#else
     39#include <osgEarthUtil/SkyNode>
     40#endif
    3541#include <osgEarthUtil/EarthManipulator>
    3642#include <osgEarthUtil/MouseCoordsTool>
     
    195201    void setTerrainWireframe(bool state);
    196202
     203    void setEphemerisTime(int year, int month, int day, double hours);
     204
    197205    // Image raster layers
    198206
     
    517525    osg::ref_ptr<osgEarth::MapNode> _mapNode;
    518526    osg::ref_ptr<osgEarth::Map> _map;
     527    osg::ref_ptr<osgEarth::Util::SkyNode> _skyNode;
    519528    osg::ref_ptr<osgViewer::Viewer> _viewer;
    520529    osg::ref_ptr<ScreenCaptureCallback> _captureCallback;
  • geovis/trunk/RendererCmd.cpp

    r4957 r4973  
    17271727}
    17281728
     1729static int
     1730MapTimeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1731          Tcl_Obj *const *objv)
     1732{
     1733    osgEarth::DateTime now;
     1734    int year, month, day;
     1735    double hours;
     1736    year = now.year();
     1737    month = now.month();
     1738    day = now.day();
     1739    hours = now.hours();
     1740    if (objc > 2) {
     1741        if (Tcl_GetDoubleFromObj(interp, objv[2], &hours) != TCL_OK) {
     1742            return TCL_ERROR;
     1743        }
     1744    }
     1745    if (objc > 3) {
     1746        if (Tcl_GetIntFromObj(interp, objv[3], &day) != TCL_OK) {
     1747            return TCL_ERROR;
     1748        }
     1749    }
     1750    if (objc > 4) {
     1751        if (Tcl_GetIntFromObj(interp, objv[4], &month) != TCL_OK) {
     1752            return TCL_ERROR;
     1753        }
     1754    }
     1755    if (objc > 5) {
     1756        if (Tcl_GetIntFromObj(interp, objv[5], &year) != TCL_OK) {
     1757            return TCL_ERROR;
     1758        }
     1759    }
     1760
     1761    g_renderer->setEphemerisTime(year, month, day, hours);
     1762    return TCL_OK;
     1763}
     1764
    17291765static CmdSpec mapOps[] = {
    17301766    {"box",      1, MapBoxOp,             3, 0, "op ?params..."},
     
    17391775    {"setpos",   1, MapSetPositionOp,     2, 4, "x y"},
    17401776    {"terrain",  1, MapTerrainOp,         3, 0, "op ?params...?"},
     1777    {"time",     1, MapTimeOp,            2, 6, "?hours? ?day? ?month? ?year?"},
    17411778};
    17421779static int nMapOps = NumCmdSpecs(mapOps);
  • geovis/trunk/geovis_protocol.txt

    r4957 r4973  
    206206    Set scale factor for terrain height
    207207map terrain wireframe <bool>
     208map time <?hours?> <?day?> <?month?> <?year?>
     209    Set ephemeris time for sky.  When args are omitted, set to current time.
     210    Time is interpreted as server's local time.
    208211
    209212================================================================================
Note: See TracChangeset for help on using the changeset viewer.