コード例 #1
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
            }
        }
コード例 #2
0
        private void LoadEntity(bool sameEntity)
        {
            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;
                EntityRotationQuatBox.Value               = Quaternion.Identity;
                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;
                EntityPivotRotationQuatBox.Value          = Quaternion.Identity;
                foreach (int i in EntityFlagsCheckedListBox.CheckedIndices)
                {
                    EntityFlagsCheckedListBox.SetItemCheckState(i, CheckState.Unchecked);
                }
            }
            else
            {
                populatingui = true;
                var e      = CurrentEntity._CEntityDef;
                var po     = CurrentEntity.PivotOrientation;
                var rot    = new Quaternion(e.rotation);
                var rotupd = (EntityRotationQuatBox.Value != rot);
                //EntityPanel.Enabled = true;
                EntityAddToProjectButton.Enabled          = CurrentEntity.Ymap != null ? !ProjectForm.YmapExistsInProject(CurrentEntity.Ymap) : !ProjectForm.YtypExistsInProject(CurrentEntity.MloParent?.Archetype?.Ytyp);
                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);
                EntityRotationQuatBox.Value               = rot;
                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);
                EntityPivotRotationQuatBox.Value          = po;
                for (int i = 0; i < EntityFlagsCheckedListBox.Items.Count; i++)
                {
                    var cv = ((e.flags & (1u << i)) > 0);
                    EntityFlagsCheckedListBox.SetItemCheckState(i, cv ? CheckState.Checked : CheckState.Unchecked);
                }



                MiloEntitySetsListBox.Items.Clear();
                if (CurrentEntity.MloInstance != null)
                {
                    var milo = CurrentEntity.MloInstance._Instance;
                    MiloGroupIDTextBox.Text        = milo.groupId.ToString();
                    MiloFloorIDTextBox.Text        = milo.floorId.ToString();
                    MiloNumExitPortalsTextBox.Text = milo.numExitPortals.ToString();
                    MiloFlagsTextBox.Text          = milo.MLOInstflags.ToString();
                    if (CurrentEntity.MloInstance.EntitySets != null)
                    {
                        foreach (var set in CurrentEntity.MloInstance.EntitySets)
                        {
                            if (set?.EntitySet != null)
                            {
                                MiloEntitySetsListBox.Items.Add(set.EntitySet.ToString(), set.Visible);
                            }
                        }
                    }
                }
                else
                {
                    MiloGroupIDTextBox.Text        = string.Empty;
                    MiloFloorIDTextBox.Text        = string.Empty;
                    MiloNumExitPortalsTextBox.Text = string.Empty;
                    MiloFlagsTextBox.Text          = string.Empty;
                }


                populatingui = false;


                UpdateTabVisibility();


                if (rotupd && sameEntity)
                {
                    UpdateRotationFlag();
                }


                var ms = ProjectForm.WorldForm?.CurrentMapSelection;
                if ((ms?.EntityDef != CurrentEntity) && (ms?.MloEntityDef != CurrentEntity))
                {
                    ProjectForm.WorldForm?.SelectObject(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
                //rage__eLodType lodLevel { get; set; } //84   84: IntEnum: 1264241711: lodLevel  //LODTYPES_DEPTH_
                //uint numChildren { get; set; } //88   88: UnsignedInt: 0: numChildren//2793909385
                //rage__ePriorityLevel 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
            }
        }