예제 #1
0
void Creature::attachWeaponModel(InventorySlot slot) {
	assert((slot == kInventorySlotLeftWeapon) || (slot == kInventorySlotRightWeapon));

	Common::UString hookNode;

	switch (slot) {
		case kInventorySlotLeftWeapon:
			hookNode = "lhand";
			break;
		case kInventorySlotRightWeapon:
			hookNode = "rhand";
			break;
		default:
			throw Common::Exception("Unsupported equip slot");
	}

	if (!_model->hasNode(hookNode)) {
		warning("Creature::attachWeaponModel(): Model \"%s\" does not have node \"%s\"",
		        _model->getName().c_str(), hookNode.c_str());

		return;
	}

	Graphics::Aurora::Model *weaponModel = 0;

	if (_info.isInventorySlotEquipped(slot)) {
		Item *item = _equipment[slot];
		weaponModel = loadModelObject(item->getModelName());
	}

	GfxMan.lockFrame();
	_model->attachModel(hookNode, weaponModel);
	GfxMan.unlockFrame();
}
예제 #2
0
파일: situated.cpp 프로젝트: cc9cii/xoreos
void Situated::loadModel() {
	if (_model)
		return;

	if (_modelName.empty()) {
		warning("Situated object \"%s\" (\"%s\") has no model", _name.c_str(), _tag.c_str());
		return;
	}

	_model = loadModelObject(_modelName);
	if (!_model)
		throw Common::Exception("Failed to load situated object model \"%s\"",
		                        _modelName.c_str());

	// Tinting
	if (ConfigMan.getBool("tint"))
		((Graphics::Aurora::Model_NWN2 *) _model)->setTint(_tint);

	// Positioning

	float x, y, z;

	getPosition(x, y, z);
	setPosition(x, y, z);

	getOrientation(x, y, z);
	setOrientation(x, y, z);

	// Clickable

	_model->setTag(_tag);
	_model->setClickable(isClickable());

	_ids.push_back(_model->getID());
}
예제 #3
0
파일: situated.cpp 프로젝트: cc9cii/xoreos
void Situated::loadModel() {
	if (_model)
		return;

	if (_modelName.empty()) {
		warning("Situated object \"%s\" (\"%s\") has no model", _name.c_str(), _tag.c_str());
		return;
	}

	_model = loadModelObject(_modelName);
	if (!_model)
		throw Common::Exception("Failed to load situated object model \"%s\"",
		                        _modelName.c_str());

	// Positioning

	float x, y, z;

	getPosition(x, y, z);
	setPosition(x, y, z);

	getOrientation(x, y, z);
	setOrientation(x, y, z);

	// Clickable

	_model->setTag(_tag);
	_model->setClickable(isClickable());

	_ids.push_back(_model->getID());
}
예제 #4
0
파일: area.cpp 프로젝트: clone2727/xoreos
void Area::loadTiles() {
	for (uint32 y = 0; y < _height; y++) {
		for (uint32 x = 0; x < _width; x++) {
			uint32 n = y * _width + x;

			Tile &t = _tiles[n];

			t.tile = &_tileset->getTile(t.tileID);

			t.model = loadModelObject(t.tile->model);
			if (!t.model)
				throw Common::Exception("Can't load tile model \"%s\"", t.tile->model.c_str());

			// A tile is 10 units wide and deep.
			// There's extra special 5x5 tiles at the edges.
			const float tileX = x * 10.0f + 5.0f;
			const float tileY = y * 10.0f + 5.0f;

			// The actual height of a tile is dictated by the tileset.
			const float tileZ = t.height * _tileset->getTilesHeight();

			t.model->setPosition(tileX, tileY, tileZ);
			t.model->setOrientation(0.0f, 0.0f, 1.0f, ((int) t.orientation) * 90.0f);
		}
	}
}
예제 #5
0
파일: area.cpp 프로젝트: DeejStar/xoreos
void Area::loadModels() {
	const Aurora::LYTFile::RoomArray &rooms = _lyt.getRooms();
	_rooms.reserve(rooms.size());
	for (size_t i = 0; i < rooms.size(); i++) {
		const Aurora::LYTFile::Room &lytRoom = rooms[i];

		if (lytRoom.model == "****")
			// No model for that room
			continue;

		Room *room = new Room(lytRoom);

		room->model = loadModelObject(lytRoom.model);
		if (!room->model) {
			delete room;
			throw Common::Exception("Can't load model \"%s\" for area \"%s\"",
			                        lytRoom.model.c_str(), _resRef.c_str());
		}

		room->model->setPosition(lytRoom.x, lytRoom.y, lytRoom.z);

		_rooms.push_back(room);
	}

}
예제 #6
0
void Creature::loadBody(PartModels &parts) {
	_model = loadModelObject(parts.body, parts.bodyTexture);
	if (!_model)
		return;

	_ids.push_back(_model->getID());

	_model->setTag(_tag);
	_model->setClickable(isClickable());
}
예제 #7
0
파일: room.cpp 프로젝트: Supermanu/xoreos
void Room::load(const Common::UString &resRef, float x, float y, float z) {
	if (resRef == "****")
		return;

	_model.reset(loadModelObject(resRef));
	if (!_model)
		throw Common::Exception("Can't load room model \"%s\"", resRef.c_str());

	_model->setPosition(x, y, z);
}
예제 #8
0
void Creature::loadHead(PartModels &parts) {
	if (!_model || parts.head.empty())
		return;

	Graphics::Aurora::ModelNode *headHook = _model->getNode("headhook");
	if (!headHook)
		return;

	headHook->addChild(loadModelObject(parts.head));
}
예제 #9
0
파일: area.cpp 프로젝트: farmboy0/xoreos
void Area::loadAreaModel() {
	if (_modelName.empty())
		return;

	_model.reset(loadModelObject(_modelName));
	if (!_model)
		throw Common::Exception("Can't load area geometry model \"%s\"", _modelName.c_str());

	_model->setPosition(1500.0f, 1500.0f, 0.0f);
}
예제 #10
0
파일: situated.cpp 프로젝트: berenm/xoreos
void Situated::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) {
	// General properties

	if (blueprint)
		loadProperties(*blueprint); // Blueprint
	loadProperties(instance);    // Instance


	// Specialized object properties

	if (blueprint)
		loadObject(*blueprint); // Blueprint
	loadObject(instance);    // Instance


	// Appearance

	if (_appearanceID == Aurora::kFieldIDInvalid)
		warning("Situated object \"%s\" without an appearance", _tag.c_str());

	loadAppearance();
	loadSounds();

	// Model

	if (!_modelName.empty()) {
		_model.reset(loadModelObject(_modelName));

		if (!_model)
			throw Common::Exception("Failed to load situated object model \"%s\"",
			                        _modelName.c_str());
	} else
		warning("Situated object \"%s\" (\"%s\") has no model", _name.c_str(), _tag.c_str());

	if (_model) {
		// Clickable
		_model->setTag(_tag);
		_model->setClickable(isClickable());

		// ID
		_ids.push_back(_model->getID());
	}

	// Position

	setPosition(instance.getDouble("X"),
	            instance.getDouble("Y"),
	            instance.getDouble("Z"));

	// Orientation

	float bearing = instance.getDouble("Bearing");

	setOrientation(0.0f, 0.0f, 1.0f, Common::rad2deg(bearing));
}
예제 #11
0
void Creature::loadHead(PartModels &parts) {
	if (!_model || parts.head.empty())
		return;

	_headModel = loadModelObject(parts.head);
	if (!_headModel)
		return;

	GfxMan.lockFrame();
	_model->attachModel("headhook", _headModel);
	GfxMan.unlockFrame();
}
예제 #12
0
Graphics::Aurora::Model *CharacterGenerationInfo::getModel() {
	if (_body)
		return _body.get();

	Common::UString body, head;

	body = "p";
	head = "p";

	body += "bb";
	head += "h";


	_body.reset(loadModelObject(body, ""));


	head += "0";

	Graphics::Aurora::Model *headModel = loadModelObject(head, "");
	_body->attachModel("headhook", headModel);

	return _body.get();
}
예제 #13
0
void Creature::loadBody() {
	const Aurora::TwoDARow &appearance = TwoDAReg.get2DA("appearance").getRow(_appearance);

	const Common::UString bodyModel = appearance.getString(Common::UString("MODELA"));

	_model.reset(loadModelObject(bodyModel));
	if (!_model)
		return;

	_ids.push_back(_model->getID());

	_model->setTag(_tag);
	_model->setClickable(isClickable());
}
예제 #14
0
파일: placeable.cpp 프로젝트: strand/xoreos
void Placeable::load(const Aurora::GFF4Struct &placeable) {
	_tag = placeable.getString(Aurora::kGFF4Tag);

	_id     = placeable.getUint(40023, 0xFFFFFFFF);
	_typeID = placeable.getUint(40018, 0xFFFFFFFF);

	_appearanceID = 0xFFFFFFFF;
	if (_typeID < ARRAYSIZE(kTypeAppearances))
		_appearanceID = kTypeAppearances[_typeID];

	if (_appearanceID != 0xFFFFFFFF) {
		const Aurora::GDAFile &appearances = TwoDAReg.getGDA("appearances");

		if (appearances.hasRow(_appearanceID)) {
			_modelName = appearances.getString(_appearanceID, 2122127238);
			_scale     = appearances.getFloat (_appearanceID, "Scale", 1.0f);
		}
	}

	if (!_modelName.empty()) {
		/* TODO: This basically just protects against an exception for opening the
		 *       same archive twice when loading objects using the same model.
		 *       We should probably add some kind of reference counting somewhere...
		 */
		try {
			indexMandatoryArchive(_modelName + ".nsbtx", 100 + _id, &_modelTexture);
		} catch (...) {
		}

		_model = loadModelObject(_modelName);

		if (_model) {
			_model->setScale(_scale, _scale, _scale);

			_model->setClickable(true);
			_modelID = _model->getID();
		}
	}

	if (placeable.hasField(Aurora::kGFF4Position)) {
		double x, y, z;

		placeable.getVector3(Aurora::kGFF4Position, x, y, z);
		setPosition(x, y, z);
	}

	double orientation = placeable.getDouble(Aurora::kGFF4Orientation);
	setOrientation(0.0f, Common::rad2deg(orientation), 0.0f);
}
예제 #15
0
파일: room.cpp 프로젝트: EffWun/xoreos
Room::Room(const Aurora::LYTFile::Room &lytRoom) :
	lytRoom(&lytRoom), visible(false) {

	 if (lytRoom.model == "****") {
		 // No model for that room
		 return;
	 }

	 _roomModel.reset(loadModelObject(lytRoom.model));
	 if (!_roomModel) throw Common::Exception("Can't load model for room \"%s\"", lytRoom.model.c_str());
	 _roomModel->setPosition(lytRoom.x, lytRoom.y, lytRoom.z);

	 _walkMesh = loadWalkMesh(lytRoom);
	 _walkMeshModel = _walkMesh->getMesh();
}
예제 #16
0
bool Creature::loadArmorModel(const Common::UString &body,
		const Common::UString &armor, uint8 visualType, uint8 variation) {

	const Aurora::TwoDARow &armorVisual = TwoDAReg.get2DA("armorvisualdata").getRow(visualType);
	Common::UString armorPrefix = armorVisual.getString("Prefix");

	Common::UString modelFile;
	modelFile = Common::UString::format("%s_%s_%s%02d",
	                                     body.c_str(), armorPrefix.c_str(), armor.c_str(), variation + 1);

	Graphics::Aurora::Model *model = loadModelObject(modelFile);
	if (model)
		_modelParts.push_back(model);

	return model != 0;
}
예제 #17
0
void Creature::loadHead() {
	if (!_model || !_headType)
		return;

	const Aurora::TwoDARow &chest = TwoDAReg.get2DA("creaturehooks").getRow(3); // TODO row with label Chest

	const Aurora::TwoDARow &headtype = TwoDAReg.get2DA("heads").getRow(_headType);

	const Common::UString headModelName = headtype.getString("model");

	Graphics::Aurora::Model *headModel = loadModelObject(headModelName);
	if (!headModel)
		return;

	_model->attachModel(chest.getString("hook"), headModel);
}
예제 #18
0
bool Creature::loadHairModel(uint8 appearance) {
	if (appearance == 0)
		return false;

	Common::UString hair = getBaseModel("NWN2_Model_Hair");
	if (hair.empty())
		return false;

	Common::UString modelFile;
	modelFile = Common::UString::format("%s%02d", hair.c_str(), appearance);

	Graphics::Aurora::Model *model = loadModelObject(modelFile);
	if (model)
		_modelParts.push_back(model);

	return model != 0;
}
예제 #19
0
void Placeable::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint = 0) {
	if (blueprint)
		loadProperties(*blueprint);
	loadProperties(instance);

	const Aurora::GDAFile &gda = getMGDA(kWorksheetPlaceables);

	_model = loadModelObject(gda.getString(gda.findRow(_appearanceID), "ModelName"));

	if (_model) {
		_model->setTag(_tag);
		_model->setClickable(isClickable());

		_ids.push_back(_model->getID());
	}

	syncPosition();
	syncOrientation();
}
예제 #20
0
void Creature::loadBody(PartModels &parts) {
	// Model "P_BastilaBB" has broken animations. Replace it with the
	// correct one.
	if (parts.body.stricmp("P_BastilaBB") == 0)
		parts.body = "P_BastilaBB02";

	GfxMan.lockFrame();
	_model.reset(loadModelObject(parts.body, parts.bodyTexture));
	GfxMan.unlockFrame();

	if (!_model)
		return;

	_ids.clear();
	_ids.push_back(_model->getID());

	_model->setTag(_tag);
	_model->setClickable(isClickable());

	if (_modelType != "B" && _modelType != "P")
		_model->addAnimationChannel(Graphics::Aurora::kAnimationChannelHead);
}
예제 #21
0
파일: nwn2.cpp 프로젝트: mclark4386/xoreos
void NWN2Engine::run(const Common::UString &target) {
	_baseDirectory = target;

	init();
	initCursors();

	if (EventMan.quitRequested())
		return;

	status("Successfully initialized the engine");

	CursorMan.hideCursor();
	CursorMan.set();

	playVideo("atarilogo");
	playVideo("oeilogo");
	playVideo("wotclogo");
	playVideo("nvidialogo");
	playVideo("legal");
	playVideo("intro");
	if (EventMan.quitRequested())
		return;

	CursorMan.showCursor();

	bool showFPS = ConfigMan.getBool("showfps", false);

	Graphics::Aurora::FPS *fps = 0;
	if (showFPS) {
		fps = new Graphics::Aurora::FPS(FontMan.get(Graphics::Aurora::kSystemFontMono, 13));
		fps->show();
	}

	Sound::ChannelHandle channel;

	Common::SeekableReadStream *wav = ResMan.getResource(Aurora::kResourceMusic, "mus_mulsantir");
	if (wav) {
		// Cutting off the long silence at the end of mus_mulsantir :P
		wav = new Common::SeekableSubReadStream(wav, 0, 3545548, true);

		channel = SoundMan.playSoundFile(wav, Sound::kSoundTypeMusic, true);

		SoundMan.startChannel(channel);
	}

	CameraMan.setPosition(0.0, 2.0, 0.0);

	Graphics::Aurora::Model *model = loadModelObject("plc_br_mulsantirhouse05");

	model->setPosition(0.0, 20.0, 0.0);
	model->show();

	EventMan.enableKeyRepeat();

	while (!EventMan.quitRequested()) {
		Events::Event event;
		while (EventMan.pollEvent(event)) {
			if (event.type == Events::kEventKeyDown) {
				if      (event.key.keysym.sym == SDLK_UP)
					CameraMan.move( 0.5);
				else if (event.key.keysym.sym == SDLK_DOWN)
					CameraMan.move(-0.5);
				else if (event.key.keysym.sym == SDLK_RIGHT)
					CameraMan.turn( 0.0,  5.0, 0.0);
				else if (event.key.keysym.sym == SDLK_LEFT)
					CameraMan.turn( 0.0, -5.0, 0.0);
				else if (event.key.keysym.sym == SDLK_w)
					CameraMan.move( 0.5);
				else if (event.key.keysym.sym == SDLK_s)
					CameraMan.move(-0.5);
				else if (event.key.keysym.sym == SDLK_d)
					CameraMan.turn( 0.0,  5.0, 0.0);
				else if (event.key.keysym.sym == SDLK_a)
					CameraMan.turn( 0.0, -5.0, 0.0);
				else if (event.key.keysym.sym == SDLK_e)
					CameraMan.strafe( 0.5);
				else if (event.key.keysym.sym == SDLK_q)
					CameraMan.strafe(-0.5);
				else if (event.key.keysym.sym == SDLK_INSERT)
					CameraMan.move(0.0,  0.5, 0.0);
				else if (event.key.keysym.sym == SDLK_DELETE)
					CameraMan.move(0.0, -0.5, 0.0);
				else if (event.key.keysym.sym == SDLK_PAGEUP)
					CameraMan.turn( 5.0,  0.0, 0.0);
				else if (event.key.keysym.sym == SDLK_PAGEDOWN)
					CameraMan.turn(-5.0,  0.0, 0.0);
				else if (event.key.keysym.sym == SDLK_END) {
					const float *orient = CameraMan.getOrientation();

					CameraMan.setOrientation(0.0, orient[1], orient[2]);
				}
			}
		}

		EventMan.delay(10);
	}

	EventMan.enableKeyRepeat(0);

	delete model;
	delete fps;
}
예제 #22
0
void Creature::loadModel() {
	if (_model)
		return;

	if (_appearanceID == Aurora::kFieldIDInvalid) {
		warning("Creature \"%s\" has no appearance", _tag.c_str());
		return;
	}

	const Aurora::TwoDARow &appearance = TwoDAReg.get2DA("appearance").getRow(_appearanceID);

	if (_portrait.empty())
		_portrait = appearance.getString("PORTRAIT");

	_environmentMap = appearance.getString("ENVMAP");

	if (appearance.getString("MODELTYPE") == "P") {
		getArmorModels();
		getPartModels();
		_model = loadModelObject(_partsSuperModelName);

		for (size_t i = 0; i < kBodyPartMAX; i++) {
			if (_bodyParts[i].modelName.empty())
				continue;

			TextureMan.startRecordNewTextures();

			// Try to load in the corresponding part model
			Graphics::Aurora::Model *partModel = loadModelObject(_bodyParts[i].modelName, _bodyParts[i].textureName);
			if (!partModel)
				continue;

			// Add the loaded model to the appropriate part node
			Graphics::Aurora::ModelNode *partNode = _model->getNode(kBodyPartNodes[i]);
			if (partNode)
				partNode->addChild(partModel);

			std::list<Common::UString> newTextures;
			TextureMan.stopRecordNewTextures(newTextures);

			for (std::list<Common::UString>::const_iterator t = newTextures.begin(); t != newTextures.end(); ++t) {
				Graphics::Aurora::TextureHandle texture = TextureMan.getIfExist(*t);
				if (texture.empty())
					continue;

				_bodyParts[i].textures.push_back(texture);
			}

			finishPLTs(_bodyParts[i].textures);
		}

	} else
		_model = loadModelObject(appearance.getString("RACE"));

	// Positioning

	float x, y, z, angle;

	getPosition(x, y, z);
	setPosition(x, y, z);

	getOrientation(x, y, z, angle);
	setOrientation(x, y, z, angle);

	// Clickable

	if (_model) {
		_model->setTag(_tag);
		_model->setClickable(isClickable());

		_ids.push_back(_model->getID());

		if (!_environmentMap.empty()) {
			Common::UString environmentMap = _environmentMap;
			if (environmentMap.equalsIgnoreCase("default"))
				environmentMap = _area ? _area->getEnvironmentMap() : "";

			_model->setEnvironmentMap(environmentMap);
		}
	}
}
예제 #23
0
void TheWitcherEngine::run(const Common::UString &target) {
	_baseDirectory = target;

	init();
	initCursors();

	if (EventMan.quitRequested())
		return;

	status("Successfully initialized the engine");

	CursorMan.hideCursor();
	CursorMan.set();

	playVideo("publisher");
	playVideo("developer");
	playVideo("engine");
	playVideo("intro");
	playVideo("title");
	if (EventMan.quitRequested())
		return;

	CursorMan.showCursor();

	bool showFPS = ConfigMan.getBool("showfps", false);

	Graphics::Aurora::FPS *fps = 0;
	if (showFPS) {
		fps = new Graphics::Aurora::FPS(FontMan.get(Graphics::Aurora::kSystemFontMono, 13));
		fps->show();
	}

	playSound("m1_axem00020005", Sound::kSoundTypeVoice);

	CameraMan.setPosition(0.0, 1.0, 0.0);

	Graphics::Aurora::Model *model = loadModelObject("cm_naked3");

	model->setRotation(0.0, 0.0, 180.0);
	model->setPosition(0.0, 2.0, 0.0);
	model->show();

	EventMan.enableKeyRepeat();

	while (!EventMan.quitRequested()) {
		Events::Event event;
		while (EventMan.pollEvent(event)) {
			if (event.type == Events::kEventKeyDown) {
				if      (event.key.keysym.sym == SDLK_UP)
					CameraMan.move( 0.5);
				else if (event.key.keysym.sym == SDLK_DOWN)
					CameraMan.move(-0.5);
				else if (event.key.keysym.sym == SDLK_RIGHT)
					CameraMan.turn( 0.0,  5.0, 0.0);
				else if (event.key.keysym.sym == SDLK_LEFT)
					CameraMan.turn( 0.0, -5.0, 0.0);
				else if (event.key.keysym.sym == SDLK_w)
					CameraMan.move( 0.5);
				else if (event.key.keysym.sym == SDLK_s)
					CameraMan.move(-0.5);
				else if (event.key.keysym.sym == SDLK_d)
					CameraMan.turn( 0.0,  5.0, 0.0);
				else if (event.key.keysym.sym == SDLK_a)
					CameraMan.turn( 0.0, -5.0, 0.0);
				else if (event.key.keysym.sym == SDLK_e)
					CameraMan.strafe( 0.5);
				else if (event.key.keysym.sym == SDLK_q)
					CameraMan.strafe(-0.5);
				else if (event.key.keysym.sym == SDLK_INSERT)
					CameraMan.move(0.0,  0.5, 0.0);
				else if (event.key.keysym.sym == SDLK_DELETE)
					CameraMan.move(0.0, -0.5, 0.0);
				else if (event.key.keysym.sym == SDLK_PAGEUP)
					CameraMan.turn( 5.0,  0.0, 0.0);
				else if (event.key.keysym.sym == SDLK_PAGEDOWN)
					CameraMan.turn(-5.0,  0.0, 0.0);
				else if (event.key.keysym.sym == SDLK_END) {
					const float *orient = CameraMan.getOrientation();

					CameraMan.setOrientation(0.0, orient[1], orient[2]);
				}
			}
		}

		EventMan.delay(10);
	}

	EventMan.enableKeyRepeat(0);

	delete model;
	delete fps;
}