Example #1
0
        public SplineData(PathData splineData, EditorItemSelection selectionManager)
            : base(selectionManager)
        {
            this.splineData = splineData;

            selectionManager.SelectionChanged += selectionManager_SelectionChanged;
            vertexHelper.PointChanged += vertexHelper_PointChanged;
        }
Example #2
0
 public DeathZoneItem(Device device, EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     this.device = device;
     Model = new NJS_OBJECT();
     ImportModel();
     Paste();
 }
Example #3
0
        public SplineData(EditorItemSelection selectionManager)
            : base(selectionManager)
        {
            splineData = new PathData();

            selectionManager.SelectionChanged += selectionManager_SelectionChanged;
            vertexHelper.PointChanged += vertexHelper_PointChanged;
        }
Example #4
0
        public void InitSceneControl(EditorItemSelection selection)
        {
            this.selection = selection;

            // subscribe to our editor select change events
            selection.SelectionChanged += Selection_SelectionChanged;
            sceneTreeView.AfterSelect  += SceneTreeView_AfterSelect;
        }
Example #5
0
 /// <summary>
 /// Creates a LevelItem from an existing COL data.
 /// </summary>
 /// <param name="col"></param>
 /// <param name="dev">Current Direct3d Device.</param>
 public LevelItem(COL col, Device dev, int index, EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     this.index = index;
     COL = col;
     col.Model.ProcessVertexData();
     Mesh = col.Model.Attach.CreateD3DMesh(dev);
 }
Example #6
0
 public DeathZoneItem(NJS_OBJECT model, SA1CharacterFlags flags, Device device, EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     Model = model;
     model.ProcessVertexData();
     Flags = flags;
     Mesh = Model.Attach.CreateD3DMesh(device);
     this.device = device;
 }
Example #7
0
 public SETItem(EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     Position = new Vertex();
     Rotation = new Rotation();
     Scale = new Vertex();
     objdef = LevelData.ObjDefs[id];
     bounds = objdef.GetBounds(this);
 }
Example #8
0
 public StartPosItem(NJS_OBJECT model, string textures, float offset, Vertex position, int yrot, Device dev, EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     Model = model;
     model.ProcessVertexData();
     NJS_OBJECT[] models = model.GetObjects();
     Meshes = new Mesh[models.Length];
     for (int i = 0; i < models.Length; i++)
         if (models[i].Attach != null)
             Meshes[i] = models[i].Attach.CreateD3DMesh(dev);
     texture = textures;
     this.offset = offset;
     Position = position;
     YRotation = yrot;
 }
Example #9
0
 public SETItem(byte[] file, int address, EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     ushort _id = ByteConverter.ToUInt16(file, address);
     ID = _id;
     ClipLevel = (byte)(_id >> 12);
     ushort xrot = BitConverter.ToUInt16(file, address + 2);
     ushort yrot = BitConverter.ToUInt16(file, address + 4);
     ushort zrot = BitConverter.ToUInt16(file, address + 6);
     Rotation = new Rotation(xrot, yrot, zrot);
     Position = new Vertex(file, address + 8);
     Scale = new Vertex(file, address + 0x14);
     isLoaded = true;
     objdef = LevelData.ObjDefs[id];
     bounds = objdef.GetBounds(this);
 }
Example #10
0
 /// <summary>
 /// Creates a Levelitem from an external file.
 /// </summary>
 /// <param name="dev">Current Direct3D device.</param>
 /// <param name="filePath">location of the file to use.</param>
 /// <param name="position">Position to place the resulting model (worldspace).</param>
 /// <param name="rotation">Rotation to apply to the model.</param>
 public LevelItem(Device dev, string filePath, Vertex position, Rotation rotation, int index, EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     this.index = index;
     COL = new COL
     {
         Model = new NJS_OBJECT
         {
             Position = position,
             Rotation = rotation
         }
     };
     ImportModel(filePath, dev);
     COL.CalculateBounds();
     Paste();
 }
