예제 #1
0
int16 ScriptFunctions::sfGetAnimFrameCount(int16 argc, int16 *argv) {
	int16 frameCount = 0;
	AnimationResource *anim = _vm->_res->getAnimation(argv[0]);
	if (anim) {
		frameCount = anim->getCount();
		_vm->_res->freeResource(anim);
	}
	return frameCount;
}
예제 #2
0
void Screen::drawAnimFrame(uint16 animIndex, int16 x, int16 y, int16 frameNum, int16 flipX, int16 flipY, const ClipInfo &clipInfo) {

	if (frameNum < 0)
		return;

	AnimationResource *anim = _vm->_res->getAnimation(animIndex);
	Graphics::Surface *sourceSurface = anim->getFrame(frameNum);

	drawSurface(sourceSurface, x, y, flipX, flipY, 0, clipInfo);

	_vm->_res->freeResource(anim);
}
예제 #3
0
uint16 Screen::placeAnim(uint16 channelIndex, uint16 animIndex, int16 x, int16 y, int16 frameNum) {

	if (channelIndex < 1 || channelIndex >= 100)
		return 0;

	channelIndex--;

	AnimationResource *anim = _vm->_res->getAnimation(animIndex);

	if (anim) {

		int16 state = 1;
		/*int16 x1, y1, x2, y2;

		x1 = x;
		y1 = y;
		x2 = x + anim->getWidth();
		y2 = y + anim->getHeight();*/

		if (anim->getFlags() == 1 || _ground == 0)
			state |= 2;
		if (_clip != 0)
			state |= 4;
		if (_exclude != 0)
			state |= 8;

		_channels[channelIndex].state = state;
		_channels[channelIndex].type = 3;
		_channels[channelIndex].index = animIndex;
		_channels[channelIndex].frameNum = frameNum;
		_channels[channelIndex].x = x;
		_channels[channelIndex].y = y;

		if (_channelsUsedCount <= channelIndex)
			_channelsUsedCount = channelIndex + 1;

		_vm->_res->freeResource(anim);
	} else {
		_channels[channelIndex].type = 0;
		_channels[channelIndex].state = 0;
	}

	return channelIndex + 1;

}
예제 #4
0
void AnimationController::mapAnimRes( uint32 node, uint32 stage )
{
	static std::string maskStart, maskEnd;
	
	_dirty = true;
	
	AnimationResource *animRes = _animStages[stage].anim;
	if( animRes == 0x0 )
	{	
		_nodeList[node].animEntities[stage] = 0x0;
		return;
	}

	// Animation mask
	bool includeNode = true;

	if( _animStages[stage].startNodeNameId != 0 )
	{
		includeNode = false;
		
		IAnimatableNode *animNode = _nodeList[node].node;
		while( animNode != 0x0 )
		{
			if( hashName( animNode->getANName().c_str() ) == _animStages[stage].startNodeNameId )
			{
				includeNode = true;
				break;
			}
			animNode = animNode->getANParent();
		}
	}
	
	// Find node in animation resource if not masked out
	if( includeNode )
	{
		uint32 nameId = hashName( _nodeList[node].node->getANName().c_str() );
		_nodeList[node].animEntities[stage] = animRes->findEntity( nameId );
	}
	else
	{
		_nodeList[node].animEntities[stage] = 0x0;
	}
}
예제 #5
0
void ModelNode::updateStageAnimations( uint32 stage, const string &startNode )
{
	AnimationResource *anim = _animStages[stage]->anim;
	if( anim == 0x0 )
	{	
		for( size_t i = 0, s = _nodeList.size(); i < s; ++i ) 
		{
			_nodeList[i].animEntities[stage] = 0x0;
		}
		
		return;
	}

	// Find animation resource entries for nodes
	for( size_t i = 0, s = _nodeList.size(); i < s; ++i )
	{
		bool includeNode = true;
		
		if( startNode != "" )
		{
			includeNode = false;
			
			SceneNode *node = _nodeList[i].node;
			while( node->getType() != SceneNodeTypes::Model )
			{
				if( node->getName() == startNode )
				{
					includeNode = true;
					break;
				}
				node = node->getParent();
			}
		}
		
		if( includeNode )
			_nodeList[i].animEntities[stage] = anim->findEntity( _nodeList[i].node->getParamstr( SceneNodeParams::Name ) );
		else
			_nodeList[i].animEntities[stage] = 0x0;
	}
}
void ResourceManager::LoadResources(xml_node<>* resList, ZipArchive* pZip)
{
	xml_node<>* child;

	if (!resList)
		return;

	child = resList->first_node("resource");
	while (child != NULL)
	{
		xml_attribute<>* attr = child->first_attribute("type");
		if (!attr)
			break;

		std::string type = attr->value();

		if (type == "font")
		{
			FontResource* res = new FontResource(child, pZip);
			if (res == NULL || res->GetResource() == NULL)
			{
				xml_attribute<>* attr_name = child->first_attribute("name");

				if (!attr_name) {
					std::string res_name = attr_name->value();
					LOGERR("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
				} else
					LOGERR("Resource type (%s) failed to load\n", type.c_str());

				delete res;
			}
			else
			{
				mResources.push_back((Resource*) res);
			}
		}
		else if (type == "image")
		{
			ImageResource* res = new ImageResource(child, pZip);
			if (res == NULL || res->GetResource() == NULL)
			{
				xml_attribute<>* attr_name = child->first_attribute("name");

				if (!attr_name) {
					std::string res_name = attr_name->value();
					LOGERR("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
				} else
					LOGERR("Resource type (%s) failed to load\n", type.c_str());

				delete res;
			}
			else
			{
				mResources.push_back((Resource*) res);
			}
		}
		else if (type == "animation")
		{
			AnimationResource* res = new AnimationResource(child, pZip);
			if (res == NULL || res->GetResource() == NULL)
			{
				xml_attribute<>* attr_name = child->first_attribute("name");

				if (!attr_name) {
					std::string res_name = attr_name->value();
					LOGERR("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
				} else
					LOGERR("Resource type (%s) failed to load\n", type.c_str());

				delete res;
			}
			else
			{
				mResources.push_back((Resource*) res);
			}
		}
		else
		{
			LOGERR("Resource type (%s) not supported.\n", type.c_str());
		}

		child = child->next_sibling("resource");
	}
}