//----------------------------------------------------------------------------- // onCommitName() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onCommitName(LLUICtrl* ctrl, void* data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data; if (!previewp->getEnabled()) return; LLVOAvatar* avatarp; if (previewp->mInWorld) { if (!gAgent.getAvatarObject()) { return; } avatarp = gAgent.getAvatarObject(); } else { if (!previewp->mAnimPreview) { return; } avatarp = previewp->mAnimPreview->getDummyAvatar(); } LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); if (motionp) { motionp->setName(previewp->childGetValue("name_form").asString()); } LLFloaterNameDesc::doCommit(ctrl, data); }
//----------------------------------------------------------------------------- // onCommitLoopOut() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onCommitLoopOut(LLUICtrl* ctrl, void* data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data; if (!previewp->getEnabled()) return; LLVOAvatar* avatarp; if (previewp->mInWorld) { if (!gAgent.getAvatarObject()) { return; } avatarp = gAgent.getAvatarObject(); } else { if (!previewp->mAnimPreview) { return; } avatarp = previewp->mAnimPreview->getDummyAvatar(); } LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); if (motionp) { motionp->setLoopOut((F32)previewp->childGetValue("loop_out_point").asReal() * 0.01f * motionp->getDuration()); previewp->resetMotion(); previewp->childSetValue("loop_check", LLSD(TRUE)); onCommitLoop(ctrl, data); } }
//----------------------------------------------------------------------------- // onCommitBaseAnim() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onCommitBaseAnim(LLUICtrl* ctrl, void* data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data; if (!previewp->getEnabled()) return; if (previewp->mAnimPreview) { LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); BOOL paused = avatarp->areAnimationsPaused(); // stop all other possible base motions avatarp->stopMotion(ANIM_AGENT_STAND, TRUE); avatarp->stopMotion(ANIM_AGENT_WALK, TRUE); avatarp->stopMotion(ANIM_AGENT_SIT, TRUE); avatarp->stopMotion(ANIM_AGENT_HOVER, TRUE); previewp->resetMotion(); if (!paused) { previewp->mPauseRequest = NULL; } } }
//----------------------------------------------------------------------------- // validateLoopOut() //----------------------------------------------------------------------------- BOOL LLFloaterAnimPreview::validateLoopOut(LLUICtrl* spin, void* data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data; if (!previewp->getEnabled()) return FALSE; F32 loop_out_value = (F32)previewp->childGetValue("loop_out_point").asReal(); F32 loop_in_value = (F32)previewp->childGetValue("loop_in_point").asReal(); if (loop_out_value < 0.f) { loop_out_value = 0.f; } else if (loop_out_value > 100.f) { loop_out_value = 100.f; } else if (loop_out_value < loop_in_value) { loop_out_value = loop_in_value; } previewp->childSetValue("loop_out_point", LLSD(loop_out_value)); return TRUE; }
//----------------------------------------------------------------------------- // onBtnStop() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onBtnStop(void* user_data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)user_data; if (!previewp->getEnabled()) return; if (previewp->mMotionID.notNull()) { LLVOAvatar* avatarp; if (previewp->mInWorld) { if (!gAgent.getAvatarObject()) { return; } avatarp = gAgent.getAvatarObject(); } else { if (!previewp->mAnimPreview) { return; } avatarp = previewp->mAnimPreview->getDummyAvatar(); } previewp->resetMotion(); previewp->mPauseRequest = avatarp->requestPause(); } }
//----------------------------------------------------------------------------- // onSliderMove() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onSliderMove(LLUICtrl* ctrl, void*user_data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)user_data; if (!previewp->getEnabled()) return; LLVOAvatar* avatarp; if (previewp->mInWorld) { if (!gAgent.getAvatarObject()) { return; } avatarp = gAgent.getAvatarObject(); } else { if (!previewp->mAnimPreview) { return; } avatarp = previewp->mAnimPreview->getDummyAvatar(); } F32 slider_value = (F32)previewp->childGetValue("playback_slider").asReal(); LLUUID base_id = previewp->mIDList[previewp->childGetValue("preview_base_anim").asString()]; LLMotion* motionp = avatarp->findMotion(previewp->mMotionID); F32 duration = motionp->getDuration();// + motionp->getEaseOutDuration(); F32 delta_time = duration * slider_value; avatarp->deactivateAllMotions(); avatarp->startMotion(base_id, delta_time + BASE_ANIM_TIME_OFFSET); avatarp->startMotion(previewp->mMotionID, delta_time); previewp->mPauseRequest = avatarp->requestPause(); previewp->refresh(); }
//----------------------------------------------------------------------------- // validateEaseOut() //----------------------------------------------------------------------------- BOOL LLFloaterAnimPreview::validateEaseOut(LLUICtrl* spin, void* data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data; if (!previewp->getEnabled()) return FALSE; LLVOAvatar* avatarp; if (previewp->mInWorld) { if (!gAgent.getAvatarObject()) { return FALSE; } avatarp = gAgent.getAvatarObject(); } else { if (!previewp->mAnimPreview) { return FALSE; } avatarp = previewp->mAnimPreview->getDummyAvatar(); } LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); if (!motionp->getLoop()) { F32 new_ease_out = llclamp((F32)previewp->childGetValue("ease_out_time").asReal(), 0.f, motionp->getDuration() - motionp->getEaseInDuration()); previewp->childSetValue("ease_out_time", LLSD(new_ease_out)); } return TRUE; }
//----------------------------------------------------------------------------- // onCommitEaseOut() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onCommitEaseOut(LLUICtrl* ctrl, void* data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data; if (!previewp->getEnabled()) return; LLVOAvatar* avatarp; if (previewp->mInWorld) { if (!gAgent.getAvatarObject()) { return; } avatarp = gAgent.getAvatarObject(); } else { if (!previewp->mAnimPreview) { return; } avatarp = previewp->mAnimPreview->getDummyAvatar(); } LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); motionp->setEaseOut((F32)previewp->childGetValue("ease_out_time").asReal()); previewp->resetMotion(); }
//----------------------------------------------------------------------------- // onBtnPlay() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onBtnPlay(void* user_data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)user_data; if (!previewp->getEnabled()) return; if (previewp->mMotionID.notNull() && previewp->mAnimPreview) { LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); if(!avatarp->isMotionActive(previewp->mMotionID)) { previewp->resetMotion(); previewp->mPauseRequest = NULL; } else { if (avatarp->areAnimationsPaused()) { previewp->mPauseRequest = NULL; } else { previewp->mPauseRequest = avatarp->requestPause(); } } } }
//----------------------------------------------------------------------------- // onCommitEmote() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onCommitEmote(LLUICtrl* ctrl, void* data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data; if (!previewp->getEnabled()) return; previewp->resetMotion(); // ssts emote }
//----------------------------------------------------------------------------- // onBtnReload() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onBtnReload(void* userdata) { LLFloaterAnimPreview* floaterp = (LLFloaterAnimPreview*)userdata; if (!floaterp->getEnabled()) return; floaterp->unloadMotion(); floaterp->loadBVH(); }
//----------------------------------------------------------------------------- // onCommitHandPose() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onCommitHandPose(LLUICtrl* ctrl, void* data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data; if (!previewp->getEnabled()) return; previewp->resetMotion(); // sets hand pose }
//----------------------------------------------------------------------------- // onBtnOK() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onBtnOK(void* userdata) { LLFloaterAnimPreview* floaterp = (LLFloaterAnimPreview*)userdata; if (!floaterp->getEnabled()) return; if (floaterp->mAnimPreview) { LLKeyframeMotion* motionp = (LLKeyframeMotion*)floaterp->mAnimPreview->getPreviewAvatar()->findMotion(floaterp->mMotionID); S32 file_size = motionp->getFileSize(); U8* buffer = new U8[file_size]; LLDataPackerBinaryBuffer dp(buffer, file_size); if (motionp->serialize(dp)) { LLVFile file(gVFS, motionp->getID(), LLAssetType::AT_ANIMATION, LLVFile::APPEND); S32 size = dp.getCurrentSize(); file.setMaxSize(size); if (file.write((U8*)buffer, size)) { std::string name = floaterp->getChild<LLUICtrl>("name_form")->getValue().asString(); std::string desc = floaterp->getChild<LLUICtrl>("description_form")->getValue().asString(); LLAssetStorage::LLStoreAssetCallback callback = NULL; S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); void *userdata = NULL; upload_new_resource(floaterp->mTransactionID, // tid LLAssetType::AT_ANIMATION, name, desc, 0, LLFolderType::FT_NONE, LLInventoryType::IT_ANIMATION, LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(), name, callback, expected_upload_cost, userdata); } else { llwarns << "Failure writing animation data." << llendl; LLNotificationsUtil::add("WriteAnimationFail"); } } delete [] buffer; // clear out cache for motion data floaterp->resetMotion(); floaterp->mAnimPreview->getPreviewAvatar()->removeMotion(floaterp->mMotionID); LLKeyframeDataCache::removeKeyframeData(floaterp->mMotionID); floaterp->mMotionID.setNull(); } floaterp->closeFloater(false); }
//----------------------------------------------------------------------------- // onCommitPriority() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onCommitPriority(LLUICtrl* ctrl, void* data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data; if (!previewp->getEnabled()) return; LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); motionp->setPriority(llfloor((F32)previewp->childGetValue("priority").asReal())); }
//----------------------------------------------------------------------------- // onCommitEaseIn() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onCommitEaseIn(LLUICtrl* ctrl, void* data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data; if (!previewp->getEnabled()) return; LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); motionp->setEaseIn((F32)previewp->childGetValue("ease_in_time").asReal()); previewp->resetMotion(); }
//----------------------------------------------------------------------------- // onBtnStop() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onBtnStop(void* user_data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)user_data; if (!previewp->getEnabled()) return; if (previewp->mMotionID.notNull() && previewp->mAnimPreview) { LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); previewp->resetMotion(); previewp->mPauseRequest = avatarp->requestPause(); } }
//----------------------------------------------------------------------------- // onBtnOK() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onBtnOK(void* userdata) { LLFloaterAnimPreview* floaterp = (LLFloaterAnimPreview*)userdata; if (!floaterp->getEnabled()) return; if (floaterp->mAnimPreview) { LLKeyframeMotion* motionp = (LLKeyframeMotion*)floaterp->mAnimPreview->getDummyAvatar()->findMotion(floaterp->mMotionID); S32 file_size = motionp->getFileSize(); U8* buffer = new U8[file_size]; LLDataPackerBinaryBuffer dp(buffer, file_size); if (motionp->serialize(dp)) { LLVFile file(gVFS, motionp->getID(), LLAssetType::AT_ANIMATION, LLVFile::APPEND); S32 size = dp.getCurrentSize(); file.setMaxSize(size); if (file.write((U8*)buffer, size)) { std::string name = floaterp->childGetValue("name_form").asString(); std::string desc = floaterp->childGetValue("description_form").asString(); upload_new_resource(floaterp->mTransactionID, // tid LLAssetType::AT_ANIMATION, name, desc, 0, LLAssetType::AT_NONE, LLInventoryType::IT_ANIMATION, PERM_NONE, name); } else { llwarns << "Failure writing animation data." << llendl; gViewerWindow->alertXml("WriteAnimationFail"); } } delete [] buffer; // clear out cache for motion data floaterp->mAnimPreview->getDummyAvatar()->removeMotion(floaterp->mMotionID); LLKeyframeDataCache::removeKeyframeData(floaterp->mMotionID); } floaterp->close(false); }
//----------------------------------------------------------------------------- // onCommitLoop() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onCommitLoop(LLUICtrl* ctrl, void* data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data; if (!previewp->getEnabled()) return; LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); if (motionp) { motionp->setLoop(previewp->childGetValue("loop_check").asBoolean()); motionp->setLoopIn((F32)previewp->childGetValue("loop_in_point").asReal() * 0.01f * motionp->getDuration()); motionp->setLoopOut((F32)previewp->childGetValue("loop_out_point").asReal() * 0.01f * motionp->getDuration()); } }
//----------------------------------------------------------------------------- // onCommitLoopIn() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onCommitLoopIn(LLUICtrl* ctrl, void* data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data; if (!previewp->getEnabled()) return; LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); if (motionp) { motionp->setLoopIn((F32)previewp->childGetValue("loop_in_point").asReal() / 100.f); previewp->resetMotion(); previewp->childSetValue("loop_check", LLSD(TRUE)); onCommitLoop(ctrl, data); } }
//----------------------------------------------------------------------------- // validateEaseIn() //----------------------------------------------------------------------------- BOOL LLFloaterAnimPreview::validateEaseIn(LLUICtrl* spin, void* data) { LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data; if (!previewp->getEnabled()) return FALSE; LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); if (!motionp->getLoop()) { F32 new_ease_in = llclamp((F32)previewp->childGetValue("ease_in_time").asReal(), 0.f, motionp->getDuration() - motionp->getEaseOutDuration()); previewp->childSetValue("ease_in_time", LLSD(new_ease_in)); } return TRUE; }
//----------------------------------------------------------------------------- // onBtnOK() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onBtnOK(void* userdata) { LLFloaterAnimPreview* floaterp = (LLFloaterAnimPreview*)userdata; if (!floaterp->getEnabled()) return; if ((!floaterp->mInWorld && floaterp->mAnimPreview) || (floaterp->mInWorld && gAgent.getAvatarObject())) { LLKeyframeMotion* motionp; if (floaterp->mInWorld) { motionp = (LLKeyframeMotion*)gAgent.getAvatarObject()->findMotion(floaterp->mMotionID); } else { motionp = (LLKeyframeMotion*)floaterp->mAnimPreview->getDummyAvatar()->findMotion(floaterp->mMotionID); } S32 file_size = motionp->getFileSize(); U8* buffer = new U8[file_size]; LLDataPackerBinaryBuffer dp(buffer, file_size); if (motionp->serialize(dp)) { LLVFile file(gVFS, motionp->getID(), LLAssetType::AT_ANIMATION, LLVFile::APPEND); S32 size = dp.getCurrentSize(); file.setMaxSize(size); if (file.write((U8*)buffer, size)) { std::string name = floaterp->childGetValue("name_form").asString(); std::string desc = floaterp->childGetValue("description_form").asString(); LLAssetStorage::LLStoreAssetCallback callback = NULL; S32 expected_upload_cost = sUploadAmount; void *userdata = NULL; upload_new_resource(floaterp->mTransactionID, // tid LLAssetType::AT_ANIMATION, name, desc, 0, LLAssetType::AT_NONE, LLInventoryType::IT_ANIMATION, LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(), name, callback, expected_upload_cost, userdata); } else { llwarns << "Failure writing animation data." << llendl; LLNotifications::instance().add("WriteAnimationFail"); } } delete [] buffer; // clear out cache for motion data if (floaterp->mInWorld) { gAgent.getAvatarObject()->removeMotion(floaterp->mMotionID); gAgent.getAvatarObject()->deactivateAllMotions(); } else { floaterp->mAnimPreview->getDummyAvatar()->removeMotion(floaterp->mMotionID); } LLKeyframeDataCache::removeKeyframeData(floaterp->mMotionID); } floaterp->close(false); }
//----------------------------------------------------------------------------- // onBtnOK() //----------------------------------------------------------------------------- void LLFloaterAnimPreview::onBtnOK(void* userdata) { LLFloaterAnimPreview* floaterp = (LLFloaterAnimPreview*)userdata; if (!floaterp->getEnabled()) return; if ((!floaterp->mInWorld && floaterp->mAnimPreview) || (floaterp->mInWorld && gAgent.getAvatarObject())) { LLKeyframeMotion* motionp; if (floaterp->mInWorld) { motionp = (LLKeyframeMotion*)gAgent.getAvatarObject()->findMotion(floaterp->mMotionID); } else { motionp = (LLKeyframeMotion*)floaterp->mAnimPreview->getDummyAvatar()->findMotion(floaterp->mMotionID); } S32 file_size = motionp->getFileSize(); U8* buffer = new U8[file_size]; LLDataPackerBinaryBuffer dp(buffer, file_size); if (motionp->serialize(dp)) { LLVFile file(gVFS, motionp->getID(), LLAssetType::AT_ANIMATION, LLVFile::APPEND); S32 size = dp.getCurrentSize(); file.setMaxSize(size); if (file.write((U8*)buffer, size)) { std::string name = floaterp->childGetValue("name_form").asString(); std::string desc = floaterp->childGetValue("description_form").asString(); LLAssetStorage::LLStoreAssetCallback callback = NULL; S32 expected_upload_cost = sUploadAmount; void *userdata = NULL; // <edit> if(floaterp->mItem) { // Update existing item instead of creating a new one LLViewerInventoryItem* item = (LLViewerInventoryItem*)floaterp->mItem; LLSaveInfo* info = new LLSaveInfo(item->getUUID(), LLUUID::null, desc, floaterp->mTransactionID); gAssetStorage->storeAssetData(floaterp->mTransactionID, LLAssetType::AT_ANIMATION, NULL, info, FALSE); // I guess I will do this now because the floater is closing... LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); new_item->setDescription(desc); new_item->setTransactionID(floaterp->mTransactionID); new_item->setAssetUUID(motionp->getID()); new_item->updateServer(FALSE); gInventory.updateItem(new_item); gInventory.notifyObservers(); } else // </edit> upload_new_resource(floaterp->mTransactionID, // tid LLAssetType::AT_ANIMATION, name, desc, 0, LLAssetType::AT_NONE, LLInventoryType::IT_ANIMATION, LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(), name, callback, expected_upload_cost, userdata); } else { llwarns << "Failure writing animation data." << llendl; LLNotifications::instance().add("WriteAnimationFail"); } } delete [] buffer; // clear out cache for motion data if (floaterp->mInWorld) { gAgent.getAvatarObject()->removeMotion(floaterp->mMotionID); gAgent.getAvatarObject()->deactivateAllMotions(); } else { floaterp->mAnimPreview->getDummyAvatar()->removeMotion(floaterp->mMotionID); } LLKeyframeDataCache::removeKeyframeData(floaterp->mMotionID); } floaterp->close(false); }