Exemplo n.º 1
0
        private void SaveFile()
        {
            translokator.Grids = new Grid[TranslokatorTree.Nodes[1].GetNodeCount(false)];
            for (int i = 0; i < translokator.Grids.Length; i++)
            {
                Grid grid = (TranslokatorTree.Nodes[1].Nodes[i].Tag as Grid);
                translokator.Grids[i] = grid;
            }

            translokator.ObjectGroups = new ObjectGroup[TranslokatorTree.Nodes[2].GetNodeCount(false)];
            for (int i = 0; i < translokator.ObjectGroups.Length; i++)
            {
                ObjectGroup objectGroup = (TranslokatorTree.Nodes[2].Nodes[i].Tag as ObjectGroup);
                objectGroup.Objects    = new ResourceTypes.Translokator.Object[TranslokatorTree.Nodes[2].Nodes[i].GetNodeCount(false)];
                objectGroup.NumObjects = objectGroup.Objects.Length;
                for (int y = 0; y < objectGroup.Objects.Length; y++)
                {
                    ResourceTypes.Translokator.Object obj = (TranslokatorTree.Nodes[2].Nodes[i].Nodes[y].Tag as ResourceTypes.Translokator.Object);
                    obj.Instances    = new Instance[TranslokatorTree.Nodes[2].Nodes[i].Nodes[y].GetNodeCount(false)];
                    obj.NumInstances = obj.Instances.Length;
                    for (int z = 0; z < obj.Instances.Length; z++)
                    {
                        Instance instance = (TranslokatorTree.Nodes[2].Nodes[i].Nodes[y].Nodes[z].Tag as Instance);
                        obj.Instances[z] = instance;
                    }
                    objectGroup.Objects[y] = obj;
                }

                translokator.ObjectGroups[i] = objectGroup;
            }
            translokator.WriteToFile(file);

            Text          = Language.GetString("$TRANSLOKATOR_EDITOR");
            bIsFileEdited = false;
        }
Exemplo n.º 2
0
        private void AddInstanceNode()
        {
            if (TranslokatorTree.SelectedNode.Tag is ResourceTypes.Translokator.Object)
            {
                ResourceTypes.Translokator.Object obj = (TranslokatorTree.SelectedNode.Tag as ResourceTypes.Translokator.Object);
                Instance instance     = new Instance();
                TreeNode instanceNode = new TreeNode(obj.Name + " " + TranslokatorTree.SelectedNode.GetNodeCount(false));
                instanceNode.Tag = instance;
                TranslokatorTree.SelectedNode.Nodes.Add(instanceNode);

                Text          = Language.GetString("$TRANSLOKATOR_EDITOR") + "*";
                bIsFileEdited = true;
            }
            if (TranslokatorTree.SelectedNode.Tag is Instance && TranslokatorTree.SelectedNode.Parent.Tag is ResourceTypes.Translokator.Object)
            {
                var      obj          = (TranslokatorTree.SelectedNode.Parent.Tag as ResourceTypes.Translokator.Object);
                Instance instance     = new Instance();
                TreeNode instanceNode = new TreeNode(obj.Name + " " + TranslokatorTree.SelectedNode.Parent.GetNodeCount(false));
                instanceNode.Tag = instance;
                TranslokatorTree.SelectedNode.Parent.Nodes.Add(instanceNode);

                Text          = Language.GetString("$TRANSLOKATOR_EDITOR") + "*";
                bIsFileEdited = true;
            }
        }
Exemplo n.º 3
0
        private void AddInstance_Click(object sender, EventArgs e)
        {
            ResourceTypes.Translokator.Object obj = (TranslokatorTree.SelectedNode.Tag as ResourceTypes.Translokator.Object);
            Instance instance     = new Instance();
            TreeNode instanceNode = new TreeNode(obj.Name + " " + TranslokatorTree.SelectedNode.GetNodeCount(false));

            instanceNode.Tag = instance;
            TranslokatorTree.SelectedNode.Nodes.Add(instanceNode);
        }
Exemplo n.º 4
0
        private void AddObjectOnClick(object sender, EventArgs e)
        {
            ObjectGroup group = (TranslokatorTree.SelectedNode.Tag as ObjectGroup);

            ResourceTypes.Translokator.Object obj = new ResourceTypes.Translokator.Object();
            TreeNode instanceNode = new TreeNode(obj.Name + " " + TranslokatorTree.SelectedNode.GetNodeCount(false));

            instanceNode.Tag = obj;
            TranslokatorTree.SelectedNode.Nodes.Add(instanceNode);
        }
