Exemplo n.º 1
0
 private void SetTransformEdit()
 {
     IsEntryReady = false;
     if (FrameResource.IsFrameType(currentObject))
     {
         FrameObjectBase fObject = (currentObject as FrameObjectBase);
         CurrentEntry.Text      = fObject.Name.String;
         PositionXNumeric.Value = Convert.ToDecimal(fObject.Matrix.Position.X);
         PositionYNumeric.Value = Convert.ToDecimal(fObject.Matrix.Position.Y);
         PositionZNumeric.Value = Convert.ToDecimal(fObject.Matrix.Position.Z);
         RotationXNumeric.Value = Convert.ToDecimal(fObject.Matrix.Rotation.X);
         RotationYNumeric.Value = Convert.ToDecimal(fObject.Matrix.Rotation.Y);
         RotationZNumeric.Value = Convert.ToDecimal(fObject.Matrix.Rotation.Z);
         ScaleXNumeric.Enabled  = ScaleYNumeric.Enabled = ScaleZNumeric.Enabled = true;
         ScaleXNumeric.Value    = Convert.ToDecimal(fObject.Matrix.Scale.X);
         ScaleYNumeric.Value    = Convert.ToDecimal(fObject.Matrix.Scale.Y);
         ScaleZNumeric.Value    = Convert.ToDecimal(fObject.Matrix.Scale.Z);
     }
     else if (currentObject is ResourceTypes.Collisions.Collision.Placement)
     {
         ResourceTypes.Collisions.Collision.Placement placement = (currentObject as ResourceTypes.Collisions.Collision.Placement);
         CurrentEntry.Text      = placement.Hash.ToString();
         PositionXNumeric.Value = Convert.ToDecimal(placement.Position.X);
         PositionYNumeric.Value = Convert.ToDecimal(placement.Position.Y);
         PositionZNumeric.Value = Convert.ToDecimal(placement.Position.Z);
         RotationXNumeric.Value = Convert.ToDecimal(placement.Rotation.X);
         RotationYNumeric.Value = Convert.ToDecimal(placement.Rotation.Y);
         RotationZNumeric.Value = Convert.ToDecimal(placement.Rotation.Z);
         ScaleXNumeric.Value    = ScaleYNumeric.Value = ScaleZNumeric.Value = 0.0M;
         ScaleXNumeric.Enabled  = ScaleYNumeric.Enabled = ScaleZNumeric.Enabled = false;
     }
     IsEntryReady = true;
 }
Exemplo n.º 2
0
        private void LoadMaterials()
        {
            if (isMaterialTabFocused && !hasLoadedMaterials)
            {
                MatViewPanel.Controls.Clear();
                currentMaterials.Clear();
                if (FrameResource.IsFrameType(currentObject))
                {
                    if (currentObject is FrameObjectSingleMesh)
                    {
                        var entry = (currentObject as FrameObjectSingleMesh);
                        MaterialStruct[] materialAssignments = entry.Material.Materials[LODComboBox.SelectedIndex];
                        for (int x = 0; x != materialAssignments.Length; x++)
                        {
                            TextureEntry textEntry = new TextureEntry();

                            var       mat      = materialAssignments[x];
                            IMaterial material = MaterialsManager.LookupMaterialByHash(mat.MaterialHash);

                            textEntry.OnEntrySingularClick += MatViewPanel_TextureEntryOnSingularClick;
                            textEntry.OnEntryDoubleClick   += MatViewPanel_TextureEntryOnDoubleClick;
                            textEntry.SetMaterial(material);

                            currentMaterials.Add(textEntry, mat);
                            MatViewPanel.Controls.Add(textEntry);
                        }
                    }
                }

                hasLoadedMaterials = true;
            }
        }
