コード例 #1
0
        public void UpdateCamera(CameraProvider cp, IProjectionMatrixProvider proj)
        {
            _motionProvider.UpdateCamera(cp, proj);
            Vector3 la2cp  = cp.CameraPosition - cp.CameraLookAt;
            Vector3 la2cp2 = Vector3.TransformNormal(la2cp, Matrix.RotationQuaternion(_rotation));

            cp.CameraPosition = cp.CameraLookAt + la2cp2;
        }
コード例 #2
0
        void ICameraMotionProvider.UpdateCamera(CameraProvider cp1, IProjectionMatrixProvider proj)
        {
            Vector3 cp2la = Vector3.TransformCoordinate(new Vector3(0, 0, 1),
                                                        Matrix.RotationQuaternion(this.cameraPositionRotation));

            this.xAxis = Vector3.Cross(cp2la, cp1.CameraUpVec);
            this.xAxis.Normalize();
            this.yAxis = Vector3.Cross(this.xAxis, cp2la);
            this.yAxis.Normalize();
            cp1.CameraLookAt            += this.xAxis * this.cameraLookatTranslation.X + this.yAxis * this.cameraLookatTranslation.Y;
            cp1.CameraPosition           = cp1.CameraLookAt + this.distance * (-cp2la);
            this.cameraLookatTranslation = Vector2.Zero;
        }
コード例 #3
0
        public virtual void UpdateCamera(CameraProvider cp1, IProjectionMatrixProvider proj)
        {
            Vector3 cp2la = Vector3.TransformCoordinate(new Vector3(0, 0, 1),
                                                        Matrix.RotationQuaternion(cameraPositionRotation));

            xAxis = Vector3.Cross(cp2la, cp1.CameraUpVec);
            xAxis.Normalize();
            yAxis = Vector3.Cross(xAxis, cp2la);
            yAxis.Normalize();
            cp1.CameraLookAt              += xAxis * cameraLookatTranslation.X + yAxis * cameraLookatTranslation.Y;
            cp1.CameraLookAt              += cameraLookatTranslationOfWorld;
            cp1.CameraPosition             = cp1.CameraLookAt + distance * (-cp2la);
            cameraLookatTranslation        = Vector2.Zero;
            cameraLookatTranslationOfWorld = Vector3.Zero;
        }
コード例 #4
0
        public void UpdateCamera(CameraProvider cp, IProjectionMatrixProvider proj)
        {
            t += 0.01f;
            cp.CameraPosition = new Vector3(0, 0, (float)Math.Sin(t) * 50);//changing camera position trig functions according to t

            /*
             * 説明:
             * CameraProvider.CameraPositionがカメラの位置を指す
             * CameraProvider.CameraLookAtがカメラの注視点を指す
             * CameraProvider.CameraUpVecがカメラの上方向ベクトルを指す
             *
             * IProjectionMatrixProviderのプロパティは以下
             * ・ZNear 近クリップ距離
             * ・ZFar 遠クリップ距離
             * ・AspectRatio アスペクト比
             * ・Fovy 視野角
             */
        }
コード例 #5
0
        void ICameraMotionProvider.UpdateCamera(CameraProvider cp, IProjectionMatrixProvider proj)
        {
            //Ask the world coordinates of the bone matrix
            Matrix bonePoseMatrix = this.followBone.GlobalPose * Matrix.Scaling(this.followModel.Transformer.Scale) *
                                    Matrix.RotationQuaternion(this.followModel.Transformer.Rotation) *
                                    Matrix.Translation(this.followModel.Transformer.Position);
            Vector3 bonePosition = Vector3.TransformCoordinate(this.followBone.Position, bonePoseMatrix);
            Vector3 la2cp        = Vector3.TransformNormal(-this.ViewFrom, bonePoseMatrix);//Fixation and then head to camera location vector

            la2cp.Normalize();
            cp.CameraPosition = bonePosition + this.Distance * la2cp;
            cp.CameraLookAt   = bonePosition;
            if (this.IsRotationZAxis)
            {
                Vector3 newUp = Vector3.TransformNormal(new Vector3(0, 1, 0), bonePoseMatrix);
                newUp.Normalize();
                cp.CameraUpVec = newUp;
            }
        }
コード例 #6
0
        void ICameraMotionProvider.UpdateCamera(CameraProvider cp, IProjectionMatrixProvider proj)
        {
            //ボーンのワールド座標を求める行列を作成
            Matrix bonePoseMatrix = followBone.GlobalPose * Matrix.Scaling(followModel.Transformer.Scale) *
                                    Matrix.RotationQuaternion(followModel.Transformer.Rotation) *
                                    Matrix.Translation(followModel.Transformer.Position);
            Vector3 bonePosition = Vector3.TransformCoordinate(followBone.Position, bonePoseMatrix);
            Vector3 la2cp        = Vector3.TransformNormal(-ViewFrom, bonePoseMatrix);//注視点から、カメラの場所に向かうベクトル

            la2cp.Normalize();
            cp.CameraPosition = bonePosition + Distance * la2cp;
            cp.CameraLookAt   = bonePosition;
            if (IsRotationZAxis)
            {
                Vector3 newUp = Vector3.TransformNormal(new Vector3(0, 1, 0), bonePoseMatrix);
                newUp.Normalize();
                cp.CameraUpVec = newUp;
            }
        }
