Example #1
0
 public void SetEntity(YmapEntityDef entity)
 {
     CurrentEntity = entity;
     Tag           = entity;
     LoadEntity();
     UpdateFormTitle();
 }
Example #2
0
        private AABB_s GetAABB(YmapEntityDef ent)
        {
            var     arch  = ent.Archetype;
            var     ori   = ent.Orientation;
            Vector3 bbmin = ent.Position - ent.BSRadius; //sphere
            Vector3 bbmax = ent.Position + ent.BSRadius;

            if (arch != null)
            {
                Vector3[] c     = new Vector3[8];
                Vector3   abmin = arch.BBMin * ent.Scale; //entity box
                Vector3   abmax = arch.BBMax * ent.Scale;
                c[0]  = abmin;
                c[1]  = new Vector3(abmin.X, abmin.Y, abmax.Z);
                c[2]  = new Vector3(abmin.X, abmax.Y, abmin.Z);
                c[3]  = new Vector3(abmin.X, abmax.Y, abmax.Z);
                c[4]  = new Vector3(abmax.X, abmin.Y, abmin.Z);
                c[5]  = new Vector3(abmax.X, abmin.Y, abmax.Z);
                c[6]  = new Vector3(abmax.X, abmax.Y, abmin.Z);
                c[7]  = abmax;
                bbmin = new Vector3(float.MaxValue);
                bbmax = new Vector3(float.MinValue);
                for (int j = 0; j < 8; j++)
                {
                    Vector3 corn = ori.Multiply(c[j]) + ent.Position;
                    bbmin = Vector3.Min(bbmin, corn);
                    bbmax = Vector3.Max(bbmax, corn);
                }
            }
            AABB_s b = new AABB_s();

            b.Min = new Vector4(bbmin, 0f);
            b.Max = new Vector4(bbmax, 0f);
            return(b);
        }
        public TreeNode FindEntityTreeNode(YmapEntityDef ent)
        {
            if (ent == null)
            {
                return(null);
            }
            TreeNode ymapnode = FindYmapTreeNode(ent.Ymap);

            if (ymapnode == null)
            {
                return(null);
            }
            var entsnode = GetChildTreeNode(ymapnode, "Entities");

            if (entsnode == null)
            {
                return(null);
            }
            for (int i = 0; i < entsnode.Nodes.Count; i++)
            {
                TreeNode entnode = entsnode.Nodes[i];
                if (entnode.Tag == ent)
                {
                    return(entnode);
                }
            }
            return(null);
        }
Example #4
0
        private AABB_s GetAABB2(YmapEntityDef ent)
        {
            var arch   = ent.Archetype;
            var ori    = ent.Orientation;
            var pos    = ent.Position;
            var sca    = ent.Scale;
            var mat    = Matrix.Transformation(Vector3.Zero, Quaternion.Identity, sca, Vector3.Zero, ori, pos);
            var matabs = mat;

            matabs.Column1 = mat.Column1.Abs();
            matabs.Column2 = mat.Column2.Abs();
            matabs.Column3 = mat.Column3.Abs();
            matabs.Column4 = mat.Column4.Abs();
            Vector3 bbmin = pos - ent.BSRadius; //sphere
            Vector3 bbmax = pos + ent.BSRadius;

            if (arch != null)
            {
                var bbcenter = (arch.BBMax + arch.BBMin) * 0.5f;
                var bbextent = (arch.BBMax - arch.BBMin) * 0.5f;
                var ncenter  = Vector3.TransformCoordinate(bbcenter, mat);
                var nextent  = Vector3.TransformNormal(bbextent, matabs);
                bbmin = ncenter - nextent;
                bbmax = ncenter + nextent;
            }
            AABB_s b = new AABB_s();

            b.Min = new Vector4(bbmin, 0f);
            b.Max = new Vector4(bbmax, 0f);
            return(b);
        }
Example #5
0
        private void InitProp(CutPropModelObject prop, GameFileCache gfc)
        {
            Prop = new YmapEntityDef();
            Prop.SetArchetype(gfc.GetArchetype(prop.StreamingName));

            AnimHash = prop.StreamingName;
        }
