Exemplo n.º 1
0
        private void LoadItems()
        {
            MultiItem = new MapSelection();
            MultiItem.Clear();
            MultiItem.SetMultipleSelectionItems(Items);

            if (Items == null)
            {
                PositionTextBox.Text = string.Empty;
                RotationTextBox.Text = string.Empty;
                ScaleTextBox.Text    = string.Empty;
                ItemsListBox.Items.Clear();
            }
            else
            {
                populatingui = true;


                PositionTextBox.Text = FloatUtil.GetVector3String(MultiItem.MultipleSelectionCenter);
                RotationTextBox.Text = FloatUtil.GetVector4String(MultiItem.MultipleSelectionRotation.ToVector4());
                ScaleTextBox.Text    = FloatUtil.GetVector3String(MultiItem.MultipleSelectionScale);
                ItemsListBox.Items.Clear();
                foreach (var item in Items)
                {
                    ItemsListBox.Items.Add(item);
                }

                populatingui = false;
            }
        }
Exemplo n.º 2
0
        private void EntityPivotRotationNormalizeButton_Click(object sender, EventArgs e)
        {
            Vector4    v = FloatUtil.ParseVector4String(EntityPivotRotationTextBox.Text);
            Quaternion q = Quaternion.Normalize(new Quaternion(v));

            EntityPivotRotationTextBox.Text = FloatUtil.GetVector4String(new Vector4(q.X, q.Y, q.Z, q.W));
        }
Exemplo n.º 3
0
        private void SelectGeometry(DrawableGeometry geom)
        {
            MaterialPropertiesPanel.Controls.Clear();

            var pl = geom?.Shader?.ParametersList;

            if (pl == null)
            {
                return;
            }

            var tmpPanel = new Panel(); //need this so textboxes resize correctly in case of scrollbar

            tmpPanel.Size     = new Size(MaterialPropertiesPanel.Width, 10);
            tmpPanel.Location = new System.Drawing.Point(0, 0);
            tmpPanel.Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;

            var w = MaterialPropertiesPanel.Width - 140;

            var h = pl.Hashes;
            var p = pl.Parameters;

            for (int ip = 0; ip < h.Length; ip++)
            {
                var hash = pl.Hashes[ip];
                var parm = pl.Parameters[ip];
                var data = parm?.Data;

                tmpPanel.Height += 25;

                var l = new Label();
                l.AutoSize = true;
                l.Location = new System.Drawing.Point(5, 5 + ip * 25);
                l.Text     = hash.ToString();
                tmpPanel.Controls.Add(l);

                var t = new TextBox();
                t.Size     = new Size(w, 20);
                t.Location = new System.Drawing.Point(130, 2 + ip * 25);
                t.Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                t.Tag      = parm;
                tmpPanel.Controls.Add(t);

                if (data is Vector4)
                {
                    t.Text = FloatUtil.GetVector4String((Vector4)data);
                }
                else if (data is Vector4[])
                {
                    var txt  = "";
                    var vecs = (Vector4[])data;
                    foreach (var vec in vecs)
                    {
                        if (txt.Length > 0)
                        {
                            txt += "; ";
                        }
                        txt += FloatUtil.GetVector4String(vec);
                    }
                    t.Text = txt;
                }
                else if (data is TextureBase)
                {
                    var tex = (TextureBase)data;
                    t.Text = tex.Name;
                    if (tex is Texture)
                    {
                        t.Text    += " (embedded)";
                        t.ReadOnly = true;
                    }
                }

                t.TextChanged += ParamTextBox_TextChanged;
            }


            MaterialPropertiesPanel.Controls.Add(tmpPanel);
        }
