//----------------------------------------------------------------------------- // 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); }
//----------------------------------------------------------------------------- // 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); }
void LLPreviewAnim::dupliAnim( void *userdata ) { LLPreviewAnim* self = (LLPreviewAnim*) userdata; //if(!self->childGetValue("Anim play btn").asBoolean()) //{ // printchat("anim must be playing to copy by this method; please try again"); // LLPreviewAnim::playAnim( userdata ); // return; //} const LLInventoryItem *item = self->getItem(); if(item) { if(self->mAnimBuffer == NULL) { return; } LLKeyframeMotion* motionp = NULL; //LLBVHLoader* loaderp = NULL; LLAssetID xMotionID; LLTransactionID xTransactionID; // generate unique id for this motion xTransactionID.generate(); xMotionID = xTransactionID.makeAssetID(gAgent.getSecureSessionID()); motionp = (LLKeyframeMotion*)gAgent.getAvatarObject()->createMotion(xMotionID); /* // pass animation data through memory buffer //loaderp->serialize(dp); gAgent.getAvatarObject()->startMotion(item->getAssetUUID()); LLVOAvatar* avatar = gAgent.getAvatarObject(); LLMotion* motion = avatar->findMotion(item->getAssetUUID()); LLKeyframeMotion* tmp = (LLKeyframeMotion*)motion; S32 file_size = tmp->getFileSize(); U8* buffer = new U8[file_size]; LLDataPackerBinaryBuffer dp(buffer, file_size);*/ LLDataPackerBinaryBuffer dp(self->mAnimBuffer, self->mAnimBufferSize); LLVOAvatar* avatar = gAgent.getAvatarObject(); LLMotion* motion = avatar->findMotion(item->getAssetUUID()); LLKeyframeMotion* tmp = (LLKeyframeMotion*)motion; tmp->serialize(dp); dp.reset(); BOOL success = motionp && motionp->deserialize(dp); //delete []buffer; if (success) { motionp->setName(item->getName()); gAgent.getAvatarObject()->startMotion(xMotionID); //////////////////////////////////////////////////////////////////// /*LLKeyframeMotion* */motionp = (LLKeyframeMotion*)gAgent.getAvatarObject()->findMotion(xMotionID); 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 = item->getName(); std::string desc = item->getDescription(); upload_new_resource(xTransactionID, // tid LLAssetType::AT_ANIMATION, name, desc, 0, LLAssetType::AT_NONE, LLInventoryType::IT_ANIMATION, PERM_NONE,PERM_NONE,PERM_NONE, name,0,10,0); } else { llwarns << "Failure writing animation data." << llendl; LLNotifications::instance().add("WriteAnimationFail"); } } delete [] buffer; // clear out cache for motion data gAgent.getAvatarObject()->removeMotion(xMotionID); LLKeyframeDataCache::removeKeyframeData(xMotionID); //////////////////////////////////////////////////////////////////// } } }
//----------------------------------------------------------------------------- // 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); }
//----------------------------------------------------------------------------- // 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); }