Пример #1
0
 void Start()
 {
     currentLocation  = new CameraLocation(0f, 0f, -10f, 5f);
     previousLocation = currentLocation;
     instance         = this;
     GetComponent <Camera>().orthographicSize = 5;
 }
Пример #2
0
 void LoadPassage(int passage, CameraPos pos)
 {
     if (active != null) active.Cleanup();
     active = passages[passage];
     active.Initialize(cam);
     LoadCamera(pos);
 }
Пример #3
0
    void GoLerp()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("Move Camera: " + cameraPosState);

            lerpTime     = 0.0f;
            goCameraMove = true;
            if (cameraPosState == CameraPos.Near)
            {
                cameraPosState = CameraPos.Far;
            }
            else
            {
                cameraPosState = CameraPos.Near;
            }
        }

        if (goCameraMove)
        {
            lerpTime += Time.deltaTime;
            if (lerpTime > lerpStopTime)
            {
                lerpTime = lerpStopTime;
            }
        }
    }
Пример #4
0
 void LoadCamera(CameraPos pos)
 {
     switch(pos) {
         case CameraPos.BEDROOM:
             camPos.position = new Vector3(2, 15, -37);
             camPos.rotation = Quaternion.Euler(new Vector3(0, 0, 0));
             break;
         case CameraPos.HALLWAY:
             camPos.position = new Vector3(140, 25, 34);
             camPos.rotation = Quaternion.Euler(new Vector3(0, 0, 0));
             break;
         case CameraPos.LIVING_ROOM:
             camPos.position = new Vector3(110, 25, 440);
             camPos.rotation = Quaternion.Euler(new Vector3(0, 0, 0));
             break;
         case CameraPos.LIVING_ROOM_BATH:
             camPos.position = new Vector3(195, 25, 490);
             camPos.rotation = Quaternion.Euler(new Vector3(0, 270, 0));
             break;
         case CameraPos.LIVING_ROOM_KITCHEN:
             camPos.position = new Vector3(100, 25, 529);
             camPos.rotation = Quaternion.Euler(new Vector3(0, 180, 0));
             break;
         case CameraPos.KITCHEN:
             camPos.position = new Vector3(42, 25, 568);
             camPos.rotation = Quaternion.Euler(new Vector3(0, 0, 0));
             break;
         case CameraPos.BATHROOM:
             camPos.position = new Vector3(321, 22, 310);
             camPos.rotation = Quaternion.Euler(new Vector3(0, 90, 0));
             break;
     }
 }
Пример #5
0
 public virtual void Register(MonoBehaviour mb)
 {
     if (mainPos)
     {
         cameraPos = CameraPos.main;
     }
     cameraPos.RegisterEffect(this);
     disRegCorou = cameraPos.StartCoroutine(disregisterWhileDestroy(mb));
 }
Пример #6
0
    private void SetCameraListener(EventData data)
    {
        CameraPos next    = (CameraPos)data.Param;
        CameraPos current = BattleManager.Instance.GetCameraPos();

        if (next == current)
        {
            return;
        }
        BattleManager.Instance.SetCameraPos(next);
    }
    public void ChangeState(int direction)
    {
        if (!canRotate)
        {
            canRotate    = true;
            rotDirection = direction;
            // Right Rotation
            if (direction == -1)
            {
                switch (currentPos)
                {
                case CameraPos.LeftDown:
                    currentPos = CameraPos.RightDown;
                    break;

                case CameraPos.RightDown:
                    currentPos = CameraPos.RightUp;
                    break;

                case CameraPos.RightUp:
                    currentPos = CameraPos.LeftUp;
                    break;

                case CameraPos.LeftUp:
                    currentPos = CameraPos.LeftDown;
                    break;
                }
            }
            // Left Rotation
            else
            {
                switch (currentPos)
                {
                case CameraPos.LeftDown:
                    currentPos = CameraPos.LeftUp;
                    break;

                case CameraPos.LeftUp:
                    currentPos = CameraPos.RightUp;
                    break;

                case CameraPos.RightUp:
                    currentPos = CameraPos.RightDown;
                    break;

                case CameraPos.RightDown:
                    currentPos = CameraPos.LeftDown;
                    break;
                }
            }
        }
    }
