| 459 | } |
| 460 | |
| 461 | CubismMotionQueueEntryHandle LAppModel::StartMotion(const csmChar* group, csmInt32 no, csmInt32 priority, ACubismMotion::FinishedMotionCallback onFinishedMotionHandler) |
| 462 | { |
| 463 | if (priority == PriorityForce) |
| 464 | { |
| 465 | _motionManager->SetReservePriority(priority); |
| 466 | } |
| 467 | else if (!_motionManager->ReserveMotion(priority)) |
| 468 | { |
| 469 | if (_debugMode) LAppPal::PrintLog("[APP]can't start motion."); |
| 470 | return InvalidMotionQueueEntryHandleValue; |
| 471 | } |
| 472 | |
| 473 | const csmString fileName = _modelSetting->GetMotionFileName(group, no); |
| 474 | |
| 475 | //ex) idle_0 |
| 476 | csmString name = Utils::CubismString::GetFormatedString("%s_%d", group, no); |
| 477 | CubismMotion* motion = static_cast<CubismMotion*>(_motions[name.GetRawString()]); |
| 478 | csmBool autoDelete = false; |
| 479 | |
| 480 | if (motion == NULL) |
| 481 | { |
| 482 | csmString path = fileName; |
| 483 | path = _modelHomeDir + path; |
| 484 | |
| 485 | csmByte* buffer; |
| 486 | csmSizeInt size; |
| 487 | buffer = CreateBuffer(path.GetRawString(), &size); |
| 488 | motion = static_cast<CubismMotion*>(LoadMotion(buffer, size, NULL, onFinishedMotionHandler)); |
| 489 | csmFloat32 fadeTime = _modelSetting->GetMotionFadeInTimeValue(group, no); |
| 490 | if (fadeTime >= 0.0f) |
| 491 | { |
| 492 | motion->SetFadeInTime(fadeTime); |
| 493 | } |
| 494 | |
| 495 | fadeTime = _modelSetting->GetMotionFadeOutTimeValue(group, no); |
| 496 | if (fadeTime >= 0.0f) |
| 497 | { |
| 498 | motion->SetFadeOutTime(fadeTime); |
| 499 | } |
| 500 | motion->SetEffectIds(_eyeBlinkIds, _lipSyncIds); |
| 501 | autoDelete = true; // 終了時にメモリから削除 |
| 502 | |
| 503 | DeleteBuffer(buffer, path.GetRawString()); |
| 504 | } |
| 505 | else |
| 506 | { |
| 507 | motion->SetFinishedMotionHandler(onFinishedMotionHandler); |
| 508 | } |
| 509 | |
| 510 | //voice |
| 511 | csmString voice = _modelSetting->GetMotionSoundFileName(group, no); |
| 512 | if (strcmp(voice.GetRawString(), "") != 0) |
| 513 | { |
| 514 | csmString path = voice; |
| 515 | path = _modelHomeDir + path; |
| 516 | #if USE_AUDIO_ENGINE |
| 517 | AudioEngine::play2d(path.GetRawString()); |
| 518 | #elif USE_SIMPLE_AUDIO_ENGINE |
nothing calls this directly
no test coverage detected