Exemple #1
0
    public static Vector3 CalculateGTE_RTPT(Vector3 vertex, Matrix4x4 localRTS, Matrix4x4 globalRT, Single viewDist, Vector2 offset)
    {
        Vector3 result = PSX.CalculateGTE_RTPT_POS(vertex, localRTS, globalRT, viewDist, offset, true);

        result.z = 0f;
        return(result);
    }
Exemple #2
0
    private void _RainLoop()
    {
        FieldMap fieldmap = PersistenSingleton <EventEngine> .Instance.fieldmap;

        if (fieldmap == (UnityEngine.Object)null)
        {
            return;
        }
        BGCAM_DEF currentBgCamera = fieldmap.GetCurrentBgCamera();

        for (Int32 i = 0; i < this.numRain; i++)
        {
            FieldRainRenderer.Rain rain = this.rainList[i];
            this._RTPTRain(rain, this.speed, this.gen);
            Vector3 p  = PSX.CalculateGTE_RTPT_POS(rain.p0, Matrix4x4.identity, currentBgCamera.GetMatrixR(), currentBgCamera.GetViewDistance(), fieldmap.GetProjectionOffset(), false);
            Vector3 p2 = PSX.CalculateGTE_RTPT_POS(rain.p1, Matrix4x4.identity, currentBgCamera.GetMatrixR(), currentBgCamera.GetViewDistance(), fieldmap.GetProjectionOffset(), false);
            Vector3 p3 = PSX.CalculateGTE_RTPT_POS(rain.p2, Matrix4x4.identity, currentBgCamera.GetMatrixR(), currentBgCamera.GetViewDistance(), fieldmap.GetProjectionOffset(), false);
            rain.p0   = p;
            rain.p1   = p2;
            rain.p2   = p3;
            rain.col0 = new Color(0f, 0f, 0f, 1f);
            Int32 num  = (Int32)p.z;
            Int32 num2 = num >> 6;
            Int32 num3 = 240;
            num3     -= num2;
            rain.col1 = new Color((Single)num3 / 255f, (Single)num3 / 255f, (Single)num3 / 255f, 1f);
        }
    }