Exemplo n.º 5
0
 private void AddObjectNode()
 {
     if (TranslokatorTree.SelectedNode.Tag is ObjectGroup)
     {
         ObjectGroup group = (TranslokatorTree.SelectedNode.Tag as ObjectGroup);
         ResourceTypes.Translokator.Object obj = new ResourceTypes.Translokator.Object();
         obj.Name.Set("NewObject");
         TreeNode instanceNode = new TreeNode(obj.Name + " " + TranslokatorTree.SelectedNode.GetNodeCount(false));
         instanceNode.Tag = obj;
         TranslokatorTree.SelectedNode.Nodes.Add(instanceNode);
     }
 }
Exemplo n.º 6
0
        private void LoadFile()
        {
            translokator = new TranslokatorLoader(file);
            TranslokatorTree.Nodes.Clear();

            TreeNode headerData = new TreeNode("Header Data");

            headerData.Tag = translokator;

            TreeNode gridNode = new TreeNode("Grids");

            for (int i = 0; i < translokator.Grids.Length; i++)
            {
                Grid     grid  = translokator.Grids[i];
                TreeNode child = new TreeNode("Grid " + i);
                child.Tag = grid;
                gridNode.Nodes.Add(child);
            }
            TreeNode ogNode = new TreeNode("Objects Groups");

            for (int i = 0; i < translokator.ObjectGroups.Length; i++)
            {
                ObjectGroup objectGroup     = translokator.ObjectGroups[i];
                TreeNode    objectGroupNode = new TreeNode("Object Group " + i);
                objectGroupNode.Tag = objectGroup;

                for (int y = 0; y < objectGroup.Objects.Length; y++)
                {
                    ResourceTypes.Translokator.Object obj = objectGroup.Objects[y];
                    TreeNode objNode = new TreeNode(obj.Name.ToString());
                    objNode.Tag = obj;
                    objectGroupNode.Nodes.Add(objNode);

                    for (int x = 0; x < obj.Instances.Length; x++)
                    {
                        Instance instance     = obj.Instances[x];
                        TreeNode instanceNode = new TreeNode(obj.Name + " " + x);
                        instanceNode.Tag = instance;
                        objNode.Nodes.Add(instanceNode);
                    }
                }

                ogNode.Nodes.Add(objectGroupNode);
            }
            TranslokatorTree.Nodes.Add(headerData);
            TranslokatorTree.Nodes.Add(gridNode);
            TranslokatorTree.Nodes.Add(ogNode);

            Text          = Language.GetString("$TRANSLOKATOR_EDITOR");
            bIsFileEdited = false;
        }
Exemplo n.º 7
0
        private void AddObjectNode()
        {
            if (TranslokatorTree.SelectedNode.Tag is ObjectGroup)
            {
                ObjectGroup group = (TranslokatorTree.SelectedNode.Tag as ObjectGroup);
                ResourceTypes.Translokator.Object obj = new ResourceTypes.Translokator.Object();
                obj.Name.Set("NewObject");
                TreeNode instanceNode = new TreeNode(obj.Name + " " + TranslokatorTree.SelectedNode.GetNodeCount(false));
                instanceNode.Tag = obj;
                TranslokatorTree.SelectedNode.Nodes.Add(instanceNode);

                Text          = Language.GetString("$TRANSLOKATOR_EDITOR") + "*";
                bIsFileEdited = true;
            }
        }
Exemplo n.º 8
0
 private void AddInstanceNode()
 {
     if (TranslokatorTree.SelectedNode.Tag is ResourceTypes.Translokator.Object)
     {
         ResourceTypes.Translokator.Object obj = (TranslokatorTree.SelectedNode.Tag as ResourceTypes.Translokator.Object);
         Instance instance     = new Instance();
         TreeNode instanceNode = new TreeNode(obj.Name + " " + TranslokatorTree.SelectedNode.GetNodeCount(false));
         instanceNode.Tag = instance;
         TranslokatorTree.SelectedNode.Nodes.Add(instanceNode);
     }
     if (TranslokatorTree.SelectedNode.Tag is Instance && TranslokatorTree.SelectedNode.Parent.Tag is ResourceTypes.Translokator.Object)
     {
         var      obj          = (TranslokatorTree.SelectedNode.Parent.Tag as ResourceTypes.Translokator.Object);
         Instance instance     = new Instance();
         TreeNode instanceNode = new TreeNode(obj.Name + " " + TranslokatorTree.SelectedNode.Parent.GetNodeCount(false));
         instanceNode.Tag = instance;
         TranslokatorTree.SelectedNode.Parent.Nodes.Add(instanceNode);
     }
 }
