Esempio n. 1
0
        private ModelVisual3D GetShipCompassBlip(Ship ship)
        {
            ScreenSpaceLines3D retVal = new ScreenSpaceLines3D(true);
            retVal.Thickness = 2d;
            retVal.Color = Colors.DodgerBlue;
            retVal.AddLine(new Point3D(0, 170, 20), new Point3D(0, 1000, 20));

            retVal.Transform = new TranslateTransform3D(ship.PositionWorld.ToVector());

            // Exit Function
            return retVal;
        }
Esempio n. 2
0
        private ModelVisual3D GetShipBlip_OLD(Ship ship)
        {
            // Material
            MaterialGroup materials = new MaterialGroup();
            materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(ship.HullColor)));
            materials.Children.Add(new SpecularMaterial(Brushes.White, 20d));

            // Geometry Model
            GeometryModel3D geometry = new GeometryModel3D();
            geometry.Material = materials;
            geometry.BackMaterial = materials;
            geometry.Geometry = GetBlipGeometry();
            geometry.Transform = new ScaleTransform3D(7, 7, 2);

            // Model Visual
            ModelVisual3D retVal = new ModelVisual3D();
            retVal.Content = geometry;
            retVal.Transform = new TranslateTransform3D(ship.PositionWorld.ToVector());

            // Exit Function
            return retVal;
        }
Esempio n. 3
0
        //NOTE: The map WILL remove the ModelVisual3D's from the main viewport
        public void RemoveItem(IMapObject item)
        {
            int index = -1;

            if (item is Mineral)
            {
                #region Mineral

                index = _minerals.IndexOf((Mineral)item);

                if (_mineralBlips[index] != null)
                {
                    _viewportMap.Children.Remove(_mineralBlips[index]);
                }

                foreach (ModelVisual3D model in item.Visuals3D)
                {
                    _viewport.Children.Remove(model);
                }

                _minerals.RemoveAt(index);
                _mineralBlips.RemoveAt(index);

                _world.RemoveBody(item.PhysicsBody);

                #endregion
            }
            else if (item is Asteroid)
            {
                #region Asteroid

                index = _asteroids.IndexOf((Asteroid)item);

                if (_asteroidBlips[index] != null)
                {
                    _viewportMap.Children.Remove(_asteroidBlips[index]);
                }

                foreach (ModelVisual3D model in item.Visuals3D)
                {
                    _viewport.Children.Remove(model);
                }

                _asteroids.RemoveAt(index);
                _asteroidBlips.RemoveAt(index);

                _world.RemoveBody(item.PhysicsBody);

                #endregion
            }
            else if (item is SpaceStation)
            {
                #region Space Station

                index = _spaceStations.IndexOf((SpaceStation)item);

                _viewportMap.Children.Remove(_spaceStationBlips[index]);

                foreach (ModelVisual3D model in item.Visuals3D)
                {
                    _viewport.Children.Remove(model);
                }

                _spaceStations.RemoveAt(index);
                _spaceStationBlips.RemoveAt(index);

                #endregion
            }
            else if (item is Ship)
            {
                #region Ship

                throw new ApplicationException("finish this");

                _ship = null;
                _viewportMap.Children.Remove(_shipBlip);
                _shipBlip = null;

                foreach (ModelVisual3D model in item.Visuals3D)
                {
                    _viewport.Children.Remove(model);
                }

                _world.RemoveBody(item.PhysicsBody);

                #endregion
            }
            else if (item is SwarmBot2)
            {
                #region SwarmBot2

                ((SwarmBot2)item).ShouldDrawThrustLine = false;		// it's leaving its thrust line on the viewport (thrustline isn't returned by Visuals3D)
                ((SwarmBot2)item).ShouldShowDebugVisuals = false;

                foreach (ModelVisual3D model in item.Visuals3D)
                {
                    _viewport.Children.Remove(model);
                }

                _swarmbots.Remove((SwarmBot2)item);

                _world.RemoveBody(item.PhysicsBody);

                #endregion
            }
            else
            {
                throw new ApplicationException("Unknown item type: " + item.ToString());
            }
        }
Esempio n. 4
0
        private ModelVisual3D GetShipBlip(Ship ship)
        {
            //TODO:  This makes an arrow that always points north, which is just annoying.  Instead, make the ship a dot, but put the arrow along the edge
            // of the minimap (just translate the arrow by a certain Y)

            // Material
            MaterialGroup materials = new MaterialGroup();
            materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(Colors.DodgerBlue)));
            materials.Children.Add(new SpecularMaterial(Brushes.RoyalBlue, 20d));

            // Geometry Model
            GeometryModel3D geometry = new GeometryModel3D();
            geometry.Material = materials;
            geometry.BackMaterial = materials;

            List<TubeRingDefinition_ORIG> rings = new List<TubeRingDefinition_ORIG>();
            rings.Add(new TubeRingDefinition_ORIG(30, 18, 0, true, false));
            rings.Add(new TubeRingDefinition_ORIG(5, false));

            geometry.Geometry = UtilityWPF.GetMultiRingedTube_ORIG(3, rings, false, true);

            Transform3DGroup transform = new Transform3DGroup();
            transform.Children.Add(new TranslateTransform3D(0, 0, 20));
            transform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), 90)));
            geometry.Transform = transform;

            //geometry.Transform = new ScaleTransform3D(7, 7, 2);

            // Model Visual
            ModelVisual3D retVal = new ModelVisual3D();
            retVal.Content = geometry;
            retVal.Transform = new TranslateTransform3D(ship.PositionWorld.ToVector());

            // Exit Function
            return retVal;
        }
Esempio n. 5
0
        //NOTE: The map won't load ModelVisual3D's to the main viewport, because the physics engine needs them added in it's constructor
        public void AddItem(IMapObject item)
        {
            ModelVisual3D blip = null;

            // These if statements are in order of what is most likely to be added
            if (item is Mineral)
            {
                #region Mineral

                blip = GetMineralBlip((Mineral)item);

                _minerals.Add((Mineral)item);
                _mineralBlips.Add(blip);

                if (blip != null)        // I may not bother making a blip for the tiny minerals
                {
                    _viewportMap.Children.Add(blip);
                }

                #endregion
            }
            else if (item is Asteroid)
            {
                #region Asteroid

                blip = GetAsteroidBlip((Asteroid)item);

                _asteroids.Add((Asteroid)item);
                _asteroidBlips.Add(blip);

                if (blip != null)        // I may not bother making a blip for the tiny asteroids
                {
                    _viewportMap.Children.Add(blip);
                }

                #endregion
            }
            else if (item is SpaceStation)
            {
                #region Space Station

                blip = GetSpaceStationBlip((SpaceStation)item);

                _spaceStations.Add((SpaceStation)item);
                _spaceStationBlips.Add(blip);

                _viewportMap.Children.Add(blip);

                #endregion
            }
            else if (item is Ship)
            {
                #region Ship

                _ship = (Ship)item;

                _shipBlip = GetShipBlip(_ship);
                _shipCompassBlip = GetShipCompassBlip(_ship);
                _viewportMap.Children.Add(_shipBlip);
                _viewportMap.Children.Add(_shipCompassBlip);

                #endregion
            }
            else if (item is SwarmBot2)
            {
                #region SwarmBot2

                _swarmbots.Add((SwarmBot2)item);

                #endregion
            }
            else
            {
                throw new ApplicationException("Unknown item type: " + item.ToString());
            }
        }