Exemple #3
0
    private void _GenerateSPSMesh()
    {
        if (this.spsPrims.Count == 0)
        {
            return;
        }
        Boolean   flag            = false;
        BGCAM_DEF currentBgCamera = this.fieldMap.GetCurrentBgCamera();

        if (currentBgCamera == null)
        {
            return;
        }
        Single    num      = (Single)this.scale / 4096f;
        Matrix4x4 localRTS = Matrix4x4.identity;
        Boolean   flag2    = false;

        if (FF9StateSystem.Common.FF9.fldMapNo == 2929)
        {
            flag = true;
        }
        if (flag)
        {
            if (FF9StateSystem.Common.FF9.fldMapNo == 2929)
            {
                localRTS = Matrix4x4.TRS(this.pos * 0.9925f, Quaternion.Euler(-this.rot.x / 2f, -this.rot.y / 2f, this.rot.z / 2f), new Vector3(num, -num, 1f));
            }
            else
            {
                localRTS = Matrix4x4.TRS(this.pos, Quaternion.Euler(this.rot.x, this.rot.y, this.rot.z), new Vector3(num, -num, 1f));
            }
        }
        else
        {
            Vector3 vector = PSX.CalculateGTE_RTPT_POS(this.pos, Matrix4x4.identity, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), this.fieldMap.GetProjectionOffset(), true);
            num *= currentBgCamera.GetViewDistance() / vector.z;
            if (vector.z < 0f)
            {
                flag2 = true;
            }
            vector.z /= 4f;
            vector.z += (Single)currentBgCamera.depthOffset;
            base.transform.localPosition = new Vector3(vector.x, vector.y, vector.z + (Single)this.zOffset);
            base.transform.localScale    = new Vector3(num, -num, 1f);
            base.transform.localRotation = Quaternion.Euler(this.rot.x, this.rot.y, -this.rot.z);
        }
        this._vertices.Clear();
        this._colors.Clear();
        this._uv.Clear();
        this._indices.Clear();
        for (Int32 i = 0; i < this.spsPrims.Count; i++)
        {
            if (flag2)
            {
                break;
            }
            FieldSPS.FieldSPSPrim fieldSPSPrim = this.spsPrims[i];
            Int32 count = this._vertices.Count;
            if (flag)
            {
                Vector3 a    = PSX.CalculateGTE_RTPT(fieldSPSPrim.v0, localRTS, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), this.fieldMap.GetProjectionOffset());
                Vector3 a2   = PSX.CalculateGTE_RTPT(fieldSPSPrim.v1, localRTS, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), this.fieldMap.GetProjectionOffset());
                Vector3 a3   = PSX.CalculateGTE_RTPT(fieldSPSPrim.v2, localRTS, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), this.fieldMap.GetProjectionOffset());
                Vector3 a4   = PSX.CalculateGTE_RTPT(fieldSPSPrim.v3, localRTS, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), this.fieldMap.GetProjectionOffset());
                Single  num2 = PSX.CalculateGTE_RTPTZ(Vector3.zero, localRTS, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), this.fieldMap.GetProjectionOffset());
                num2 /= 4f;
                num2 += (Single)currentBgCamera.depthOffset;
                Vector3 b = new Vector3(0f, 0f, num2 - (Single)i / 100f);
                this._vertices.Add(a + b);
                this._vertices.Add(a2 + b);
                this._vertices.Add(a3 + b);
                this._vertices.Add(a4 + b);
            }
            else
            {
                Vector3 b2 = new Vector3(0f, 0f, (Single)(this.spsPrims.Count - i) / 100f);
                this._vertices.Add(fieldSPSPrim.v0 + b2);
                this._vertices.Add(fieldSPSPrim.v1 + b2);
                this._vertices.Add(fieldSPSPrim.v2 + b2);
                this._vertices.Add(fieldSPSPrim.v3 + b2);
            }
            this._colors.Add(fieldSPSPrim.color);
            this._colors.Add(fieldSPSPrim.color);
            this._colors.Add(fieldSPSPrim.color);
            this._colors.Add(fieldSPSPrim.color);
            this._uv.Add((fieldSPSPrim.uv0 + new Vector2(0.5f, 0.5f)) * 0.00390625f);
            this._uv.Add((fieldSPSPrim.uv1 + new Vector2(-0.5f, 0.5f)) * 0.00390625f);
            this._uv.Add((fieldSPSPrim.uv2 + new Vector2(0.5f, -0.5f)) * 0.00390625f);
            this._uv.Add((fieldSPSPrim.uv3 + new Vector2(-0.5f, -0.5f)) * 0.00390625f);
            this._indices.Add(count);
            this._indices.Add(count + 1);
            this._indices.Add(count + 2);
            this._indices.Add(count + 1);
            this._indices.Add(count + 3);
            this._indices.Add(count + 2);
        }
        Mesh mesh = this.meshFilter.mesh;

        mesh.Clear();
        mesh.vertices        = this._vertices.ToArray();
        mesh.colors          = this._colors.ToArray();
        mesh.uv              = this._uv.ToArray();
        mesh.triangles       = this._indices.ToArray();
        this.meshFilter.mesh = mesh;
        FieldSPS.FieldSPSPrim fieldSPSPrim2 = this.spsPrims[0];
        PSXTexture            texture       = PSXTextureMgr.GetTexture(fieldSPSPrim2.FlagTP, fieldSPSPrim2.FlagTY, fieldSPSPrim2.FlagTX, fieldSPSPrim2.FlagClutY, fieldSPSPrim2.FlagClutX);

        texture.SetFilter(FilterMode.Bilinear);
        Int32 num3 = (Int32)((this.arate >= 4) ? 4 : this.arate);

        this.materials[num3].mainTexture = texture.texture;
        this.meshRenderer.material       = this.materials[num3];
        if (this.spsActor != (UnityEngine.Object)null)
        {
            this.spsActor.spsPos = this.pos;
        }
    }
