Exemple #1
0
        /// <summary>
        /// Opens and parses a .scene file and puts its components into the Blocks collection.
        /// </summary>
        void OpenSceneFile(string filename)
        {
            DSL = new DotSceneLoader();
            DSL.ParseDotScene(filename);

            Blocks = new Collection<Block>();

            // go through each of the nodes in the .scene and find which ones are shapes
            foreach (Node node in DSL.Nodes) {
                // shapes
                if (node.Entity.Mesh == "box.mesh") {
                    Shape shape = new Shape();
                    shape.Type = ShapeTypes.Box;
                    shape.Position = node.Position;
                    shape.Orientation = node.Orientation;
                    shape.Dimensions = node.Dimensions;
                    shape.Name = node.Name;

                    Blocks.Add(shape);
                }
                else if (node.Entity.Mesh == "sphere.mesh") {
                    Shape shape = new Shape();
                    shape.Type = ShapeTypes.Sphere;
                    shape.Position = node.Position;
                    shape.Orientation = node.Orientation;
                    shape.Radius = node.Dimensions.x / 2f;
                    shape.Name = node.Name;

                    Blocks.Add(shape);
                }
                else if (node.Entity.Mesh == "cylinder.mesh") {
                    Shape shape = new Shape();
                    shape.Type = ShapeTypes.Cylinder;
                    shape.Position = node.Position;
                    shape.Orientation = node.Orientation;
                    shape.Dimensions = node.Dimensions;
                    shape.Name = node.Name;

                    Blocks.Add(shape);
                }
                else if (node.Entity.Mesh == "cone.mesh") {
                    Shape shape = new Shape();
                    shape.Type = ShapeTypes.Cone;
                    shape.Position = node.Position;
                    shape.Orientation = node.Orientation;
                    shape.Radius = node.Dimensions.x / 2f;
                    shape.Height = node.Dimensions.y;
                    shape.Name = node.Name;

                    Blocks.Add(shape);
                }
                else if (node.Entity.Mesh == "capsule.mesh") {
                    Shape shape = new Shape();
                    shape.Type = ShapeTypes.Capsule;
                    shape.Position = node.Position;
                    shape.Orientation = node.Orientation;
                    shape.Radius = node.Dimensions.x / 2f;
                    shape.Height = node.Dimensions.y;
                    shape.Name = node.Name;

                    Blocks.Add(shape);
                }
                // not shapes
                else {
                    Blocks.Add(node);
                }
            }

            sceneListBox.Items.Clear();

            // add the blocks to the list box
            foreach (var block in Blocks) {
                ListBoxItem item = new ListBoxItem();
                sceneListBox.Items.Add(block);
            }

            // update the name box
            // remove the .scene from the filename
            filename = filename.Remove(filename.IndexOf(".scene"));
            // get rid of the folder stuff before the scene name
            if (filename.Contains("/"))
                nameBox.Text = filename.Substring(filename.LastIndexOf('/') + 1);
            else if (filename.Contains("\\"))
                nameBox.Text = filename.Substring(filename.LastIndexOf('\\') + 1);
            else
                nameBox.Text = filename;

            saveButton.IsEnabled = true;
            nameBox.IsEnabled = true;
            physicsBox.IsEnabled = true;
        }
Exemple #2
0
        /// <summary>
        /// Takes the stuff from the .scene loader and puts them into our NodeData classes
        /// </summary>
        private void OpenSceneFile(string filename)
        {
            DSL = new DotSceneLoader();
            DSL.ParseDotScene(filename);

            Data = new Collection<NodeData>();

            foreach (Node node in DSL.Nodes) {
                NodeData data = new NodeData {
                    Name = node.Name,
                    // basically, if our object's name has a # in it, it's treated as a thing. Otherwise it isn't.
                    UsesThing = node.Name.Contains("#"),
                    ThingFile = node.Name.Contains("#") ? node.Name.Substring(0, node.Name.IndexOf("#")) : "",
                    // have to split up all of these since the table doesn't know what to do with a Vector3 etc
                    PosX = node.Position.x,
                    PosY = node.Position.y,
                    PosZ = node.Position.z,
                    OrientX = node.Orientation.x,
                    OrientY = node.Orientation.y,
                    OrientZ = node.Orientation.z,
                    OrientW = node.Orientation.w,
                    ScaleX = node.Dimensions.x,
                    ScaleY = node.Dimensions.y,
                    ScaleZ = node.Dimensions.z,
                    // only using these for re-exporting the .scene with the things removed
                    Mesh = node.Entity != null ? node.Entity.Mesh : null,
                    Material = node.Entity != null ? node.Entity.Material : null,
                    Static = node.Entity != null ? node.Entity.Static : false,
                    CastShadows = node.Entity != null ? node.Entity.CastShadows : false,
                    ReceiveShadows = node.Entity != null ? node.Entity.ReceiveShadows : false,
                };

                Data.Add(data);
            }
            dataGrid.ItemsSource = Data;

            mapRegionTextBox.Text = "";
            Title = ".scene to .muffin converter - " + filename;
        }
Exemple #3
0
        /// <summary>
        /// Takes the stuff from the .scene loader and puts them into our NodeData classes
        /// </summary>
        private void OpenSceneFile(string filename)
        {
            DSL = new DotSceneLoader();
            DSL.ParseDotScene(filename);

            Data = new List<NodeData>();

            foreach (Node node in DSL.Nodes) {
                NodeData data = new NodeData {
                    // we'll use this as the trigger ID
                    Name = node.Name.Contains("_")
                        ? node.Name.Substring(13, node.Name.IndexOf("_") - 13)
                        : node.Name.Substring(13),
                    // have to split up all of these since the table doesn't know what to do with a Vector3 etc
                    PosX = node.Position.x,
                    PosY = node.Position.y,
                    PosZ = node.Position.z,
                    OrientX = node.Orientation.x,
                    OrientY = node.Orientation.y,
                    OrientZ = node.Orientation.z,
                    OrientW = node.Orientation.w,
                    ScaleX = node.Dimensions.x,
                    ScaleY = node.Dimensions.y,
                    ScaleZ = node.Dimensions.z,
                };
                // and we'll use this as the ID it goes to
                data.ThingFile = node.Name.Contains("_")
                        ? node.Name.Substring(node.Name.IndexOf("_") + 1)
                        : "" + (int.Parse(data.Name, culture) + 1);

                Data.Add(data);
            }
        }