Exemplo n.º 4
0
        private void UpdateUI()
        {
            if (CurrentZone?.AudioZone == null)
            {
                AddToProjectButton.Enabled = false;
                DeleteButton.Enabled       = false;

                populatingui           = true;
                NameTextBox.Text       = string.Empty;
                ShapeComboBox.Text     = string.Empty;
                InnerPosTextBox.Text   = string.Empty;
                InnerSizeTextBox.Text  = string.Empty;
                InnerAngleTextBox.Text = string.Empty;
                InnerVec1TextBox.Text  = string.Empty;
                InnerVec2TextBox.Text  = string.Empty;
                InnerVec3TextBox.Text  = string.Empty;
                OuterPosTextBox.Text   = string.Empty;
                OuterSizeTextBox.Text  = string.Empty;
                OuterAngleTextBox.Text = string.Empty;
                OuterVec1TextBox.Text  = string.Empty;
                OuterVec2TextBox.Text  = string.Empty;
                OuterVec3TextBox.Text  = string.Empty;
                UnkVec1TextBox.Text    = string.Empty;
                UnkVec2TextBox.Text    = string.Empty;
                UnkVec3TextBox.Text    = string.Empty;
                UnkBytesTextBox.Text   = string.Empty;
                Flags0TextBox.Text     = string.Empty;
                Flags1TextBox.Text     = string.Empty;
                Flags2TextBox.Text     = string.Empty;
                Hash0TextBox.Text      = string.Empty;
                Hash1TextBox.Text      = string.Empty;
                HashesTextBox.Text     = string.Empty;
                ExtParamsTextBox.Text  = string.Empty;
                populatingui           = false;
            }
            else
            {
                AddToProjectButton.Enabled = CurrentZone?.RelFile != null ? !ProjectForm.AudioFileExistsInProject(CurrentZone.RelFile) : false;
                DeleteButton.Enabled       = !AddToProjectButton.Enabled;

                populatingui = true;
                var z = CurrentZone.AudioZone;
                NameTextBox.Text       = z.NameHash.ToString();
                ShapeComboBox.Text     = z.Shape.ToString();
                InnerPosTextBox.Text   = FloatUtil.GetVector3String(z.PlaybackZonePosition);
                InnerSizeTextBox.Text  = FloatUtil.GetVector3String(z.PlaybackZoneSize);
                InnerAngleTextBox.Text = z.PlaybackZoneAngle.ToString();
                InnerVec1TextBox.Text  = FloatUtil.GetVector4String(z.PlaybackZoneVec1);
                InnerVec2TextBox.Text  = FloatUtil.GetVector4String(z.PlaybackZoneVec2);
                InnerVec3TextBox.Text  = FloatUtil.GetVector3String(z.PlaybackZoneVec3);
                OuterPosTextBox.Text   = FloatUtil.GetVector3String(z.ActivationZonePosition);
                OuterSizeTextBox.Text  = FloatUtil.GetVector3String(z.ActivationZoneSize);
                OuterAngleTextBox.Text = z.ActivationZoneAngle.ToString();
                OuterVec1TextBox.Text  = FloatUtil.GetVector4String(z.ActivationZoneVec1);
                OuterVec2TextBox.Text  = FloatUtil.GetVector4String(z.ActivationZoneVec2);
                OuterVec3TextBox.Text  = FloatUtil.GetVector3String(z.ActivationZoneVec3);
                UnkVec1TextBox.Text    = FloatUtil.GetVector4String(z.UnkVec1);
                UnkVec2TextBox.Text    = FloatUtil.GetVector4String(z.UnkVec2);
                UnkVec3TextBox.Text    = FloatUtil.GetVector2String(z.UnkVec3);
                UnkBytesTextBox.Text   = string.Format("{0}, {1}, {2}", z.Unk14, z.Unk15, z.Unk16);
                Flags0TextBox.Text     = z.Flags0.Hex;
                Flags1TextBox.Text     = z.Flags1.Hex;
                Flags2TextBox.Text     = z.Flags2.Hex;
                Hash0TextBox.Text      = z.UnkHash0.ToString();
                Hash1TextBox.Text      = z.UnkHash1.ToString();

                StringBuilder sb = new StringBuilder();
                if (z.Rules != null)
                {
                    foreach (var hash in z.Rules)
                    {
                        sb.AppendLine(hash.ToString());
                    }
                }
                HashesTextBox.Text = sb.ToString();

                sb.Clear();
                if (z.ExtParams != null)
                {
                    foreach (var extparam in z.ExtParams)
                    {
                        sb.Append(extparam.Hash.ToString());
                        sb.Append(", ");
                        sb.Append(FloatUtil.ToString(extparam.Value));
                        sb.AppendLine();
                    }
                }
                ExtParamsTextBox.Text = sb.ToString();

                populatingui = false;

                if (ProjectForm.WorldForm != null)
                {
                    ProjectForm.WorldForm.SelectObject(CurrentZone);
                }
            }
        }