Exemplo n.º 3
0
        public Vector3 JumpToHelper()
        {
            object data = TreeView_Explorer.SelectedNode.Tag;

            if (FrameResource.IsFrameType(data))
            {
                return((data as FrameObjectBase).WorldTransform.Translation);
            }

            if (data.GetType() == typeof(ResourceTypes.Collisions.Collision.Placement))
            {
                return((data as ResourceTypes.Collisions.Collision.Placement).Position);
            }

            if (data.GetType() == typeof(Rendering.Graphics.RenderJunction))
            {
                return((data as Rendering.Graphics.RenderJunction).Data.Position);
            }

            if (data.GetType() == typeof(Rendering.Graphics.RenderNav))
            {
                return((data as Rendering.Graphics.RenderNav).Transform.Translation);
            }

            if (data.GetType() == typeof(ResourceTypes.Actors.ActorEntry))
            {
                return((data as ResourceTypes.Actors.ActorEntry).Position);
            }

            return(new Vector3(0, 0, 0));
        }
Exemplo n.º 4
0
        private void OpenEntryContext(object sender, System.ComponentModel.CancelEventArgs e)
        {
            EntryMenuStrip.Items[0].Visible = false;
            EntryMenuStrip.Items[1].Visible = false;
            EntryMenuStrip.Items[2].Visible = false;
            EntryMenuStrip.Items[3].Visible = false;
            EntryMenuStrip.Items[4].Visible = false;

            if (treeView1.SelectedNode != null && treeView1.SelectedNode.Tag != null)
            {
                EntryMenuStrip.Items[1].Visible = true;
                EntryMenuStrip.Items[2].Visible = true;

                if (FrameResource.IsFrameType(treeView1.SelectedNode.Tag) ||
                    treeView1.SelectedNode.Tag.GetType() == typeof(Rendering.Graphics.RenderJunction))
                {
                    EntryMenuStrip.Items[0].Visible = true;
                }
                if ((treeView1.SelectedNode.Tag.GetType() == typeof(FrameObjectSingleMesh) ||
                     treeView1.SelectedNode.Tag.GetType() == typeof(FrameObjectModel) ||
                     treeView1.SelectedNode.Tag.GetType() == typeof(ResourceTypes.Collisions.Collision.NXSStruct)))
                {
                    EntryMenuStrip.Items[3].Visible = true;
                }

                if (FrameResource.IsFrameType(treeView1.SelectedNode.Tag))
                {
                    EntryMenuStrip.Items[4].Visible = true;
                }
            }
        }
Exemplo n.º 5
0
 private void SetMaterialTab()
 {
     LODComboBox.Items.Clear();
     if (FrameResource.IsFrameType(currentObject))
     {
         if (currentObject is FrameObjectSingleMesh)
         {
             var entry = (currentObject as FrameObjectSingleMesh);
             for (int i = 0; i != entry.Geometry.NumLods; i++)
             {
                 LODComboBox.Items.Add("LOD #" + i);
             }
             LODComboBox.SelectedIndex = 0;
         }
     }
 }
Exemplo n.º 6
0
 public void UpdateObject()
 {
     if (IsEntryReady && currentObject != null)
     {
         if (FrameResource.IsFrameType(currentObject))
         {
             FrameObjectBase fObject = (currentObject as FrameObjectBase);
             fObject.Matrix.Position = new Vector3(Convert.ToSingle(PositionXNumeric.Value), Convert.ToSingle(PositionYNumeric.Value), Convert.ToSingle(PositionZNumeric.Value));
             fObject.Matrix.SetRotationMatrix(new Vector3(Convert.ToSingle(RotationXNumeric.Value), Convert.ToSingle(RotationYNumeric.Value), Convert.ToSingle(RotationZNumeric.Value)));
             fObject.Matrix.SetScaleMatrix(new Vector3(Convert.ToSingle(ScaleXNumeric.Value), Convert.ToSingle(ScaleYNumeric.Value), Convert.ToSingle(ScaleZNumeric.Value)));
         }
         else if (currentObject is ResourceTypes.Collisions.Collision.Placement)
         {
             ResourceTypes.Collisions.Collision.Placement placement = (currentObject as ResourceTypes.Collisions.Collision.Placement);
             placement.Position = new Vector3(Convert.ToSingle(PositionXNumeric.Value), Convert.ToSingle(PositionYNumeric.Value), Convert.ToSingle(PositionZNumeric.Value));
             placement.Rotation = new Vector3(Convert.ToSingle(RotationXNumeric.Value), Convert.ToSingle(RotationYNumeric.Value), Convert.ToSingle(RotationZNumeric.Value));
         }
     }
 }
