Example #1
0
        /// <summary>
        /// updates the ModelFeature to the new mesh, position and color
        /// </summary>
        public virtual void updateModel(bool forceUpdate)
        {
            if (forceUpdate || (RenderModel && !m_modelFeatureError && (DistanceToIcon < ModelShowDistance)))
            {
                if (m_modelFeature == null)
                {
                    try
                    {
                        // do for current models that happen to point right 90.
                        float rotZ = (float)(180 - Rotation.Degrees);
                        if (rotZ < 0)
                        {
                            rotZ += 360;
                        }

                        // use generic commercial airliner mesh
                        m_modelFeature = new ModelFeature(name,
                                                          DrawArgs.CurrentWorldStatic,
                                                          m_modelFilePath,
                                                          (float)Latitude,
                                                          (float)Longitude,
                                                          (float)Altitude,
                                                          ModelScale,
                                                          ModelRotX,
                                                          0,
                                                          rotZ);

                        m_modelFeature.IsElevationRelativeToGround = IsAGL;
                    }
                    catch
                    {
                        m_modelFeature      = null;
                        m_modelFeatureError = true;
                    }
                }

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

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

                    ModelFeature model = new ModelFeature(name, parentWorld
                        , meshFilePath, lat, lon, alt,scaleFactor,rotX,rotY,rotZ);
                     if(iter.Current.Select("IsVerticalExaggerable").Count > 0)
                    {
						model.isVertExaggerable = Convert.ToBoolean(getInnerTextFromFirstChild(iter.Current.Select("IsVerticalExaggerable")));
					}
                    if(iter.Current.Select("IsElevationRelativeToGround").Count > 0)
                    {
						model.isElevationRelative2Ground = Convert.ToBoolean(getInnerTextFromFirstChild(iter.Current.Select("IsElevationRelativeToGround")));
					}
                   parentRenderable.Add(model);
                }
            }
        }