Exemplo n.º 5
0
        private void LoadEntity()
        {
            if (CurrentEntity == null)
            {
                //EntityPanel.Enabled = false;
                EntityAddToProjectButton.Enabled          = false;
                EntityDeleteButton.Enabled                = false;
                EntityArchetypeTextBox.Text               = string.Empty;
                EntityArchetypeHashLabel.Text             = "Hash: 0";
                EntityFlagsTextBox.Text                   = string.Empty;
                EntityGuidTextBox.Text                    = string.Empty;
                EntityPositionTextBox.Text                = string.Empty;
                EntityRotationTextBox.Text                = string.Empty;
                EntityScaleXYTextBox.Text                 = string.Empty;
                EntityScaleZTextBox.Text                  = string.Empty;
                EntityParentIndexTextBox.Text             = string.Empty;
                EntityLodDistTextBox.Text                 = string.Empty;
                EntityChildLodDistTextBox.Text            = string.Empty;
                EntityLodLevelComboBox.SelectedIndex      = 0; // Math.Max(EntityLodLevelComboBox.FindString(), 0);
                EntityNumChildrenTextBox.Text             = string.Empty;
                EntityPriorityLevelComboBox.SelectedIndex = 0; //Math.Max(..
                EntityAOMultiplierTextBox.Text            = string.Empty;
                EntityArtificialAOTextBox.Text            = string.Empty;
                EntityTintValueTextBox.Text               = string.Empty;
                EntityPivotEditCheckBox.Checked           = false;
                EntityPivotPositionTextBox.Text           = string.Empty;
                EntityPivotRotationTextBox.Text           = string.Empty;
                foreach (int i in EntityFlagsCheckedListBox.CheckedIndices)
                {
                    EntityFlagsCheckedListBox.SetItemCheckState(i, CheckState.Unchecked);
                }
            }
            else
            {
                populatingui = true;
                var e  = CurrentEntity.CEntityDef;
                var po = CurrentEntity.PivotOrientation;
                //EntityPanel.Enabled = true;
                EntityAddToProjectButton.Enabled          = !ProjectForm.YmapExistsInProject(CurrentEntity.Ymap);
                EntityDeleteButton.Enabled                = !EntityAddToProjectButton.Enabled;
                EntityArchetypeTextBox.Text               = e.archetypeName.ToString();
                EntityArchetypeHashLabel.Text             = "Hash: " + e.archetypeName.Hash.ToString();
                EntityFlagsTextBox.Text                   = e.flags.ToString();
                EntityGuidTextBox.Text                    = e.guid.ToString();
                EntityPositionTextBox.Text                = FloatUtil.GetVector3String(e.position);
                EntityRotationTextBox.Text                = FloatUtil.GetVector4String(e.rotation);
                EntityScaleXYTextBox.Text                 = FloatUtil.ToString(e.scaleXY);
                EntityScaleZTextBox.Text                  = FloatUtil.ToString(e.scaleZ);
                EntityParentIndexTextBox.Text             = e.parentIndex.ToString();
                EntityLodDistTextBox.Text                 = FloatUtil.ToString(e.lodDist);
                EntityChildLodDistTextBox.Text            = FloatUtil.ToString(e.childLodDist);
                EntityLodLevelComboBox.SelectedIndex      = Math.Max(EntityLodLevelComboBox.FindString(e.lodLevel.ToString()), 0);
                EntityNumChildrenTextBox.Text             = e.numChildren.ToString();
                EntityPriorityLevelComboBox.SelectedIndex = Math.Max(EntityPriorityLevelComboBox.FindString(e.priorityLevel.ToString()), 0);
                EntityAOMultiplierTextBox.Text            = e.ambientOcclusionMultiplier.ToString();
                EntityArtificialAOTextBox.Text            = e.artificialAmbientOcclusion.ToString();
                EntityTintValueTextBox.Text               = e.tintValue.ToString();
                EntityPivotPositionTextBox.Text           = FloatUtil.GetVector3String(CurrentEntity.PivotPosition);
                EntityPivotRotationTextBox.Text           = FloatUtil.GetVector4String(new Vector4(po.X, po.Y, po.Z, po.W));
                for (int i = 0; i < EntityFlagsCheckedListBox.Items.Count; i++)
                {
                    var cv = ((e.flags & (1u << i)) > 0);
                    EntityFlagsCheckedListBox.SetItemCheckState(i, cv ? CheckState.Checked : CheckState.Unchecked);
                }
                populatingui = false;



                ProjectForm.WorldForm?.SelectEntity(CurrentEntity); //hopefully the drawable is already loaded - this will try get from cache

                ////struct CEntityDef:
                //MetaHash archetypeName { get; set; } //8   8: Hash: 0: archetypeName
                //uint flags { get; set; } //12   12: UnsignedInt: 0: flags
                //uint guid { get; set; } //16   16: UnsignedInt: 0: guid
                //Vector3 position { get; set; } //32   32: Float_XYZ: 0: position
                //Vector4 rotation { get; set; } //48   48: Float_XYZW: 0: rotation
                //float scaleXY { get; set; } //64   64: Float: 0: 2627937847
                //float scaleZ { get; set; } //68   68: Float: 0: 284916802
                //int parentIndex { get; set; } //72   72: SignedInt: 0: parentIndex
                //float lodDist { get; set; } //76   76: Float: 0: lodDist
                //float childLodDist { get; set; } //80   80: Float: 0: childLodDist//3398912973
                //Unk_1264241711 lodLevel { get; set; } //84   84: IntEnum: 1264241711: lodLevel  //LODTYPES_DEPTH_
                //uint numChildren { get; set; } //88   88: UnsignedInt: 0: numChildren//2793909385
                //Unk_648413703 priorityLevel { get; set; } //92   92: IntEnum: 648413703: priorityLevel//647098393
                //Array_StructurePointer extensions { get; set; } //96   96: Array: 0: extensions  {0: StructurePointer: 0: 256}
                //int ambientOcclusionMultiplier { get; set; } //112   112: SignedInt: 0: ambientOcclusionMultiplier//415356295
                //int artificialAmbientOcclusion { get; set; } //116   116: SignedInt: 0: artificialAmbientOcclusion//599844163
                //uint tintValue { get; set; } //120   120: UnsignedInt: 0: tintValue//1015358759
            }
        }
