Example #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);
    }
Example #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);
        }
    }
Example #3
0
    private static Matrix4x4 PsxProj2UnityProj(Single psxGeomScreen, Single clipDistance)
    {
        Single halfScreenWidth  = FieldMap.HalfScreenWidth;
        Single halfScreenHeight = FieldMap.HalfScreenHeight;
        Single far = psxGeomScreen + clipDistance;

        return(PSX.PerspectiveOffCenter(-halfScreenWidth, halfScreenWidth, halfScreenHeight, -halfScreenHeight, psxGeomScreen, far));
    }
Example #4
0
    private void SetQuad(BGSCENE_DEF scene, Int32 camIdx, Vector2 offset)
    {
        Color[] array = new Color[]
        {
            Color.cyan,
            Color.blue,
            Color.green,
            Color.yellow,
            Color.red,
            Color.white,
            Color.black,
            Color.grey
        };
        BGCAM_DEF bgcam_DEF = scene.cameraList[camIdx];

        Int32[] array2 = new Int32[]
        {
            2222,
            -5555,
            -2222,
            -5555,
            -2222,
            -4080,
            2222,
            -4080
        };
        Int32[] quad = this.fieldMapData[this.currentQuad].quad;
        String  str  = String.Empty;

        for (Int32 i = 0; i < (Int32)quad.Length; i++)
        {
            str = str + ", " + quad[i].ToString();
        }
        Vector3[] array3 = new Vector3[(Int32)quad.Length / 2];
        for (Int32 j = 0; j < (Int32)array3.Length; j++)
        {
            array3[j] = new Vector3((Single)quad[j * 2], 0f, (Single)quad[j * 2 + 1]);
            array3[j] = PSX.CalculateGTE_RTPT(array3[j], Matrix4x4.identity, bgcam_DEF.GetMatrixRT(), bgcam_DEF.GetViewDistance(), offset);
            Color   color = array[j];
            Single  num   = 5f;
            Vector3 b     = new Vector3(0f, 0f, (Single)scene.curZ);
            global::Debug.DrawLine(array3[j] + new Vector3(-num, -num, 0f) + b, array3[j] + new Vector3(num, num, 0f) + b, color, 0f, true);
            global::Debug.DrawLine(array3[j] + new Vector3(-num, num, 0f) + b, array3[j] + new Vector3(num, -num, 0f) + b, color, 0f, true);
        }
        for (Int32 k = 0; k < (Int32)array3.Length; k++)
        {
            Int32  num2 = (Int32)array3.Length - 1;
            Int32  num3 = (Int32)((k - 1 >= 0) ? (k - 1) : num2);
            Int32  num4 = (Int32)((k + 1 <= num2) ? (k + 1) : 0);
            Single num5 = Vector3.Angle(array3[k] - array3[num3], array3[k] - array3[num4]);
        }
        for (Int32 l = 0; l < (Int32)array3.Length - 1; l++)
        {
            global::Debug.DrawLine(array3[l], array3[l + 1], Color.cyan, 0f, true);
            global::Debug.DrawLine(array3[0], array3[l + 1], Color.cyan, 0f, true);
        }
    }
Example #5
0
 public Color32[] CreateBufferColor32()
 {
     Color32[] array = new Color32[this.pixelCount];
     for (UInt32 num = 0u; num < this.pixelCount; num += 1u)
     {
         UInt32 num2 = num * 2u;
         UInt16 raw  = (UInt16)((Int32)this.rawData[(Int32)((UIntPtr)num2)] | (Int32)this.rawData[(Int32)((UIntPtr)(num2 + 1u))] << 8);
         PSX.ConvertColor16toARGB(raw, out array[(Int32)((UIntPtr)num)].a, out array[(Int32)((UIntPtr)num)].r, out array[(Int32)((UIntPtr)num)].g, out array[(Int32)((UIntPtr)num)].b);
     }
     return(array);
 }
Example #6
0
    public static void World2Screen(Vector3 v, out Single x, out Single y)
    {
        FieldMap  fieldmap        = PersistenSingleton <EventEngine> .Instance.fieldmap;
        Camera    mainCamera      = fieldmap.GetMainCamera();
        BGCAM_DEF currentBgCamera = fieldmap.GetCurrentBgCamera();
        Vector3   vector          = PSX.CalculateGTE_RTPT(v, Matrix4x4.identity, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), fieldmap.GetProjectionOffset());
        Vector2   cameraOffset    = fieldmap.GetCameraOffset();
        Single    num             = vector.x - cameraOffset.x;
        Single    num2            = vector.y - cameraOffset.y;

        ETb.ConvertGTEToUIScreenPosition(ref num, ref num2);
        x = num;
        y = num2;
    }
