Ejemplo n.º 1
0
    internal void _Serialize(MSBBB.Part part, GameObject parent)
    {
        part.Name        = parent.name;
        part.Placeholder = Placeholder;

        part.Position.X = parent.transform.position.x;
        part.Position.Y = parent.transform.position.y;
        part.Position.Z = parent.transform.position.z;
        // :trashcat:
        //part.Rotation.X = parent.transform.rotation.eulerAngles.x;
        //part.Rotation.Y = parent.transform.rotation.eulerAngles.z;
        //part.Rotation.Z = -parent.transform.rotation.eulerAngles.y;
        //part.Rotation = ConvertEuler(parent.transform.eulerAngles);
        //part.Rotation = new System.Numerics.Vector3(Rotation.x, Rotation.y, Rotation.z);
        part.Rotation = EulerUtils.quaternion2EulerDeg(parent.transform.rotation.normalized, EulerUtils.RotSeq.yzx);
        //print($@"{part.Name}: {parent.transform.eulerAngles}, {parent.transform.localEulerAngles} -> {part.Rotation}");
        part.Scale.X = parent.transform.localScale.x;
        part.Scale.Y = parent.transform.localScale.y;
        part.Scale.Z = parent.transform.localScale.z;

        part.ModelName     = ModelName;
        part.DrawGroups[0] = DrawGroup1;
        part.DrawGroups[1] = DrawGroup2;
        part.DrawGroups[2] = DrawGroup3;
        part.DrawGroups[3] = DrawGroup4;
        part.DrawGroups[4] = DrawGroup5;
        part.DrawGroups[5] = DrawGroup6;
        part.DrawGroups[6] = DrawGroup7;
        part.DrawGroups[7] = DrawGroup8;

        part.DispGroups[0] = DispGroup1;
        part.DispGroups[1] = DispGroup2;
        part.DispGroups[2] = DispGroup3;
        part.DispGroups[3] = DispGroup4;
        part.DispGroups[4] = DispGroup5;
        part.DispGroups[5] = DispGroup6;
        part.DispGroups[6] = DispGroup7;
        part.DispGroups[7] = DispGroup8;

        part.BackreadGroups[0] = BackreadGroup1;
        part.BackreadGroups[1] = BackreadGroup2;
        part.BackreadGroups[2] = BackreadGroup3;
        part.BackreadGroups[3] = BackreadGroup4;
        part.BackreadGroups[4] = BackreadGroup5;
        part.BackreadGroups[5] = BackreadGroup6;
        part.BackreadGroups[6] = BackreadGroup7;
        part.BackreadGroups[7] = BackreadGroup8;
        part.UnkFA4            = UnkFA4;

        part.EventEntityID   = EventEntityID;
        part.OldLightID      = OldLightID;
        part.OldFogID        = OldFogID;
        part.OldScatterID    = OldScatterID;
        part.OldLensFlareID  = OldLensFlareID;
        part.OldLanternID    = OldLanternID;
        part.OldLodParamID   = OldLodParamID;
        part.UnkB0E          = UnkB0E;
        part.OldIsShadowDest = OldIsShadowDest;
    }