Exemplo n.º 6
0
        public void UpdateUI()
        {
            var b = CollisionBounds;

            if (b == null)
            {
                AddToProjectButton.Enabled = false;
                DeleteButton.Enabled       = false;
                BBMinTextBox.Text          = string.Empty;
                BBMaxTextBox.Text          = string.Empty;
                BBCenterTextBox.Text       = string.Empty;
                BSCenterTextBox.Text       = string.Empty;
                BSRadiusTextBox.Text       = string.Empty;
                MarginTextBox.Text         = string.Empty;
                VolumeTextBox.Text         = string.Empty;
                UnkVectorTextBox.Text      = string.Empty;
                MaterialColourUpDown.Value = 0;
                MaterialCombo.Text         = "";
                ProceduralIDUpDown.Value   = 0;
                RoomIDUpDown.Value         = 0;
                PedDensityUpDown.Value     = 0;
                PolyFlagsUpDown.Value      = 0;
                UnkFlagsUpDown.Value       = 0;
                UnkTypeUpDown.Value        = 0;
                BoundsTabControl.TabPages.Remove(GeometryTabPage);
                BoundsTabControl.TabPages.Remove(CompositeFlagsTabPage);
                BoundsTabControl.TabPages.Remove(CompositeXformTabPage);
                CenterGeomTextBox.Text = string.Empty;
                QuantumTextBox.Text    = string.Empty;
                UnkFloat1TextBox.Text  = string.Empty;
                UnkFloat2TextBox.Text  = string.Empty;
                SetCheckedListBoxValues(CompFlags1CheckedListBox, 0);
                SetCheckedListBoxValues(CompFlags2CheckedListBox, 0);
                CompPositionTextBox.Text = string.Empty;
                CompRotationTextBox.Text = string.Empty;
                CompScaleTextBox.Text    = string.Empty;
                VertexCountLabel.Text    = "0 vertices";
                PolyCountLabel.Text      = "0 polygons";
            }
            else
            {
                populatingui = true;

                BBMinTextBox.Text           = FloatUtil.GetVector3String(b.BoxMin);
                BBMaxTextBox.Text           = FloatUtil.GetVector3String(b.BoxMax);
                BBCenterTextBox.Text        = FloatUtil.GetVector3String(b.BoxCenter);
                BSCenterTextBox.Text        = FloatUtil.GetVector3String(b.SphereCenter);
                BSRadiusTextBox.Text        = FloatUtil.ToString(b.SphereRadius);
                MarginTextBox.Text          = FloatUtil.ToString(b.Margin);
                VolumeTextBox.Text          = FloatUtil.ToString(b.Volume);
                UnkVectorTextBox.Text       = FloatUtil.GetVector3String(b.Unknown_60h);
                MaterialColourUpDown.Value  = b.MaterialColorIndex;
                MaterialCombo.SelectedIndex = b.MaterialIndex;
                ProceduralIDUpDown.Value    = b.ProceduralId;
                RoomIDUpDown.Value          = b.RoomId;
                PedDensityUpDown.Value      = b.PedDensity;
                PolyFlagsUpDown.Value       = b.PolyFlags;
                UnkFlagsUpDown.Value        = b.UnkFlags;
                UnkTypeUpDown.Value         = b.Unknown_3Ch;

                if (b is BoundGeometry bg)
                {
                    if (!BoundsTabControl.TabPages.Contains(GeometryTabPage))
                    {
                        BoundsTabControl.TabPages.Add(GeometryTabPage);
                    }

                    CenterGeomTextBox.Text = FloatUtil.GetVector3String(bg.CenterGeom);
                    QuantumTextBox.Text    = FloatUtil.GetVector3String(bg.Quantum);
                    UnkFloat1TextBox.Text  = FloatUtil.ToString(bg.Unknown_9Ch);
                    UnkFloat2TextBox.Text  = FloatUtil.ToString(bg.Unknown_ACh);
                    VertexCountLabel.Text  = bg.VerticesCount.ToString() + ((bg.VerticesCount == 1) ? " vertex" : " vertices");
                    PolyCountLabel.Text    = bg.PolygonsCount.ToString() + ((bg.PolygonsCount == 1) ? " polygon" : " polygons");
                }
                else
                {
                    BoundsTabControl.TabPages.Remove(GeometryTabPage);
                    CenterGeomTextBox.Text = string.Empty;
                    QuantumTextBox.Text    = string.Empty;
                    UnkFloat1TextBox.Text  = string.Empty;
                    UnkFloat2TextBox.Text  = string.Empty;
                    VertexCountLabel.Text  = "0 vertices";
                    PolyCountLabel.Text    = "0 polygons";
                }

                if (b.Parent != null)
                {
                    if (!BoundsTabControl.TabPages.Contains(CompositeFlagsTabPage))
                    {
                        BoundsTabControl.TabPages.Add(CompositeFlagsTabPage);
                    }
                    if (!BoundsTabControl.TabPages.Contains(CompositeXformTabPage))
                    {
                        BoundsTabControl.TabPages.Add(CompositeXformTabPage);
                    }

                    SetCheckedListBoxValues(CompFlags1CheckedListBox, (uint)b.CompositeFlags1.Flags1);
                    SetCheckedListBoxValues(CompFlags2CheckedListBox, (uint)b.CompositeFlags1.Flags2);
                    CompPositionTextBox.Text = FloatUtil.GetVector3String(b.Position);
                    CompRotationTextBox.Text = FloatUtil.GetVector4String(b.Orientation.ToVector4());
                    CompScaleTextBox.Text    = FloatUtil.GetVector3String(b.Scale);
                }
                else
                {
                    BoundsTabControl.TabPages.Remove(CompositeFlagsTabPage);
                    BoundsTabControl.TabPages.Remove(CompositeXformTabPage);
                    SetCheckedListBoxValues(CompFlags1CheckedListBox, 0);
                    SetCheckedListBoxValues(CompFlags2CheckedListBox, 0);
                    CompPositionTextBox.Text = string.Empty;
                    CompRotationTextBox.Text = string.Empty;
                    CompScaleTextBox.Text    = string.Empty;
                }

                var ybn = b.GetRootYbn();
                AddToProjectButton.Enabled = (ybn != null) ? !ProjectForm.YbnExistsInProject(ybn) : false;
                DeleteButton.Enabled       = !AddToProjectButton.Enabled;

                populatingui = false;

                ProjectForm.WorldForm?.SelectObject(b);
            }
        }