Example #11
0
        /// <summary>
        ///  Create a new CAM Item from within the editor.
        /// </summary>
        /// <param name="dev">An active Direct3D device for meshing/material/rendering purposes.</param>
        public CAMItem(Vertex position, EditorItemSelection selectionManager)
            : base(selectionManager)
        {
            CamType = 0x23;

            Position = position;
            Rotation = new Rotation();
            Scale = new Vertex(1, 1, 1);
            Priority = 2;
            PanSpeed = 0x14;

            PointA = new Vertex(position.X + 25, position.Y - 38, position.Z);
            PointB = new Vertex(position.X - 40, position.Y - 38, position.Z);

            Variable = 45f;

            selectionManager.SelectionChanged += selectionManager_SelectionChanged;
        }
Example #12
0
        /// <summary>
        /// Creates a new CAM Item from a byte array and offset.
        /// </summary>
        /// <param name="file"></param>
        /// <param name="address"></param>
        public CAMItem(byte[] file, int address, EditorItemSelection selectionManager)
            : base(selectionManager)
        {
            CamType = file[address];
            Unknown = file[address + 1];
            PanSpeed = file[address + 2];
            Priority = file[address + 3];
            Unknown_2 = BitConverter.ToInt16(file, address + 4);
            Rotation = new Rotation(0, BitConverter.ToInt16(file, address + 6), 0);
            Position = new Vertex(file, address + 8);
            Scale = new Vertex(file, address + 20);
            NotUsed = BitConverter.ToInt32(file, address + 32);
            PointA = new Vertex(file, address + 36);
            PointB = new Vertex(file, address + 48);
            Variable = BitConverter.ToSingle(file, address + 60);

            selectionManager.SelectionChanged += selectionManager_SelectionChanged;
        }
Example #13
0
 /// <summary>
 /// Creates a new instance of an existing item with the specified position and rotation.
 /// </summary>
 /// <param name="attach">Attach to use for this levelItem</param>
 /// <param name="position">Position in worldspace to place this LevelItem.</param>
 /// <param name="rotation">Rotation.</param>
 public LevelItem(Device dev, Attach attach, Vertex position, Rotation rotation, int index, EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     this.index = index;
     COL = new COL
     {
         Model = new NJS_OBJECT
         {
             Attach = attach,
             Position = position,
             Rotation = rotation
         }
     };
     Visible = true;
     Solid = true;
     COL.CalculateBounds();
     Mesh = COL.Model.Attach.CreateD3DMesh(dev);
     Paste();
 }