Ejemplo n.º 2
0
    internal void _Serialize(MSB1.Part part, GameObject parent)
    {
        part.Name        = parent.name;
        part.Placeholder = Placeholder;

        var pos = new System.Numerics.Vector3();

        pos.X         = parent.transform.position.x;
        pos.Y         = parent.transform.position.y;
        pos.Z         = parent.transform.position.z;
        part.Position = pos;

        var rot = new System.Numerics.Vector3();

        rot.X = Rotation.x;
        rot.Y = Rotation.y;
        rot.Z = Rotation.z;
        //part.Rotation = rot;
        part.Rotation = EulerUtils.quaternion2EulerDeg(parent.transform.rotation.normalized, EulerUtils.RotSeq.yzx);

        var scale = new System.Numerics.Vector3();

        scale.X    = parent.transform.localScale.x;
        scale.Y    = parent.transform.localScale.y;
        scale.Z    = parent.transform.localScale.z;
        part.Scale = scale;

        part.ModelName     = (ModelName == "") ? null : ModelName;
        part.DrawGroups[0] = DrawGroup1;
        part.DrawGroups[1] = DrawGroup2;
        part.DrawGroups[2] = DrawGroup3;
        part.DrawGroups[3] = DrawGroup4;
        part.DispGroups[0] = DispGroup1;
        part.DispGroups[1] = DispGroup2;
        part.DispGroups[2] = DispGroup3;
        part.DispGroups[3] = DispGroup4;

        part.EntityID                = EventEntityID;
        part.LightID                 = LightID;
        part.FogID                   = FogID;
        part.ScatterID               = ScatterID;
        part.LensFlareID             = LensFlareID;
        part.ShadowID                = ShadowID;
        part.DofID                   = DepthOfFieldID;
        part.ToneMapID               = ToneMapID;
        part.ToneCorrectID           = ToneCorrectID;
        part.LanternID               = LanternID;
        part.LodParamID              = LodParamID;
        part.IsShadowSrc             = IsShadowSrc;
        part.IsShadowDest            = (byte)(IsShadowDest ? 1 : 0);
        part.IsShadowOnly            = (byte)(IsShadowOnly ? 1 : 0);
        part.DrawByReflectCam        = (byte)(DrawByReflectCam ? 1 : 0);
        part.DrawOnlyReflectCam      = (byte)(DrawOnlyReflectCam ? 1 : 0);
        part.UseDepthBiasFloat       = (byte)(UseDepthBiasFloat ? 1 : 0);
        part.DisablePointLightEffect = (byte)(DisablePointLightEffect ? 1 : 0);
    }
Ejemplo n.º 3
0
    public MSBBB.Region Serialize(MSBBB.Region region, GameObject parent)
    {
        region.Name = parent.name;

        region.Position.X = parent.transform.position.x;
        region.Position.Y = parent.transform.position.y;
        region.Position.Z = parent.transform.position.z;
        //var rot = ConvertEuler(parent.transform.rotation.eulerAngles);
        //region.Rotation.X = rot.X;
        //region.Rotation.Y = rot.Y;
        //region.Rotation.Z = rot.Z;
        region.Rotation = EulerUtils.quaternion2EulerDeg(parent.transform.rotation.normalized, EulerUtils.RotSeq.yzx);

        region.Unk2          = Unk2;
        region.Unk3          = Unk3;
        region.Unk4          = Unk4;
        region.EventEntityID = EventEntityID;

        if (parent.GetComponent <SphereCollider>() != null && IsPointOrCircle)
        {
            region.Shape = new MSBBB.Shape.Point();
        }
        else if (parent.GetComponent <CapsuleCollider>() != null && IsPointOrCircle)
        {
            var shape = new MSBBB.Shape.Circle();
            var col   = parent.GetComponent <CapsuleCollider>();
            shape.Radius = col.radius;
            region.Shape = shape;
        }
        else if (parent.GetComponent <BoxCollider>() != null)
        {
            var shape = new MSBBB.Shape.Box();
            var col   = parent.GetComponent <BoxCollider>();
            shape.Width  = col.size.x;
            shape.Height = col.size.y;
            shape.Depth  = col.size.z;
            region.Shape = shape;
        }
        else if (parent.GetComponent <CapsuleCollider>() != null)
        {
            var shape = new MSBBB.Shape.Cylinder();
            var col   = parent.GetComponent <CapsuleCollider>();
            shape.Radius = col.radius;
            shape.Height = col.height;
            region.Shape = shape;
        }
        else if (parent.GetComponent <SphereCollider>() != null)
        {
            var shape = new MSBBB.Shape.Sphere();
            var col   = parent.GetComponent <SphereCollider>();
            shape.Radius = col.radius;
            region.Shape = shape;
        }
        return(region);
    }
