本文整理汇总了C++中LLMotion类的典型用法代码示例。如果您正苦于以下问题:C++ LLMotion类的具体用法?C++ LLMotion怎么用?C++ LLMotion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LLMotion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findMotion
//-----------------------------------------------------------------------------
// stopMotionLocally()
//-----------------------------------------------------------------------------
BOOL LLMotionController::stopMotionLocally(const LLUUID &id, BOOL stop_immediate)
{
// if already inactive, return false
LLMotion *motion = findMotion(id);
if (!motion)
{
return FALSE;
}
// If on active list, stop it
if (isMotionActive(motion) && !motion->isStopped())
{
// when using timesteps, set stop time to last frame's time, otherwise grab current timer value
// *FIX: should investigate this inconsistency...hints of obscure bugs
F32 stop_time = (mTimeStep != 0.f || mPaused) ? (mTime) : mTimeOffset + (mTimer.getElapsedTimeF32() * mTimeFactor);
motion->setStopTime(stop_time);
if (stop_immediate)
{
deactivateMotion(motion, false);
}
return TRUE;
}
else if (isMotionLoading(motion))
{
motion->setStopped(TRUE);
return TRUE;
}
return FALSE;
}
示例2: createMotion
//-----------------------------------------------------------------------------
// startMotion()
//-----------------------------------------------------------------------------
BOOL LLMotionController::startMotion(const LLUUID &id, F32 start_offset)
{
// look for motion in our list of created motions
LLMotion *motion = createMotion(id);
if (!motion)
{
return FALSE;
}
//if the motion is already active, then we're done
else if (isMotionActive(motion)) // motion is playing and...
{
if (motion->isStopped()) // motion has been stopped
{
deactivateMotion(motion, false);
}
else if (mTime < motion->mSendStopTimestamp) // motion is still active
{
return TRUE;
}
}
// llinfos << "Starting motion " << name << llendl;
return activateMotion(motion, mTime - start_offset);
}
示例3: auditionAnim
// static
void LLPreviewAnim::auditionAnim( void *userdata )
{
LLPreviewAnim* self = (LLPreviewAnim*) userdata;
const LLInventoryItem *item = self->getItem();
if(item)
{
LLUUID itemID=item->getAssetUUID();
LLButton* btn = self->getChild<LLButton>("Anim audition btn");
if (btn)
{
btn->toggleState();
}
if (self->childGetValue("Anim audition btn").asBoolean() )
{
self->mPauseRequest = NULL;
gAgent.getAvatarObject()->startMotion(item->getAssetUUID());
LLVOAvatar* avatar = gAgent.getAvatarObject();
LLMotion* motion = avatar->findMotion(itemID);
if (motion)
{
motion->setDeactivateCallback(&endAnimCallback, (void *)(new LLHandle<LLFloater>(self->getHandle())));
}
}
else
{
gAgent.getAvatarObject()->stopMotion(itemID);
gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_STOP);
}
}
}
示例4: onSliderMove
//-----------------------------------------------------------------------------
// 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();
}
示例5: flushAllMotions
//-----------------------------------------------------------------------------
// flushAllMotions()
//-----------------------------------------------------------------------------
void LLMotionController::flushAllMotions()
{
std::vector<std::pair<LLUUID,F32> > active_motions;
active_motions.reserve(mActiveMotions.size());
for (motion_list_t::iterator iter = mActiveMotions.begin();
iter != mActiveMotions.end(); )
{
motion_list_t::iterator curiter = iter++;
LLMotion* motionp = *curiter;
F32 dtime = mAnimTime - motionp->mActivationTimestamp;
active_motions.push_back(std::make_pair(motionp->getID(),dtime));
motionp->deactivate(); // don't call deactivateMotionInstance() because we are going to reactivate it
}
mActiveMotions.clear();
// delete all motion instances
deleteAllMotions();
// kill current hand pose that was previously called out by
// keyframe motion
mCharacter->removeAnimationData("Hand Pose");
// restart motions
for (std::vector<std::pair<LLUUID,F32> >::iterator iter = active_motions.begin();
iter != active_motions.end(); ++iter)
{
startMotion(iter->first, iter->second);
}
}
示例6: pauseAllSyncedCharacters
void LLMotionController::pauseAllSyncedCharacters(std::vector<LLAnimPauseRequest>& avatar_pause_handles)
{
// Run over all motions.
for (motion_list_t::iterator iter = mActiveMotions.begin(); iter != mActiveMotions.end(); ++iter)
{
LLMotion* motionp = *iter;
AISyncServer* server = motionp->server();
if (server && !server->never_synced() && motionp->isActive()) // Skip motions that aren't synchronized at all or that are not active.
{
// Run over all clients of the found servers.
AISyncServer::client_list_t const& clients = server->getClients();
for (AISyncServer::client_list_t::const_iterator client = clients.begin(); client != clients.end(); ++client)
{
LLMotion* motion = dynamic_cast<LLMotion*>(client->mClientPtr);
if (!motion)
{
continue;
}
LLMotionController* controller = motion->getController();
if (controller == this)
{
continue;
}
controller->requestPause(avatar_pause_handles);
}
}
}
}
示例7: deactivateAllMotions
//-----------------------------------------------------------------------------
// deactivateAllMotions()
//-----------------------------------------------------------------------------
void LLMotionController::deactivateAllMotions()
{
//They must all die, precious.
for (std::map<LLUUID, LLMotion*>::iterator iter = mAllMotions.begin();
iter != mAllMotions.end(); iter++)
{
LLMotion* motionp = iter->second;
if (motionp) motionp->deactivate();
}
// delete all motion instances
deleteAllMotions();
}
示例8: invisible
//<singu>
//-----------------------------------------------------------------------------
// toggle_hidden()
//-----------------------------------------------------------------------------
void LLMotionController::toggle_hidden(void)
{
mHaveVisibleSyncedMotions = mHidden; // Default is false if we just became invisible (otherwise this value isn't used).
mHidden = !mHidden;
synceventset_t const visible = mHidden ? 0 : 4;
// Run over all motions.
for (motion_list_t::iterator iter = mActiveMotions.begin(); iter != mActiveMotions.end(); ++iter)
{
LLMotion* motionp = *iter;
AISyncServer* server = motionp->server();
if (server && !server->never_synced() && motionp->isActive()) // Skip motions that aren't synchronized at all or that are not active.
{
bool visible_before = server->events_with_at_least_one_client_ready() & 4;
server->ready(4, visible, motionp); // Mark that now we are visible or no longer visible.
bool visible_after = server->events_with_at_least_one_client_ready() & 4;
if (visible_after) // Are there any synchronized motions (left) that ARE visible?
{
mHaveVisibleSyncedMotions = true;
}
if (visible_before != visible_after)
{
// The group as a whole now might need to change whether or not it is animated.
AISyncServer::client_list_t const& clients = server->getClients();
for (AISyncServer::client_list_t::const_iterator client = clients.begin(); client != clients.end(); ++client)
{
LLMotion* motion = dynamic_cast<LLMotion*>(client->mClientPtr);
if (!motion)
{
continue;
}
LLMotionController* controller = motion->getController();
if (controller == this)
{
continue;
}
if (visible_after)
{
// Us becoming visible means that all synchronized avatars need to be animated again too.
controller->setHaveVisibleSyncedMotions();
}
else
{
// Us becoming hidden means that all synchronized avatars might stop animating.
controller->refresh_hidden(); // It is extremely unlikely, but harmless, to call this twice on the same controller.
}
}
}
}
}
}
示例9: deactivateStoppedMotions
//-----------------------------------------------------------------------------
// deactivateStoppedMotions()
//-----------------------------------------------------------------------------
void LLMotionController::deactivateStoppedMotions()
{
// Since we're hidden, deactivate any stopped motions.
for (motion_list_t::iterator iter = mActiveMotions.begin();
iter != mActiveMotions.end(); )
{
motion_list_t::iterator curiter = iter++;
LLMotion* motionp = *curiter;
if (motionp->isStopped())
{
deactivateMotionInstance(motionp);
}
}
}
示例10: activateMotionInstance
//-----------------------------------------------------------------------------
// updateLoadingMotions()
//-----------------------------------------------------------------------------
void LLMotionController::updateLoadingMotions()
{
// query pending motions for completion
for (motion_set_t::iterator iter = mLoadingMotions.begin();
iter != mLoadingMotions.end(); )
{
motion_set_t::iterator curiter = iter++;
LLMotion* motionp = *curiter;
if( !motionp)
{
continue; // maybe shouldn't happen but i've seen it -MG
}
LLMotion::LLMotionInitStatus status = motionp->onInitialize(mCharacter);
if (status == LLMotion::STATUS_SUCCESS)
{
mLoadingMotions.erase(curiter);
// add motion to our loaded motion list
mLoadedMotions.insert(motionp);
// this motion should be playing
if (!motionp->isStopped())
{
//<singu>
F32 start_time = mAnimTime;
if (!mDisableSyncing)
{
motionp->aisync_loaded();
start_time = motionp->syncActivationTime(start_time);
}
++mDisableSyncing;
//</singu>
activateMotionInstance(motionp, start_time);
//<singu>
--mDisableSyncing;
//</singu>
}
}
else if (status == LLMotion::STATUS_FAILURE)
{
llinfos << "Motion " << motionp->getID() << " init failed." << llendl;
sRegistry.markBad(motionp->getID());
mLoadingMotions.erase(curiter);
// Singu note: a motion in mLoadingMotions will not be in mActiveMotions
// and therefore not be in mDeprecatedMotions. So, we don't have to
// check for it's existence there.
llassert(mDeprecatedMotions.find(motionp) == mDeprecatedMotions.end());
mAllMotions.erase(motionp->getID());
//<singu>
// Make sure we're not registered anymore.
motionp->unregister_client();
//</singu>
delete motionp;
}
}
}
示例11: mt
//-----------------------------------------------------------------------------
// createMotion()
//-----------------------------------------------------------------------------
LLMotion* LLMotionController::createMotion( const LLUUID &id )
{
LLMemType mt(LLMemType::MTYPE_ANIMATION);
// do we have an instance of this motion for this character?
LLMotion *motion = findMotion(id);
// if not, we need to create one
if (!motion)
{
// look up constructor and create it
motion = sRegistry.createMotion(id);
if (!motion)
{
return NULL;
}
// look up name for default motions
const char* motion_name = gAnimLibrary.animStateToString(id);
if (motion_name)
{
motion->setName(motion_name);
}
// initialize the new instance
LLMotion::LLMotionInitStatus stat = motion->onInitialize(mCharacter);
switch(stat)
{
case LLMotion::STATUS_FAILURE:
llinfos << "Motion " << id << " init failed." << llendl;
sRegistry.markBad(id);
delete motion;
return NULL;
case LLMotion::STATUS_HOLD:
mLoadingMotions.insert(motion);
break;
case LLMotion::STATUS_SUCCESS:
// add motion to our list
mLoadedMotions.insert(motion);
break;
default:
llerrs << "Invalid initialization status" << llendl;
break;
}
mAllMotions[id] = motion;
}
return motion;
}
示例12: addKeyframeMotion
//-----------------------------------------------------------------------------
// LLKeyframeMotionParam::addKeyframeMotion()
//-----------------------------------------------------------------------------
BOOL LLKeyframeMotionParam::addKeyframeMotion(char *name, const LLUUID &id, char *param, F32 value)
{
LLMotion *newMotion = mCharacter->createMotion( id );
if (!newMotion)
{
return FALSE;
}
newMotion->setName(name);
// now add motion to this list
mParameterizedMotions[param].insert(ParameterizedMotion(newMotion, value));
return TRUE;
}
示例13: getItem
void LLPreviewAnim::onClose(bool app_quitting)
{
const LLInventoryItem *item = getItem();
if(item)
{
gAgentAvatarp->stopMotion(item->getAssetUUID());
gAgent.sendAnimationRequest(item->getAssetUUID(), ANIM_REQUEST_STOP);
LLMotion* motion = gAgentAvatarp->findMotion(item->getAssetUUID());
if (motion)
{
// *TODO: minor memory leak here, user data is never deleted (Use real callbacks)
motion->setDeactivateCallback(NULL, (void *)NULL);
}
}
destroy();
}
示例14: refresh_hidden
void LLMotionController::refresh_hidden(void)
{
mHaveVisibleSyncedMotions = !mHidden;
// Run over all motions.
for (motion_list_t::iterator iter = mActiveMotions.begin(); iter != mActiveMotions.end(); ++iter)
{
LLMotion* motionp = *iter;
AISyncServer* server = motionp->server();
if (server && !server->never_synced() && motionp->isActive()) // Skip motions that aren't synchronized at all or that are not active.
{
bool visible_after = server->events_with_at_least_one_client_ready() & 4;
if (visible_after) // Are there any synchronized motions (left) that ARE visible?
{
mHaveVisibleSyncedMotions = true;
}
}
}
}
示例15: setTimeStep
//-----------------------------------------------------------------------------
// setTimeStep()
//-----------------------------------------------------------------------------
void LLMotionController::setTimeStep(F32 step)
{
mTimeStep = step;
if (step != 0.f)
{
// make sure timestamps conform to new quantum
for (motion_list_t::iterator iter = mActiveMotions.begin();
iter != mActiveMotions.end(); ++iter)
{
LLMotion* motionp = *iter;
motionp->mActivationTimestamp = (F32)llfloor(motionp->mActivationTimestamp / step) * step;
BOOL stopped = motionp->isStopped();
motionp->setStopTime((F32)llfloor(motionp->getStopTime() / step) * step);
motionp->setStopped(stopped);
motionp->mSendStopTimestamp = (F32)llfloor(motionp->mSendStopTimestamp / step) * step;
}
}
}