Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

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.
 
Live2D Cubism
Cubism Products and Downloads
Cubism product manuals and tutorials
Cubism Editor Manual    Cubism Editor Tutorial    Cubism SDK Manual    Cubism SDK Tutorial
[INFORMATION](4/11/2024)
Cubism Editor 5.1 alpha2 is now available!

We have incorporated some of your comments and suggestions. Thank you for your comments and requests!
We will continue to welcome your feedback on alpha2.

Download/ Manual and Update History
Options

Multiple models when using TranslateRelative()

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).
Tagged:

Best Answer

  • Options
    @catCoder

    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.

    Thank you.

Answers

  • Options
    Hello @catCoder ,
    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.
  • Options
    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?
  • Options
    @catCoder

    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.
    void LAppLive2DManager::ChangeScene(Csm::csmInt32 index)
    {
        ...
    
        ReleaseAllModel();
        _models.PushBack(new LAppModel());
        _models[0]->LoadAssets(modelPath.c_str(), modelJsonName.c_str());
    
        // The second model.
        _models.PushBack(new LAppModel());
        _models[1]->LoadAssets("Resources/Haru/", "Haru.model3.json");
        _models[1]->GetModelMatrix()->TranslateRelative(0.7f, 0.0f);
    
        ...
    }
    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?
  • Options
    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
  • Options
    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);
  • Options
    @catCoder

    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.
  • Options
    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.
  • Options
    @catCoder

    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.
Sign In or Register to comment.