Ejemplo n.º 4
0
    internal void _Serialize(MSB2.Part part, GameObject parent)
    {
        part.Name = parent.name;

        var pos = new System.Numerics.Vector3();

        pos.X         = parent.transform.position.x;
        pos.Y         = parent.transform.position.y;
        pos.Z         = parent.transform.position.z;
        part.Position = pos;

        //part.Rotation = ConvertEuler(parent.transform.eulerAngles);
        part.Rotation = EulerUtils.quaternion2EulerDeg(parent.transform.rotation.normalized, EulerUtils.RotSeq.yzx);
        //Debug.Log($@"{part.Name}: {Rotation}, {parent.transform.eulerAngles} -> {part.Rotation}");

        /*if (Mathf.Abs(Rotation.x - part.Rotation.X) > 0.01f ||
         *  Mathf.Abs(Rotation.y - part.Rotation.Y) > 0.01f ||
         *  Mathf.Abs(Rotation.z - part.Rotation.Z) > 0.01f)
         * {
         *  Debug.Log($@"{part.Name}: {Rotation}, {parent.transform.eulerAngles} -> {part.Rotation} Q: {parent.transform.rotation.normalized}");
         * }*/
        //var rotation = new System.Numerics.Vector3();
        //rotation.X = parent.transform.eulerAngles.x;
        //rotation.Y = parent.transform.eulerAngles.y;
        //rotation.Z = parent.transform.eulerAngles.z;
        //part.Rotation = rotation;

        var scale = new System.Numerics.Vector3();

        scale.X    = parent.transform.localScale.x;
        scale.Y    = parent.transform.localScale.y;
        scale.Z    = parent.transform.localScale.z;
        part.Scale = scale;

        part.ModelName     = (ModelName == "") ? null : ModelName;
        part.DrawGroups[0] = DrawGroup1;
        part.DrawGroups[1] = DrawGroup2;
        part.DrawGroups[2] = DrawGroup3;
        part.DrawGroups[3] = DrawGroup4;
        part.DispGroups[0] = DispGroup1;
        part.DispGroups[1] = DispGroup2;
        part.DispGroups[2] = DispGroup3;
        part.DispGroups[3] = DispGroup4;
        part.Unk44         = NvmGroup1;
        part.Unk48         = NvmGroup2;
        part.Unk4C         = NvmGroup3;
        part.Unk50         = NvmGroup4;
        part.Unk64         = Unk64;
        part.Unk68         = Unk68;
        part.Unk6C         = Unk6C;
    }
Ejemplo n.º 5
0
    internal void _Serialize(MSB3.Region region, GameObject parent)
    {
        region.Name = parent.name;

        region.Position.X = parent.transform.position.x;
        region.Position.Y = parent.transform.position.y;
        region.Position.Z = parent.transform.position.z;
        //region.Rotation.X = parent.transform.eulerAngles.x;
        //region.Rotation.Y = parent.transform.eulerAngles.y;
        //region.Rotation.Z = parent.transform.eulerAngles.z;
        //region.Rotation = ConvertEuler(parent.transform.rotation.eulerAngles);
        //region.Rotation = new System.Numerics.Vector3(Rotation.x, Rotation.y, Rotation.z);
        region.Rotation = EulerUtils.quaternion2EulerDeg(parent.transform.rotation.normalized, EulerUtils.RotSeq.yzx);

        region.HasTypeData        = HasTypeData;
        region.Unk2               = Unk2;
        region.UnkA               = UnkA;
        region.UnkB               = UnkB;
        region.MapStudioLayer     = MapStudioLayer;
        region.ActivationPartName = (ActivationPartName == "") ? null : ActivationPartName;
        region.EventEntityID      = EventEntityID;

        if (parent.GetComponent <SphereCollider>() != null)
        {
            var col = parent.GetComponent <SphereCollider>();
            if (IsPoint)
            {
                region.Shape = new MSB3.Shape.Point();
            }
            else
            {
                region.Shape = new MSB3.Shape.Sphere(col.radius);
            }
        }
        else if (parent.GetComponent <BoxCollider>() != null)
        {
            var col = parent.GetComponent <BoxCollider>();
            region.Shape = new MSB3.Shape.Box(col.size.x, col.size.z, col.size.y);
        }
        else if (parent.GetComponent <CapsuleCollider>() != null)
        {
            var col = parent.GetComponent <CapsuleCollider>();
            region.Shape = new MSB3.Shape.Cylinder(col.radius, col.height);
        }
        else
        {
            throw new Exception($@"Region {parent.name} has no shape. Attach a spherical, box, or capsule collider.");
        }
    }
