24 kDefaultCameraFrontVec{
Vector3::GetFrontVec() },
25 kDefaultCameraUpVec{
Vector3::GetUpVec() },
26 camera_view_mode_(enums::CameraViewMode::kTopView),
27 free_controlled_target_pos_{},
37 now_camera_state_.camera_quat =
47 now_camera_state_.length_camera_to_target,
48 goal_camera_state_.length_camera_to_target,
53 now_camera_state_.camera_quat,
54 goal_camera_state_.camera_quat,
57 now_camera_state_.camera_quat = now_camera_state_.camera_quat.GetNormalized();
64 now_camera_state_.target_pos,
65 goal_camera_state_.target_pos,
71 now_camera_state_.target_pos,
72 free_controlled_target_pos_,
82 printfDx(
"cameraの姿勢(クォータニオン) w = %f, v= { %f, %f, %f }\n",
83 now_camera_state_.camera_quat.w,
84 now_camera_state_.camera_quat.v.x,
85 now_camera_state_.camera_quat.v.y,
86 now_camera_state_.camera_quat.v.z);
88 printfDx(
"cameraの注視点 x = %f, y = %f, z = %f\n",
89 now_camera_state_.target_pos.x,
90 now_camera_state_.target_pos.y,
91 now_camera_state_.target_pos.z);
93 printfDx(
"cameraの距離 %f\n", now_camera_state_.length_camera_to_target);
100 camera_view_mode_ = mode;
107 goal_camera_state_.camera_quat =
114 goal_camera_state_.camera_quat =
127 goal_camera_state_.camera_quat = quat1 * quat2;
134 goal_camera_state_.camera_quat =
141 goal_camera_state_.camera_quat =
153 free_controlled_target_pos_ = goal_camera_state_.target_pos;
167 goal_camera_state_.length_camera_to_target = kDefaultCameraZoom;
173 goal_camera_state_.length_camera_to_target += length_dif;
189void DxlibCamera::SetCameraPosAndRot()
195 RotateVector3(kDefaultCameraFrontVec, now_camera_state_.camera_quat) *
196 now_camera_state_.length_camera_to_target;
201 VECTOR camera_upvec =
203 RotateVector3(kDefaultCameraUpVec, now_camera_state_.camera_quat));
205 SetCameraPositionAndTargetAndUpVec(
213 -
RotateVector3(kDefaultCameraFrontVec, now_camera_state_.camera_quat));
215 ChangeLightTypeDir(light_dir);
void AddCameraToTargetLength(float length_dif)
カメラの注視する目標の座標からカメラまでの距離を増やす.
void InitCameraTargetLength()
カメラと注視点との距離を初期化する.
void Update()
カメラの位置などの更新を行う.毎フレーム実行すること.
void SetCameraViewMode(enums::CameraViewMode mode)
カメラのモードをセットする.同時にカメラの目標回転角度などを設定する.
static const float kCameraToTargetMax
カメラと注視目標の最大距離.
static const float kCameraToTargetMin
カメラと注視目標の最小距離.
VECTOR ConvertToDxlibVec(const Vector3 &vec)
Dxlibの座標を示すVECTORと,このプログラムで使用しているVectorを変換する. ロボット座標系は右手座標系, Dxlibは左手座標系(工学は右手・ゲームライブラリは左手が多い)なのでyを...
CameraViewMode
カメラの視点を表す列挙体.
@ kFreeControlledAndMovableTarget
自由に操作可能かつ注視点を設定可能.
@ kRightSideView
右から真横の視点.
@ kFreeControlled
自由に操作可能.
T ApproachTarget(const T ¤t, const T &target, float rate)
目標値に値を近づける関数. 描画用なので,線形でなく,適当に値を近づける. そのため,計算に使いたいなら作り直すこと.
constexpr T ConvertDegToRad(const T deg) noexcept
角度を [deg] から [rad] に変換する関数.
Vector3 RotateVector3(const Vector3 &vec, const EulerXYZ &rot)
回転させたベクトルを返す.三角関数の処理が多く重たいので注意.
Quaternion SlerpQuaternion(const Quaternion &q1, const Quaternion &q2, const float t)
球面線形補間を行う.
static Quaternion MakeByAngleAxis(float rad_angle, const Vector3 &axis)
回転軸と回転角からクォータニオンを作成する. q = cos(θ/2) * w + sin(θ/2) * { v.x + v.y + v.z } となる. ノルムは必ず1になる.
static constexpr Vector3 GetUpVec() noexcept
上に進む単位ベクトルを返す. 静的な関数なので,Vector3::GetUpVec() と呼び出せる.
static constexpr Vector3 GetFrontVec() noexcept
正面に進む単位ベクトルを返す. 静的な関数なので,Vector3::GetFrontVec() と呼び出せる.
static constexpr Vector3 GetLeftVec() noexcept
左に進む単位ベクトルを返す. 静的な関数なので,Vector3::GetLeftVec() と呼び出せる.