Exemple #4
0
    public override void HonoLateUpdate()
    {
        if (FF9StateSystem.Common.FF9.fldMapNo == 70)
        {
            return;
        }
        BGCAM_DEF currentBgCamera  = this._fieldMap.GetCurrentBgCamera();
        Matrix4x4 cam              = FF9StateSystem.Common.FF9.cam;
        UInt16    proj             = FF9StateSystem.Common.FF9.proj;
        Vector2   projectionOffset = FF9StateSystem.Common.FF9.projectionOffset;
        Vector3   position         = base.transform.position;

        this.projectedPos   = PSX.CalculateGTE_RTPT_POS(position, Matrix4x4.identity, cam, (Single)proj, projectionOffset, true);
        this.projectedDepth = this.projectedPos.z / 4f + (Single)FF9StateSystem.Field.FF9Field.loc.map.charOTOffset;
        this.charOTOffset   = FF9StateSystem.Field.FF9Field.loc.map.charOTOffset;
        if (this.projectedDepth < 100f || this.projectedDepth > 3996f)
        {
        }
        Single num  = PSX.CalculateGTE_RTPTZ(base.transform.position, Matrix4x4.identity, cam, (Single)proj, projectionOffset) * 1f;
        Single num2 = num / 4f + (Single)FF9StateSystem.Field.FF9Field.loc.map.charOTOffset;

        if (this.meshRenderer != null)
        {
            if (this.actor != null)
            {
                PosObj posObj = this.actor;
                if (num2 < 100f || num2 > 3996f)
                {
                    if (FF9StateSystem.Common.FF9.fldMapNo == 1413)
                    {
                        FieldMapActorController component = base.GetComponent <FieldMapActorController>();
                        if (component.originalActor.sid == 12)
                        {
                            posObj.frontCamera = true;
                        }
                        else
                        {
                            posObj.frontCamera = false;
                        }
                    }
                    else if (FF9StateSystem.Common.FF9.fldMapNo == 1414)
                    {
                        FieldMapActorController component2 = base.GetComponent <FieldMapActorController>();
                        if (component2.originalActor.sid == 16)
                        {
                            posObj.frontCamera = true;
                        }
                        else
                        {
                            posObj.frontCamera = false;
                        }
                    }
                    else if (FF9StateSystem.Common.FF9.fldMapNo != 2752 && FF9StateSystem.Common.FF9.fldMapNo != 1707)
                    {
                        posObj.frontCamera = false;
                    }
                    return;
                }
                posObj.frontCamera = true;
            }
            Renderer[] array = this.meshRenderer;
            for (Int32 i = 0; i < (Int32)array.Length; i++)
            {
                Renderer renderer = array[i];
                if (renderer.enabled)
                {
                    Single num3;
                    if (MBG.MarkCharacterDepth)
                    {
                        num3 = 8f;
                    }
                    else
                    {
                        num3 = num;
                    }
                    this.charPsxZ = num3;
                    this.charZ    = (Single)(((Int32)num3 / 4 + FF9StateSystem.Field.FF9Field.loc.map.charOTOffset) * 1);
                    this.charZ    = (Single)(-(Single)((Int32)this.charZ));
                    if (FF9StateSystem.Common.FF9.fldMapNo == 2510 && this.actor.uid == 8)
                    {
                        renderer.material.SetFloat("_CharZ", 20f);
                    }
                    if (FF9StateSystem.Common.FF9.fldMapNo == 2363 && this.actor.uid == 33)
                    {
                        renderer.material.SetFloat("_CharZ", 20f);
                    }
                }
            }
        }
        if (this.actor == null)
        {
            return;
        }
        FF9Shadow ff9Shadow = FF9StateSystem.Field.FF9Field.loc.map.shadowArray[(Int32)this.actor.uid];
        Vector3   zero      = Vector3.zero;

        if (FF9StateSystem.Common.FF9.fldMapNo == 661 && this.actor.uid == 3)
        {
            zero = new Vector3(-39f, -14f, 80f);
        }
        else if (FF9StateSystem.Common.FF9.fldMapNo == 1659 && this.actor.uid == 128)
        {
            zero = new Vector3(0f, -66f, 0f);
        }
        else if (FF9StateSystem.Common.FF9.fldMapNo == 1659 && this.actor.uid == 129)
        {
            zero = new Vector3(0f, -21f, 0f);
        }
        else if (FF9StateSystem.Common.FF9.fldMapNo == 2363 && (this.actor.uid == 16 || this.actor.uid == 15 || this.actor.uid == 32 || this.actor.uid == 33))
        {
            zero = new Vector3(0f, -15f, 0f);
        }
        Vector3 a = this.GetShadowCurrentPos();

        if ((FF9StateSystem.Common.FF9.fldMapNo == 2107 && this.actor.uid == 5) || (FF9StateSystem.Common.FF9.fldMapNo == 2102 && this.actor.uid == 4))
        {
            a   = base.transform.position;
            a.y = 0f;
        }
        this.shadowTran.localPosition = a + new Vector3(ff9Shadow.xOffset, this.shadowHeightOffset * 1f, ff9Shadow.zOffset) + zero;
        Single num4 = PSX.CalculateGTE_RTPTZ(this.shadowTran.position, Matrix4x4.identity, cam, (Single)proj, projectionOffset);

        num4          = (Single)(((Int32)num4 / 4 + FF9StateSystem.Field.FF9Field.loc.map.charOTOffset) * 1);
        num4          = (Single)(-(Single)((Int32)num4));
        this.shadowZ  = (Int32)num4;
        this.charAbsZ = base.transform.position.z;
    }