[Switch] * added in the three-dimensional model WorldWind .x format WorldWind added in the three-dimensional model

 Nasa supported WorldWind project recently launched version 1.4RC5, can add three-dimensional model, the effect is as shown below:


    WW1.4 XML configuration file adds a number of new elements, which ModelFeature is used to increase the three-dimensional model, as follows:

<?xml version="1.0" encoding="utf-8"?>
<LayerSet Name="Clart Test" ShowOnlyOneLayer="false" ShowAtStartup="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="LayerSet.xsd">
  <ModelFeature ShowAtStartup="true">
    <Name>Tiny1</Name>
    <DistanceAboveSurface>160.0</DistanceAboveSurface>
    <Latitude>
      <Value>39.93</Value>
    </Latitude>
    <Longitude>
      <Value>116.400002</Value>
    </Longitude>
    <ScaleFactor>2</ScaleFactor>
    <MeshFilePath>Data\Model\tiny.x</MeshFilePath>
    <Orientation>
      <RotationX>0.0</RotationX>
      <RotationY></90.0RotationY>
      <RotationZ>90.0</RotationZ>
    </Orientation>
    <MaxViewRange>10000.0</MaxViewRange>
    <MinViewRange>10</MinViewRange>
  </ModelFeature>

  <ModelFeature ShowAtStartup="true">
    <Name>Tiny2</Name>
    <DistanceAboveSurface>160.0</DistanceAboveSurface>
    <Latitude>
      <Value>39.93</Value>
    </Latitude>
    <Longitude>
      <Value>116.410002</Value>
    </Longitude>
    <ScaleFactor>2</ScaleFactor>
    <MeshFilePath>Data\Model\tiny.x</MeshFilePath>
    <Orientation>
      <RotationX>0.0</RotationX>
      <RotationY>-90.0</RotationY>
      <RotationZ>90.0</RotationZ>
    </Orientation>
    <MaxViewRange>10000.0</MaxViewRange>
    <MinViewRange>10</MinViewRange>
  </ModelFeature>
</LayerSet>

 Originally LayerSet.xsd should be described technique, but I downloaded the latest version of the file has not been updated, so when in VS2005 edit the XML file will be prompted to find ModelFeature this element, do not ignore it, open source code WorldWind project in the ConfigurationLoader unit, find getRenderableFromLayerFile function, there is a piece of code like this:

addImageLayersFromXPathNodeIterator(iter.Current.Select("ImageLayer"), parentWorld, parentRenderable);
addQuadTileLayersFromXPathNodeIterator(iter.Current.Select("QuadTileSet"), parentWorld, parentRenderable, cache);
addPathList(iter.Current.Select("PathList"), parentWorld, parentRenderable);
addPolygonFeature(iter.Current.Select("PolygonFeature"), parentWorld, parentRenderable);
addLineFeature(iter.Current.Select("LineFeature"), parentWorld, parentRenderable);
addModelFeature(iter.Current.Select("ModelFeature"), parentWorld, parentRenderable);
addWater(iter.Current.Select("Water"), parentWorld, parentRenderable);
addTiledPlacenameSet(iter.Current.Select("TiledPlacenameSet"), parentWorld, parentRenderable);
addTiledWFSPlacenameSet(iter.Current.Select("TiledWFSPlacenameSet"), parentWorld, parentRenderable);
addIcon(iter.Current.Select("Icon"), parentWorld, parentRenderable, cache);
addScreenOverlays(iter.Current.Select("ScreenOverlay"), parentWorld, parentRenderable, cache);
addChildLayerSet(iter.Current.Select("ChildLayerSet"), parentWorld, parentRenderable, cache);

addExtendedInformation(iter.Current.Select("ExtendedInformation"), parentRenderable);

From this we can see that the source has provided support for ModelFeature, and in addModelFeature function can be found in all ModelFeature sub-elements, such as "Name", "Latitude" "Longitude" and so on.

private static void addModelFeature(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable)
{
    if (iter.Count > 0)
    {
        while (iter.MoveNext())
        {
            string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
            string refreshurl = getInnerTextFromFirstChild(iter.Current.Select("RefreshURL"));
            float lat = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.Select("Latitude")));
            float lon = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.Select("Longitude")));
            float alt = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface")));
            float scaleFactor = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.Select("ScaleFactor")));
            string meshFilePath = getInnerTextFromFirstChild(iter.Current.Select("MeshFilePath"));

            float rotX = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.SelectSingleNode("Orientation")
                .Select("RotationX")));
            float rotY = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.SelectSingleNode("Orientation")
                .Select("RotationY")));
            float rotZ = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.SelectSingleNode("Orientation")
                .Select("RotationZ")));

            ModelFeature model = new ModelFeature(name, parentWorld
                , meshFilePath, lat, lon, alt,scaleFactor,rotX,rotY,rotZ);
            model.RefreshURL = refreshurl;
            parentRenderable.Add(model);
        }
    }
}

 According to these, as long as we generate an XML file into the appropriate model (such as the Earth) profile directory, you can display your own three-dimensional model of it! 

    I made an example, after downloading, unzip to WorldWind1.4 installation directory (such as : D: \ program Files \ NASA \ World Wind 1.4), restart the program can be seen in a new layer in the layer Manager, as shown below:


    Then the menu Edit-> Place Finder jump to the corresponding coordinates can see the own model, as shown below:



Examples Download: http://www.cnblogs.com/Files/reonlyrun/ClarkTest.rar

 

Original link: join the three-dimensional model in WorldWind

Guess you like

Origin www.cnblogs.com/rainbow70626/p/12128410.html