public override void Parse(MetaFile meta, CMloInstanceDef CMloInstanceDef)
        {
            this.Meta          = meta;
            this.MetaStructure = CMloInstanceDef;

            this.ArchetypeName = CMloInstanceDef.archetypeName;
            this.Flags         = CMloInstanceDef.flags;
            this.Guid          = CMloInstanceDef.guid;
            this.Position      = CMloInstanceDef.position;
            this.Rotation      = CMloInstanceDef.rotation;
            this.ScaleXY       = CMloInstanceDef.scaleXY;
            this.ScaleZ        = CMloInstanceDef.scaleZ;
            this.ParentIndex   = CMloInstanceDef.parentIndex;
            this.LodDist       = CMloInstanceDef.lodDist;
            this.ChildLodDist  = CMloInstanceDef.childLodDist;
            this.LodLevel      = CMloInstanceDef.lodLevel;
            this.NumChildren   = CMloInstanceDef.numChildren;
            this.PriorityLevel = CMloInstanceDef.priorityLevel;
            this.Extensions    = new Array_StructurePointer();
            this.AmbientOcclusionMultiplier = CMloInstanceDef.ambientOcclusionMultiplier;
            this.ArtificialAmbientOcclusion = CMloInstanceDef.artificialAmbientOcclusion;
            this.TintValue         = CMloInstanceDef.tintValue;
            this.GroupId           = CMloInstanceDef.groupId;
            this.FloorId           = CMloInstanceDef.floorId;
            this.DefaultEntitySets = CMloInstanceDef.defaultEntitySets;
            this.NumExitPortals    = CMloInstanceDef.numExitPortals;
            this.MLOInstflags      = CMloInstanceDef.MLOInstflags;
        }
Beispiel #2
0
        public static T[] ConvertDataArray <T>(PsoFile pso, Array_StructurePointer array) where T : struct, IPsoSwapEnd
        {
            uint count = array.Count1;

            if (count == 0)
            {
                return(null);
            }
            PsoPOINTER[] ptrs = GetPointerArray(pso, array);
            if (ptrs == null)
            {
                return(null);
            }
            if (ptrs.Length < count)
            {
                return(null);
            }

            T[] items    = new T[count];
            int itemsize = Marshal.SizeOf(typeof(T));

            for (int i = 0; i < count; i++)
            {
                var sptr   = ptrs[i];
                int blocki = sptr.BlockID - 1;
                int offset = (int)sptr.ItemOffset;// * 16;//block data size...
                if (blocki >= pso.DataMappingSection.EntriesCount)
                {
                    continue;
                }
                var block = pso.DataMappingSection.Entries[blocki];

                if ((offset < 0) || (offset >= block.Length))
                {
                    continue;
                }

                int boffset = block.Offset + offset;

                items[i] = ConvertData <T>(pso.DataSection.Data, boffset);
            }

            return(items);
        }
Beispiel #3
0
        public static PsoPOINTER[] GetPointerArray(PsoFile pso, Array_StructurePointer array)
        {
            uint count = array.Count1;

            if (count == 0)
            {
                return(null);
            }

            int  ptrsize   = Marshal.SizeOf(typeof(MetaPOINTER));
            int  itemsleft = (int)count; //large arrays get split into chunks...
            uint ptr       = array.Pointer;
            int  ptrindex  = (int)(ptr & 0xFFF) - 1;
            int  ptroffset = (int)((ptr >> 12) & 0xFFFFF);
            var  ptrblock  = (ptrindex < pso.DataMappingSection.EntriesCount) ? pso.DataMappingSection.Entries[ptrindex] : null;

            if ((ptrblock == null) || ((MetaName)ptrblock.NameHash != MetaName.PsoPOINTER))
            {
                return(null);
            }

            var offset  = ptrblock.Offset;
            int boffset = offset + ptroffset;

            var ptrs = ConvertDataArrayRaw <PsoPOINTER>(pso.DataSection.Data, boffset, (int)count);

            if (ptrs != null)
            {
                for (int i = 0; i < ptrs.Length; i++)
                {
                    ptrs[i].SwapEnd();
                }
            }

            return(ptrs);
        }