Ejemplo n.º 6
0
    internal void _Serialize(MSBS.Part part, GameObject parent)
    {
        part.Name        = parent.name;
        part.Placeholder = Placeholder;
        part.ModelName   = ModelName;
        part.Position    = new System.Numerics.Vector3(parent.transform.position.x, parent.transform.position.y, parent.transform.position.z);
        // :trashcat:
        //part.Rotation.X = parent.transform.rotation.eulerAngles.x;
        //part.Rotation.Y = parent.transform.rotation.eulerAngles.z;
        //part.Rotation.Z = -parent.transform.rotation.eulerAngles.y;
        //part.Rotation = ConvertEuler(parent.transform.eulerAngles);
        //part.Rotation = new System.Numerics.Vector3(Rotation.x, Rotation.y, Rotation.z);
        part.Rotation = EulerUtils.quaternion2EulerDeg(parent.transform.rotation.normalized, EulerUtils.RotSeq.yzx);
        //print($@"{part.Name}: {parent.transform.eulerAngles}, {parent.transform.localEulerAngles} -> {part.Rotation}");
        part.Scale = new System.Numerics.Vector3(parent.transform.localScale.x, parent.transform.localScale.y, parent.transform.localScale.z);

        part.EntityID                = EntityID;
        part.UnkE18                  = UnkE18;
        part.UnkE3C                  = UnkE3C;
        part.UnkE40                  = UnkE40;
        part.EntityGroupIDs[0]       = EntityGroupID1;
        part.EntityGroupIDs[1]       = EntityGroupID2;
        part.EntityGroupIDs[2]       = EntityGroupID3;
        part.EntityGroupIDs[3]       = EntityGroupID4;
        part.EntityGroupIDs[4]       = EntityGroupID5;
        part.EntityGroupIDs[5]       = EntityGroupID6;
        part.EntityGroupIDs[6]       = EntityGroupID7;
        part.EntityGroupIDs[7]       = EntityGroupID8;
        part.LanternID               = LanternID;
        part.LodParamID              = LodParamID;
        part.EnableOnAboveShadow     = EnableOnAboveShadow;
        part.IsStaticShadowSrc       = IsStaticShadowSrc;
        part.IsCascade3ShadowSrc     = IsCascade3ShadowSrc;
        part.UnkE04                  = UnkE04;
        part.UnkE05                  = UnkE05;
        part.UnkE06                  = UnkE06;
        part.UnkE09                  = UnkE09;
        part.UnkE0B                  = UnkE0B;
        part.UnkE0F                  = UnkE0F;
        part.UnkE10                  = UnkE10;
        part.UnkE17                  = UnkE17;
        part.IsPointLightShadowSrc   = IsPointLightShadowSrc;
        part.IsShadowSrc             = IsShadowSrc;
        part.IsShadowDest            = IsShadowDest;
        part.IsShadowOnly            = IsShadowOnly;
        part.DrawByReflectCam        = DrawByReflectCam;
        part.DrawOnlyReflectCam      = DrawOnlyReflectCam;
        part.DisablePointLightEffect = DisablePointLightEffect;
    }
