Files
Yosuga_rk3566/3rdparty/Live2D/Src/LAppLive2D/Inc/LAppView.hpp
T
Misaki 7551a85abe first
2026-06-10 00:57:54 +08:00

171 lines
5.2 KiB
C++

/**
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
#pragma once
#include "LAppOpenGL.hpp"
#include <Math/CubismMatrix44.hpp>
#include <Math/CubismViewMatrix.hpp>
#include "CubismFramework.hpp"
#include <Rendering/OpenGL/CubismOffscreenSurface_OpenGLES2.hpp>
class TouchManager;
class LAppSprite;
class LAppModel;
/**
* @brief 描画クラス
*/
class LAppView
{
public:
/**
* @brief LAppModelのレンダリング先
*/
enum SelectTarget
{
SelectTarget_None, ///< デフォルトのフレームバッファにレンダリング
SelectTarget_ModelFrameBuffer, ///< LAppModelが各自持つフレームバッファにレンダリング
SelectTarget_ViewFrameBuffer, ///< LAppViewの持つフレームバッファにレンダリング
};
/**
* @brief コンストラクタ
*/
LAppView();
/**
* @brief デストラクタ
*/
~LAppView();
/**
* @brief 初期化する。
*/
void Initialize();
/**
* @brief 描画する。
*/
void Render();
/**
* @brief 画像の初期化を行う。
*/
void InitializeSprite();
/**
* @brief スプライト系のサイズ再設定
*/
void ResizeSprite();
/**
* @brief タッチされたときに呼ばれる。
*
* @param[in] pointX スクリーンX座標
* @param[in] pointY スクリーンY座標
*/
void OnTouchesBegan(float pointX, float pointY) const;
/**
* @brief タッチしているときにポインタが動いたら呼ばれる。
*
* @param[in] pointX スクリーンX座標
* @param[in] pointY スクリーンY座標
*/
void OnTouchesMoved(float pointX, float pointY) const;
/**
* @brief タッチが終了したら呼ばれる。
*
* @param[in] pointX スクリーンX座標
* @param[in] pointY スクリーンY座標
*/
void OnTouchesEnded(float pointX, float pointY) const;
/**
* @brief X座標をView座標に変換する。
*
* @param[in] deviceX デバイスX座標
*/
[[nodiscard]] float TransformViewX(float deviceX) const;
/**
* @brief Y座標をView座標に変換する。
*
* @param[in] deviceY デバイスY座標
*/
[[nodiscard]] float TransformViewY(float deviceY) const;
/**
* @brief X座標をScreen座標に変換する。
*
* @param[in] deviceX デバイスX座標
*/
[[nodiscard]] float TransformScreenX(float deviceX) const;
/**
* @brief Y座標をScreen座標に変換する。
*
* @param[in] deviceY デバイスY座標
*/
[[nodiscard]] float TransformScreenY(float deviceY) const;
/**
* @brief 检测坐标是否在模型上(跨平台穿透功能核心)
* @param deviceX 设备坐标X(鼠标位置)
* @param deviceY 设备坐标Y
* @return 是否击中模型
*/
[[nodiscard]] bool IsModelHit(float deviceX, float deviceY) const;
/**
* @brief モデル1体を描画する直前にコールされる
*/
void PreModelDraw(LAppModel& refModel);
/**
* @brief モデル1体を描画した直後にコールされる
*/
void PostModelDraw(LAppModel& refModel);
/**
* @brief 別レンダリングターゲットにモデルを描画するサンプルで
* 描画時のαを決定する
*/
[[nodiscard]] float GetSpriteAlpha(int assign) const;
/**
* @brief レンダリング先を切り替える
*/
void SwitchRenderingTarget(SelectTarget targetType);
/**
* @brief レンダリング先をデフォルト以外に切り替えた際の背景クリア色設定
* @param[in] r 赤(0.0~1.0)
* @param[in] g 緑(0.0~1.0)
* @param[in] b 青(0.0~1.0)
*/
void SetRenderTargetClearColor(float r, float g, float b);
private:
TouchManager* _touchManager; ///< タッチマネージャー
Csm::CubismMatrix44* _deviceToScreen; ///< デバイスからスクリーンへの行列
Csm::CubismViewMatrix* _viewMatrix; ///< viewMatrix
GLuint _programId; ///< シェーダID
//LAppSprite* _back; ///< 背景画像
//LAppSprite* _gear; ///< ギア画像
//LAppSprite* _power; ///< 電源画像
// レンダリング先を別ターゲットにする方式の場合に使用
LAppSprite* _renderSprite; ///< モードによっては_renderBufferのテクスチャを描画
Csm::Rendering::CubismOffscreenSurface_OpenGLES2 _renderBuffer; ///< モードによってはCubismモデル結果をこっちにレンダリング
SelectTarget _renderTarget; ///< レンダリング先の選択肢
float _clearColor[4]; ///< レンダリングターゲットのクリアカラー
};