Пример #8
0
    private void OnEnable()
    {
        oneSec = new WaitForSecondPair(TimeToWaitBetweenMove);

        firstCamera_gameobject = firstCamera.gameObject;
        secondCamera_gameoject = secondCamera.gameObject;
        camera_pos_original    = firstCamera_gameobject.transform.position;
        camera_pos_solution    = camera_transform_solution.position;

        secondCamera.transform.position = Camera.main.transform.position;
        secondCamera_gameoject.SetActive(false);
        currentPos = CameraPos.Left;
        tweening   = false;
    }
Пример #9
0
    // Start is called before the first frame update
    void Start()
    {
        //materials= new Material(shaders);
        //meshRenderer.material = materials;

        look          = GetComponent <LookForCamera>();
        look.RainFall = true;
        cameraPos     = Camera.main.gameObject.GetComponent <CameraPos>();
        //Ray ray = new Ray(transform.position, transform.TransformDirection(Vector3.down));
        //RaycastHit hit;
        //if (Physics.Raycast(ray, out hit, 200, layerMask))
        //{
        //    waterHi = hit.collider.gameObject.GetComponent<WaterHi>();
        //}
    }
Пример #10
0
 void ChangeCameraPos()
 {
     if (tweening)
     {
         return;
     }
     tweening = true;
     if (currentPos == CameraPos.Left)
     {
         secondCamera_gameoject.transform.DOMove(camera_pos_solution, timeToMove).OnComplete(() => { tweening = false; });
         currentPos = CameraPos.Right;
     }
     else
     {
         secondCamera_gameoject.transform.DOMove(camera_pos_original, timeToMove).OnComplete(() => { tweening = false; });;
         currentPos = CameraPos.Left;
     }
 }
Пример #11
0
    /// <summary>
    /// 设置相机位置
    /// </summary>
    /// <param name="pos"></param>
    public void SetCameraPos(CameraPos pos)
    {
        switch (pos)
        {
        case CameraPos.Mid:
            currentCameraPos = CameraPos.Mid;
            camera.transform.DOMove(new Vector3(0, 0, -5), 0.8f);
            break;

        case CameraPos.Left:
            currentCameraPos = CameraPos.Left;
            camera.transform.DOMove(new Vector3(CameraXMin, 0, -5), 0.8f);
            break;

        case CameraPos.Right:
            currentCameraPos = CameraPos.Right;
            camera.transform.DOMove(new Vector3(CameraXMax, 0, -5), 0.8f);
            break;
        }
    }
Пример #12
0
 public bool changeLocation(CameraLocation pos, CameraPos camera)
 {
     if (!pos.Equals(this))
     {
         frameCount++;
         double posDiff = frameCount / ZOOM_RATE;
         float  newX    = (float)(this.x - ((this.x - pos.x) * posDiff));
         float  newY    = (float)(this.y - ((this.y - pos.y) * posDiff));
         float  newZ    = (float)(this.z - ((this.z - pos.z) * posDiff));
         float  newSize = (float)(this.size - ((this.size - pos.size) * posDiff));
         camera.transform.position = new Vector3(newX, newY, newZ);
         camera.currentSize        = newSize;
         if (frameCount % ZOOM_RATE == 0)
         {
             frameCount = 0;
             return(true);
         }
     }
     return(false);
 }
Пример #13
0
    //// Use this for initialization
    //void Start () {

    //}

    //// Update is called once per frame
    //void Update () {

    //}

    public IEnumerator GoToPosition(CameraPos pos)
    {
        const float moveDur = 2f;
        Tween       t       = null;

        switch (pos)
        {
        case CameraPos.Left:
            t = transform.DOMoveX(leftPos, moveDur);
            break;

        case CameraPos.Center:
            t = transform.DOMoveX(centerPos, moveDur);
            break;

        case CameraPos.Right:
            t = transform.DOMoveX(rightPos, moveDur);
            break;
        }

        yield return(t.WaitForCompletion());
    }