Ejemplo n.º 7
0
    internal void _Serialize(MSBS.Region region, GameObject parent)
    {
        region.Name = parent.name;

        region.Position = new System.Numerics.Vector3(parent.transform.position.x, parent.transform.position.y, parent.transform.position.z);
        //region.Rotation.X = parent.transform.eulerAngles.x;
        //region.Rotation.Y = parent.transform.eulerAngles.y;
        //region.Rotation.Z = parent.transform.eulerAngles.z;
        //region.Rotation = ConvertEuler(parent.transform.rotation.eulerAngles);
        region.Rotation = EulerUtils.quaternion2EulerDeg(parent.transform.rotation.normalized, EulerUtils.RotSeq.yzx);

        region.MapStudioLayer = MapStudioLayer;
        region.Unk2C          = Unk2C;
        for (int i = 0; i < UnkA.Length; i++)
        {
            region.UnkA.Add(UnkA[i]);
        }
        for (int i = 0; i < UnkB.Length; i++)
        {
            region.UnkB.Add(UnkB[i]);
        }
        region.ActivationPartName = (ActivationPartName == "") ? null : ActivationPartName;
        region.EntityID           = EntityID;

        if (parent.GetComponent <SphereCollider>() != null)
        {
            var col = parent.GetComponent <SphereCollider>();
            if (IsPoint)
            {
                region.Shape = new MSBS.Shape.Point();
            }
            else
            {
                MSBS.Shape.Sphere shape = new MSBS.Shape.Sphere();
                shape.Radius = col.radius;
                region.Shape = shape;
            }
        }
        else if (parent.GetComponent <BoxCollider>() != null)
        {
            var            col   = parent.GetComponent <BoxCollider>();
            MSBS.Shape.Box shape = new MSBS.Shape.Box();
            shape.Width  = col.size.x;
            shape.Height = col.size.y;
            shape.Depth  = col.size.z;
            region.Shape = shape;
        }
        else if (parent.GetComponent <CapsuleCollider>() != null)
        {
            var col = parent.GetComponent <CapsuleCollider>();
            MSBS.Shape.Cylinder shape = new MSBS.Shape.Cylinder();
            shape.Radius = col.radius;
            shape.Height = col.height;
            region.Shape = shape;
        }
        else if (parent.GetComponent <MSBSCompositeShape>() != null)
        {
            var col = parent.GetComponent <MSBSCompositeShape>();
            MSBS.Shape.Composite shape = col.Serialize();
            region.Shape = shape;
        }
        else
        {
            throw new Exception($@"Region {parent.name} has no shape. Attach a spherical, box, or capsule collider.");
        }
    }
Ejemplo n.º 8
0
    internal void _Serialize(MSB3.Part part, GameObject parent)
    {
        part.Name        = parent.name;
        part.Placeholder = Placeholder;

        part.Position.X = parent.transform.position.x;
        part.Position.Y = parent.transform.position.y;
        part.Position.Z = parent.transform.position.z;
        // :trashcat:
        //part.Rotation.X = parent.transform.rotation.eulerAngles.x;
        //part.Rotation.Y = parent.transform.rotation.eulerAngles.z;
        //part.Rotation.Z = -parent.transform.rotation.eulerAngles.y;
        //part.Rotation = ConvertEuler(parent.transform.eulerAngles);
        part.Rotation = EulerUtils.quaternion2EulerDeg(parent.transform.rotation.normalized, EulerUtils.RotSeq.yzx);
        //part.Rotation = ConvertQuatEuler(parent.transform.rotation);
        //part.Rotation = new System.Numerics.Vector3(Rotation.x, Rotation.y, Rotation.z);
        //print($@"{part.Name}: {Rotation}, {parent.transform.eulerAngles} -> {part.Rotation}");
        part.Scale.X = parent.transform.localScale.x;
        part.Scale.Y = parent.transform.localScale.y;
        part.Scale.Z = parent.transform.localScale.z;
        //part.Scale = new System.Numerics.Vector3(Scale.x, Scale.y, Scale.z);

        part.ModelName      = ModelName;
        part.MapStudioLayer = MapStudioLayer;
        part.DrawGroups[0]  = DrawGroup1;
        part.DrawGroups[1]  = DrawGroup2;
        part.DrawGroups[2]  = DrawGroup3;
        part.DrawGroups[3]  = DrawGroup4;
        part.DrawGroups[4]  = DrawGroup5;
        part.DrawGroups[5]  = DrawGroup6;
        part.DrawGroups[6]  = DrawGroup7;
        part.DrawGroups[7]  = DrawGroup8;

        part.DispGroups[0] = DispGroup1;
        part.DispGroups[1] = DispGroup2;
        part.DispGroups[2] = DispGroup3;
        part.DispGroups[3] = DispGroup4;
        part.DispGroups[4] = DispGroup5;
        part.DispGroups[5] = DispGroup6;
        part.DispGroups[6] = DispGroup7;
        part.DispGroups[7] = DispGroup8;

        part.BackreadGroups[0] = BackreadGroup1;
        part.BackreadGroups[1] = BackreadGroup2;
        part.BackreadGroups[2] = BackreadGroup3;
        part.BackreadGroups[3] = BackreadGroup4;
        part.BackreadGroups[4] = BackreadGroup5;
        part.BackreadGroups[5] = BackreadGroup6;
        part.BackreadGroups[6] = BackreadGroup7;
        part.BackreadGroups[7] = BackreadGroup8;

        part.EventEntityID           = EventEntityID;
        part.OldLightID              = OldLightID;
        part.OldFogID                = OldFogID;
        part.OldScatterID            = OldScatterID;
        part.OldLensFlareID          = OldLensFlareID;
        part.LanternID               = LanternID;
        part.LodParamID              = LodParamID;
        part.UnkB0E                  = UnkB0E;
        part.PointLightShadowSource  = PointLightShadowSource;
        part.ShadowSource            = ShadowSource;
        part.ShadowDest              = ShadowDest;
        part.IsShadowOnly            = IsShadowOnly;
        part.DrawByReflectCam        = DrawByReflectCam;
        part.DrawOnlyReflectCam      = DrawOnlyReflectCam;
        part.UseDepthBiasFloat       = UseDepthBiasFloat;
        part.DisablePointLightEffect = DisablePointLightEffect;
        part.UnkB17                  = UnkB17;
        part.UnkB18                  = UnkB18;

        for (int i = 0; i < 8; i++)
        {
            if (i >= EventEntityGroups.Length)
            {
                part.EventEntityGroups[i] = -1;
                continue;
            }
            part.EventEntityGroups[i] = EventEntityGroups[i];
        }
    }