コード例 #7
0
        private void Leap(CameraProvider cp, IProjectionMatrixProvider projection, float frame)
        {
            if (CameraFrames.Count == 0)
            {
                return;
            }
            for (int j = 0; j < CameraFrames.Count - 1; j++)
            {
                if (CameraFrames[j].FrameNumber < frame && CameraFrames[j + 1].FrameNumber >= frame)
                {
                    //フレームが挟まれている時

                    uint  frameMargin = CameraFrames[j + 1].FrameNumber - CameraFrames[j].FrameNumber;
                    float progress    = (frame - CameraFrames[j].FrameNumber) / (float)frameMargin;
                    LeapFrame(CameraFrames[j], CameraFrames[j + 1], cp, projection, progress);
                    return;
                }
            }
            //returnされなかったとき(つまり最終フレーム以降のとき)
            LeapFrame(CameraFrames.Last(), CameraFrames.Last(), cp, projection, 0);
        }
コード例 #8
0
        private void Leap(CameraProvider cp, IProjectionMatrixProvider projection, float frame)
        {
            if (this.CameraFrames.Count == 0)
            {
                return;
            }
            for (int j = 0; j < this.CameraFrames.Count - 1; j++)
            {
                if (this.CameraFrames[j].FrameNumber < frame && this.CameraFrames[j + 1].FrameNumber >= frame)
                {
                    //When you have pinched frame

                    uint  frameMargin = this.CameraFrames[j + 1].FrameNumber - this.CameraFrames[j].FrameNumber;
                    float progress    = (frame - this.CameraFrames[j].FrameNumber) / (float)frameMargin;
                    LeapFrame(this.CameraFrames[j], this.CameraFrames[j + 1], cp, projection, progress);
                    return;
                }
            }
            //did not return when (or after the last frame)
            LeapFrame(this.CameraFrames.Last(), this.CameraFrames.Last(), cp, projection, 0);
        }
コード例 #9
0
 public void UpdateCamera(CameraProvider cp, IProjectionMatrixProvider proj)
 {
     if (lastMillisecound == 0)
     {
         lastMillisecound = stopWatch.ElapsedMilliseconds;
     }
     else
     {
         long currentMillisecound = stopWatch.ElapsedMilliseconds;
         long elapsed             = currentMillisecound - lastMillisecound;//前回とのフレームの差
         if (isPlaying)
         {
             currentFrame += elapsed / 30f;
         }
         if (needReplay && finalFrame < currentFrame)
         {
             currentFrame = 0;
         }
         lastMillisecound = currentMillisecound;
     }
     Leap(cp, proj, currentFrame);
 }
コード例 #10
0
 public void UpdateCamera(CameraProvider cp, IProjectionMatrixProvider proj)
 {
     if (this.lastMillisecound == 0)
     {
         this.lastMillisecound = this.stopWatch.ElapsedMilliseconds;
     }
     else
     {
         long currentMillisecound = this.stopWatch.ElapsedMilliseconds;
         long elapsed             = currentMillisecound - this.lastMillisecound;//Difference between the frame and the previous
         if (this.isPlaying)
         {
             this.currentFrame += elapsed / 30f;
         }
         if (this.needReplay && this.finalFrame < this.currentFrame)
         {
             this.currentFrame = 0;
         }
         this.lastMillisecound = currentMillisecound;
     }
     Leap(cp, proj, this.currentFrame);
 }
コード例 #11
0
        private void LeapFrame(CameraFrameData cf1, CameraFrameData cf2, CameraProvider cp, IProjectionMatrixProvider proj, float f)
        {
            float ProgX, ProgY, ProgZ, ProgR, ProgL, ProgP;;

            ProgX           = cf1.Curves[0].Evaluate(f);
            ProgY           = cf1.Curves[1].Evaluate(f);
            ProgZ           = cf1.Curves[2].Evaluate(f);
            ProgR           = cf1.Curves[3].Evaluate(f);
            ProgL           = cf1.Curves[4].Evaluate(f);
            ProgP           = cf1.Curves[5].Evaluate(f);
            cp.CameraLookAt = CGHelper.ComplementTranslate(cf1, cf2,
                                                           new Vector3(ProgX, ProgY, ProgZ));
            Quaternion rotation = CGHelper.ComplementRotateQuaternion(cf1, cf2,
                                                                      ProgR);
            float   length          = CGHelper.Lerp(cf1.Distance, cf2.Distance, ProgL);
            float   angle           = CGHelper.Lerp(cf1.ViewAngle, cf2.ViewAngle, ProgP);
            Vector3 Position2target = Vector3.TransformCoordinate(new Vector3(0, 0, 1),
                                                                  Matrix.RotationQuaternion(rotation));
            Vector3 TargetPosition = cp.CameraLookAt + length * Position2target;

            cp.CameraPosition = TargetPosition;
            proj.Fovy         = CGHelper.ToRadians(angle);
        }
コード例 #12
0
ファイル: MatrixManager.cs プロジェクト: kyasbal-1994/MMF
 public MatrixManager(IWorldMatrixProvider world, CameraProvider cam, IProjectionMatrixProvider projection)
 {
     worldMatrixManager      = world;
     viewMatrixManager       = cam;
     projectionMatrixManager = projection;
 }