Пример #1
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);
            }
        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 static bool LoadStringArray(ref List <string> array, ref CDynMemoryReader r)
        {
            uint i = 0, count = 0;

            if (!r.Get(ref count))
            {
                return(false);
            }
            array.Capacity = (int)count;
            string s;

            for (i = 0; i < count; i++)
            {
                s = r.ReadPascalStr();
                if (s == "")
                {
                    return(false);
                }
                if (array.Count <= i)
                {
                    array.Add("");
                }
                array[(int)i] = s;
            }

            return(true);
        }
Пример #5
0
        public bool Load(ref CDynMemoryReader r, ref CUberData data)
        {
            string s0 = r.ReadPascalStr();

            if (s0 == "")
            {
                return(false);
            }
            Name = s0;

            string s1 = r.ReadPascalStr();

            if (s1 == "")
            {
                return(false);
            }
            ModelName = s1;

            if (!r.Get(ref LOD))
            {
                return(false);
            }
            if (!r.Get(ref BBMin))
            {
                return(false);
            }
            if (!r.Get(ref BBMax))
            {
                return(false);
            }
            if (!r.Get(ref MeshSectionCount2))
            {
                return(false);
            }
            //Could be quality
            if (!r.Get(ref ID))
            {
                return(false);
            }
            if (!r.Get(ref MeshSectionCount))
            {
                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, ref CUberData data)
            {
                string s = r.ReadPascalStr();

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

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

                return(true);
            }
Пример #8
0
        //todo: CCollisionPart operator functions
        //CCollisionPart &operator=(const CCollisionPart &b) = delete;
        //CCollisionPart(const CCollisionPart &b) = delete;
        //CCollisionPart(CCollisionPart &&b)
        //CCollisionPart &operator=(CCollisionPart &&b)

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

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

            // This is a workaround for Marshal.SizeOf not working with enums. Assign to a temporary variable of the correct byte length first.
            uint typeTemp = 0;

            if (!r.Get(ref typeTemp))
            {
                return(false);
            }
            Type = (eCollisionType)typeTemp;

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

            switch (Type)
            {
            case eCollisionType.Sphere:
                pSphere = new CCollisionPartSphere();
                if (!pSphere.Load(ref r, ref data))
                {
                    return(false);
                }
                break;

            case eCollisionType.Box:
                pBox = new CCollisionPartBox();
                if (!pBox.Load(ref r, ref data))
                {
                    return(false);
                }
                break;

            case eCollisionType.Mesh:
                pMesh = new CCollisionPartMesh();
                if (!pMesh.Load(ref r, ref data))
                {
                    return(false);
                }
                break;

            case eCollisionType.Cylinder:
                pCylinder = new CCollisionPartCylinder();
                if (!pCylinder.Load(ref r, ref data))
                {
                    return(false);
                }
                break;

            case eCollisionType.OOBB:
                pOOBB = new CCollisionPartOOBB();
                if (!pOOBB.Load(ref r, ref data))
                {
                    return(false);
                }
                break;

            case eCollisionType.Undefined:
                break;

            default:
                //Should never happen.
                break;
            }

            return(true);
        }
Пример #9
0
        public bool Load(ref CDynMemoryReader r, ref CUberData data)
        {
            string s0 = r.ReadPascalStr();

            if (s0 == "")
            {
                return(false);
            }
            MaterialName = s0;

            uint n = 0;

            if (!r.Get(ref Flags))
            {
                return(false);
            }
            if (!r.Get(ref ID))
            {
                return(false);
            }
            if (!r.Get(ref MeshID))
            {
                return(false);
            }
            if (!r.Get(ref LOD))
            {
                return(false);
            }

            // This is a workaround for Marshal.SizeOf not working with enums. Assign to a temporary variable of the correct byte length first.
            uint vertexTypeTemp = 0;

            if (!r.Get(ref vertexTypeTemp))
            {
                return(false);
            }
            VertexType = (eVertexType)vertexTypeTemp;

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

            var pIndexData = data.ReadMeshData(sizeof(UInt16) * IndexCount);

            Indices.Capacity = (int)IndexCount;
            // Convert from byte to short
            UInt16[] indices = new ushort[pIndexData.Length / 2];
            Buffer.BlockCopy(pIndexData, 0, indices, 0, pIndexData.Length);
            Indices = indices.ToList();

            uint d = 0;

            switch (VertexType)
            {
            case eVertexType.Fat:
            case eVertexType.Lit:
            case eVertexType.Unlit:
            case eVertexType.Thin:
            case eVertexType.Raw:
            case eVertexType.FatDeform:
            case eVertexType.Deform:
                if (!r.Get(ref VertexCount))
                {
                    return(false);
                }
                LookupOffset = data.GetLookup(VertexCount);
                n            = U32PerVert(VertexType);
                U32Offset    = n != 0 ? data.GetU32(VertexCount * n) : 0;
                break;

            default:
                VertexCount = 0;
                break;
            }

            switch (VertexType)
            {
            case eVertexType.Fat:
                BuildVertices_Fat(ref data);
                break;

            case eVertexType.Lit:
                BuildVerticies_Lit(ref data);
                break;

            case eVertexType.Unlit:
                BuildVertices_Unlit(ref data);
                break;

            case eVertexType.Thin:
                BuildVertices_Thin(ref data);
                break;

            case eVertexType.Raw:
                BuildVertices_Raw(ref data);
                break;

            case eVertexType.Deform:
                BuildVertices_Deform(ref data);
                break;

            case eVertexType.FatDeform:
                // Do nothing?
                break;
            }

            return(true);
        }