Пример #14
0
    /// <summary>
    /// 相机移动函数
    /// </summary>
    private void CameraMoveTest()
    {
        if (playerId != 0)
        {
            return;//只对玩家主机1有效
        }
        CameraPos next = default;

        if (transform.localPosition.x <= BattleController.Instance.GetTriggerOne() &&
            BattleController.Instance.GetCurrentCameraPos() == CameraPos.Mid)
        {
            //左移
            next = CameraPos.Left;
            EventCenter.Instance.SendEvent(SGEventType.BattleCameraSet, new EventData(next, null));
        }
        else if (transform.localPosition.x >= BattleController.Instance.GetTriggerTwo() &&
                 BattleController.Instance.GetCurrentCameraPos() == CameraPos.Left)
        {
            //归中
            next = CameraPos.Mid;
            EventCenter.Instance.SendEvent(SGEventType.BattleCameraSet, new EventData(next, null));
        }
        else if (transform.localPosition.x >= BattleController.Instance.GetTriggerFour() &&
                 BattleController.Instance.GetCurrentCameraPos() == CameraPos.Mid)
        {
            //右移
            next = CameraPos.Right;
            EventCenter.Instance.SendEvent(SGEventType.BattleCameraSet, new EventData(next, null));
        }
        else if (transform.localPosition.x <= BattleController.Instance.GetTriggerThree() &&
                 BattleController.Instance.GetCurrentCameraPos() == CameraPos.Right)
        {
            //归中
            next = CameraPos.Mid;
            EventCenter.Instance.SendEvent(SGEventType.BattleCameraSet, new EventData(next, null));
        }
    }
Пример #15
0
 void Start()
 {
     currentPosition = CameraPos.UnderLeft;
 }
Пример #16
0
 void Start()
 {
     maincamVe3 = MainCamera.transform.localPosition;
     campos     = GetComponent <CameraPos>();
 }
 public void SetInitialPos()
 {
     currentPos         = CameraPos.LeftDown;
     transform.position = new Vector3(-1.0f * cameraDist, posY, 1.0f * cameraDist);
     transform.rotation = Quaternion.Euler(33.0f, 135.0f, 0.0f);
 }
Пример #18
0
 public CameraPosEffect(CameraPosEffect cpe)
 {
     cameraPos = cpe.cameraPos;
     mainPos   = cpe.mainPos;
     priority  = cpe.priority;
 }
