ModelVisual3D GetSelectionBox(ContentBase content)
        {
            WireLines lines = GetWireBox(content.GetMesh().Bounds);

            lines.Transform = content.Model.Transform;

            return(lines);
        }
        void camera_SelectionChanged(DependencyObject visual)
        {
            ModelVisual3D model = (ModelVisual3D)visual;

            foreach (ContentBase content in Objects)
            {
                if (content.Model == model)
                {
                    SelectedContent = content;
                    OnSelectionChanged(content);
                    return;
                }
            }
        }
        public void Add(List <TableBlock> blocks)
        {
            foreach (TableBlock block in blocks)
            {
                ContentBase content = GetContent(block);

                if (content != null)
                {
                    Objects.Add(content);
                }
            }

            //reload models and resort everything
            RefreshDisplay();
        }
        ContentBase GetContent(TableBlock block)
        {
            ContentBase content = GetContentFromType(block.ObjectType);

            if (content == null)
            {
                return(null);
            }

            content.Visibility = block.Visibility;
            content.ID         = block.ID;
            SetValues(content, block);

            content.Block = block;
            return(content);
        }
Example #5
0
        static bool SetBlock(ContentBase content, TableBlock block, bool animate)
        {
            // update the model if the object type or the archetype was changed
            bool modelChanged =
                content.Block == null ||
                content.Block.ObjectType != block.ObjectType ||
                content.Block.Archetype != block.Archetype;

            // set reference to block (this one is different than the one passed in the argument because a new copy was create in the undomanager)
            content.Block = block;

            // update transform after block was set
            content.UpdateTransform(animate);

            return(modelChanged);
        }
        public void SetVisibility(ContentBase content, bool visibility)
        {
            if (content.Visibility != visibility)
            {
                content.Visibility = visibility;

                if (visibility)
                {
                    //Viewport.Children.Insert(content.ModelIndex, content.Model);
                    //reload models and resort everything
                    RefreshDisplay();
                }
                else
                {
                    //hide model
                    Viewport.Remove(content.Model);
                }
            }
        }
        void SetSelectedContent(ContentBase content)
        {
            selectedContent = content;

            if (content != null)
            {
                //goto content
                Viewport.LookAt(content.Position.ToPoint3D(), ContentAnimator.AnimationDuration.TimeSpan.TotalMilliseconds);

                //select content visually
                Selection = GetSelectionBox(content);

                if (content.Block != null)
                {
                    Viewport.Title = GetTitle(content.Block.Block);
                }
            }
            else
            {
                Selection      = null;
                Viewport.Title = string.Empty;
            }
        }
        void SetValues(ContentBase content, TableBlock block)
        {
            string positionString = "0,0,0";
            string rotationString = "0,0,0";
            string shapeString    = "box";
            string scaleString    = "1,1,1";

            //get transformation of content
            foreach (EditorINIOption option in block.Block.Options)
            {
                if (option.Values.Count > 0)
                {
                    switch (option.Name.ToLower())
                    {
                    case "pos":
                        positionString = option.Values[0].Value.ToString();
                        break;

                    case "rotate":
                        rotationString = option.Values[0].Value.ToString();
                        break;

                    case "shape":
                        shapeString = option.Values[0].Value.ToString();
                        break;

                    case "size":
                        scaleString = option.Values[0].Value.ToString();
                        break;
                    }
                }
            }

            Vector3D   position = ParsePosition(positionString);
            Rotation3D rotation;
            Vector3D   scale;

            //set content values
            if (block.ObjectType == ContentType.Zone)
            {
                ZoneShape shape = ParseShape(shapeString);
                scale    = ParseScale(scaleString, shape);
                rotation = ParseRotation(rotationString, shape == ZoneShape.Cylinder);

                ((Zone)content).Shape = shape;
            }
            else if (block.ObjectType == ContentType.LightSource)
            {
                scale    = new Vector3D(1, 1, 1);
                rotation = ParseRotation(rotationString, false);
            }
            else
            {
                scale    = new Vector3D(block.Archtype.Radius, block.Archtype.Radius, block.Archtype.Radius) / 1000;
                rotation = ParseRotation(rotationString, false);
            }

            content.SetDisplay(position, rotation, scale);

            if (selectedContent == content)
            {
                //update selection if changed content is selected
                SetSelectedContent(content);
            }
        }
 public void ChangeValues(ContentBase content, TableBlock block)
 {
     content.Block = block;
     SetValues(content, block);
 }
Example #10
0
        public static bool SetValues(ContentBase content, TableBlock block, bool animate)
        {
            string positionString = "0,0,0";
            string rotationString = "0,0,0";
            string scaleString    = "1,1,1";
            string fileString     = string.Empty;

            //get properties of content
            foreach (EditorINIOption option in block.Block.Options)
            {
                if (option.Values.Count > 0)
                {
                    string value = option.Values[0].Value.ToString();
                    switch (option.Name.ToLowerInvariant())
                    {
                    case "pos":
                        positionString = value;
                        break;

                    case "rotate":
                        rotationString = value;
                        break;

                    case "size":
                        scaleString = value;
                        break;

                    case "file":
                        fileString = value;
                        break;
                    }
                }
            }

            content.Position = ParsePosition(positionString);

            //set content values
            switch (block.ObjectType)
            {
            case ContentType.System:
                content.Position = ParseUniverseVector(positionString);
                content.Scale    = new Vector3D(UNIVERSE_SYSTEM_SCALE, UNIVERSE_SYSTEM_SCALE, UNIVERSE_SYSTEM_SCALE);

                Content.System system = (Content.System)content;
                system.Path = fileString;
                break;

            case ContentType.LightSource:
                content.Scale    = new Vector3D(1, 1, 1);
                content.Rotation = ParseRotation(rotationString, false);
                break;

            case ContentType.Construct:
            case ContentType.Depot:
            case ContentType.DockingRing:
            case ContentType.JumpGate:
            case ContentType.JumpHole:
            case ContentType.Planet:
            case ContentType.Satellite:
            case ContentType.Ship:
            case ContentType.Station:
            case ContentType.Sun:
            case ContentType.TradeLane:
            case ContentType.WeaponsPlatform:
                content.Scale    = new Vector3D(1, 1, 1);
                content.Rotation = ParseRotation(rotationString, false);

                if (block.Archetype != null)
                {
                    if (block.Archetype.Radius != 0.0)
                    {
                        content.Scale = new Vector3D(block.Archetype.Radius, block.Archetype.Radius, block.Archetype.Radius) * SYSTEM_SCALE;
                    }
                }
                break;

            default:     // all zones
                content.Scale    = ParseScale(scaleString, block.ObjectType);
                content.Rotation = ParseRotation(rotationString, IsCylinder(block.ObjectType));
                break;
            }

            return(SetBlock(content, block, animate));
        }
Example #11
0
        public static bool SetModelPreviewValues(ContentBase content, TableBlock block)
        {
            content.Scale = new Vector3D(MODEL_PREVIEW_SCALE, MODEL_PREVIEW_SCALE, MODEL_PREVIEW_SCALE);

            return(SetBlock(content, block, false));
        }