Example #6
0
        public CollisionPositionUndoStep(Bounds bounds, YmapEntityDef ent, Vector3 startpos, WorldForm wf)
        {
            Bounds        = bounds;
            Entity        = ent;
            StartPosition = startpos;
            EndPosition   = bounds?.Position ?? Vector3.Zero;

            UpdateGraphics(wf);
        }
        public void TrySelectEntityTreeNode(YmapEntityDef ent)
        {
            TreeNode entnode = FindEntityTreeNode(ent);

            if (entnode != null)
            {
                ProjectTreeView.SelectedNode = entnode;
            }
        }
Example #8
0
        public CollisionVertexPositionUndoStep(BoundVertex vertex, YmapEntityDef ent, Vector3 startpos, WorldForm wf)
        {
            Vertex        = vertex;
            Entity        = ent;
            StartPosition = startpos;
            EndPosition   = vertex?.Position ?? Vector3.Zero;

            UpdateGraphics(wf);
        }
Example #9
0
        public CollisionPolyPositionUndoStep(BoundPolygon poly, YmapEntityDef ent, Vector3 startpos, WorldForm wf)
        {
            Polygon       = poly;
            Entity        = ent;
            StartPosition = startpos;
            EndPosition   = poly?.Position ?? Vector3.Zero;

            UpdateGraphics(wf);
        }
Example #10
0
        public void RemoveEntityTreeNode(YmapEntityDef ent)
        {
            var tn = FindEntityTreeNode(ent);

            if ((tn != null) && (tn.Parent != null))
            {
                tn.Parent.Text = "Entities (" + ent.Ymap.AllEntities.Length.ToString() + ")";
                tn.Parent.Nodes.Remove(tn);
            }
        }
Example #11
0
        public void SetEntity(YmapEntityDef entity)
        {
            CurrentEntity = entity;
            MloInstanceData instance = entity?.MloParent?.MloInstance;

            CurrentMCEntity = instance?.TryGetArchetypeEntity(entity);
            Tag             = entity;
            LoadEntity();
            UpdateFormTitle();
        }
Example #12
0
        public CollisionRotationUndoStep(Bounds bounds, YmapEntityDef ent, Quaternion startrot, WorldForm wf)
        {
            Bounds        = bounds;
            Entity        = ent;
            StartRotation = startrot;
            EndRotation   = bounds?.Orientation ?? Quaternion.Identity;
            if (ent != null)
            {
                EndRotation = EndRotation * ent.Orientation;
            }

            UpdateGraphics(wf);
        }
Example #13
0
        public CollisionPolyRotationUndoStep(BoundPolygon poly, YmapEntityDef ent, Quaternion startrot, WorldForm wf)
        {
            Polygon       = poly;
            Entity        = ent;
            StartRotation = startrot;
            EndRotation   = poly?.Orientation ?? Quaternion.Identity;
            if (ent != null)
            {
                EndRotation = EndRotation * ent.Orientation;
            }

            UpdateGraphics(wf);
        }
Example #14
0
        private void AddSelectionEntityHierarchyNodes(YmapEntityDef entity)
        {
            if (entity == null)
            {
                return;
            }

            var      e     = entity;
            TreeNode tn    = null;
            TreeNode seltn = null;

            while (e != null)
            {
                var newtn = new TreeNode(e.Name);
                newtn.Tag = e;
                if (tn != null)
                {
                    newtn.Nodes.Add(tn);
                }
                else
                {
                    seltn = newtn;
                }
                if (e.Children != null)
                {
                    foreach (var c in e.Children)
                    {
                        if ((tn != null) && (c == tn.Tag))
                        {
                            continue;
                        }
                        var ctn = new TreeNode(c.Name);
                        ctn.Tag = c;
                        newtn.Nodes.Add(ctn);
                    }
                }

                tn = newtn;
                e  = e.Parent;
            }

            if (tn != null)
            {
                HierarchyTreeView.Nodes.Add(tn);
                tn.ExpandAll();
            }
            if (seltn != null)
            {
                HierarchyTreeView.SelectedNode = seltn;
            }
        }
Example #15
0
 private void EntitySearchAddResult(YmapEntityDef ent)
 {
     try
     {
         if (InvokeRequired)
         {
             BeginInvoke(new Action(() => { EntitySearchAddResult(ent); }));
         }
         else
         {
             EntityResults.Add(ent);
             EntityResultsListView.VirtualListSize = EntityResults.Count;
         }
     }
     catch { }
 }
