コード例 #1
0
        private static void ProcessLSTPseRelativeObjects(List <Pse_RelativeObject> pseRelativeObjects, List <PlanetSideObject> identifiableObjects, PlanetSideObject ownerObject, ref int id)
        {
            foreach (var line in pseRelativeObjects)
            {
                if (!_objectsWithGuids.Contains(line.ObjectName.ToLower()))
                {
                    continue;
                }
                Console.WriteLine($"Processing sub-object {line.ObjectName}");

                var uber = _ubrData.Single(x =>
                                           x.Value.Entries.Select(y => y.Name).Contains(line.ObjectName.ToLower()));
                var mesh = UBRReader.GetMeshSystem(line.ObjectName, uber.Value);

                var(relativeObjectRotX, relativeObjectRotY)  = MathFunctions.RotateXY(line.RelX, line.RelY, MathFunctions.DegreesToRadians(ownerObject.YawDegrees));
                (float x, float y, float z)relativeObjectPos = (relativeObjectRotX + ownerObject.AbsX, relativeObjectRotY + ownerObject.AbsY, line.RelZ + ownerObject.AbsZ);

                var relativeObjectRotationDegrees = MathFunctions.PS1RotationToDegrees((int)line.Yaw);

                // Process any sub-objects in the ubr file for this relative object (e.g. bfr_door within bfr_building ubr)
                foreach (var meshItem in mesh.PortalSystem.MeshItems)
                {
                    if (!_objectsWithGuids.Contains(meshItem.AssetName))
                    {
                        continue;
                    }

                    var subObjectRotationDegrees = MathFunctions.TransformToRotationDegrees(meshItem.Transform);

                    var(subObjectRotX, subObjectRotY) = MathFunctions.RotateXY(meshItem.Transform[12], meshItem.Transform[13], MathFunctions.DegreesToRadians(ownerObject.YawDegrees + relativeObjectRotationDegrees));
                    identifiableObjects.Add(new PlanetSideObject
                    {
                        Id            = id,
                        ObjectName    = meshItem.AssetName,
                        ObjectType    = meshItem.AssetName,
                        Owner         = ownerObject.Id,
                        AbsX          = relativeObjectPos.x + subObjectRotX,
                        AbsY          = relativeObjectPos.y + subObjectRotY,
                        AbsZ          = relativeObjectPos.z + line.RelZ,
                        IsChildObject = true
                    });
                    id++;
                }
            }
        }
コード例 #2
0
        private static void ProcessObject(List <PlanetSideObject> identifiableObjects, MapObject entry, ref int id, int?mapId, bool isTopLevel = false)
        {
            if (!_objectsWithGuids.Contains(entry.ObjectType))
            {
                return;
            }
            Console.WriteLine($"Processing {entry.ObjectType}");

            // Load the relevant *.lst files for this object
            var(peHiddens, peEdits, pseRelativeObjects) = LSTReader.ReadLSTFile(_planetsideModReadyFolder, entry.ObjectType, entry.LstType);

            // Get the root mesh for this object
            var uberData = _ubrData.First(x =>
                                          x.Value.Entries.Select(y => y.Name).Contains(entry.ObjectType, StringComparer.OrdinalIgnoreCase));

            var objectRotationDegrees = MathFunctions.PS1RotationToDegrees(entry.HorizontalRotation);
            var objectRotationRadians = MathFunctions.DegreesToRadians(objectRotationDegrees);

            var entryObject = new PlanetSideObject
            {
                Id            = id,
                ObjectName    = entry.ObjectName,
                ObjectType    = entry.ObjectType,
                AbsX          = entry.HorizontalPosition,
                AbsY          = entry.VerticalPosition,
                AbsZ          = entry.HeightPosition,
                YawDegrees    = objectRotationDegrees,
                MapID         = mapId,
                IsChildObject = !isTopLevel
            };

            identifiableObjects.Add(entryObject);
            id++;

            var parentRotationClockwise =
                MathFunctions.CounterClockwiseToClockwiseRotation(entry.HorizontalRotation);

            // Get the sub-entities from the UBR file that would have a GUID within this object
            var baseMesh = UBRReader.GetMeshSystem(entry.ObjectType, uberData.Value);

            foreach (var meshItem in baseMesh.PortalSystem.MeshItems)
            {
                // If it's not an entity that would be assigned a GUID we don't care about it and should skip it
                if (!_objectsWithGuids.Contains(meshItem.AssetName, StringComparer.OrdinalIgnoreCase))
                {
                    continue;
                }

                // If a line is in the pe_hidden list it should be removed from the game world e.g. Neti pad_landing is removed where the BFR building now exists
                if (peHiddens.Any(x => x.InstanceName == meshItem.InstanceName))
                {
                    continue;
                }

                var(rotX, rotY) = MathFunctions.RotateXY(meshItem.Transform[12], meshItem.Transform[13],
                                                         objectRotationRadians);
                var meshItemYaw = MathFunctions.TransformToRotationDegrees(meshItem.Transform);

                // Convert from CCW to CW and apply 180 degree offset
                var yaw = parentRotationClockwise + (360 - (180 - meshItemYaw));

                identifiableObjects.Add(new PlanetSideObject
                {
                    Id            = id,
                    ObjectName    = meshItem.AssetName,
                    ObjectType    = meshItem.AssetName,
                    Owner         = entryObject.Id,
                    AbsX          = entry.HorizontalPosition + rotX,
                    AbsY          = entry.VerticalPosition + rotY,
                    AbsZ          = entry.HeightPosition + meshItem.Transform[14],
                    YawDegrees    = MathFunctions.NormalizeDegrees((int)yaw),
                    IsChildObject = true
                });
                id++;
            }

            ProcessLSTPeEdits(peEdits, identifiableObjects, objectRotationRadians, baseX: entry.HorizontalPosition, baseY: entry.VerticalPosition, baseZ: entry.HeightPosition, ownerId: entryObject.Id, id: ref id);

            ProcessLSTPseRelativeObjects(pseRelativeObjects, identifiableObjects, ownerObject: entryObject, id: ref id);
        }