Example #7
0
    public Matrix4x4 PsxMatrix2UnityMatrix(Int16[,] rotation)
    {
        Matrix4x4 identity = Matrix4x4.identity;

        identity.m00 = PSX.Fp12ToFloat(rotation[0, 0]);
        identity.m01 = PSX.Fp12ToFloat(rotation[0, 1]);
        identity.m02 = PSX.Fp12ToFloat(rotation[0, 2]);
        identity.m10 = PSX.Fp12ToFloat(rotation[1, 0]);
        identity.m11 = PSX.Fp12ToFloat(rotation[1, 1]);
        identity.m12 = PSX.Fp12ToFloat(rotation[1, 2]);
        identity.m20 = PSX.Fp12ToFloat(rotation[2, 0]);
        identity.m21 = PSX.Fp12ToFloat(rotation[2, 1]);
        identity.m22 = PSX.Fp12ToFloat(rotation[2, 2]);
        return(identity);
    }
        public void OnGUI()
        {
            try
            {
                if (_obj == null)
                {
                    return;
                }

                if (_controler == null)
                {
                    _controler = FindObjectOfType <FieldMapActorController>();
                    if (_controler == null)
                    {
                        return;
                    }
                }

                Vector3 a = _obj.transform.position;

                Camera    mainCamera      = _controler.fieldMap.GetMainCamera();
                BGCAM_DEF currentBgCamera = _controler.fieldMap.GetCurrentBgCamera();
                Vector3   position        = PSX.CalculateGTE_RTPT(a + new Vector3(0f, 0, 0f), Matrix4x4.identity, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), _controler.fieldMap.GetProjectionOffset());
                position   = mainCamera.WorldToScreenPoint(position);
                position.y = (Single)Screen.height - position.y;
                Int32 targetMarkSize = 40;
                Rect  position2      = new Rect(position.x - targetMarkSize / 2f, position.y - targetMarkSize, targetMarkSize, targetMarkSize);
                GUI.Label(position2, _obj.name);

                Component[] components = _obj.GetComponents <Component>();
                Log.Message(_obj.name);
                foreach (Component cmp in components)
                {
                    Log.Message(cmp.name + '_' + cmp.GetType());
                }
                for (Int32 i = 0; i < _obj.transform.childCount; i++)
                {
                    GameObject child = _obj.GetChild(i);
                    Log.Message("child: " + child.name);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
Example #9
0
    public static void UnityMatrix2PsxMatrix(Matrix4x4 unityWorldToCameraMatrix, Int16[,] psxRotation, Int32[] psxTranslation)
    {
        Matrix4x4 matrix4x = unityWorldToCameraMatrix;

        psxRotation[0, 0] = PSX.FloatToFp12(matrix4x.m00);
        psxRotation[0, 1] = PSX.FloatToFp12(-matrix4x.m01);
        psxRotation[0, 2] = PSX.FloatToFp12(matrix4x.m02);
        psxRotation[1, 0] = PSX.FloatToFp12(-matrix4x.m10);
        psxRotation[1, 1] = PSX.FloatToFp12(matrix4x.m11);
        psxRotation[1, 2] = PSX.FloatToFp12(-matrix4x.m12);
        psxRotation[2, 0] = PSX.FloatToFp12(-matrix4x.m20);
        psxRotation[2, 1] = PSX.FloatToFp12(matrix4x.m21);
        psxRotation[2, 2] = PSX.FloatToFp12(-matrix4x.m22);
        psxTranslation[0] = (Int32)matrix4x.m03;
        psxTranslation[1] = -(Int32)matrix4x.m13;
        psxTranslation[2] = -(Int32)matrix4x.m23;
    }
Example #10
0
    private void Update()
    {
        try
        {
            if (!_eventObject.IsEnabled())
            {
                _position = Vector3.zero;
                return;
            }

            if (_actorControler == null)
            {
                _actorControler = gameObject.GetComponent <FieldMapActorController>();
                if (_actorControler == null)
                {
                    return;
                }

                if (!_actorControler.IsActive())
                {
                    return;
                }
            }

            Camera    mainCamera      = _actorControler.fieldMap.GetMainCamera();
            BGCAM_DEF currentBgCamera = _actorControler.fieldMap.GetCurrentBgCamera();

            Vector3 position = PSX.CalculateGTE_RTPT(
                this.gameObject.transform.position,
                Matrix4x4.identity,
                currentBgCamera.GetMatrixRT(),
                currentBgCamera.GetViewDistance(),
                _actorControler.fieldMap.GetProjectionOffset());

            position   = mainCamera.WorldToScreenPoint(position);
            position.y = Screen.height - position.y;

            _position = position;
        }
        catch (Exception ex)
        {
            Log.Error(ex, "Failed to update {0}", this);
            _position = Vector3.zero;
        }
    }
Example #11
0
 private void FollowTarget()
 {
     if (this.lastPosition != this.target.position || this.updateEveryFrame)
     {
         this.lastPosition = this.target.position;
         Camera    mainCamera      = this.fieldMap.GetMainCamera();
         BGCAM_DEF currentBgCamera = this.fieldMap.GetCurrentBgCamera();
         Vector2   cameraOffset    = this.fieldMap.GetCameraOffset();
         Vector3   position        = PSX.CalculateGTE_RTPT(this.lastPosition + this.transformOffset, Matrix4x4.identity, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), this.fieldMap.GetProjectionOffset());
         position.x -= cameraOffset.x;
         position.y -= cameraOffset.y;
         position.x *= UIManager.ResourceXMultipier;
         position.y *= UIManager.ResourceYMultipier;
         position.z  = 0f;
         this.selfPosition.position       = this.uiCam.transform.parent.TransformPoint(position);
         this.selfPosition.localPosition  = new Vector3(this.selfPosition.localPosition.x, this.selfPosition.localPosition.y, 0f);
         this.selfPosition.localPosition += this.uiOffset;
     }
 }
Example #12
0
    // Token: 0x060014D9 RID: 5337 RVA: 0x00150974 File Offset: 0x0014EB74
    public static void SetCenterPosition(int type)
    {
        if (type != 0)
        {
            if (type != 1)
            {
                SFX_Rush.px = 0.5f;
                SFX_Rush.py = 0.5f;
            }
            else if (ff9.w_moveActorPtr != null)
            {
                Vector3 pos = ff9.w_moveActorPtr.pos;
                Camera  w_frameCameraPtr = ff9.w_frameCameraPtr;
                Vector3 vector           = w_frameCameraPtr.WorldToScreenPoint(pos);
                vector.x   /= (float)w_frameCameraPtr.pixelWidth;
                vector.y   /= (float)w_frameCameraPtr.pixelHeight;
                SFX_Rush.px = vector.x;
                SFX_Rush.py = vector.y;
                global::Debug.Log(string.Concat(new object[]
                {
                    "px : ",
                    SFX_Rush.px,
                    " , py : ",
                    SFX_Rush.py
                }));
            }
            else
            {
                SFX_Rush.px = 0.5f;
                SFX_Rush.py = 0.5f;
            }
        }
        else
        {
            Obj objUID = PersistenSingleton <EventEngine> .Instance.GetObjUID(250);

            if (objUID != null && objUID.cid == 4)
            {
                PosObj    posObj          = (PosObj)objUID;
                FieldMap  fieldmap        = PersistenSingleton <EventEngine> .Instance.fieldmap;
                Camera    mainCamera      = fieldmap.GetMainCamera();
                BGCAM_DEF currentBgCamera = fieldmap.GetCurrentBgCamera();
                Vector3   vertex          = new Vector3(posObj.pos[0], posObj.pos[1], posObj.pos[2]);
                Vector3   position        = PSX.CalculateGTE_RTPT(vertex, Matrix4x4.identity, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), fieldmap.GetProjectionOffset());
                position    = mainCamera.WorldToScreenPoint(position);
                position.x /= (float)mainCamera.pixelWidth;
                position.y /= (float)mainCamera.pixelHeight;
                SFX_Rush.px = position.x;
                SFX_Rush.py = position.y;
                global::Debug.Log(string.Concat(new object[]
                {
                    "px : ",
                    SFX_Rush.px,
                    " , py : ",
                    SFX_Rush.py
                }));
            }
            else
            {
                SFX_Rush.px = 0.5f;
                SFX_Rush.py = 0.5f;
            }
        }
    }