Ejemplo n.º 9
0
    internal void _Serialize(MSB2.Region region, GameObject parent)
    {
        region.Name = parent.name;

        var pos = new System.Numerics.Vector3();

        pos.X           = parent.transform.position.x;
        pos.Y           = parent.transform.position.y;
        pos.Z           = parent.transform.position.z;
        region.Position = pos;

        //var rot = ConvertEuler(parent.transform.rotation.eulerAngles);
        region.Rotation = EulerUtils.quaternion2EulerDeg(parent.transform.rotation.normalized, EulerUtils.RotSeq.yzx);

        /*if (Mathf.Abs(Rotation.x - region.Rotation.X) > 0.01f ||
         *  Mathf.Abs(Rotation.y - region.Rotation.Y) > 0.01f ||
         *  Mathf.Abs(Rotation.z - region.Rotation.Z) > 0.01f)
         * {
         *  Debug.Log($@"{region.Name}: {Rotation}, {parent.transform.eulerAngles} -> {region.Rotation} Q: {parent.transform.rotation.normalized}");
         * }*/

        region.Unk08 = Unk08;
        region.Unk0E = Unk0E;

        if (parent.GetComponent <SphereCollider>() != null && IsPointOrCircle)
        {
            region.Shape = new MSB2.Shape.Point();
        }
        else if (parent.GetComponent <CapsuleCollider>() != null && IsPointOrCircle)
        {
            var shape = new MSB2.Shape.Circle();
            var col   = parent.GetComponent <CapsuleCollider>();
            shape.Radius = col.radius;
            region.Shape = shape;
        }
        else if (parent.GetComponent <BoxCollider>() != null)
        {
            var shape = new MSB2.Shape.Box();
            var col   = parent.GetComponent <BoxCollider>();
            shape.Width  = col.size.x;
            shape.Height = col.size.y;
            shape.Depth  = col.size.z;
            region.Shape = shape;
        }
        else if (parent.GetComponent <CapsuleCollider>() != null)
        {
            var shape = new MSB2.Shape.Cylinder();
            var col   = parent.GetComponent <CapsuleCollider>();
            shape.Radius = col.radius;
            shape.Height = col.height;
            region.Shape = shape;
        }
        else if (parent.GetComponent <SphereCollider>() != null)
        {
            var shape = new MSB2.Shape.Sphere();
            var col   = parent.GetComponent <SphereCollider>();
            shape.Radius = col.radius;
            region.Shape = shape;
        }
        else
        {
            throw new Exception($@"Region {parent.name} has no shape. Attach a spherical, box, or capsule collider.");
        }
    }