Example #14
0
        public void TransformGizmoMove(System.Drawing.Point mouseDelta, EditorCamera cam, EditorItemSelection selectedItems)
        {
            if (Enabled)
            {
                Vector2 gizmoMouseInput = new Vector2(mouseDelta.X / 2 * cam.MoveSpeed, mouseDelta.Y / 2 * cam.MoveSpeed);

                switch (Mode)
                {
                case TransformMode.NONE:
                    break;

                case TransformMode.TRANFORM_MOVE:
                    // move all of our editor selected items
                    foreach (Item item in selectedItems.Items)
                    {
                        item.Position = Move(gizmoMouseInput,
                                             item.Position.ToVector3(), cam).ToVertex();

                        if (item is LevelItem)
                        {
                            LevelItem levelItem = item as LevelItem;                         // recalculating the entire bounds could be slow
                            levelItem.CalculateBounds();                                     // what if we just moved the bounds position instead?
                        }
                    }

                    Item firstItem = selectedItems.Get(0);
                    //transformGizmo.SetGizmo(transformGizmo.Position, firstItem.TransformMatrix);
                    SetGizmo(
                        ((Pivot == Pivot.CenterOfMass) ? firstItem.Bounds.Center : firstItem.Position).ToVector3(),
                        firstItem.TransformMatrix);
                    break;

                case TransformMode.TRANSFORM_ROTATE:
                    // rotate all of our editor selected items
                    foreach (Item item in selectedItems.Items)
                    {
                        item.Rotation = Rotate(gizmoMouseInput, cam, item.Rotation);
                    }

                    firstItem = selectedItems.Get(0);
                    SetGizmo(Position, firstItem.TransformMatrix);
                    break;

                case TransformMode.TRANSFORM_SCALE:
                    // scale all of our editor selected items
                    foreach (Item item in selectedItems.Items)
                    {
                        if (item is IScaleable scalableItem)
                        {
                            scalableItem.SetScale(Scale(gizmoMouseInput, scalableItem.GetScale(), cam, true, 0));
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        }
Example #15
0
        public static List<Item> ImportFromFile(string filePath, Device d3ddevice, EditorCamera camera, out bool errorFlag, out string errorMsg, EditorItemSelection selectionManager)
        {
            List<Item> createdItems = new List<Item>();

            if (!File.Exists(filePath))
            {
                errorFlag = true;
                errorMsg = "File does not exist!";
                return null;
            }

            DirectoryInfo filePathInfo = new DirectoryInfo(filePath);

            bool importError = false;
            string importErrorMsg = "";

            switch (filePathInfo.Extension)
            {
                case ".obj":
                case ".objf":
                    Vector3 pos = camera.Position + (-20 * camera.Look);
                    LevelItem item = new LevelItem(d3ddevice, filePath, new Vertex(pos.X, pos.Y, pos.Z), new Rotation(), LevelItems.Count, selectionManager)
                    {
                        Visible = true
                    };

                    createdItems.Add(item);
                    break;

                case ".txt":
                    NodeTable.ImportFromFile(d3ddevice, filePath, out importError, out importErrorMsg, selectionManager);
                    break;

                default:
                    errorFlag = true;
                    errorMsg = "Invalid file format!";
                    return null;
            }

            StateChanged();

            errorFlag = importError;
            errorMsg = importErrorMsg;

            return createdItems;
        }
Example #16
0
 public Item(EditorItemSelection selectionManager)
 {
     selectionManager.SelectionChanged += selectionManager_SelectionChanged;
 }
Example #17
0
        public static void DuplicateSelection(Device d3ddevice, EditorItemSelection selection, out bool errorFlag, out string errorMsg)
        {
            if (selection.ItemCount < 0) { errorFlag = true; errorMsg = "Negative selection count... what did you do?!?"; return; }

            List<Item> newItems = new List<Item>();
            List<Item> currentItems = selection.GetSelection();

            // duplicate goes here
            for (int i = 0; i < selection.ItemCount; i++)
            {
                if (currentItems[i] is SETItem)
                {
                    SETItem originalItem = (SETItem)currentItems[i];
                    SETItem newItem = new SETItem(originalItem.GetBytes(), 0, selection);

                    SETItems[Character].Add(newItem);
                    newItems.Add(newItem);
                }
                else if (currentItems[i] is LevelItem)
                {
                    LevelItem originalItem = (LevelItem)currentItems[0];
                    LevelItem newItem = new LevelItem(d3ddevice, originalItem.CollisionData.Model.Attach, originalItem.Position, originalItem.Rotation, LevelItems.Count, selection);

                    newItem.CollisionData.SurfaceFlags = originalItem.CollisionData.SurfaceFlags;
                    newItems.Add(newItem);
                }
                else if (currentItems[i] is CAMItem)
                {
                    CAMItem originalItem = (CAMItem)currentItems[i];
                    CAMItem newItem = new CAMItem(originalItem.GetBytes(), 0, selection);

                    CAMItems[Character].Add(newItem);
                    newItems.Add(newItem);
                }
            }

            selection.Clear();
            selection.Add(newItems);

            InvalidateRenderState();

            errorFlag = false;
            errorMsg = "";
        }
Example #18
0
        private void Selection_SelectionChanged(EditorItemSelection sender)
        {
            if (suppressSelectionEvents)
            {
                return;
            }

            // match our tree to our editor selection
            List <TreeNode> selectedNodes = new List <TreeNode>();

            foreach (Item item in sender.Items)
            {
                if (item is LevelItem)
                {
                    LevelItem levelItem = (LevelItem)item;

                    // find the index of the level item
                    int index = LevelData.GetIndexOfItem(levelItem);

                    selectedNodes.Add(levelItemNode.Nodes[index]);
                }
                else if (item is DeathZoneItem)
                {
                    DeathZoneItem deathZoneItem = (DeathZoneItem)item;

                    int index = LevelData.DeathZones.IndexOf(deathZoneItem);

                    selectedNodes.Add(deathZoneNode.Nodes[index]);
                }
                else if (item is SETItem)
                {
                    SETItem setItem = (SETItem)item;

                    int index = LevelData.GetIndexOfSETItem(LevelData.Character, setItem);                    //LevelData.SETItems[LevelData.Character].IndexOf(setItem);

                    selectedNodes.Add(setNode.Nodes[index]);
                }
                else if (item is CAMItem)
                {
                    CAMItem camItem = (CAMItem)item;

                    int index = LevelData.CAMItems[LevelData.Character].IndexOf(camItem);

                    selectedNodes.Add(camNode.Nodes[index]);
                }
                else if (item is MissionSETItem)
                {
                    MissionSETItem miSetItem = (MissionSETItem)item;

                    int index = LevelData.MissionSETItems[LevelData.Character].IndexOf(miSetItem);

                    selectedNodes.Add(missionSETNode.Nodes[index]);
                }
                else if (item is SplineData)
                {
                    SplineData spline = (SplineData)item;

                    int index = LevelData.LevelSplines.IndexOf(spline);

                    selectedNodes.Add(splineNode.Nodes[index]);
                }
            }

            sceneTreeView.SelectedNodes = selectedNodes;
        }
Example #19
0
 void selectionManager_SelectionChanged(EditorItemSelection sender)
 {
     selected = (sender.GetSelection().Contains(this));
 }
Example #20
0
 void selectionManager_SelectionChanged(EditorItemSelection sender)
 {
     if (sender.ItemCount != 1)
     {
         vertexHelper.Enabled = false;
     }
     else
     {
         if (Selected)
         {
             vertexHelper.Enabled = (selectedKnot != -1);
         }
     }
 }
Example #21
0
 public DuplicateTo(EditorItemSelection items)
 {
     InitializeComponent();
     this.items = items;
 }
        public bool TransformGizmoMove(System.Drawing.Point mouseDelta, EditorCamera cam, EditorItemSelection selectedItems)
        {
            bool result = false;

            // Returns false if no actual movement happened
            if (!Enabled)
            {
                return(false);
            }

            float xChange = mouseDelta.X / 2 * cam.MoveSpeed;
            float yChange = mouseDelta.Y / 2 * cam.MoveSpeed;

            if (xChange == 0 && yChange == 0)
            {
                return(false);
            }

            Item    firstItem       = selectedItems.Get(0);
            Vector2 gizmoMouseInput = new Vector2(xChange, yChange);

            switch (Mode)
            {
            case TransformMode.TRANFORM_MOVE:
                // Move selected items
                foreach (Item item in selectedItems.Items)
                {
                    Vertex backuppos = item.Position.Clone();
                    item.Position = Move(gizmoMouseInput,
                                         item.Position.ToVector3(), cam).ToVertex();
                    // Update item bounds
                    if (item is LevelItem)
                    {
                        LevelItem levelItem = item as LevelItem;
                        Vertex    newpos    = item.Position;
                        levelItem.Bounds.Center.X += newpos.X - backuppos.X;
                        levelItem.Bounds.Center.Y += newpos.Y - backuppos.Y;
                        levelItem.Bounds.Center.Z += newpos.Z - backuppos.Z;
                    }
                    result = true;
                }
                // Update gizmo position
                SetGizmo(
                    ((Pivot == Pivot.CenterOfMass) ? firstItem.Bounds.Center : firstItem.Position).ToVector3(),
                    firstItem.TransformMatrix);
                return(result);

            case TransformMode.TRANSFORM_ROTATE:
                // rotate all of our editor selected items
                foreach (Item item in selectedItems.Items)
                {
                    item.Rotation = Rotate(gizmoMouseInput, cam, item.Rotation);
                    result        = true;
                }
                SetGizmo(
                    ((Pivot == Pivot.CenterOfMass) ? firstItem.Bounds.Center : firstItem.Position).ToVector3(),
                    firstItem.TransformMatrix);
                return(result);

            case TransformMode.TRANSFORM_SCALE:
                // scale all of our editor selected items
                foreach (Item item in selectedItems.Items)
                {
                    if (item is IScaleable scalableItem)
                    {
                        // Scaling speed for SET items
                        float speed = 1.0f;

                        // Non-SET items should have slower scaling
                        if (item is LevelItem || item is DeathZoneItem)
                        {
                            speed = 0.01f;
                        }

                        scalableItem.SetScale(Scale(gizmoMouseInput, scalableItem.GetScale(), cam, true, 0, speed));
                    }
                    result = true;
                }
                SetGizmo(
                    ((Pivot == Pivot.CenterOfMass) ? firstItem.Bounds.Center : firstItem.Position).ToVector3(),
                    firstItem.TransformMatrix);
                return(result);

            case TransformMode.NONE:
            default:
                return(false);
            }
        }
Example #23
0
        /// <summary>
        /// Imports a nodetable (a single-level instance heirarchy layout) file.
        /// </summary>
        /// <param name="filePath">full path to file (with extension) to import data from.</param>
        /// <param name="errorFlag">Set to TRUE if an error occured.</param>
        /// <param name="errorMsg">Suggested error message to show to the user.</param>
        public static void ImportFromFile(Device dev, string filePath, out bool errorFlag, out string errorMsg, EditorItemSelection selectionManager)
        {
            if (!File.Exists(filePath))
            {
                errorFlag = true;
                errorMsg = "File not found!";
                return;
            }

            Stream nodeTable = File.OpenRead(filePath);
            StreamReader nodeTableStream = new StreamReader(nodeTable);
            string folderPath = Path.GetDirectoryName(filePath);

            string version = nodeTableStream.ReadLine();

            string[] versionSplit = version.Split(' ');

            #region Version Validity Check
            if (versionSplit.Length <= 1 || versionSplit[0] != "ver") // invalid file
            {
                errorFlag = true;
                errorMsg = "Invalid file! (Version Check Failed)";
                return;
            }

            // versionNumber is the last string in the split sequence, with the ; character as the delimiter
            string[] versionNumberSplit = versionSplit[1].Split(';');
            string versionNumber = versionNumberSplit[0];

            if ((versionNumber != "1") && (versionNumber != "1.5") && (versionNumber != "1.6"))
            {
                errorFlag = true;
                errorMsg = "Invalid Nodetable version number was supplied";
                nodeTable.Close();
                return;
            }
            #endregion

            // get node count from next line
            string[] nodeCountLines = nodeTableStream.ReadLine().Split(' ');
            if ((nodeCountLines[0] != "node") || (nodeCountLines[1] != "count"))
            {
                errorFlag = true;
                errorMsg = "Error in node count!";
                nodeTable.Close();
                return;
            }

            nodeCountLines = nodeCountLines[2].Split(';');
            int nodeCount = 0;

            if (!Int32.TryParse(nodeCountLines[0], out nodeCount))
            {
                errorFlag = true;
                errorMsg = "Error parsing node count!";
                nodeTable.Close();
                return;
            }

            nodeTableStream.ReadLine(); // aligning

            List<KeyValuePair<int, Attach>> instanceMgr = new List<KeyValuePair<int, Attach>>();

            if (versionNumber == "1.5")
            {
                for (int n = 0; n < nodeCount; n++)
                {
                    string nodeInput = nodeTableStream.ReadLine();
                    string[] nodeDescriptorSplit = nodeInput.Split(' ');
                    string[] nodeIndexSplit = nodeDescriptorSplit[1].Split(';');

                    int nodeIndex = 0;

                    if (!Int32.TryParse(nodeIndexSplit[0], out nodeIndex))
                    {
                        errorFlag = true;
                        errorMsg = String.Format("Error parsing node label for node {0}.", n);
                        nodeTableStream.Close();
                        return;
                    }

                    #region Position Read/Parse
                    Vertex position;
                    float xPos, yPos, zPos;
                    string[] positionSplit = nodeTableStream.ReadLine().Split(' ');

                    if (positionSplit[0] != "pos")
                    {
                        errorFlag = true;
                        errorMsg = String.Format("Error retrieving position values for node {0}", n);
                        nodeTableStream.Close();
                        return;
                    }
                    positionSplit[3] = positionSplit[3].Split(';')[0];

                    if ((float.TryParse(positionSplit[1], out xPos)) && (float.TryParse(positionSplit[2], out yPos)) && (float.TryParse(positionSplit[3], out zPos)))
                    {
                        position = new Vertex(xPos, yPos, zPos);
                    }
                    else
                    {
                        errorFlag = true;
                        errorMsg = String.Format("Error parsing position values for node {0}", n);
                        nodeTableStream.Close();
                        return;
                    }
                    #endregion

                    #region Rotation Read/Parse
                    Rotation rotation;
                    float xRot, yRot, zRot;

                    string[] rotationSplit = nodeTableStream.ReadLine().Split(' ');

                    if (rotationSplit[0] != "rot")
                    {
                        errorFlag = true;
                        errorMsg = String.Format("Error retrieving rotation values for node {0}", n);
                        nodeTableStream.Close();
                        return;
                    }
                    rotationSplit[3] = rotationSplit[3].Split(';')[0];

                    if (float.TryParse(rotationSplit[1], out xRot) && float.TryParse(rotationSplit[2], out yRot) && float.TryParse(rotationSplit[3], out zRot))
                    {

                        rotation = new Rotation(Rotation.DegToBAMS(xRot), Rotation.DegToBAMS(yRot), Rotation.DegToBAMS(zRot));
                    }
                    else
                    {
                        errorFlag = true;
                        errorMsg = String.Format("Error parsing rotation values for node {0}", n);
                        nodeTableStream.Close();
                        return;
                    }
                    #endregion

                    #region Creating LevelItem
                    string modelFilePath = String.Concat(folderPath, "/", nodeIndex, ".obj");
                    if (!File.Exists(modelFilePath))
                    {
                        errorFlag = true;
                        errorMsg = String.Format("File not found: {0}", modelFilePath);
                        nodeTableStream.Close();
                        return;
                    }

                    if (nodeDescriptorSplit[0] == "node")
                    {
                        LevelItem levelItem = new LevelItem(dev, modelFilePath, position, rotation, LevelData.LevelItems.Count, selectionManager);
                        instanceMgr.Add(new KeyValuePair<int, Attach>(nodeIndex, levelItem.CollisionData.Model.Attach));
                    }
                    else if (nodeDescriptorSplit[0] == "instance")
                    {
                        Attach instanceBaseAttach = instanceMgr.Find(item => item.Key == nodeIndex).Value;
                        LevelItem levelItem = new LevelItem(dev, instanceBaseAttach, position, rotation, LevelData.LevelItems.Count, selectionManager);
                    }
                    #endregion

                    nodeTableStream.ReadLine(); // aligning
                }
            }
            else if (versionNumber == "1")
            {
                // version 1 does not support instances. Just read and construct.
                throw new NotImplementedException();
            }
            else if (versionNumber == "1.6")
            {
                for (int n = 0; n < nodeCount; n++)
                {
                    string nodeInput = nodeTableStream.ReadLine();
                    string[] nodeDescriptorSplit = nodeInput.Split(' ');
                    string[] nodeIndexSplit = nodeDescriptorSplit[1].Split(';');

                    int nodeIndex = 0;

                    if (!Int32.TryParse(nodeIndexSplit[0], out nodeIndex))
                    {
                        errorFlag = true;
                        errorMsg = String.Format("Error parsing node label for node {0}.", n);
                        nodeTableStream.Close();
                        return;
                    }

                    #region Position Read/Parse
                    Vertex position;
                    float xPos, yPos, zPos;
                    string[] positionSplit = nodeTableStream.ReadLine().Split(' ');

                    if (positionSplit[0] != "pos")
                    {
                        errorFlag = true;
                        errorMsg = String.Format("Error retrieving position values for node {0}", n);
                        nodeTableStream.Close();
                        return;
                    }
                    positionSplit[3] = positionSplit[3].Split(';')[0];

                    if ((float.TryParse(positionSplit[1], out xPos)) && (float.TryParse(positionSplit[2], out yPos)) && (float.TryParse(positionSplit[3], out zPos)))
                    {
                        position = new Vertex(xPos, yPos, zPos);
                    }
                    else
                    {
                        errorFlag = true;
                        errorMsg = String.Format("Error parsing position values for node {0}", n);
                        nodeTableStream.Close();
                        return;
                    }
                    #endregion

                    #region Rotation Read/Parse
                    Rotation rotation;
                    float xRot, yRot, zRot;

                    string[] rotationSplit = nodeTableStream.ReadLine().Split(' ');

                    if (rotationSplit[0] != "rot")
                    {
                        errorFlag = true;
                        errorMsg = String.Format("Error retrieving rotation values for node {0}", n);
                        nodeTableStream.Close();
                        return;
                    }
                    rotationSplit[3] = rotationSplit[3].Split(';')[0];

                    if (float.TryParse(rotationSplit[1], out xRot) && float.TryParse(rotationSplit[2], out yRot) && float.TryParse(rotationSplit[3], out zRot))
                    {

                        rotation = new Rotation(Rotation.DegToBAMS(xRot), Rotation.DegToBAMS(yRot), Rotation.DegToBAMS(zRot));
                    }
                    else
                    {
                        errorFlag = true;
                        errorMsg = String.Format("Error parsing rotation values for node {0}", n);
                        nodeTableStream.Close();
                        return;
                    }
                    #endregion

                    #region SurfaceFlags Read/Parse
                    string surfaceFlags = "";
                    string surfaceFlagsLine = nodeTableStream.ReadLine();
                    string[] surfaceFlagsSplit = surfaceFlagsLine.Split(' ');

                    if (surfaceFlagsSplit[0] == "surfaceflags")
                    {
                        surfaceFlags = surfaceFlagsSplit[1].Split(';')[0];
                        surfaceFlagsSplit = surfaceFlags.Split('X');
                        surfaceFlags = surfaceFlagsSplit[1];
                    }
                    #endregion

                    #region Creating LevelItem
                    string modelFilePath = String.Concat(folderPath, "/", nodeIndex, ".obj");
                    if (!File.Exists(modelFilePath))
                    {
                        errorFlag = true;
                        errorMsg = String.Format("File not found: {0}", modelFilePath);
                        nodeTableStream.Close();
                        return;
                    }

                    if (nodeDescriptorSplit[0] == "node")
                    {
                        LevelItem levelItem = new LevelItem(dev, modelFilePath, position, rotation, LevelData.LevelItems.Count, selectionManager);
                        levelItem.Flags = surfaceFlags;
                        instanceMgr.Add(new KeyValuePair<int, Attach>(nodeIndex, levelItem.CollisionData.Model.Attach));
                    }
                    else if (nodeDescriptorSplit[0] == "instance")
                    {
                        Attach instanceBaseAttach = instanceMgr.Find(item => item.Key == nodeIndex).Value;
                        LevelItem levelItem = new LevelItem(dev, instanceBaseAttach, position, rotation, LevelData.LevelItems.Count, selectionManager);
                        levelItem.Flags = surfaceFlags;
                    }
                    #endregion

                    nodeTableStream.ReadLine(); // aligning
                }
            }

            nodeTable.Close();

            errorFlag = false;
            errorMsg = "Import successful!";
        }
Example #24
0
        void selectionManager_SelectionChanged(EditorItemSelection sender)
        {
            if (sender.ItemCount != 1)
            {
                pointHelperA.Enabled = false;
                pointHelperB.Enabled = false;
            }
            else
            {
                if (Selected)
                {
                    pointHelperA.SetPoint(PointA);
                    pointHelperB.SetPoint(PointB);

                    pointHelperA.Enabled = true;
                    pointHelperB.Enabled = true;
                }
            }
        }
Example #25
0
        void SelectionChanged(EditorItemSelection sender)
        {
            propertyGrid1.SelectedObjects = sender.GetSelection().ToArray();

            if (cam.mode == 1)
            {
                cam.FocalPoint = Item.CenterFromSelection(sender.GetSelection()).ToVector3();
            }

            if (sender.ItemCount > 0) // set up gizmo
            {
                transformGizmo.Enabled = true;
                transformGizmo.AffectedItems = sender.GetSelection();
            }
            else
            {
                if (transformGizmo != null)
                {
                    transformGizmo.AffectedItems = new List<Item>();
                    transformGizmo.Enabled = false;
                }
            }
        }
Example #26
0
 public DuplicateTo(EditorItemSelection items)
 {
     InitializeComponent();
     this.items = items;
 }