Пример #1
0
                public bool Load(ref CDynMemoryReader r, ref CUberData data)
                {
                    if (!r.Get(ref A))
                    {
                        return(false);
                    }
                    if (!r.Get(ref BBMin))
                    {
                        return(false);
                    }
                    if (!r.Get(ref BBMax))
                    {
                        return(false);
                    }
                    if (!Loaders.LoadArray(ref Planes, ref r, ref data))
                    {
                        return(false);
                    }
                    if (!Loaders.LoadPrimitiveArray(ref Verts, ref r))
                    {
                        return(false);
                    }

                    return(true);
                }
        public bool Load(ref CDynMemoryReader r, ref CUberData data)
        {
            uint   n = 0;
            string s;

            if (!r.Get(ref n))
            {
                return(false);
            }
            if (n == 0)
            {
                return(true);
            }

            s = r.ReadPascalStr();
            if (s == "")
            {
                return(false);
            }
            Name = s;

            if (!Loaders.LoadArray(ref Parts, ref r, ref data))
            {
                return(false);
            }

            return(true);
        }
Пример #3
0
        public bool Load(ref CDynMemoryReader r, ref CUberData data)
        {
            string s;
            uint   n = 0;

            s = r.ReadPascalStr();
            if (s == "")
            {
                return(false);
            }
            Name = s;

            if (!Loaders.LoadArray(ref Bones, ref r, ref data))
            {
                return(false);
            }
            if (!r.Get(ref n))
            {
                return(false);
            }
            if (n != 0)
            {
                if (!Loaders.LoadArray(ref ExternalInstances, ref r, ref data))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #4
0
        public bool Load(ref CDynMemoryReader r, ref CUberData data)
        {
            byte[] d;
            if (!r.Get(ref FaceCount))
            {
                return(false);
            }
            if (FaceCount != 0)
            {
                d = data.ReadMeshData(FaceCount * (uint)Marshal.SizeOf(typeof(SAABFace)));
                if (d == null || d.Length == 0)
                {
                    return(false);
                }
                Faces.Capacity = (int)FaceCount;
                Loaders.LoadBytesIntoObjectList(ref Faces, ref d);
            }

            if (!r.Get(ref NodeCount))
            {
                return(false);
            }

            d = data.ReadMeshData(0x28); // 40 bytes
            if (d == null || d.Length == 0)
            {
                return(false);
            }
            Loaders.LoadBytesIntoObject(ref RootNode, ref d);

            if (NodeCount != 0)
            {
                d = data.ReadMeshData(NodeCount * (uint)Marshal.SizeOf(typeof(SAABBNode)));
                if (d == null || d.Length == 0)
                {
                    return(false);
                }
                Nodes.Capacity = (int)NodeCount;
                Loaders.LoadBytesIntoObjectList(ref Nodes, ref d);
            }

            if (!r.Get(ref FaceIndexMapCount))
            {
                return(false);
            }
            if (FaceIndexMapCount != 0)
            {
                d = data.ReadMeshData(FaceIndexMapCount * sizeof(uint));
                if (d == null || d.Length == 0)
                {
                    return(false);
                }
                FaceIndexMap.Capacity = (int)FaceIndexMapCount;
                Loaders.LoadBytesIntoObjectList(ref FaceIndexMap, ref d);
            }

            return(true);
        }
Пример #5
0
            public List <float> Transform; // This was float Transform[4 * 4]

            public bool Load(ref CDynMemoryReader r, ref CUberData data)
            {
                string s;

                if (!r.Get(ref A))
                {
                    return(false);
                }
                if (!r.Get(ref Index))
                {
                    return(false);
                }
                if (!r.Get(ref ID))
                {
                    return(false);
                }
                if (!r.Get(ref Flags))
                {
                    return(false);
                }
                if (!r.Get(ref RegionA))
                {
                    return(false);
                }
                if (!r.Get(ref RegionB))
                {
                    return(false);
                }

                s = r.ReadPascalStr();
                if (s == "")
                {
                    return(false);
                }
                InstanceName = s;

                s = r.ReadPascalStr();
                if (s == "")
                {
                    return(false);
                }
                AssetName = s;

                Materials = new List <uint>();
                if (!Loaders.LoadPrimitiveArray(ref Materials, ref r))
                {
                    return(false);
                }

                Transform = new List <float>();
                if (!r.GetRaw(ref Transform, 4 * 4))
                {
                    return(false);
                }

                return(true);
            }
Пример #6
0
            public bool Load(ref CDynMemoryReader r, ref CUberData data)
            {
                string s;

                s = r.ReadPascalStr();
                if (s == "")
                {
                    return(false);
                }
                Name = s;

                if (!r.Get(ref ID))
                {
                    return(false);
                }
                if (!r.Get(ref BBMin))
                {
                    return(false);
                }
                if (!r.Get(ref BBMax))
                {
                    return(false);
                }
                if (!Loaders.LoadArray(ref Portals, ref r, ref data))
                {
                    return(false);
                }
                if (!Loaders.LoadArray(ref ConvexHulls, ref r, ref data))
                {
                    return(false);
                }
                if (!Loaders.LoadPrimitiveArray(ref U32Array, ref r))
                {
                    return(false);
                }
                if (!Loaders.LoadArray(ref RegionSubStructs0, ref r, ref data))
                {
                    return(false);
                }

                return(true);
            }
Пример #7
0
        public bool Load(ref CDynMemoryReader r, CUberData data)
        {
            Console.WriteLine($"Loading {GetType().Name}");
            Clear();

            uint i, n = 0;

            if (!r.Get(ref Flags))
            {
                return(false);
            }
            if (!r.Get(ref BBMin))
            {
                return(false);
            }
            if (!r.Get(ref BBMax))
            {
                return(false);
            }
            if (!r.Get(ref A))
            {
                return(false);
            }
            if (!r.Get(ref B))
            {
                return(false);
            }

            if (!Loaders.LoadArray(ref MeshArray, ref r, ref data))
            {
                return(false);
            }
            foreach (var mesh in MeshArray)
            {
                Meshes[mesh.Name] = mesh;
            }

            if ((Flags & (uint)MeshFlags.MESHSYS_FLAG_PORTALSYSTEM) != 0)
            {
                if (!PortalSystem.Load(ref r, ref data))
                {
                    return(false);
                }
            }

            if ((Flags & (uint)MeshFlags.MESHSYS_FLAG_VEC3ARRAY) != 0)
            {
                if (!r.Get(ref n))
                {
                    return(false);
                }
                Vec3Data.Capacity = (int)n;
                for (i = 0; i < n; i++)
                {
                    if (Vec3Data.Count <= i)
                    {
                        Vec3Data.Add(new List <CVec3f>());
                    }
                    var element = Vec3Data[(int)i];
                    if (!Loaders.LoadPrimitiveArray(ref element, ref r))
                    {
                        return(false);
                    }
                    Vec3Data[(int)i] = element;
                }
            }

            if ((Flags & (uint)MeshFlags.MESHSYS_FLAG_USERDATA) != 0)
            {
                if (!r.Get(ref n))
                {
                    return(false);
                }

                UserData.Capacity = (int)n;
                if (!r.GetRaw(ref UserData, sizeof(byte) * n))
                {
                    return(false);
                }
            }

            if ((Flags & (uint)MeshFlags.MESHSYS_FLAG_SKELETONS) != 0)
            {
                if (!Loaders.LoadArray(ref Skeletons, ref r, ref data))
                {
                    return(false);
                }

                foreach (var skel in Skeletons)
                {
                    foreach (var bone in skel.Bones)
                    {
                        if (bone.Name.StartsWith("ef_"))
                        {
                            Flags |= (uint)MeshFlags.MESHSYS_FLAG_HAS_EF;
                            break;
                        }
                    }

                    if ((Flags & (uint)MeshFlags.MESHSYS_FLAG_HAS_EF) != 0)
                    {
                        break;
                    }
                }
            }

            foreach (var mesh in MeshArray)
            {
                if (!mesh.LoadMeshSections(ref r, ref data))
                {
                    return(false);
                }
            }

            if ((Flags & (uint)MeshFlags.MESHSYS_FLAG_NO_AAB) == 0)
            {
                if (!AAB.Load(ref r, ref data))
                {
                    return(false);
                }
            }

            if ((Flags & (uint)MeshFlags.MESHSYS_FLAG_COLLISION) != 0)
            {
                if (!Collision.Load(ref r, ref data))
                {
                    return(false);
                }
            }

            foreach (var mesh in MeshArray)
            {
                if (mesh.LOD == 14)
                {
                    if (LODs[0] == null)
                    {
                        LODs[0] = mesh;
                    }
                }
                else if (mesh.LOD >= 1001 && mesh.LOD <= 1008)
                {
                    n = mesh.LOD - 1000;
                    if (LODs[n] == null)
                    {
                        LODs[n] = mesh;
                    }
                }
            }

            return(true);
        }
Пример #8
0
        public bool Load(ref CDynMemoryReader r, ref CUberData data)
        {
            Console.WriteLine($"Loading {GetType().Name}");
            uint   n = 0, i = 0;
            string s;

            Clear();

            if (!r.Get(ref n))
            {
                return(false);
            }
            if (n == 0)
            {
                return(true);
            }

            if (!r.Get(ref BBMin))
            {
                return(false);
            }
            if (!r.Get(ref BBMax))
            {
                return(false);
            }

            if (!PortalMesh0.Load(ref r, ref data))
            {
                return(false);
            }
            if (!PortalMesh1.Load(ref r, ref data))
            {
                return(false);
            }
            if (!PortalMesh2.Load(ref r, ref data))
            {
                return(false);
            }
            if (!PortalMesh3.Load(ref r, ref data))
            {
                return(false);
            }
            if (!PortalMesh4.Load(ref r, ref data))
            {
                return(false);
            }

            if (!Loaders.LoadArray(ref ExteriorPortals, ref r, ref data))
            {
                return(false);
            }

            if (!Loaders.LoadArray(ref Regions, ref r, ref data))
            {
                return(false);
            }
            if (!Loaders.LoadStringArray(ref Strings, ref r))
            {
                return(false);
            }

            if (!r.Get(ref n))
            {
                return(false);
            }

            var aabv = new CAABV();

            if (n != 0)
            {
                MeshItems.Capacity = (int)n;
                for (i = 0; i < n; i++)
                {
                    if (MeshItems.Count <= i)
                    {
                        MeshItems.Add(new CMeshItem());
                    }
                    var element = MeshItems[(int)i];
                    if (!element.Load(ref r, ref data))
                    {
                        return(false);
                    }
                    MeshItems[(int)i] = element;
                }

                if (!r.Get(ref n))
                {
                    return(false);
                }
                if (n != 0)
                {
                    if (!AABV.Load(ref r, ref data))
                    {
                        return(false);
                    }
                }
                for (i = 0; i < Regions.Count; i++)
                {
                    uint PortalID = 0;
                    uint HasAABV  = 0;
                    if (!r.Get(ref PortalID))
                    {
                        return(false);
                    }
                    if (!r.Get(ref HasAABV))
                    {
                        return(false);
                    }
                    if (HasAABV != 0)
                    {
                        if (!aabv.Load(ref r, ref data))
                        {
                            return(false);
                        }
                    }
                }
            }

            if (!Loaders.LoadPrimitiveArray(ref U32s, ref r))
            {
                return(false);
            }

            if (U32s.Count != 0)
            {
                if (!r.Get(ref n))
                {
                    return(false);
                }
                if (n != 0)
                {
                    if (!aabv.Load(ref r, ref data))
                    {
                        return(false);
                    }
                }
            }

            if (!Loaders.LoadArray(ref SubStructs1, ref r, ref data))
            {
                Loaded = true;
            }

            return(true);
        }