Пример #19
0
 private void glControlView_Paint(object sender, PaintEventArgs e)
 {
     try
     {
         sortEntities();
         CurrentContext = ContextView;
         glControlView.MakeCurrent();
         GL.ClearBuffer(ClearBuffer.Color, 0, new float[] { 0.1f, 0.1f, 0.1f, 1f });
         GL.ClearBuffer(ClearBuffer.Depth, 0, new float[] { 1.0f });
         GL.Enable(EnableCap.DepthTest);
         if (renderLightingToolStripMenuItem.Checked)
         {
             s_shadow.Bind();
             for (int i = 0; i < Lights.Count; i++)
             {
                 for (int x = 0; x < Lights[i].InternalLights.Count; x++)
                 {
                     Lights[i].InternalLights[x].Attach();
                     Render3D(CurrentContext, false, false, true, false);
                     Lights[i].InternalLights[x].Complete();
                 }
             }
             SetViewport();
             s_fbo.Bind();
             Location CameraTarget = CameraPos + Utilities.ForwardVector_Deg(CameraYaw, CameraPitch);
             proj     = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(CameraFOV), (float)CurrentContext.Control.Width / (float)CurrentContext.Control.Height, CameraZNear, CameraZFar);
             view     = Matrix4.LookAt(CameraPos.ToOVector(), CameraTarget.ToOVector(), CameraUp.ToOVector());
             combined = view * proj;
             GL.UniformMatrix4(1, false, ref combined);
             GL.ActiveTexture(TextureUnit.Texture0);
             RS4P.Bind();
             Render3D(CurrentContext, true, false, true, true);
             RS4P.Unbind();
             GL.BindFramebuffer(FramebufferTarget.Framebuffer, fbo_main);
             GL.ClearBuffer(ClearBuffer.Color, 0, new float[] { 0.0f, 0.0f, 0.0f, 1.0f });
             GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
             GL.BindFramebuffer(FramebufferTarget.Framebuffer, fbo2_main);
             GL.ClearBuffer(ClearBuffer.Color, 0, new float[] { 0.0f, 0.0f, 0.0f, 1.0f });
             GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
             s_shadowadder.Bind();
             GL.ActiveTexture(TextureUnit.Texture1);
             GL.BindTexture(TextureTarget.Texture2D, RS4P.PositionTexture);
             GL.ActiveTexture(TextureUnit.Texture2);
             GL.BindTexture(TextureTarget.Texture2D, RS4P.NormalsTexture);
             GL.ActiveTexture(TextureUnit.Texture3);
             GL.BindTexture(TextureTarget.Texture2D, RS4P.DepthTexture);
             GL.ActiveTexture(TextureUnit.Texture5);
             GL.BindTexture(TextureTarget.Texture2D, RS4P.RenderhintTexture);
             GL.ActiveTexture(TextureUnit.Texture6);
             GL.BindTexture(TextureTarget.Texture2D, RS4P.DiffuseTexture);
             Matrix4 mat = Matrix4.CreateOrthographicOffCenter(-1, 1, -1, 1, -1, 1);
             GL.UniformMatrix4(1, false, ref mat);
             mat = Matrix4.Identity;
             GL.UniformMatrix4(2, false, ref mat);
             GL.Uniform3(10, CameraPos.ToOVector());
             bool first = true;
             GL.BindFramebuffer(FramebufferTarget.Framebuffer, first ? fbo_main : fbo2_main);
             GL.DrawBuffer(DrawBufferMode.ColorAttachment0);
             GL.Disable(EnableCap.CullFace);
             for (int i = 0; i < Lights.Count; i++)
             {
                 for (int x = 0; x < Lights[i].InternalLights.Count; x++)
                 {
                     GL.BindFramebuffer(FramebufferTarget.Framebuffer, first ? fbo_main : fbo2_main);
                     GL.ActiveTexture(TextureUnit.Texture0);
                     GL.BindTexture(TextureTarget.Texture2D, first ? fbo2_texture : fbo_texture);
                     GL.ActiveTexture(TextureUnit.Texture4);
                     GL.BindTexture(TextureTarget.Texture2D, Lights[i].InternalLights[x].fbo_depthtex);
                     Matrix4 smat = Lights[i].InternalLights[x].GetMatrix();
                     GL.UniformMatrix4(3, false, ref smat);
                     GL.Uniform3(4, ref Lights[i].InternalLights[x].eye);
                     GL.Uniform3(8, ref Lights[i].InternalLights[x].color);
                     GL.Uniform1(9, Lights[i].InternalLights[x].maxrange);
                     CurrentContext.Rendering.RenderRectangle(-1, -1, 1, 1);
                     first = !first;
                     GL.ActiveTexture(TextureUnit.Texture0);
                     GL.BindTexture(TextureTarget.Texture2D, 0);
                 }
             }
             GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
             GL.DrawBuffer(DrawBufferMode.Back);
             s_main.Bind();
             GL.Uniform3(5, ambient.ToOVector());
             GL.ActiveTexture(TextureUnit.Texture4);
             GL.BindTexture(TextureTarget.Texture2D, first ? fbo2_texture : fbo_texture);
             GL.ActiveTexture(TextureUnit.Texture0);
             GL.BindTexture(TextureTarget.Texture2D, RS4P.DiffuseTexture);
             mat = Matrix4.CreateOrthographicOffCenter(-1, 1, -1, 1, -1, 1);
             GL.UniformMatrix4(1, false, ref mat);
             mat = Matrix4.Identity;
             GL.UniformMatrix4(2, false, ref mat);
             CurrentContext.Rendering.RenderRectangle(-1, -1, 1, 1);
             GL.ActiveTexture(TextureUnit.Texture6);
             GL.BindTexture(TextureTarget.Texture2D, 0);
             GL.ActiveTexture(TextureUnit.Texture5);
             GL.BindTexture(TextureTarget.Texture2D, 0);
             GL.ActiveTexture(TextureUnit.Texture4);
             GL.BindTexture(TextureTarget.Texture2D, 0);
             GL.ActiveTexture(TextureUnit.Texture3);
             GL.BindTexture(TextureTarget.Texture2D, 0);
             GL.ActiveTexture(TextureUnit.Texture2);
             GL.BindTexture(TextureTarget.Texture2D, 0);
             GL.ActiveTexture(TextureUnit.Texture1);
             GL.BindTexture(TextureTarget.Texture2D, 0);
             GL.ActiveTexture(TextureUnit.Texture0);
             GL.BindTexture(TextureTarget.Texture2D, 0);
             s_transponly.Bind();
             GL.UniformMatrix4(1, false, ref combined);
             GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, RS4P.fbo);
             GL.BlitFramebuffer(0, 0, glControlView.Width, glControlView.Height, 0, 0, glControlView.Width, glControlView.Height, ClearBufferMask.DepthBufferBit, BlitFramebufferFilter.Nearest);
             GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, 0);
             Render3D(CurrentContext, false, false, true, false);
             CurrentContext.Shaders.ColorMultShader.Bind();
             GL.UniformMatrix4(1, false, ref combined);
             GL.Enable(EnableCap.CullFace);
             if (wireframe)
             {
                 renderWires(CurrentContext);
             }
             renderSelections(CurrentContext, true);
         }
         else
         {
             CurrentContext.Shaders.ColorMultShader.Bind();
             Location CameraTarget = CameraPos + Utilities.ForwardVector_Deg(CameraYaw, CameraPitch);
             proj     = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(CameraFOV), (float)CurrentContext.Control.Width / (float)CurrentContext.Control.Height, CameraZNear, CameraZFar);
             view     = Matrix4.LookAt(CameraPos.ToOVector(), CameraTarget.ToOVector(), CameraUp.ToOVector());
             combined = view * proj;
             GL.UniformMatrix4(1, false, ref combined);
             Render3D(CurrentContext, true, false, true, false);
             if (wireframe)
             {
                 renderWires(CurrentContext);
             }
             renderSelections(CurrentContext, true);
         }
         GL.Disable(EnableCap.DepthTest);
         CurrentContext.Shaders.ColorMultShader.Bind();
         ortho = Matrix4.CreateOrthographicOffCenter(0, CurrentContext.Control.Width, CurrentContext.Control.Height, 0, -1, 1);
         CurrentContext.FontSets.SlightlyBigger.DrawColoredText("^S^" + (glControlView.Focused ? "@" : "!") + "^e^7" + CameraYaw + "/" + CameraPitch + " at " + CameraPos.ToString(), new Location(0, 0, 0));
         glControlView.SwapBuffers();
     }
     catch (Exception ex)
     {
         SysConsole.Output(OutputType.ERROR, "PaintView: " + ex.ToString());
     }
 }