Example #16
0
        private uint GetLightHash(YmapEntityDef ent, int lightIndex)
        {
            unchecked
            {
                var len = 7;

                var center = ent.Position + ent.Archetype.BSCenter;
                var aa     = center + ent.Archetype.BBMin;
                var bb     = center + ent.Archetype.BBMax;

                var ints = new uint[len];
                ints[0] = (uint)(aa.X * 10.0f);
                ints[1] = (uint)(aa.Y * 10.0f);
                ints[2] = (uint)(aa.Z * 10.0f);
                ints[3] = (uint)(bb.X * 10.0f);
                ints[4] = (uint)(bb.Y * 10.0f);
                ints[5] = (uint)(bb.Z * 10.0f);
                ints[6] = (uint)lightIndex;

                return(ComputeHash(ints));
            }
        }
Example #17
0
 public EntityPivotRotationUndoStep(YmapEntityDef ent, Quaternion startrot)
 {
     Entity        = ent;
     StartRotation = startrot;
     EndRotation   = ent?.WidgetOrientation ?? Quaternion.Identity;
 }
Example #18
0
 public EntityPivotPositionUndoStep(YmapEntityDef ent, Vector3 startpos)
 {
     Entity        = ent;
     StartPosition = startpos;
     EndPosition   = ent?.WidgetPosition ?? Vector3.Zero;
 }
Example #19
0
 public EntityScaleUndoStep(YmapEntityDef ent, Vector3 startscale)
 {
     Entity     = ent;
     StartScale = startscale;
     EndScale   = ent?.Scale ?? Vector3.One;
 }
Example #20
0
 private void InitHiddenModel(CutHiddenModelObject hid, GameFileCache gfc)
 {
     HideEntity = new YmapEntityDef();
     HideEntity._CEntityDef.archetypeName = hid.cName;
     HideEntity.SetPosition(hid.vPosition);
 }
Example #21
0
        private uint GetLightHash(YmapEntityDef ent, int lightIndex)
        {
            unchecked
            {
                //var aabb1 = GetAABB(ent);
                var aabb = GetAABB2(ent);

                var hashData = new int[7];
                hashData[0] = (int)(aabb.Min.X * 10.0f);
                hashData[1] = (int)(aabb.Min.Y * 10.0f);
                hashData[2] = (int)(aabb.Min.Z * 10.0f);
                hashData[3] = (int)(aabb.Max.X * 10.0f);
                hashData[4] = (int)(aabb.Max.Y * 10.0f);
                hashData[5] = (int)(aabb.Max.Z * 10.0f);
                hashData[6] = lightIndex;


                int v3 = 7;
                int v4 = 0;                    //=hashData index
                int v5 = (int)0xDEADBEEF + 28; // -559038709;
                int v6 = (int)0xDEADBEEF + 28;
                int v7 = (int)0xDEADBEEF + 28;

                uint v8 = 2;
                do
                {
                    int v9  = hashData[v4 + 2] + v5;
                    int v10 = hashData[v4 + 1] + v6;
                    int v11 = hashData[v4 + 0] - v9;
                    int v13 = v10 + v9;
                    int v14 = (v7 + v11) ^ RotateLeft(v9, 4);
                    int v17 = v13 + v14;
                    int v18 = (v10 - v14) ^ RotateLeft(v14, 6);
                    int v21 = v17 + v18;
                    int v22 = (v13 - v18) ^ RotateLeft(v18, 8);
                    int v25 = v21 + v22;
                    int v26 = (v17 - v22) ^ RotateLeft(v22, 16);
                    int v29 = (v21 - v26) ^ RotateRight(v26, 13);
                    int v30 = v25 - v29;
                    v7  = v25 + v26;
                    v6  = v7 + v29;
                    v5  = v30 ^ RotateLeft(v29, 4);
                    v4 += 3;
                    v3 -= 3;
                    --v8;
                }while (v8 > 0);

                int v32 = v3 - 1; //should always be 0
                if (v32 != 0)
                {
                }

                int v50 = v7 + hashData[v4];
                int v34 = (v6 ^ v5) - RotateLeft(v6, 14);
                int v35 = (v34 ^ v50) - RotateLeft(v34, 11);
                int v36 = (v35 ^ v6) - RotateRight(v35, 7);
                int v37 = (v36 ^ v34) - RotateLeft(v36, 16);
                int v51 = (v35 ^ v37) - RotateLeft(v37, 4);
                int v38 = (v51 ^ v36) - RotateLeft(v51, 14);
                int v53 = (v38 ^ v37) - RotateRight(v38, 8);
                return((uint)v53);
            }
        }