void Room::loadLayout(const Common::UString &roomFile) { if (!ResMan.hasResource(roomFile, Aurora::kFileTypeRML) || EventMan.quitRequested()) return; GFF4File rml(roomFile, Aurora::kFileTypeRML, kRMLID); if (rml.getTypeVersion() != kVersion40) throw Common::Exception("Unsupported RML version %s", Common::debugTag(rml.getTypeVersion()).c_str()); const GFF4Struct &rmlTop = rml.getTopLevel(); float roomPos[3] = { 0.0f, 0.0f, 0.0f }; rmlTop.getVector3(kGFF4Position, roomPos[0], roomPos[1], roomPos[2]); float roomOrient[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; rmlTop.getVector4(kGFF4Orientation, roomOrient[0], roomOrient[1], roomOrient[2], roomOrient[3]); roomOrient[3] = Common::rad2deg(acos(roomOrient[3]) * 2.0); Common::Matrix4x4 roomTransform; roomTransform.translate(roomPos[0], roomPos[1], roomPos[2]); roomTransform.rotate(roomOrient[3], roomOrient[0], roomOrient[1], roomOrient[2]); status("Loading room \"%s\" (%d)", roomFile.c_str(), _id); const GFF4List &models = rmlTop.getList(kGFF4EnvRoomModelList); _models.reserve(models.size()); for (GFF4List::const_iterator m = models.begin(); m != models.end(); ++m) { if (!*m || ((*m)->getLabel() != kMDLID)) continue; float scale = (*m)->getFloat(kGFF4EnvModelScale); float pos[3] = { 0.0f, 0.0f, 0.0f }; (*m)->getVector3(kGFF4Position, pos[0], pos[1], pos[2]); float orient[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; (*m)->getVector4(kGFF4Orientation, orient[0], orient[1], orient[2], orient[3]); orient[3] = Common::rad2deg(acos(orient[3]) * 2.0); // TODO: Instances Graphics::Aurora::Model *model = loadModelObject((*m)->getString(kGFF4EnvModelFile)); if (!model) continue; _models.push_back(model); Common::Matrix4x4 modelTransform(roomTransform); modelTransform.translate(pos[0], pos[1], pos[2]); modelTransform.rotate(orient[3], orient[0], orient[1], orient[2]); modelTransform.getPosition(pos[0], pos[1], pos[2]); modelTransform.getAxisAngle(orient[3], orient[0], orient[1], orient[2]); model->setPosition(pos[0], pos[1], pos[2]); model->setOrientation(orient[0], orient[1], orient[2], orient[3]); model->setScale(scale, scale, scale); } }
static Graphics::Aurora::Model *createNewGameFog() { Graphics::Aurora::Model *model = 0; try { model = new NewGameFog("pnl_fog"); } catch (...) { delete model; } model->setPosition(0.0, 0.0, 100.0); return model; }
void Creature::playHeadAnimation(const Common::UString &anim, bool restart, float length, float speed) { if (!_model) return; Graphics::Aurora::AnimationChannel *headChannel = 0; if (_modelType == "B" || _modelType == "P") { Graphics::Aurora::Model *head = _model->getAttachedModel("headhook"); if (head) headChannel = head->getAnimationChannel(Graphics::Aurora::kAnimationChannelAll); } else headChannel = _model->getAnimationChannel(Graphics::Aurora::kAnimationChannelHead); if (headChannel) headChannel->playAnimation(anim, restart, length, speed); }
void Creature::playDefaultHeadAnimation() { if (!_model) return; Graphics::Aurora::AnimationChannel *headChannel = 0; if (_modelType == "B" || _modelType == "P") { Graphics::Aurora::Model *head = _model->getAttachedModel("headhook"); if (head) headChannel = head->getAnimationChannel(Graphics::Aurora::kAnimationChannelAll); } else headChannel = _model->getAnimationChannel(Graphics::Aurora::kAnimationChannelHead); if (headChannel) headChannel->playDefaultAnimation(); }
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; }
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; }