Exemplo n.º 7
0
 public static string FormatVector4Swap(Vector4 v) //for use with WriteItemArray, swaps endianness
 {
     return(FloatUtil.GetVector4String(MetaUtils.SwapBytes(v)));
 }
Exemplo n.º 8
0
 public static string FormatVector4(Vector4 v) //for use with WriteItemArray
 {
     return(FloatUtil.GetVector4String(v));
 }
Exemplo n.º 9
0
        private void EntitySearchExportResultsButton_Click(object sender, EventArgs e)
        {
            if (EntityResults.Count == 0)
            {
                MessageBox.Show("Nothing to export!");
                return;
            }

            SaveFileDialog.FileName = "Entities_" + EntitySearchTextBox.Text;
            if (SaveFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string fname = SaveFileDialog.FileName;

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("ArchetypeName, PositionX, PositionY, PositionZ, RotationX, RotationY, RotationZ, RotationW, YmapFile");
            foreach (var ent in EntityResults)
            {
                sb.AppendLine(string.Format("{0}, {1}, {2}, {3}", ent.Name, FloatUtil.GetVector3String(ent._CEntityDef.position), FloatUtil.GetVector4String(ent._CEntityDef.rotation), ent.Ymap?.RpfFileEntry?.Path ?? ""));
            }

            File.WriteAllText(fname, sb.ToString());
        }