Exemplo n.º 7
0
        private void SetTransformEdit()
        {
            IsEntryReady = false;
            if (FrameResource.IsFrameType(currentObject))
            {
                FrameObjectBase fObject   = (currentObject as FrameObjectBase);
                Vector3         position  = Vector3.Zero;
                Quaternion      rotation2 = Quaternion.Identity;
                Vector3         scale     = Vector3.Zero;
                Matrix4x4.Decompose(fObject.LocalTransform, out scale, out rotation2, out position);

                CurrentEntry.Text      = fObject.Name.ToString();
                PositionXNumeric.Value = Convert.ToDecimal(position.X);
                PositionYNumeric.Value = Convert.ToDecimal(position.Y);
                PositionZNumeric.Value = Convert.ToDecimal(position.Z);

                Vector3 rotation = rotation2.ToEuler();
                RotationXNumeric.Value = Convert.ToDecimal(rotation.X);
                RotationYNumeric.Value = Convert.ToDecimal(rotation.Y);
                RotationZNumeric.Value = Convert.ToDecimal(rotation.Z);
                ScaleXNumeric.Enabled  = ScaleYNumeric.Enabled = ScaleZNumeric.Enabled = true;
                ScaleXNumeric.Value    = Convert.ToDecimal(scale.X);
                ScaleYNumeric.Value    = Convert.ToDecimal(scale.Y);
                ScaleZNumeric.Value    = Convert.ToDecimal(scale.Z);
            }
            else if (currentObject is ResourceTypes.Collisions.Collision.Placement)
            {
                ResourceTypes.Collisions.Collision.Placement placement = (currentObject as ResourceTypes.Collisions.Collision.Placement);
                CurrentEntry.Text      = placement.Hash.ToString();
                PositionXNumeric.Value = Convert.ToDecimal(placement.Position.X);
                PositionYNumeric.Value = Convert.ToDecimal(placement.Position.Y);
                PositionZNumeric.Value = Convert.ToDecimal(placement.Position.Z);
                Vector3 placementRotation = placement.RotationDegrees;
                RotationXNumeric.Value = Convert.ToDecimal(placementRotation.X);
                RotationYNumeric.Value = Convert.ToDecimal(placementRotation.Y);
                RotationZNumeric.Value = Convert.ToDecimal(placementRotation.Z);
                ScaleXNumeric.Value    = ScaleYNumeric.Value = ScaleZNumeric.Value = 0.0M;
                ScaleXNumeric.Enabled  = ScaleYNumeric.Enabled = ScaleZNumeric.Enabled = false;
            }
            IsEntryReady = true;
        }
Exemplo n.º 8
0
        public void UpdateObject()
        {
            if (IsEntryReady && currentObject != null)
            {
                Vector3 position = new Vector3(Convert.ToSingle(PositionXNumeric.Value), Convert.ToSingle(PositionYNumeric.Value), Convert.ToSingle(PositionZNumeric.Value));
                Vector3 rotation = new Vector3(Convert.ToSingle(RotationXNumeric.Value), Convert.ToSingle(RotationYNumeric.Value), Convert.ToSingle(RotationZNumeric.Value));
                Vector3 scale    = new Vector3(Convert.ToSingle(ScaleXNumeric.Value), Convert.ToSingle(ScaleYNumeric.Value), Convert.ToSingle(ScaleZNumeric.Value));

                if (FrameResource.IsFrameType(currentObject))
                {
                    FrameObjectBase fObject = (currentObject as FrameObjectBase);
                    fObject.LocalTransform = MatrixUtils.SetMatrix(rotation, scale, position);
                }
                else if (currentObject is ResourceTypes.Collisions.Collision.Placement)
                {
                    ResourceTypes.Collisions.Collision.Placement placement = (currentObject as ResourceTypes.Collisions.Collision.Placement);
                    placement.Position        = position;
                    placement.RotationDegrees = rotation;
                }
            }
        }
