This commit is contained in:
2026-06-14 15:54:35 +08:00
commit 3caeb07e54
2804 changed files with 373231 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
target_sources(${LIB_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CubismMoc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CubismMoc.hpp
${CMAKE_CURRENT_SOURCE_DIR}/CubismModel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CubismModel.hpp
${CMAKE_CURRENT_SOURCE_DIR}/CubismModelUserData.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CubismModelUserData.hpp
${CMAKE_CURRENT_SOURCE_DIR}/CubismModelUserDataJson.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CubismModelUserDataJson.hpp
${CMAKE_CURRENT_SOURCE_DIR}/CubismUserModel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CubismUserModel.hpp
)
+117
View File
@@ -0,0 +1,117 @@
/**
* 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.
*/
#include "CubismMoc.hpp"
#include "CubismModel.hpp"
namespace Live2D { namespace Cubism { namespace Framework {
CubismMoc* CubismMoc::Create(const csmByte* mocBytes, csmSizeInt size, csmBool shouldCheckMocConsistency)
{
CubismMoc* cubismMoc = NULL;
void* alignedBuffer = CSM_MALLOC_ALLIGNED(size, Core::csmAlignofMoc);
memcpy(alignedBuffer, mocBytes, size);
if (shouldCheckMocConsistency)
{
// .moc3の整合性を確認
csmBool consistency = HasMocConsistency(alignedBuffer, size);
if (!consistency)
{
CSM_FREE_ALLIGNED(alignedBuffer);
// 整合性が確認できなければ処理しない
CubismLogError("Inconsistent MOC3.");
return cubismMoc;
}
}
Core::csmMoc* moc = Core::csmReviveMocInPlace(alignedBuffer, size);
const Core::csmMocVersion version = Core::csmGetMocVersion(alignedBuffer, size);
if (moc)
{
cubismMoc = CSM_NEW CubismMoc(moc);
cubismMoc->_mocVersion = version;
}
return cubismMoc;
}
void CubismMoc::Delete(CubismMoc* moc)
{
CSM_DELETE_SELF(CubismMoc, moc);
}
CubismMoc::CubismMoc(Core::csmMoc* moc)
: _moc(moc)
, _modelCount(0)
, _mocVersion(0)
{ }
CubismMoc::~CubismMoc()
{
CSM_ASSERT(_modelCount == 0);
CSM_FREE_ALLIGNED(_moc);
}
CubismModel* CubismMoc::CreateModel()
{
CubismModel* cubismModel = NULL;
const csmUint32 modelSize = Core::csmGetSizeofModel(_moc);
void* modelMemory = CSM_MALLOC_ALLIGNED(modelSize, Core::csmAlignofModel);
Core::csmModel* model = Core::csmInitializeModelInPlace(_moc, modelMemory, modelSize);
if (model)
{
cubismModel = CSM_NEW CubismModel(model);
cubismModel->Initialize();
++_modelCount;
}
return cubismModel;
}
void CubismMoc::DeleteModel(CubismModel* model)
{
CSM_DELETE_SELF(CubismModel, model);
--_modelCount;
}
Core::csmMocVersion CubismMoc::GetLatestMocVersion()
{
return Core::csmGetLatestMocVersion();
}
Core::csmMocVersion CubismMoc::GetMocVersion()
{
return _mocVersion;
}
csmBool CubismMoc::HasMocConsistency(void* address, const csmUint32 size)
{
csmInt32 isConsistent = Core::csmHasMocConsistency(address, size);
return isConsistent != 0 ? true : false;
}
csmBool CubismMoc::HasMocConsistencyFromUnrevivedMoc(const csmByte* mocBytes, csmSizeInt size)
{
void* alignedBuffer = CSM_MALLOC_ALLIGNED(size, Core::csmAlignofMoc);
memcpy(alignedBuffer, mocBytes, size);
csmBool consistency = CubismMoc::HasMocConsistency(alignedBuffer, size);
CSM_FREE_ALLIGNED(alignedBuffer);
return consistency;
}
}}}
+98
View File
@@ -0,0 +1,98 @@
/**
* 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 "CubismFramework.hpp"
namespace Live2D { namespace Cubism { namespace Framework {
class CubismModel;
/**
* Handles management of MOC data
*/
class CubismMoc
{
friend class CubismModel;
public:
/**
* Makes an instance.
*
* @param mocBytes Buffer containing the loaded MOC file
* @param size Size of the buffer in bytes
*
* @return Created instance
*/
static CubismMoc* Create(const csmByte* mocBytes, csmSizeInt size, csmBool shouldCheckMocConsistency = false);
/**
* Destroys an instance.
*
* @param moc `CubismMoc` instance to be destroyed
*/
static void Delete(CubismMoc* moc);
/**
* Makes a model instance.
*
* @return Created model instance
*/
CubismModel* CreateModel();
/**
* Destroys a model instance.
*
* @param model `CubismModel` instance to be destroyed
*/
void DeleteModel(CubismModel* model);
/**
* Returns the latest MOC file version.
*
* @return Version
*/
static Core::csmMocVersion GetLatestMocVersion();
/**
* Returns the version of the loaded MOC file.
*
* @return Version
*/
Core::csmMocVersion GetMocVersion();
/**
* Checks the consistency of the MOC file.
*
* @param address Address of the un-restored MOC file. The address must be aligned to 'csmAlignofMoc'.
* @param size Size of the MOC file in bytes
*
* @return true if the file is consistent; otherwise false
*/
static csmBool HasMocConsistency(void* address, const csmUint32 size);
/**
* Checks the consistency of the MOC file.
*
* @param mocBytes Buffer of the MOC file
* @param size Size of the buffer
*
* @return true if the file is consistent; otherwise false
*/
static csmBool HasMocConsistencyFromUnrevivedMoc(const csmByte* mocBytes, csmSizeInt size);
private:
CubismMoc(Core::csmMoc* moc);
virtual ~CubismMoc();
Core::csmMoc* _moc;
csmInt32 _modelCount;
csmUint32 _mocVersion;
};
}}}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,76 @@
/**
* 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.
*/
#include "CubismModelUserData.hpp"
#include "CubismModelUserDataJson.hpp"
#include "Utils/CubismString.hpp"
namespace Live2D { namespace Cubism { namespace Framework {
namespace
{
const Live2D::Cubism::Framework::csmChar* ArtMesh = "ArtMesh";
}
CubismModelUserData::~CubismModelUserData()
{
for (csmUint32 i = 0;i < _userDataNodes.GetSize(); ++i)
{
CSM_DELETE(const_cast<CubismModelUserDataNode*>(_userDataNodes[i]));
}
}
const csmVector<const CubismModelUserData::CubismModelUserDataNode*>& CubismModelUserData::GetArtMeshUserDatas() const
{
return _artMeshUserDataNodes;
}
CubismModelUserData* CubismModelUserData::Create(const csmByte* buffer, const csmSizeInt size)
{
CubismModelUserData* ret = CSM_NEW CubismModelUserData();
ret->ParseUserData(buffer, size);
return ret;
}
void CubismModelUserData::Delete(CubismModelUserData* modelUserData)
{
CSM_DELETE_SELF(CubismModelUserData, modelUserData);
}
void CubismModelUserData::ParseUserData(const csmByte* buffer, const csmSizeInt size)
{
CubismModelUserDataJson* json = CSM_NEW CubismModelUserDataJson(buffer, size);
if (!json->IsValid())
{
CSM_DELETE(json);
return;
}
const ModelUserDataType typeOfArtMesh = CubismFramework::GetIdManager()->GetId(ArtMesh);
const csmUint32 nodeCount = json->GetUserDataCount();
for (csmUint32 i = 0; i < nodeCount; i++)
{
CubismModelUserDataNode* addNode = CSM_NEW CubismModelUserDataNode();
addNode->TargetId = json->GetUserDataId(i);
addNode->TargetType = CubismFramework::GetIdManager()->GetId(json->GetUserDataTargetType(i));
addNode->Value = json->GetUserDataValue(i);
_userDataNodes.PushBack(addNode);
if (addNode->TargetType == typeOfArtMesh)
{
_artMeshUserDataNodes.PushBack(addNode);
}
}
CSM_DELETE(json);
}
}}}
@@ -0,0 +1,68 @@
/**
* 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 "CubismModel.hpp"
namespace Live2D { namespace Cubism { namespace Framework {
typedef CubismIdHandle ModelUserDataType;
/**
* Handles management of user data.
*/
class CubismModelUserData
{
public:
/**
* Structure for user data information
*/
struct CubismModelUserDataNode
{
ModelUserDataType TargetType; ///< User data type
CubismIdHandle TargetId; ///< ID of the object attached to the user data
csmString Value; ///< User data value
};
/**
* Makes an instance.
*
* @param buffer Buffer where the user data file is loaded
* @param size Byte size of the buffer
*
* @return Instance
*/
static CubismModelUserData* Create(const csmByte* buffer, csmSizeInt size);
/**
* Destroys the instance.
*
* @param modelUserData Instance of `CubismModelUserData` to destroy
*/
static void Delete(CubismModelUserData* modelUserData);
/**
* Destructor
*/
virtual ~CubismModelUserData();
/**
* Returns the list of user data for ArtMesh.
*
* @return List of user data
*/
const csmVector<const CubismModelUserDataNode*>& GetArtMeshUserDatas() const;
private:
void ParseUserData(const csmByte* buffer, csmSizeInt size);
csmVector<const CubismModelUserDataNode*> _userDataNodes;
csmVector<const CubismModelUserDataNode*> _artMeshUserDataNodes;
};
}}} //--------- LIVE2D NAMESPACE ------------
@@ -0,0 +1,58 @@
/**
* 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.
*/
#include "CubismModelUserDataJson.hpp"
#include "CubismModelUserData.hpp"
//--------- LIVE2D NAMESPACE ------------
namespace Live2D { namespace Cubism { namespace Framework {
namespace {
const csmChar* Meta = "Meta";
const csmChar* UserDataCount = "UserDataCount";
const csmChar* TotalUserDataSize = "TotalUserDataSize";
const csmChar* UserData = "UserData";
const csmChar* Target = "Target";
const csmChar* Id = "Id";
const csmChar* Value = "Value";
}
CubismModelUserDataJson::CubismModelUserDataJson(const csmByte* buffer, csmSizeInt size)
{
CreateCubismJson(buffer, size);
}
CubismModelUserDataJson::~CubismModelUserDataJson()
{
DeleteCubismJson();
}
csmInt32 CubismModelUserDataJson::GetUserDataCount() const
{
return _json->GetRoot()[Meta][UserDataCount].ToInt();
}
csmInt32 CubismModelUserDataJson::GetTotalUserDataSize() const
{
return _json->GetRoot()[Meta][TotalUserDataSize].ToInt();
}
csmString CubismModelUserDataJson::GetUserDataTargetType(const csmInt32 i) const
{
return _json->GetRoot()[UserData][i][Target].GetRawString();
}
CubismIdHandle CubismModelUserDataJson::GetUserDataId(const csmInt32 i) const
{
return CubismFramework::GetIdManager()->GetId(_json->GetRoot()[UserData][i][Id].GetRawString());
}
const csmChar* CubismModelUserDataJson::GetUserDataValue(const csmInt32 i) const
{
return _json->GetRoot()[UserData][i][Value].GetRawString();
}
}}}
@@ -0,0 +1,79 @@
/**
* 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 "CubismJsonHolder.hpp"
#include "Utils/CubismJson.hpp"
#include "Model/CubismModel.hpp"
#include "Id/CubismIdManager.hpp"
//--------- LIVE2D NAMESPACE ------------
namespace Live2D { namespace Cubism { namespace Framework {
/**
* Handles user data.
*/
class CubismModelUserDataJson : public CubismJsonHolder
{
public:
/**
* Constructor
*
* @param buffer Buffer where the user data file is loaded
* @param size Number of bytes in the buffer
*/
CubismModelUserDataJson(const csmByte* buffer, csmSizeInt size);
/**
* Destructor
*/
virtual ~CubismModelUserDataJson();
/**
* Returns the number of user data entries in the user data file.
*
* @return Number of user data entries
*/
csmInt32 GetUserDataCount() const;
/**
* Returns the number of bytes in the user data file.
*
* @return Number of bytes
*/
csmInt32 GetTotalUserDataSize() const;
/**
* Returns the type of user data at the specified index.
*
* @param i Index of the user data
*
* @return Type of user data
*/
csmString GetUserDataTargetType(csmInt32 i) const;
/**
* Returns the ID of the target attached to the user data at the specified index.
*
* @param i Index of the user data
*
* @return ID of the target attached to the user data
*/
CubismIdHandle GetUserDataId(csmInt32 i) const;
/**
* Returns the value of the user data at the specified index.
*
* @param i Index of the user data
*
* @return Value of the user data
*/
const csmChar* GetUserDataValue(csmInt32 i) const;
};
}}}
@@ -0,0 +1,309 @@
/**
* 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.
*/
#include "CubismUserModel.hpp"
#include "Motion/CubismMotion.hpp"
#include "Physics/CubismPhysics.hpp"
namespace Live2D { namespace Cubism { namespace Framework {
CubismUserModel::CubismUserModel()
: _moc(NULL)
, _model(NULL)
, _motionManager(NULL)
, _expressionManager(NULL)
, _eyeBlink(NULL)
, _breath(NULL)
, _modelMatrix(NULL)
, _pose(NULL)
, _dragManager(NULL)
, _physics(NULL)
, _modelUserData(NULL)
, _initialized(false)
, _updating(false)
, _opacity(1.0f)
, _lipSync(true)
, _lastLipSyncValue(0.0f)
, _dragX(0.0f)
, _dragY(0.0f)
, _accelerationX(0.0f)
, _accelerationY(0.0f)
, _accelerationZ(0.0f)
, _mocConsistency(false)
, _motionConsistency(false)
, _debugMode(false)
, _renderer(NULL)
{
// モーションマネージャーを作成
// MotionQueueManagerクラスからの継承なので使い方は同じ
_motionManager = CSM_NEW CubismMotionManager();
_motionManager->SetEventCallback(CubismDefaultMotionEventCallback, this);
// 表情モーションマネージャを作成
_expressionManager = CSM_NEW CubismExpressionMotionManager();
// ドラッグによるアニメーション
_dragManager = CSM_NEW CubismTargetPoint();
}
CubismUserModel::~CubismUserModel()
{
CSM_DELETE(_motionManager);
CSM_DELETE(_expressionManager);
if (_moc)
{
_moc->DeleteModel(_model);
}
CubismMoc::Delete(_moc);
CSM_DELETE(_modelMatrix);
CubismPose::Delete(_pose);
CubismEyeBlink::Delete(_eyeBlink);
CubismBreath::Delete(_breath);
CSM_DELETE(_dragManager);
CubismPhysics::Delete(_physics);
CubismModelUserData::Delete(_modelUserData);
DeleteRenderer();
}
void CubismUserModel::SetAcceleration(csmFloat32 x, csmFloat32 y, csmFloat32 z)
{
_accelerationX = x;
_accelerationY = y;
_accelerationZ = z;
}
void CubismUserModel::LoadModel(const csmByte* buffer, csmSizeInt size, csmBool shouldCheckMocConsistency)
{
_moc = CubismMoc::Create(buffer, size, shouldCheckMocConsistency);
if (_moc == NULL)
{
CubismLogError("Failed to CubismMoc::Create().");
return;
}
_model = _moc->CreateModel();
if (_model == NULL)
{
CubismLogError("Failed to CreateModel().");
return;
}
_model->SaveParameters();
_modelMatrix = CSM_NEW CubismModelMatrix(_model->GetCanvasWidth(), _model->GetCanvasHeight());
}
ACubismMotion* CubismUserModel::LoadExpression(const csmByte* buffer, csmSizeInt size, const csmChar* name)
{
if (!buffer)
{
CubismLogError("Failed to LoadExpression().");
return NULL;
}
return CubismExpressionMotion::Create(buffer, size);
}
void CubismUserModel::LoadPose(const csmByte* buffer, csmSizeInt size)
{
_pose = CubismPose::Create(buffer, size);
if (!_pose)
{
CubismLogError("Failed to LoadPose().");
}
}
void CubismUserModel::LoadPhysics(const csmByte* buffer, csmSizeInt size)
{
_physics = CubismPhysics::Create(buffer, size);
if (!_physics)
{
CubismLogError("Failed to LoadPhysics().");
}
}
void CubismUserModel::LoadUserData(const csmByte* buffer, csmSizeInt size)
{
if (!buffer)
{
CubismLogError("Failed to LoadUserData().");
return;
}
_modelUserData = CubismModelUserData::Create(buffer, size);
}
csmBool CubismUserModel::IsHit(CubismIdHandle drawableId, csmFloat32 pointX, csmFloat32 pointY)
{
const csmInt32 drawIndex = _model->GetDrawableIndex(drawableId);
if (drawIndex < 0)
{
return false; // 存在しない場合はfalse
}
const csmInt32 count = _model->GetDrawableVertexCount(drawIndex);
const csmFloat32* vertices = _model->GetDrawableVertices(drawIndex);
csmFloat32 left = vertices[0];
csmFloat32 right = vertices[0];
csmFloat32 top = vertices[1];
csmFloat32 bottom = vertices[1];
for (csmInt32 j = 1; j < count; ++j)
{
csmFloat32 x = vertices[Constant::VertexOffset + j * Constant::VertexStep];
csmFloat32 y = vertices[Constant::VertexOffset + j * Constant::VertexStep + 1];
if (x < left)
{
left = x; // Min x
}
if (x > right)
{
right = x; // Max x
}
if (y < top)
{
top = y; // Min y
}
if (y > bottom)
{
bottom = y; // Max y
}
}
const csmFloat32 tx = _modelMatrix->InvertTransformX(pointX);
const csmFloat32 ty = _modelMatrix->InvertTransformY(pointY);
return ((left <= tx) && (tx <= right) && (top <= ty) && (ty <= bottom));
}
ACubismMotion* CubismUserModel::LoadMotion(const csmByte* buffer, csmSizeInt size, const csmChar* name,
ACubismMotion::FinishedMotionCallback onFinishedMotionHandler, ACubismMotion::BeganMotionCallback onBeganMotionHandler,
ICubismModelSetting* modelSetting, const csmChar* group, const csmInt32 index, csmBool shouldCheckMotionConsistency)
{
if (!buffer)
{
CubismLogError("Failed to LoadMotion(). Buffer is NULL.");
return NULL;
}
ACubismMotion* motion = CubismMotion::Create(buffer, size, onFinishedMotionHandler, onBeganMotionHandler, shouldCheckMotionConsistency);
if (!motion)
{
CubismLogError("Failed to create motion from buffer in LoadMotion().");
return NULL;
}
// 必要であればモーションフェード値を上書き
if (modelSetting)
{
const csmFloat32 fadeInTime = modelSetting->GetMotionFadeInTimeValue(group, index);
if (fadeInTime >= 0.0f)
{
motion->SetFadeInTime(fadeInTime);
}
const csmFloat32 fadeOutTime = modelSetting->GetMotionFadeOutTimeValue(group, index);
if (fadeOutTime >= 0.0f)
{
motion->SetFadeOutTime(fadeOutTime);
}
}
return motion;
}
void CubismUserModel::SetDragging(csmFloat32 x, csmFloat32 y)
{
_dragManager->Set(x, y);
}
CubismModelMatrix* CubismUserModel::GetModelMatrix() const
{
return _modelMatrix;
}
csmBool CubismUserModel::IsInitialized()
{
return _initialized;
}
void CubismUserModel::IsInitialized(csmBool v)
{
_initialized = v;
}
csmBool CubismUserModel::IsUpdating()
{
return _updating;
}
void CubismUserModel::IsUpdating(csmBool v)
{
_updating = v;
}
void CubismUserModel::SetOpacity(csmFloat32 a)
{
_opacity = a;
}
csmFloat32 CubismUserModel::GetOpacity()
{
return _opacity;
}
CubismModel* CubismUserModel::GetModel() const
{
return _model;
}
void CubismUserModel::CreateRenderer(csmInt32 maskBufferCount)
{
if (_renderer)
{
DeleteRenderer();
}
_renderer = Rendering::CubismRenderer::Create();
_renderer->Initialize(_model, maskBufferCount);
}
void CubismUserModel::DeleteRenderer()
{
if (_renderer)
{
Rendering::CubismRenderer::Delete(_renderer);
_renderer = NULL;
}
}
void CubismUserModel::CubismDefaultMotionEventCallback(const CubismMotionQueueManager* caller, const csmString& eventValue, void* customData)
{
CubismUserModel* model = reinterpret_cast<CubismUserModel*>(customData);
if (model != NULL)
{
model->MotionEventFired(eventValue);
}
}
void CubismUserModel::MotionEventFired(const csmString& eventValue)
{
CubismLogInfo("%s",eventValue.GetRawString());
}
}}}
@@ -0,0 +1,256 @@
/**
* 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 "Effect/CubismPose.hpp"
#include "Effect/CubismEyeBlink.hpp"
#include "Effect/CubismBreath.hpp"
#include "Math/CubismModelMatrix.hpp"
#include "Math/CubismTargetPoint.hpp"
#include "Model/CubismMoc.hpp"
#include "Model/CubismModel.hpp"
#include "Motion/CubismMotionManager.hpp"
#include "Motion/CubismExpressionMotion.hpp"
#include "Physics/CubismPhysics.hpp"
#include "Rendering/CubismRenderer.hpp"
#include "Model/CubismModelUserData.hpp"
#include "Motion/CubismExpressionMotionManager.hpp"
namespace Live2D { namespace Cubism { namespace Framework {
/**
* Base for models actually used by thegit a user.
*/
class CubismUserModel
{
public:
/**
* Constructor
*/
CubismUserModel();
/**
* Destructor
*/
virtual ~CubismUserModel();
/**
* Checks if it is initialized.
*
* @return true if initialized; otherwise false.
*/
virtual csmBool IsInitialized();
/**
* Sets the initialization state.
*
* @param v Initialization state. true if initialized.
*/
virtual void IsInitialized(csmBool v);
/**
* Checks if it is updated.
*
* @return true if updated; otherwise false.
*/
virtual csmBool IsUpdating();
/**
* Sets the update state.
*
* @param v Update state. true if updated.
*/
virtual void IsUpdating(csmBool v);
/**
* Sets the information during mouse dragging.
*
* @param x X position of the mouse cursor during dragging
* @param y Y position of the mouse cursor during dragging
*/
virtual void SetDragging(csmFloat32 x, csmFloat32 y);
/**
* Sets the acceleration information.
*
* @param x Acceleration in the X-axis direction
* @param y Acceleration in the Y-axis direction
* @param z Acceleration in the Z-axis direction
*/
virtual void SetAcceleration(csmFloat32 x, csmFloat32 y, csmFloat32 z);
/**
* Returns the matrix applied to the model.
*
* @return Matrix
*/
CubismModelMatrix* GetModelMatrix() const;
/**
* Sets the opacity.
*
* @param a Opacity
*/
virtual void SetOpacity(csmFloat32 a);
/**
* Returns the opacity.
*
* @return Opacity
*/
virtual csmFloat32 GetOpacity();
/**
* Loads the model from a MOC3 file.
*
* @param buffer Buffer where the MOC3 file is loaded
* @param size Number of bytes in the buffer
*/
virtual void LoadModel(const csmByte* buffer, csmSizeInt size, csmBool shouldCheckMocConsistency = false);
/**
* Loads motion from a motion file.
* If a fade value is defined in model3.json, the fade value defined in motion3.json will be overwritten.
*
* @param buffer Buffer where the motion file is loaded
* @param size Number of bytes in the buffer
* @param name Name of the motion
* @param onFinishedMotionHandler Callback function when motion playback finishes
* @param modelSetting Model setting information
* @param group Name to the desired Motion Group
* @param index Index to the desired Motion
*
* @return Instance of the motion class
*/
virtual ACubismMotion* LoadMotion(const csmByte* buffer, csmSizeInt size, const csmChar* name,
ACubismMotion::FinishedMotionCallback onFinishedMotionHandler = NULL, ACubismMotion::BeganMotionCallback onBeganMotionHandler = NULL,
ICubismModelSetting* modelSetting = NULL, const csmChar* group = NULL, const csmInt32 index = -1, csmBool shouldCheckMotionConsistency = false);
/**
* Loads expression from an expression configuration file.
*
* @param buffer Buffer where the expression configuration file is loaded
* @param size Number of bytes in the buffer
* @param name Name of the expression
*
* @return Instance of the expression motion class
*/
virtual ACubismMotion* LoadExpression(const csmByte* buffer, csmSizeInt size, const csmChar* name);
/**
* Loads pose from a pose configuration file.
*
* @param buffer Buffer where the pose configuration file is loaded
* @param size Number of bytes in the buffer
*/
virtual void LoadPose(const csmByte* buffer, csmSizeInt size);
/**
* Loads physics from a physics configuration file.
*
* @param buffer Buffer where the physics configuration file is loaded
* @param size Number of bytes in the buffer
*/
virtual void LoadPhysics(const csmByte* buffer, csmSizeInt size);
/**
* Loads user data from a user data file.
*
* @param buffer Buffer where the user data file is loaded
* @param size Number of bytes in the buffer
*/
virtual void LoadUserData(const csmByte* buffer, csmSizeInt size);
/**
* Returns whether the hit test of a drawable object hits at the specified position.
*
* @param drawableId ID of the drawable object to test
* @param pointX X position
* @param pointY Y position
*
* @return true if the hit test of the drawable object hits at the specified position; otherwise false.
*/
virtual csmBool IsHit(CubismIdHandle drawableId, csmFloat32 pointX, csmFloat32 pointY);
/**
* Returns the model.
*
* @return Instance of the model
*/
CubismModel* GetModel() const;
/**
* Returns the renderer.
*
* @return Instance of the renderer
*/
template<class T> T* GetRenderer() { return dynamic_cast<T*>(_renderer); }
/**
* Makes the renderer.
*/
void CreateRenderer(csmInt32 maskBufferCount = 1);
/**
* Destroys the renderer.
*/
void DeleteRenderer();
/**
* Handles the event when user data fires during motion playback.
*
* @param eventValue Event value of the user data that fired
*
* @note This function is intended to be overridden.<br>
* If not overridden, it outputs to the log.
*/
virtual void MotionEventFired(const csmString& eventValue);
/**
* Callback function to receive user data events registered in the motion management class.
*
* @param caller Motion management class that handled the fired user data event
* @param eventValue Event value of the fired user data
* @param customData Arbitrary data
*
* @note Calls the `MotionEventFired` of the CubismUserModel subclass.
*/
static void CubismDefaultMotionEventCallback(const CubismMotionQueueManager* caller, const csmString& eventValue, void* customData);
protected:
CubismMoc* _moc;
CubismModel* _model;
CubismMotionManager* _motionManager;
CubismExpressionMotionManager* _expressionManager;
CubismEyeBlink* _eyeBlink;
CubismBreath* _breath;
CubismModelMatrix* _modelMatrix;
CubismPose* _pose;
CubismTargetPoint* _dragManager;
CubismPhysics* _physics;
CubismModelUserData* _modelUserData;
csmBool _initialized;
csmBool _updating;
csmFloat32 _opacity;
csmBool _lipSync;
csmFloat32 _lastLipSyncValue;
csmFloat32 _dragX;
csmFloat32 _dragY;
csmFloat32 _accelerationX;
csmFloat32 _accelerationY;
csmFloat32 _accelerationZ;
csmBool _mocConsistency;
csmBool _motionConsistency;
csmBool _debugMode;
private:
Rendering::CubismRenderer* _renderer;
};
}}}