If you have any questions, reports, suggestions, or requests about Live2D, please send them to this forum.
※We cannot guarantee statements or answers from Live2D staff. Thank you for your understanding in advance.
When selecting only one model and translate it like this: modelToUse->GetModelMatrix()->TranslateRelative(speed,0); but when i have multiple models on the scene they move instead of only the selected one (for example: if model number 1 is selected models 2 and 3 will Translate too).
On investigation, we found that the reason is that the instance of CubismMatrix44 used for drawing is not being reset in every loop process. This can be avoided by rewriting a part of LAppLive2DManager::OnUpdate() as follows:
void LAppLive2DManager::OnUpdate() const
{
...
// CubismMatrix44 projection;
csmUint32 modelCount = _models.GetSize();
for (csmUint32 i = 0; i < modelCount; ++i)
{
CubismMatrix44 projection;
...
This fix will be added in a future update of the SDK.
Could you tell me how you are implementing the display of multiple models? If you are using one ModelMatrix for each model, make sure that you have an instance for each model and see if the same problem occurs.
I add new models in the same way done in LAppLive2DManager by adding a new instance to _models.
Example code: _models.PushBack(new LAppModel()); _models[_models.GetSize()-1]->LoadAssets(modelPath1.c_str(), modelJsonName1.c_str());
is there any way other then this?.
From what I understand there is a ModelMatrix for each model instance in _models what did you mean by "If you are using one ModelMatrix for each model" is there a way to use multiple models with one ModelMatrix? what are the benefits of doing so?
1. The problem still occurs for me when i try to add TranslateRelative(0.7f, 0.0f); to both models the first model translate right but the second model translate by 0.7f from the position of the first model.
2. I wrote a method for translating the first model when the user click the screen it is a simple method with only one line: _models[0]->GetModelMatrix()->TranslateRelative(speed, 0.0f); but when i start it both models translate and that is my main problem
To simplify the problem: in the case you presented when trying to translate the first model after both were created both models translate instead of only the first model.
for example using this line after both models were created: _models[0]->GetModelMatrix()->TranslateRelative(0.7f, 0.0f);
Thank you I tested the code and everything seems to work fine P.S. the last comment with the code disappeared for me can you write it again for future reference.
I found out that the reason is that the instance of CubismMatrix44 used for drawing is not being reset after each loop process. This can be avoided by rewriting a part of LAppLive2DManager::OnUpdate() as follows
void LAppLive2DManager::OnUpdate() const { ... // CubismMatrix44 projection; csmUint32 modelCount = _models.GetSize(); for (csmUint32 i = 0; i < modelCount; ++i) { CubismMatrix44 projection; ...
This fix will be added in a future update of the SDK. Thanks for the report.
Answers
Thank you for reaching out.
Could you tell me how you are implementing the display of multiple models?
If you are using one ModelMatrix for each model, make sure that you have an instance for each model and see if the same problem occurs.
by adding a new instance to _models.
Example code:
_models.PushBack(new LAppModel());
_models[_models.GetSize()-1]->LoadAssets(modelPath1.c_str(), modelJsonName1.c_str());
is there any way other then this?.
From what I understand there is a ModelMatrix for each model instance in _models
what did you mean by "If you are using one ModelMatrix for each model"
is there a way to use multiple models with one ModelMatrix? what are the benefits
of doing so?
Thanks for the answer.
The process you provided is correct.
I rewrote CubismLAppManager::ChangeScene() in the SDK sample here as follows and confirmed the operation. When I ran this, only the second model moved its position.(See the attached image)
Could you please check if the problem still occurs when you perform the same process?
2. I wrote a method for translating the first model when the user click the screen
it is a simple method with only one line:
_models[0]->GetModelMatrix()->TranslateRelative(speed, 0.0f);
but when i start it both models translate and that is my main problem
for example using this line after both models were created:
_models[0]->GetModelMatrix()->TranslateRelative(0.7f, 0.0f);
Thank you for your answer.
I was able to confirm the phenomenon.
We are going to investigate the cause of the problem, so please wait for a while.
I tested the code and everything seems to work fine
P.S. the last comment with the code disappeared for me can you write it again
for future reference.
I found out that the reason is that the instance of CubismMatrix44 used for drawing is not being reset after each loop process.
This can be avoided by rewriting a part of LAppLive2DManager::OnUpdate() as follows
void LAppLive2DManager::OnUpdate() const
{
...
// CubismMatrix44 projection;
csmUint32 modelCount = _models.GetSize();
for (csmUint32 i = 0; i < modelCount; ++i)
{
CubismMatrix44 projection;
...
This fix will be added in a future update of the SDK.
Thanks for the report.