Ejemplo n.º 1
0
void PowerupHeal::load(const PropertyBag &xml)
{
	Powerup::load(xml);

	xml.get("healValue", healValue);
	xml.get("healTime", healTime);
}
Ejemplo n.º 2
0
void GateOpener::load(const PropertyBag &xml)
{
	Listener::load(xml);

	xml.get("gateName", gateName);
	xml.get("open", open);
}
Ejemplo n.º 3
0
AnimationController* _3dsLoader::loadFromFile(const string &fileName) const
{
	PropertyBag xml;
	bool truespaceModel = false;
	string skin;

	TRACE(string("Loading 3DS model from \"") + fileName + string("\""));
	
	xml.loadFromFile(fileName);

	AnimationController* controller = new AnimationController();

	xml.get_optional("Truespace", truespaceModel);
	xml.get_optional("forceSkin", skin);

	for(size_t i=0, numAnimations=xml.count("animation"); i<numAnimations; ++i)
	{
		PropertyBag animation;
		string name;
		float fps = 0.0;
		bool looping = false;
		float priority = 0.0f;

		xml.get("animation", animation, i);

		animation.get("name", name);
		animation.get_optional("fps", fps);
		animation.get_optional("looping", looping);
		animation.get_optional("priority", priority);

		// Load all the keyframes
		vector<KeyFrame> keyFrames;
		const size_t length=animation.count("keyframe");
		for(size_t j=0; j<length; ++j)
		{
			string keyFrameFile;

			animation.get("keyframe", keyFrameFile, j);

			Model keyFrame = loadKeyFrame(keyFrameFile);

			cullDegenerateMeshes(keyFrame);

			if(!skin.empty()) forceSkin(keyFrame, skin);

			if(truespaceModel) fixTrueSpaceVertices(keyFrame);

			keyFrames.push_back(keyFrame);
		}

		TRACE(string("Adding 3DS animation \"") + name + string("\" from ") + fileName);

		// Add it to the controller
		AnimationSequence animationSequence(keyFrames, name, priority, looping, 0, length, fps);
		controller->addAnimation(animationSequence);
	}

	return controller;
}
Ejemplo n.º 4
0
void Spawn::load(const PropertyBag &xml)
{
	Listener::load(xml);

	xml.get("monsterDataFile", monsterDataFile);
	xml.get("minMonsters", minMonsters);
	xml.get("maxMonsters", maxMonsters);
	xml.get("separationDistance", separationDistance);
}
Ejemplo n.º 5
0
void ComponentBrainShooter::load(const PropertyBag &data)
{
	resetMembers();

	data.get("fov", fov); // optional tag
	data.get("maxSightDistance", maxSightDistance); // optional tag
	data.get("shootDistance", shootDistance); // optional tag

	wanderAngle = FRAND_RANGE(0.0f, 2.0f * (float)M_PI);
}
Ejemplo n.º 6
0
void ComponentPhysicsGeom::load(const PropertyBag &data)
{
	resetMembers();

	desiredHeight = data.getFloat("height");
	collisionRadius = data.getFloat("radius");

	// Create as physics geometry
	if(geom){dGeomDestroy(geom);} geom=0;
	createGeom(data.getString("physicsGeometryType"));

	// Set initial position
	{
		vec3 position;
		if(data.get("position", position)) // optional tag
		{
			setPosition(position);
		}
	}

	// Declare the initial state
	getParentBlackBoard().relayMessage(MessagePositionHasBeenSet(getPosition()));
	getParentBlackBoard().relayMessage(MessageOrientationHasBeenSet(getOrientation()));
	getParentBlackBoard().relayMessage(MessageRequestSetHeight(desiredHeight));
}
Ejemplo n.º 7
0
void ActorSet::load(const PropertyBag &objects, World *_world)
{
	ASSERT(_world!=0, "world was null");
	world = _world;

	for(size_t i=0, n=objects.getNumInstances("object"); i<n; ++i)
	{
		const tuple<OBJECT_ID, ActorPtr> t = create();
		const ActorPtr object = t.get<1>();

		const PropertyBag decl = objects.getBag("object", i);
		const FileName templateFile = decl.getFileName("template");
		const vec3 initialPosition = decl.getVec3("position");
		const PropertyBag templateData = PropertyBag::fromFile(templateFile);
		const PropertyBag base = templateData.getBag("components");

		ComponentDataSet s = ComponentDataSet::load(base, decl);

		// get actor name
		object->actorName = "(no name)";
		templateData.get("name", object->actorName);

		object->load(s, initialPosition, vec3(0,0,0), world);
		object->setParentBlackBoard(this);
	}
}
Ejemplo n.º 8
0
void ComponentRenderAsModel::load(const PropertyBag &data)
{
	resetMembers();
	const FileName modelFileName = data.getFileName("model");
	loadModel(modelFileName);
	data.get("independentModelOrientation", independentModelOrientation);
}
Ejemplo n.º 9
0
void TriggerParticles::load(const PropertyBag &xml)
{
	Trigger::load(xml);

	xml.get("pfxFileName", pfxFileName);
	xml.get("pfxLocation", pfxLocation);

	showModel = false;
}
Ejemplo n.º 10
0
void ComponentHealth::load(const PropertyBag &data)
{
    resetMembers();
    health = data.getInt("health");
    maxHealth = data.getInt("maxHealth");
    damageToPowerRatio = data.getFloat("damageToPowerRatio");
    willResurrectAfterCountDown = data.getBool("willResurrectAfterCountDown");
    timeUntilResurrection = data.getFloat("timeUntilResurrection");

    data.get("displayPower", displayPower); // optional tag
}
Ejemplo n.º 11
0
void Trigger::load(const PropertyBag &xml)
{
	Actor::load(xml);

	loadList(xml, "sounds", sounds);

	if(xml.exists("triggerRadius")) {
		xml.get("triggerRadius", triggerRadius);
	} else {
		triggerRadius = getCylinderRadius(); // default
	}
}
Ejemplo n.º 12
0
bool Light::fromXml(PropertyBag &xml)
{
	destroy();

	xml.get("constantAttenuation", constantAttenuation);
	xml.get("linearAttenuation", linearAttenuation);
	xml.get("quadraticAttenuation", quadraticAttenuation);
	xml.get("lightPosition", lightPosition);;
	xml.get("pointLight", pointLight);
	xml.get("lightDirection", lightDirection);
	xml.get("spotAngle", spotAngle);
	xml.get("spotExponent", spotExponent);
	xml.get("enable", enable);

	calculateMatrices();

    return true;
}
Ejemplo n.º 13
0
void SpellFireBall::load(PropertyBag &xml, Engine::World *zone, Engine::OBJECT_ID ownerID)
{
	Spell::load(xml, zone, ownerID);

	xml.get("damageValue", damageValue);
	xml.get("bulletSpeed", bulletSpeed);
	xml.get("particleFile", particleFile);
	xml.get("explosionParticleFile", explosionParticleFile);
	xml.get("explosionSoundEffectFile", explosionSoundEffectFile);
	xml.get("causesFreeze", causesFreeze);
	xml.get("knockbackMagnitude", knockbackMagnitude);
	xml.get("height", height);
}
Ejemplo n.º 14
0
void ActorSet::load(const PropertyBag &xml, World *world)
{
	ASSERT(world!=0, "world was null");

	TRACE("Loading ActorSet...");

	for(size_t i=0, numObjects=xml.count("object"); i<numObjects; ++i)
	{
		PropertyBag ThisObjBag;
		xml.get("object", ThisObjBag, i);
		spawnNow(ThisObjBag, world);
	}

	// Player data is saved separately
	deleteActors<Player>();

	TRACE("...finished (Loading ActorSet)");
}
Ejemplo n.º 15
0
void EditorToolBar::onLeftMouseDown()
{
	ASSERT(world!=0, "world was null!  Call setWorld first!");

	if(g_GUI.mouseOverSomeWidget) return;

	// Get a position on the ground beneath the cursor
	float e = selected ? selected->getPos().y : 0.0f;
	const vec3 groundPos = getGroundPickPos(e);

	// Grab the pool of objects we are working from
	ActorSet &objects = world->getObjects();

	// Get the id of the object under the mouse cursor
	OBJECT_ID id = objects.getClosest<Actor>(groundPos, 2.0f);

	// Process the action depending on the current tool
	switch(toolBarTools->getTool())
	{
	case ToolBarForEditorTools::EDITOR_SELECT_TOOL:
		if(objects.isMember(id))
		{
			Actor * p = &objects.get(id);
			showActorPane(p);
		}
		else
		{
			hideActorPane();
		}
		break;

	case ToolBarForEditorTools::EDITOR_MOVE_TOOL:
		{
			if(selected)
			{
				// Hold the right mouse button to slide objects along the y-axis
				if(g_Input.MouseRight)
				{
					vec3 delta = groundPos - selected->getPos();
					delta.y=0;
					float dist = delta.getMagnitude()*0.3f;

					// Place the object on this spot
					selected->Place(vec3(selected->getPos().x, dist, selected->getPos().z));
				}
				else
				{
					selected->Place(groundPos);
				}
			}
		}
		break;

	case ToolBarForEditorTools::EDITOR_ROTATE_TOOL:
		{
			if(selected)
			{
				const vec3 delta = vec3(selected->getPos().x-groundPos.x, 0, selected->getPos().z-groundPos.z);
				const vec3 zAxis = delta.getNormal();
				const vec3 yAxis = vec3(0,1,0);
				const vec3 xAxis = yAxis.cross(zAxis).getNormal();

				mat4 orientation = selected->getOrientation();
				orientation.setAxisZ(zAxis);
				orientation.setAxisY(yAxis);
				orientation.setAxisX(xAxis);
				orientation.setPos(vec3(0,0,0));
				selected->setOrientation(orientation);
			}
		}
		break;

	case ToolBarForEditorTools::EDITOR_ROTATE_X_TOOL:
		{
			if(selected)
			{
				vec3 delta = groundPos - selected->getPos();
				float angle = atan2f(delta.x, delta.y) * 0.1f;

				mat4 rot;
				rot.rotateX(angle);

		                mat4 orientation = selected->getOrientation();

				orientation *= rot;

				selected->setOrientation(orientation);
			}
		}
		break;

	case ToolBarForEditorTools::EDITOR_ROTATE_Z_TOOL:
		{
			if(selected)
			{
				vec3 delta = groundPos - selected->getPos();
				float angle = atan2f(delta.x, delta.y) * 0.1f;

				mat4 rot;
				rot.rotateZ(angle);

		                mat4 orientation = selected->getOrientation();

				orientation *= rot;

				selected->setOrientation(orientation);
			}
		}
		break;

	case ToolBarForEditorTools::EDITOR_CREATE_TOOL:
		if(!leftClickDebounce)
		{
			leftClickDebounce=true;

			// Create objects from a palette of available types
			string nextObject = getNextObject();

            // Gets the objects for the object palette
			string editorDataFile = pathAppend("data/objects/", nextObject);

			PropertyBag ThisObjBag;
            ThisObjBag.loadFromFile(editorDataFile);

			string rtti;
			ThisObjBag.get("type", rtti);

			// Create the object inside the game world
			OBJECT_ID id = objects.create(rtti, world);
			if(id != INVALID_ID)
			{
				Actor &object = objects.get(id);
				object.load(ThisObjBag);
				object.editorDataFile = editorDataFile;

				// Do not affect object y with the move command
				vec3 groundPos = getGroundPickPos(0.0f);

				// Place the object on this spot
				object.Place(groundPos);

				// Select the new object
				selected = &object;
			}
		}
		break;

	case ToolBarForEditorTools::EDITOR_DESTROY_TOOL:
		if(objects.isMember(id))
		{
			objects.removeObjectNow(id);
			hideActorPane();
		}
		break;

	case ToolBarForEditorTools::EDITOR_TILE_PENCIL_TOOL:
		{
			// get a reference to the map
			Map &map =  world->getMap();

			// Get the position on the ground plane that was clicked
			vec3 groundPos = getGroundPickPos(0.0f);

			if(map.onATile(groundPos.x, groundPos.z))
			{
				// get the tile that was picked
				Tile &tile = map.getTile(groundPos.x, groundPos.z);

#if 1
                tile.create(map.tileX(groundPos.x),
							map.tileZ(groundPos.z),
							tileEditor_type,
							tileEditor_properties,
							tileEditor_height,
							tileEditor_floorTextureFile,
							tileEditor_wallTextureFile,
							map);
#else
                tile.setMaterials(tileEditor_wallTextureFile,
                                  tileEditor_floorTextureFile,
                                  map);
#endif

				// Rebuild the map display list
				map.reaquire();

				g_SoundSystem.play("data/sound/click.wav");
			}
		}
		break;

	case ToolBarForEditorTools::EDITOR_TILE_BLOCK_TOOL:
		{
			// Drag entered
			if(!drag)
			{
				drag = true;

				g_SoundSystem.play("data/sound/click.wav");

				mouseDownPos = getGroundPickPos(0.0f);
			}
		}
		break;
	};
}
Ejemplo n.º 16
0
void ComponentBrainKamikaze::load(const PropertyBag &data)
{
	resetMembers();
	data.get("maxSightDistance", maxSightDistance); // optional tag
}
Ejemplo n.º 17
0
AnimationController*
ModelLoaderSingle::loadFromFile(const FileName &fileName,
							    TextureFactory &textureFactory) const
{
	PropertyBag xml = PropertyBag::fromFile(fileName);

	const FileName directory = fileName.getPath();

	// Winding of polygons, either "CCW" or "CW"
	string polygonWinding = "CW";
	xml.get("polygonWinding", polygonWinding);

	// Allocate a blank animation controller
	AnimationController *controller = new AnimationController();

	// Get key frames from the first source
	PropertyBag fileBag = xml.getBag("model", 0);
	const FileName file = directory.append(fileBag.getFileName("file"));
	FileName skinName;
	if(fileBag.get("skin", skinName))
	{
		skinName = directory.append(skinName);
	}
	vector<KeyFrame> keyFrames = loadKeyFrames(file, skinName, textureFactory);

	// Get the rest of the key frames
	for(size_t i = 1, numMD3 = xml.getNumInstances("model"); i<numMD3; ++i)
	{
		PropertyBag fileBag = xml.getBag("model", i);
		const FileName file = directory.append(fileBag.getFileName("file"));
		FileName skinName;
		if(fileBag.get("skin", skinName))
		{
			skinName = directory.append(skinName);
		}

		vector<KeyFrame> k = loadKeyFrames(file, skinName, textureFactory);

		for(size_t i=0; i<k.size(); ++i)
		{
			KeyFrame &keyFrame = keyFrames[i];

			keyFrame.merge(k[i]);

			// set polygon windings according to data file
			setPolygonWinding(keyFrame, polygonWinding);
		}
	}

	// Build the animations from these keyframes
	for(size_t i = 0, numAnimations = xml.getNumInstances("animation");
		i<numAnimations;
		++i)
	{
		PropertyBag animation;
		string name;
		bool looping=false;
		int start=0;
		float priority=0;
		int length=0;
		float fps=0;

		xml.get("animation", animation, i);
		animation.get("name", name);
		animation.get("priority", priority);
		animation.get("looping", looping);
		animation.get("start", start);
		animation.get("length", length);
		animation.get("fps", fps);

		// Add it to the controller
		AnimationSequence animationSequence(keyFrames,
		                                    name,
											priority,
											looping,
											start,
											length,
											fps);
		controller->addAnimation(animationSequence);
	}

	return controller;
}
Ejemplo n.º 18
0
void ComponentDestroySelfOnCollision::load(const PropertyBag &data) {
	resetMembers();
	data.get("onlyPlayers", onlyPlayers); // optional tag
}