Example #1
0
        public bool Load(ref CDynMemoryReader r, ref CUberData data)
        {
            uint n = 0;

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

            Tris.Capacity    = (int)n;
            Normals.Capacity = (int)n;
            if (!r.GetRaw(ref Tris, (uint)Marshal.SizeOf(typeof(STri)) * n))
            {
                return(false);
            }
            if (!r.GetRaw(ref Normals, (uint)Marshal.SizeOf(typeof(CVec3f)) * n))
            {
                return(false);
            }

            return(true);
        }
Example #2
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);
            }
Example #3
0
                public bool Load(ref CDynMemoryReader r, ref CUberData data, ref List <CMeshItemAABV> AABVs, ref uint index)
                {
                    UInt16 NumLeafs = 0;

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

                    if ((Flags & (int)CMeshItemAABVFlags.MESHITEMAABV_FLAG_LEAF) != 0)
                    {
                        if (!r.Get(ref NumLeafs))
                        {
                            return(false);
                        }
                        LeafIDs.Capacity = NumLeafs;
                        if (!r.GetRaw(ref LeafIDs, NumLeafs))
                        {
                            return(false);
                        }
                    }

                    if ((Flags & (int)CMeshItemAABVFlags.MESHITEMAABV_FLAG_LEFT) != 0)
                    {
                        index++;
                        pLeftNode = AABVs[(int)index];
                        if (!pLeftNode.Load(ref r, ref data, ref AABVs, ref index))
                        {
                            return(false);
                        }
                    }

                    if ((Flags & (int)CMeshItemAABVFlags.MESHITEMAABV_FLAG_RIGHT) != 0)
                    {
                        index++;
                        pRightNode = AABVs[(int)index];
                        if (!pRightNode.Load(ref r, ref data, ref AABVs, ref index))
                        {
                            return(false);
                        }
                    }

                    return(true);
                }
Example #4
0
            public List <CVec3f> B = new List <CVec3f>(); // Was CVec3f B[4]

            public bool Load(ref CDynMemoryReader r, ref CUberData data)
            {
                if (!r.Get(ref A))
                {
                    return(false);
                }
                if (!r.GetRaw(ref B, 4))
                {
                    return(false);
                }

                return(true);
            }
Example #5
0
        public List <float> RotationMatrix = new List <float>(); //Scale xform? - This was float RotationMatrix[3 * 3]


        public bool Load(ref CDynMemoryReader r, ref CUberData data)
        {
            if (!r.Get(ref Flags))
            {
                return(false);
            }
            if (!r.Get(ref Position))
            {
                return(false);
            }
            if (!r.Get(ref RotationQuat))
            {
                return(false);
            }
            if (!r.GetRaw(ref RotationMatrix, 3 * 3))
            {
                return(false);
            }

            return(true);
        }
Example #6
0
        public float B; //TODO

        public bool Load(ref CDynMemoryReader r, ref CUberData data)
        {
            if (!r.GetRaw(ref Matrix, 4 * 4))
            {
                return(false);
            }
            if (!r.Get(ref ExtendMin))
            {
                return(false);
            }
            if (!r.Get(ref ExtendMax))
            {
                return(false);
            }
            if (!r.Get(ref A))
            {
                return(false);
            }
            if (!r.Get(ref B))
            {
                return(false);
            }
            return(true);
        }
Example #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);
        }
Example #8
0
        public bool Load(ref CDynMemoryReader r)
        {
            Console.WriteLine($"Loading {GetType().Name}");
            SUberHeader hdr = new SUberHeader();    // C# Possibly Unassigned Value

            if (!r.Get(ref hdr))
            {
                return(false);
            }
            if (!hdr.FourCC.SequenceEqual(SUberHeader.FourCCValue))
            {
                return(false);
            }
            if (hdr.VersionA != SUberHeader.VersionAValue)
            {
                return(false);
            }
            if (hdr.VersionB != SUberHeader.VersionBValue)
            {
                return(false);
            }

            Console.WriteLine($"Loading {hdr.EntryCount} Entries");
            Entries.Capacity = (int)hdr.EntryCount;
            if (!r.GetRaw(ref Entries, hdr.EntryCount))
            {
                return(false);
            }

            Console.WriteLine($"Loading {hdr.Vec3Count} Vec3Data");
            Vec3Data.Capacity = (int)hdr.Vec3Count;
            if (!r.GetRaw(ref Vec3Data, hdr.Vec3Count))
            {
                return(false);
            }

            Console.WriteLine($"Loading {hdr.Vec2Count} Vec2Data");
            Vec2Data.Capacity = (int)hdr.Vec2Count;
            if (!r.GetRaw(ref Vec2Data, hdr.Vec2Count))
            {
                return(false);
            }

            Console.WriteLine($"Loading {hdr.LookupCount} LookupData");
            LookupData.Capacity = (int)hdr.LookupCount;
            if (!r.GetRaw(ref LookupData, hdr.LookupCount))
            {
                return(false);
            }

            Console.WriteLine($"Loading {hdr.MeshDataSize} MeshDataSize");
            MeshData.Capacity = (int)hdr.MeshDataSize;
            if (!r.GetRaw(ref MeshData, hdr.MeshDataSize))
            {
                return(false);
            }
            MeshDataBytes = MeshData.ToArray();

            Console.WriteLine($"Loading {hdr.U32Count} U32Count");
            U32Data.Capacity = (int)hdr.U32Count;
            if (!r.GetRaw(ref U32Data, hdr.U32Count))
            {
                return(false);
            }

            Console.WriteLine($"Loading {hdr.ModelDataSize} ModelDataSize");
            ModelData.Capacity = (int)hdr.ModelDataSize;
            if (!r.GetRaw(ref ModelData, hdr.ModelDataSize))
            {
                return(false);
            }

            Entries.Add(new SUberEntry
            {
                Name            = ".",
                LookupOffset    = hdr.LookupCount,
                MeshDataOffset  = hdr.U32Count,
                ModelDataOffset = hdr.MeshDataSize,
                U32Offset       = hdr.ModelDataSize
            });

            return(true);
        }