Exemplo n.º 9
0
        public SpatialGrid(TranslokatorLoader translokator)
        {
            bIsReady   = true;
            gridBounds = translokator.Bounds;
            width      = translokator.Grids[0].Width;
            height     = translokator.Grids[0].Height;
            cellSize   = new Vector2(gridBounds.Width / width, gridBounds.Height / height);
            cells      = new SpatialCell[width * height];
            origin     = gridBounds.Minimum;

            var index = 0;

            for (int i = 0; i < width; i++)
            {
                for (int x = 0; x < height; x++)
                {
                    var extents = new BoundingBox();
                    extents.Minimum = new Vector3(origin.X + cellSize.X * x, origin.Y + cellSize.Y * i, 10.0f);
                    extents.Maximum = new Vector3(origin.X + cellSize.X * (x + 1), origin.Y + cellSize.Y * (i + 1), 10.0f);
                    cells[index++]  = new SpatialCell(extents);
                }
            }

            for (int i = 0; i != translokator.ObjectGroups.Length; i++)
            {
                ObjectGroup objectGroup = translokator.ObjectGroups[i];

                for (int x = 0; x != objectGroup.NumObjects; x++)
                {
                    ResourceTypes.Translokator.Object obj = objectGroup.Objects[x];

                    for (int y = 0; y != obj.NumInstances; y++)
                    {
                        Instance          instance = obj.Instances[y];
                        var               cell     = GetCell(instance.Position);
                        RenderBoundingBox box      = new RenderBoundingBox();
                        box.SetTransform(Matrix.Translation(instance.Position));
                        box.Init(new BoundingBox(-Vector3.One, Vector3.One));
                        cells[cell].AddAsset(box, StringHelpers.GetNewRefID());
                    }
                }
            }
        }
Exemplo n.º 10
0
        private void LHFunctionButton_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                FileInfo           info    = new FileInfo(openFileDialog1.FileName);
                TranslokatorLoader loader2 = new TranslokatorLoader(info);

                for (int i = 0; i < loader2.ObjectGroups.Length; i++)
                {
                    ObjectGroup objectGroup = loader2.ObjectGroups[i];
                    ObjectGroup transGroup  = translokator.ObjectGroups[i];

                    for (int y = 0; y < objectGroup.Objects.Length; y++)
                    {
                        ResourceTypes.Translokator.Object loaderObj = objectGroup.Objects[y];

                        for (int z = 0; z < transGroup.Objects.Length; z++)
                        {
                            ResourceTypes.Translokator.Object transObj = transGroup.Objects[z];

                            if (loaderObj.Name == transObj.Name)
                            {
                                int size = transObj.Instances.Length - loaderObj.Instances.Length;

                                if (size > 0)
                                {
                                    Instance[] newArray = new Instance[size];
                                    Array.Copy(transObj.Instances, loaderObj.Instances.Length, newArray, 0, newArray.Length);
                                    transObj.Instances = newArray;
                                }
                            }
                        }
                    }
                }

                TranslokatorTree.Nodes.Clear();

                TreeNode headerData = new TreeNode("Header Data");
                headerData.Tag = translokator;

                TreeNode gridNode = new TreeNode("Grids");
                for (int i = 0; i < translokator.Grids.Length; i++)
                {
                    Grid     grid  = translokator.Grids[i];
                    TreeNode child = new TreeNode("Grid " + i);
                    child.Tag = grid;
                    gridNode.Nodes.Add(child);
                }
                TreeNode ogNode = new TreeNode("Objects Groups");
                for (int i = 0; i < translokator.ObjectGroups.Length; i++)
                {
                    ObjectGroup objectGroup     = translokator.ObjectGroups[i];
                    TreeNode    objectGroupNode = new TreeNode("Object Group " + i);
                    objectGroupNode.Tag = objectGroup;

                    for (int y = 0; y < objectGroup.Objects.Length; y++)
                    {
                        ResourceTypes.Translokator.Object obj = objectGroup.Objects[y];
                        TreeNode objNode = new TreeNode(obj.Name.ToString());
                        objNode.Tag = obj;
                        objectGroupNode.Nodes.Add(objNode);

                        for (int x = 0; x < obj.Instances.Length; x++)
                        {
                            Instance instance     = obj.Instances[x];
                            TreeNode instanceNode = new TreeNode(obj.Name + " " + x);
                            instanceNode.Tag = instance;
                            objNode.Nodes.Add(instanceNode);
                        }
                    }

                    ogNode.Nodes.Add(objectGroupNode);
                }
                TranslokatorTree.Nodes.Add(headerData);
                TranslokatorTree.Nodes.Add(gridNode);
                TranslokatorTree.Nodes.Add(ogNode);

                Text          = Language.GetString("$TRANSLOKATOR_EDITOR") + "*";
                bIsFileEdited = true;
            }
        }