Changeset 6518 for geovis


Ignore:
Timestamp:
Aug 31, 2016 5:40:20 PM (8 years ago)
Author:
ldelgass
Message:

Protocol additions: add terrainPatch flag, add wkt/wkt_file driver for mask
layers to allow using WKT string literal or file. Add Euler angle rotations
for model layer.

Location:
geovis/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • geovis/trunk/Renderer.cpp

    r6511 r6518  
    22532253                             bool enableCache,
    22542254                             bool lighting,
    2255                              bool visible)
     2255                             bool visible,
     2256                             bool terrainPatch)
    22562257{
    22572258    if (!_map.valid()) {
     
    22692270    }
    22702271    layerOpts.lightingEnabled() = lighting;
     2272    if (terrainPatch) {
     2273        layerOpts.terrainPatch() = true;
     2274    }
    22712275    osgEarth::ModelLayer *layer = new osgEarth::ModelLayer(layerOpts);
    22722276    if (pos < (unsigned int)_map->getNumModelLayers()) {
  • geovis/trunk/Renderer.h

    r6517 r6518  
    404404                       bool enableCache = true,
    405405                       bool lighting = true,
    406                        bool visible = true);
     406                       bool visible = true,
     407                       bool terrainPatch = false);
    407408
    408409    void removeModelLayer(const char *name);
  • geovis/trunk/RendererCmd.cpp

    r6516 r6518  
    17731773        }
    17741774
    1775         bool lighting = true;
    17761775        osgEarth::Drivers::FeatureGeomModelOptions geomOpts;
    17771776        char *styleSheetStr = (char *)malloc((size_t)(ssSize+1L));
     
    19291928            Tcl_DecrRefCount(selectorsObj);
    19301929        }
     1930        bool terrainPatch = false;
     1931        if (objc > 13) {
     1932            if (GetBooleanFromObj(interp, objv[13], &terrainPatch) != TCL_OK) {
     1933                return TCL_ERROR;
     1934            }
     1935        }
     1936        bool lighting = true;
    19311937        geomOpts.enableLighting() = lighting;
    19321938        geomOpts.minRange() = 0.f;
    19331939        geomOpts.maxRange() = FLT_MAX;
    1934         if (objc > 13) {
     1940        if (objc > 14) {
    19351941            float min, max;
    1936             if (GetFloatFromObj(interp, objv[13], &min) != TCL_OK ||
    1937                 GetFloatFromObj(interp, objv[14], &max) != TCL_OK) {
     1942            if (GetFloatFromObj(interp, objv[14], &min) != TCL_OK ||
     1943                GetFloatFromObj(interp, objv[15], &max) != TCL_OK) {
    19381944                return TCL_ERROR;
    19391945            }
     
    19731979            return TCL_ERROR;
    19741980        }
    1975         g_renderer->addModelLayer(name, geomOpts, pos, cache, lighting, visible);
     1981        g_renderer->addModelLayer(name, geomOpts, pos, cache, lighting, visible,
     1982                                  terrainPatch);
    19761983    } else if (type[0] == 'm' && strcmp(type, "mask") == 0) {
    19771984        char *driver = Tcl_GetString(objv[5]);
     
    19871994        std::string url;
    19881995        if (objc > 8) {
    1989             char *urlIn = Tcl_GetString(objv[8]);
    1990             url = g_renderer->getCanonicalPath(std::string(urlIn));
    1991             if (url.empty()) {
    1992                 Tcl_AppendResult(interp, "file not found: \"",
    1993                                  urlIn, "\"", (char*)NULL);
    1994                 return TCL_ERROR;
     1996            if (driver[0] == 'w' && strcmp(driver, "wkt") == 0) {
     1997                url = Tcl_GetString(objv[8]);
     1998                if (url.empty()) {
     1999                    Tcl_AppendResult(interp, "Empty WKT length",
     2000                                     (char*)NULL);
     2001                    return TCL_ERROR;
     2002                }
     2003            } else {
     2004                char *urlIn = Tcl_GetString(objv[8]);
     2005                url = g_renderer->getCanonicalPath(std::string(urlIn));
     2006                if (url.empty()) {
     2007                    Tcl_AppendResult(interp, "file not found: \"",
     2008                                     urlIn, "\"", (char*)NULL);
     2009                    return TCL_ERROR;
     2010                }
    19952011            }
    19962012        }
     
    20192035            opts.typeName() = typeName;
    20202036            maskOpts.featureOptions() = opts;
     2037        } else if (driver[0] == 'w' && strcmp(driver, "wkt") == 0) {
     2038            // Inline geometry, url is length of following data
     2039            char *ptr;
     2040            long len = strtol(url.c_str(), &ptr, 10);
     2041            if (len <= 0 || *ptr != '\0') {
     2042                Tcl_AppendResult(interp, "Failed to parse WKT length: \"",
     2043                                 url.c_str(), "\"", (char*)NULL);
     2044                return TCL_ERROR;
     2045            }
     2046            char *wkt = (char *)malloc((size_t)len);
     2047            if (!SocketRead(wkt, len)) {
     2048                free(wkt);
     2049                Tcl_AppendResult(interp, "Failed to read WKT string",
     2050                                 (char*)NULL);
     2051                return TCL_ERROR;
     2052            }
     2053            osgEarth::Drivers::OGRFeatureOptions opts;
     2054            opts.name() = name;
     2055            TRACE("Geometry: \"%s\"", wkt);
     2056            osgEarth::Config conf("geometry", std::string(wkt));
     2057            free(wkt);
     2058            opts.geometryConfig() = conf;
     2059            maskOpts.featureOptions() = opts;
     2060        } else if (driver[0] == 'w' && strcmp(driver, "wkt_file") == 0) {
     2061            osgEarth::Drivers::OGRFeatureOptions opts;
     2062            opts.name() = name;
     2063            opts.geometryUrl() = url;
     2064            maskOpts.featureOptions() = opts;
    20212065        } else {
    20222066            Tcl_AppendResult(interp, "unknown mask driver \"", driver,
     
    20622106        }
    20632107        modelOpts.location() = osg::Vec3d(x, y, z);
    2064         //double rotx = 0.0, roty = 0.0, rotz = 0.0;
    2065         //modelOpts.orientation() = osg::Vec3d(rotx, roty, rotz);
     2108        double rotx = 0.0, roty = 0.0, rotz = 0.0;
     2109        if (objc > 12) {
     2110            if (Tcl_GetDoubleFromObj(interp, objv[10], &rotx) != TCL_OK ||
     2111                Tcl_GetDoubleFromObj(interp, objv[11], &roty) != TCL_OK ||
     2112                Tcl_GetDoubleFromObj(interp, objv[12], &rotz) != TCL_OK) {
     2113                return TCL_ERROR;
     2114            }
     2115        }
     2116        if (rotx != 0.0 || roty != 0.0 || rotz != 0.0) {
     2117            modelOpts.orientation() = osg::Vec3d(rotx, roty, rotz);
     2118        }
    20662119        modelOpts.paged() = false;
    20672120        bool lighting = true;
    2068         g_renderer->addModelLayer(name, modelOpts, pos, cache, lighting, visible);
     2121        bool terrainPatch = false;
     2122        if (objc > 13) {
     2123            if (GetBooleanFromObj(interp, objv[13], &terrainPatch) != TCL_OK) {
     2124                return TCL_ERROR;
     2125            }
     2126        }
     2127        g_renderer->addModelLayer(name, modelOpts, pos, cache, lighting,
     2128                                  visible, terrainPatch);
    20692129    } else if (type[0] == 'i' && strcmp(type, "icon") == 0) {
    20702130        char *driver = Tcl_GetString(objv[5]);
  • geovis/trunk/geovis_protocol.txt

    r6512 r6518  
    268268<clamptechnique> = drape|gpu|scene|map
    269269
    270 map layer add <layerName> feature <driver> <format> <typeName> <url> <cache> <styleLen> <?scriptLen?> <?selectorsLen?> <?visibilityRangeMin?> <?visibilityRangeMax?>
     270map layer add <layerName> feature <driver> <format> <typeName> <url> <cache> <styleLen> <?scriptLen?> <?selectorsLen?> <?terrainPatch?> <?visibilityRangeMin?> <?visibilityRangeMax?>
    271271    Data payload follows command: style, then script, then selectors
    272272    <styleLen> = Number of bytes in style sheet. Stylesheet payload consists of
     
    278278    <selectorsLen> = Number of bytes in selectors.  Selectors payload consists
    279279    of a Tcl list of name/value pairs
     280    <terrainPatch> = Boolean indicating if layer should be used for elevation
     281    queries.
    280282map layer add <layerName> icon <driver> <format> <typeName> <url> <cache> <icon> <scale> <heading> <declutter> <placement> <alignment> <?visibilityRangeMin?> <?visibilityRangeMax?>
    281283    Add an icon feature layer from a file or URL
     
    298300    Create a terrain mask layer to cut a hole in the terrain geometry.  The
    299301    first feature found is assumed to be a boundary polygon.
     302    <driver> = db|ogr|tfs|wfs|wkt|wkt_file
    300303    <minLOD> minimum LOD to at which to apply the mask, defaults to 0.
    301 
    302 map layer add <layerName> model simple <url> <x> <y> <?z?>
     304map layer add <layerName> mask wkt <format> <typeName> <length> <?minLOD?>
     305    Like generic mask layer command, but instead of a <url>, included data in
     306    the payload which is a WKT literal string.
     307    <format> and <typeName> are unused
     308    <length> = length of following data for inline WKT string
     309map layer add <layerName> mask wkt_file <format> <typeName> <url> <?minLOD?>
     310    <url> = URL for a text file containing a WKT string
     311    <format> and <typeName> are unused
     312
     313map layer add <layerName> model simple <url> <x> <y> <?z?> <?rotx?> <?roty?> <?rotz?> <?terrainPatch?>
    303314    <url> = Path to a 3D model file that OSG can load (e.g. .osg file)
    304315    <x>,<y>,<z> = Map coordinates for placing the model
     316    <rotx>,<roty>,<rotz> = Rotations (in degrees) to apply to orient model
     317    <terrainPatch> = boolean indicating if model should be used for elevation
     318    queries.
    305319
    306320map layer delete <layerName>
Note: See TracChangeset for help on using the changeset viewer.