Пример #20
0
    /// <summary>
    /// 指示された方向にカメラを動かす
    /// </summary>
    /// <param name="direction">指示する方向</param>
    void Move(Direction direction)
    {
        if (isMoving)
        {
            return;             //カメラ移動中は無視する
        }
        switch (direction)
        {
        case Direction.Right:
            //transform.position += new Vector3(8, 0, 0);
            StartCoroutine(Scroll(new Vector3(8, 0, 0))); Debug.Log("Right");
            if (currentPosition == CameraPos.UnderLeft)
            {
                currentPosition = CameraPos.UnderRight;
            }
            else
            {
                currentPosition = CameraPos.UpperRight;
            }
            break;

        case Direction.Up:
            //transform.position += new Vector3(0, 8, 0);
            StartCoroutine(Scroll(new Vector3(0, 8, 0))); Debug.Log("Up");

            if (currentPosition == CameraPos.UnderLeft)
            {
                currentPosition = CameraPos.UpperLeft;
            }
            else
            {
                currentPosition = CameraPos.UpperRight;
            }
            break;

        case Direction.Left:
            //transform.position += new Vector3(-8, 0, 0);
            StartCoroutine(Scroll(new Vector3(-8, 0, 0))); Debug.Log("Left");
            if (currentPosition == CameraPos.UnderRight)
            {
                currentPosition = CameraPos.UnderLeft;
            }
            else
            {
                currentPosition = CameraPos.UpperLeft;
            }
            break;

        case Direction.Down:
            //transform.position += new Vector3(0, -8, 0);
            StartCoroutine(Scroll(new Vector3(0, -8, 0))); Debug.Log("Down");
            if (currentPosition == CameraPos.UpperLeft)
            {
                currentPosition = CameraPos.UnderLeft;
            }
            else
            {
                currentPosition = CameraPos.UnderRight;
            }
            break;

        default:
            break;
        }
    }