//-----------------------------------------------------------------------------
// LLKeyframeMotionParam::onInitialize(LLCharacter *character)
//-----------------------------------------------------------------------------
LLMotion::LLMotionInitStatus LLKeyframeMotionParam::onInitialize(LLCharacter *character)
{
	mCharacter = character;

	if (!loadMotions())
	{
		return STATUS_FAILURE;	
	}
	
	for (motion_map_t::iterator iter = mParameterizedMotions.begin();
		 iter != mParameterizedMotions.end(); ++iter)
	{
		motion_list_t& motionList = iter->second;
		for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
		{
			const ParameterizedMotion& paramMotion = *iter2;
			LLMotion* motion = paramMotion.mMotion;
			motion->onInitialize(character);

			// <FS> Fix copy paste error
			//if (motion->getDuration() > mEaseInDuration)
			if (motion->getEaseInDuration() > mEaseInDuration)
			// </FS>
			{
				mEaseInDuration = motion->getEaseInDuration();
			}

			if (motion->getEaseOutDuration() > mEaseOutDuration)
			{
				mEaseOutDuration = motion->getEaseOutDuration();
			}

			if (motion->getDuration() > mDuration)
			{
				mDuration = motion->getDuration();
			}

			if (motion->getPriority() > mPriority)
			{
				mPriority = motion->getPriority();
			}

			LLPose *pose = motion->getPose();

			mPoseBlender.addMotion(motion);
			for (LLJointState *jsp = pose->getFirstJointState(); jsp; jsp = pose->getNextJointState())
			{
				LLPose *blendedPose = mPoseBlender.getBlendedPose();
				blendedPose->addJointState(jsp);
			}
		}
	}

	return STATUS_SUCCESS;
}
Esempio n. 2
0
//========
// 初期化
//========
bool cMMDChar::initialize( void )
{
	if( !loadMotions() )
	{
		return false;
	}

	srand( (unsigned int)time( NULL ) );

	return true;
}
void PATransitionCreator::setInfo(bool isCreateMode, const std::string& stateName)
{
	if (isCreateMode)
	{
		inputStateName->value(getUniqueStateName("state").c_str());
		inputStateName->activate();
		buttonCreateState->label(strdup("Create State"));
	}
	else
	{
		inputStateName->value(stateName.c_str());
		inputStateName->deactivate();
		buttonCreateState->label(strdup("Save Changes"));
	}

	loadMotions();
	if (!isCreateMode)
	{
		SmartBody::SBAnimationBlendManager* stateManager = SmartBody::SBScene::getScene()->getBlendManager();
		SmartBody::SBAnimationBlend* state = stateManager->getBlend(stateName);
		if (!state)
		{
			fl_alert("State %s does not exist.", stateName.c_str());
			cancelState(this, NULL);
			return;
		}
		std::vector<SmartBody::SBMotion*>& motions = state->motions;
		for (std::vector<SmartBody::SBMotion*>::iterator iter = motions.begin();
			 iter != motions.end();
			 iter++)
		{
			stateAnimationList->add((*iter)->getName().c_str());
		}


		SmartBody::SBAnimationBlend0D* state0d = dynamic_cast<SmartBody::SBAnimationBlend0D*>(state);
		if (state0d)
			choiceStateType->value(0);
		SmartBody::SBAnimationBlend1D* state1d = dynamic_cast<SmartBody::SBAnimationBlend1D*>(state);
		if (state1d)
			choiceStateType->value(1);
		SmartBody::SBAnimationBlend2D* state2d = dynamic_cast<SmartBody::SBAnimationBlend2D*>(state);
		if (state2d)
			choiceStateType->value(2);
		SmartBody::SBAnimationBlend3D* state3d = dynamic_cast<SmartBody::SBAnimationBlend3D*>(state);
		if (state3d)
			choiceStateType->value(3);


	}
}