Example #1
0
void XMLizer::readParameter( QDomElement &element, QSharedPointer<Filter> f )
{
	QString type = element.attribute( "type" );
	QString name = element.attribute( "name" );
	QString value = element.attribute( "value" );
	QString hue;
	QString saturation;
	
	if ( type.isEmpty() || name.isEmpty() || value.isEmpty() )
		return;
	
	if ( type == "colorwheel" ) {
		hue = element.attribute( "hue" );
		saturation = element.attribute( "saturation" );
		if ( hue.isEmpty() || saturation.isEmpty() )
			return;
	}
	
	Parameter *p = NULL;
	QList<Parameter*> params = f->getParameters();
	for ( int i = 0; i < params.count(); ++i ) {
		if ( params[ i ]->id == name ) {
			p = params[ i ];
			break;
		}
	}
	
	if ( !p )
		return;
	
	if ( type == "double" ) {
		if ( p->type != Parameter::PDOUBLE )
			return;
		p->value = value.toDouble();
	}
	else if ( type == "inputdouble" ) {
		if ( p->type != Parameter::PINPUTDOUBLE )
			return;
		p->value = value.toDouble();
	}
	else if ( type == "int" ) {
		if ( p->type != Parameter::PINT )
			return;
		p->value = value.toInt();
	}
	else if ( type == "bool" ) {
		if ( p->type != Parameter::PBOOL )
			return;
		p->value = value.toInt();
	}
	else if ( type == "rgb" ) {
		if ( p->type != Parameter::PRGBCOLOR )
			return;
		QColor col;
		col.setNamedColor( value );
		p->value = col;
	}
	else if ( type == "rgba" ) {
		if ( p->type != Parameter::PRGBACOLOR )
			return;
		QStringList sl = value.split( "." );
		if ( sl.count() != 2 )
			return;
		QColor col;
		col.setNamedColor( sl[ 0 ] );
		col.setAlpha( sl[ 1 ].toInt() );
		p->value = col;
	}
	else if ( type == "colorwheel" ) {
		if ( p->type != Parameter::PCOLORWHEEL )
			return;
		QColor col;
		col.setRgbF( hue.toDouble(), saturation.toDouble(), value.toDouble() );
		p->value = col;
	}
	else if ( type == "string" ) {
		if ( p->type != Parameter::PSTRING )
			return;
		p->value = value.replace( QString::fromUtf8("ΒΆ"), "\n" );
	}
	else if ( type == "shader" ) {
		if ( p->type != Parameter::PSHADEREDIT )
			return;
		p->value = value;
	}
	
	p->graph.keys.clear();
		
	QDomNodeList nodes = element.childNodes();
	for ( int i = 0; i < nodes.count(); ++i ) {
		QDomElement e = nodes.at( i ).toElement();
		if ( e.isNull() )
			continue;
		
		if ( e.tagName() == "Key" ) {
			QString ktype = e.attribute( "type" );
			QString kposition = e.attribute( "position" );
			QString kvalue = e.attribute( "value" );
			
			if ( ktype.isEmpty() || kposition.isEmpty() || kvalue.isEmpty() )
				continue;
			
			int animType = AnimationKey::LINEAR;
			if ( ktype == "constant" )
				animType = AnimationKey::CONSTANT;
			if ( ktype == "curve" )
				animType = AnimationKey::CURVE;
			
			double x = kposition.toDouble();
			if ( x > 1 || x < 0 )
				continue;
			double y = kvalue.toDouble();
			if ( y > p->max.toDouble() || y < p->min.toDouble() )
				continue;
			
			int j;
			for ( j = 0; j < p->graph.keys.count(); ++j ) {
				if ( x < p->graph.keys[ j ].x )
					break;
			}
			p->graph.keys.insert( j, AnimationKey( animType, x, p->getNormalizedKeyValue( y ) ) );
		}
	}
}
Example #2
0
void SEQFile::load(Common::SeekableReadStream &seq) {
	const uint16 decCount = (uint16)seq.readByte() + 1;
	const uint16 aniCount = (uint16)seq.readByte() + 1;

	// Load backgrounds
	_backgrounds.reserve(decCount);
	for (uint i = 0; i < decCount; i++) {
		const Common::String dec = Util::readString(seq, 13);

		if (!_vm->_dataIO->hasFile(dec)) {
			warning("SEQFile::load(): No such background \"%s\"", dec.c_str());
			return;
		}

		_backgrounds.push_back(new DECFile(_vm, dec, 320, 200));
	}

	// Load animations
	_animations.reserve(aniCount);
	for (uint i = 0; i < aniCount; i++) {
		const Common::String ani = Util::readString(seq, 13);

		if (!_vm->_dataIO->hasFile(ani)) {
			warning("SEQFile::load(): No such animation \"%s\"", ani.c_str());
			return;
		}

		_animations.push_back(new ANIFile(_vm, ani));
	}

	_frameRate = seq.readUint16LE();

	// Load background change keys

	const uint16 bgKeyCount = seq.readUint16LE();
	_bgKeys.resize(bgKeyCount);

	for (uint16 i = 0; i < bgKeyCount; i++) {
		const uint16 frame = seq.readUint16LE();
		const uint16 index = seq.readUint16LE();

		_bgKeys[i].frame      = frame;
		_bgKeys[i].background = index < _backgrounds.size() ? _backgrounds[index] : 0;
	}

	// Load animation keys for all 4 objects

	for (uint i = 0; i < kObjectCount; i++) {
		const uint16 animKeyCount = seq.readUint16LE();
		_animKeys.reserve(_animKeys.size() + animKeyCount);

		for (uint16 j = 0; j < animKeyCount; j++) {
			_animKeys.push_back(AnimationKey());

			const uint16 frame = seq.readUint16LE();
			const uint16 index = seq.readUint16LE();

			uint16 animation;
			const ANIFile *ani = findANI(index, animation);

			_animKeys.back().object    = i;
			_animKeys.back().frame     = frame;
			_animKeys.back().ani       = ani;
			_animKeys.back().animation = animation;
			_animKeys.back().x         = seq.readSint16LE();
			_animKeys.back().y         = seq.readSint16LE();
			_animKeys.back().order     = seq.readSint16LE();
		}
	}

}
Example #3
0
void Exporter::addBoneKey(int index, int time, const FBMatrix &transform)
{
	assert(static_cast<unsigned int> (index) <= boneKeys.size());
	boneKeys[index].push_back(AnimationKey(time, transform));
}