Exemplo n.º 9
0
        public Vector3 JumpToHelper()
        {
            object data = treeView1.SelectedNode.Tag;

            if (FrameResource.IsFrameType(data))
            {
                bool            fin     = false;
                TransformMatrix matrix  = (data as FrameObjectBase).Matrix;
                TreeNode        curNode = treeView1.SelectedNode;
                while (!fin)
                {
                    if (curNode.Parent == null)
                    {
                        fin = true;
                    }
                    else
                    {
                        FrameObjectBase parent = (curNode.Parent.Tag as FrameObjectBase);
                        curNode = curNode.Parent;
                        if (parent != null)
                        {
                            matrix += parent.Matrix;
                        }
                    }
                }
                return(matrix.Position);
            }

            if (data.GetType() == typeof(ResourceTypes.Collisions.Collision.Placement))
            {
                return((data as ResourceTypes.Collisions.Collision.Placement).Position);
            }

            if (data.GetType() == typeof(Rendering.Graphics.RenderJunction))
            {
                return((data as Rendering.Graphics.RenderJunction).Data.Position);
            }

            return(new Vector3(0, 0, 0));
        }
Exemplo n.º 10
0
        /* Context function */
        private void OpenEntryContext(object sender, System.ComponentModel.CancelEventArgs e)
        {
            //TODO: Clean this messy system.
            EntryMenuStrip.Items[0].Visible       = false;
            EntryMenuStrip.Items[1].Visible       = false;
            EntryMenuStrip.Items[2].Visible       = false;
            EntryMenuStrip.Items[3].Visible       = false;
            EntryMenuStrip.Items[4].Visible       = false;
            FrameActions.DropDownItems[3].Visible = false;

            if (TreeView_Explorer.SelectedNode != null && TreeView_Explorer.SelectedNode.Tag != null)
            {
                EntryMenuStrip.Items[1].Visible = true;
                EntryMenuStrip.Items[2].Visible = true;

                object data = TreeView_Explorer.SelectedNode.Tag;
                if (FrameResource.IsFrameType(data) || data.GetType() == typeof(ResourceTypes.Collisions.Collision.Placement) || data.GetType() == typeof(Rendering.Graphics.RenderJunction) ||
                    data.GetType() == typeof(ResourceTypes.Actors.ActorEntry) || data.GetType() == typeof(Rendering.Graphics.RenderNav))
                {
                    EntryMenuStrip.Items[0].Visible = true;
                }
                if ((TreeView_Explorer.SelectedNode.Tag.GetType() == typeof(FrameObjectSingleMesh) ||
                     TreeView_Explorer.SelectedNode.Tag.GetType() == typeof(FrameObjectModel) ||
                     TreeView_Explorer.SelectedNode.Tag.GetType() == typeof(ResourceTypes.Collisions.Collision.CollisionModel)))
                {
                    EntryMenuStrip.Items[3].Visible = true;
                }

                if (FrameResource.IsFrameType(TreeView_Explorer.SelectedNode.Tag))
                {
                    EntryMenuStrip.Items[4].Visible = true;

                    if (TreeView_Explorer.SelectedNode.Tag is FrameObjectFrame)
                    {
                        FrameActions.DropDownItems[3].Visible = true;
                    }
                }
            }
        }
Exemplo n.º 11
0
        private void SelectedIndexChanged(object sender, EventArgs e)
        {
            Panel.Controls.Clear();
            if (FrameResource.IsFrameType(currentObject))
            {
                if (currentObject is FrameObjectSingleMesh)
                {
                    var entry = (currentObject as FrameObjectSingleMesh);
                    for (int i = 0; i != entry.Material.NumLods; i++)
                    {
                        for (int x = 0; x != entry.Material.Materials[i].Length; x++)
                        {
                            var          mat       = entry.Material.Materials[i][x];
                            TextureEntry textEntry = new TextureEntry();

                            textEntry.SetMaterialName(mat.MaterialName);
                            textEntry.SetMaterialTexture(GetThumbnail(mat));
                            Panel.Controls.Add(textEntry);
                        }
                    }
                }
            }
        }