예제 #1
0
파일: GenQuad.cs 프로젝트: ArtReeX/memoria
    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);
        }
    }
예제 #2
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;
    }
        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);
            }
        }
예제 #4
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;
        }
    }
예제 #5
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;
     }
 }
예제 #6
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;
            }
        }
    }
예제 #7
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;
        }
    }