Example #13
0
 public Color32[] CreateBufferColor32(Int32 tp, Int32 tx, Int32 ty, Int32 u, Int32 v, Int32 w, Int32 h, Int32 clutX, Int32 clutY, Boolean enableSemiTransparent, Int32 abr)
 {
     Color32[] array = new Color32[w * h];
     ty    = PSXGPU.GetPixelCoorTY(ty);
     tx    = PSXGPU.GetPixelCoorTX(tx);
     clutY = PSXGPU.GetPixelCoorClutY(clutY);
     clutX = PSXGPU.GetPixelCoorClutX(clutX);
     if (tp == 0)
     {
         Int32 num = w / 4;
         if (w % 4 != 0)
         {
             num++;
         }
         for (Int32 i = 0; i < h; i++)
         {
             Int32 num2 = 0;
             for (Int32 j = 0; j < num; j++)
             {
                 Int32  num3       = tx + u / 4 + j;
                 Int32  num4       = ty + v + i;
                 Int32  pixelIndex = num3 + num4 * 1024;
                 UInt16 pixel      = this.GetPixel(pixelIndex);
                 Int32  num5       = j * 4 + i * w;
                 if (num2 == w)
                 {
                     break;
                 }
                 Int32 dataFromBit = (Int32)this.GetDataFromBit((UInt32)pixel, 0, 3);
                 array[num5] = PSX.ConvertABGR16toABGR32(this.GetPixel(clutX + clutY * 1024 + dataFromBit), enableSemiTransparent, abr);
                 num2++;
                 num5++;
                 if (num2 == w)
                 {
                     break;
                 }
                 dataFromBit = (Int32)this.GetDataFromBit((UInt32)pixel, 4, 7);
                 array[num5] = PSX.ConvertABGR16toABGR32(this.GetPixel(clutX + clutY * 1024 + dataFromBit), enableSemiTransparent, abr);
                 num2++;
                 num5++;
                 if (num2 == w)
                 {
                     break;
                 }
                 dataFromBit = (Int32)this.GetDataFromBit((UInt32)pixel, 8, 11);
                 array[num5] = PSX.ConvertABGR16toABGR32(this.GetPixel(clutX + clutY * 1024 + dataFromBit), enableSemiTransparent, abr);
                 num2++;
                 num5++;
                 if (num2 == w)
                 {
                     break;
                 }
                 dataFromBit = (Int32)this.GetDataFromBit((UInt32)pixel, 12, 15);
                 array[num5] = PSX.ConvertABGR16toABGR32(this.GetPixel(clutX + clutY * 1024 + dataFromBit), enableSemiTransparent, abr);
                 num2++;
             }
         }
     }
     else if (tp == 1)
     {
         Int32 num6 = w / 2;
         if (w % 2 != 0)
         {
             num6++;
         }
         for (Int32 k = 0; k < h; k++)
         {
             Int32 num7 = 0;
             for (Int32 l = 0; l < num6; l++)
             {
                 Int32  num8        = tx + u / 2 + l;
                 Int32  num9        = ty + v + k;
                 Int32  pixelIndex2 = num8 + num9 * 1024;
                 UInt16 pixel2      = this.GetPixel(pixelIndex2);
                 Int32  num10       = l * 2 + k * w;
                 if (num7 == w)
                 {
                     break;
                 }
                 Int32 dataFromBit2 = (Int32)this.GetDataFromBit((UInt32)pixel2, 0, 7);
                 array[num10] = PSX.ConvertABGR16toABGR32(this.GetPixel(clutX + clutY * 1024 + dataFromBit2), enableSemiTransparent, abr);
                 num7++;
                 num10++;
                 if (num7 == w)
                 {
                     break;
                 }
                 dataFromBit2 = (Int32)this.GetDataFromBit((UInt32)pixel2, 8, 15);
                 array[num10] = PSX.ConvertABGR16toABGR32(this.GetPixel(clutX + clutY * 1024 + dataFromBit2), enableSemiTransparent, abr);
                 num7++;
             }
         }
     }
     else if (tp == 2)
     {
         for (Int32 m = 0; m < h; m++)
         {
             for (Int32 n = 0; n < w; n++)
             {
                 Int32 num11       = tx + u + n;
                 Int32 num12       = ty + v + m;
                 Int32 pixelIndex3 = num11 + num12 * 1024;
                 Int32 num13       = n + m * w;
                 array[num13] = PSX.ConvertABGR16toABGR32(this.GetPixel(pixelIndex3), enableSemiTransparent, abr);
             }
         }
     }
     return(array);
 }
Example #14
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;
        }
    }
Example #15
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;
    }
Example #16
0
 public static Single Fp12ToFloat(Int32 fp)
 {
     return(PSX.Fp12ToFloat((Int16)(fp & 65535)));
 }
Example #17
0
 public static void ConvertCameraPsx2Unity(Camera unityCam, Matrix4x4 psxRot, Vector3 psxTrans, Single psxGeomScreen, Single clipDistance)
 {
     unityCam.worldToCameraMatrix = PSX.PsxRotTrans2UnityModelView(psxRot, psxTrans) * unityCam.transform.worldToLocalMatrix;
     unityCam.projectionMatrix    = PSX.PsxProj2UnityProj(psxGeomScreen, clipDistance);
 }
Example #18
0
 public static Int16 AngleDegreeToFp12(Single f)
 {
     return(PSX.FloatToFp12(f / 360f));
 }
Example #19
0
 public static Single AngleFp12ToDegree(Int16 fp)
 {
     return(PSX.Fp12ToFloat(fp) * 360f);
 }