Skip to content

Commit

Permalink
WITCHER: Hook up model loading
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Jan 29, 2014
1 parent 2e17873 commit cde898f
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/engines/thewitcher/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ noinst_LTLIBRARIES = libthewitcher.la

noinst_HEADERS = \
thewitcher.h \
model.h \
$(EMPTY)

libthewitcher_la_SOURCES = \
thewitcher.cpp \
model.cpp \
$(EMPTY)
55 changes: 55 additions & 0 deletions src/engines/thewitcher/model.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names can be
* found in the AUTHORS file distributed with this source
* distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*
* The Infinity, Aurora, Odyssey, Eclipse and Lycium engines, Copyright (c) BioWare corp.
* The Electron engine, Copyright (c) Obsidian Entertainment and BioWare corp.
*/

/** @file engines/thewitcher/model.cpp
* Utility functions for The Witcher models.
*/

#include "common/maths.h"

#include "graphics/aurora/sceneman.h"
#include "graphics/aurora/model_witcher.h"

#include "engines/thewitcher/model.h"

namespace Engines {

namespace TheWitcher {

Graphics::Aurora::Model_Witcher *createWorldModel(const Common::UString &model) {
Graphics::Aurora::Model_Witcher *modelInstance = (Graphics::Aurora::Model_Witcher *) SceneMan.createModel(model);

modelInstance->setBaseOrientation(Common::deg2rad(-90.0), 1.0, 0.0, 0.0);

return modelInstance;
}

void destroyModel(Graphics::Aurora::Model_Witcher *model) {
SceneMan.destroy(model);
}

} // End of namespace TheWitcher

} // End of namespace Engines
51 changes: 51 additions & 0 deletions src/engines/thewitcher/model.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names can be
* found in the AUTHORS file distributed with this source
* distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*
* The Infinity, Aurora, Odyssey, Eclipse and Lycium engines, Copyright (c) BioWare corp.
* The Electron engine, Copyright (c) Obsidian Entertainment and BioWare corp.
*/

/** @file engines/thewitcher/model.h
* Utility functions for The Witcher models.
*/

#ifndef ENGINES_THEWITCHER_MODEL_H
#define ENGINES_THEWITCHER_MODEL_H

namespace Graphics {
namespace Aurora {
class Model_Witcher;
}
}

namespace Engines {

namespace TheWitcher {

Graphics::Aurora::Model_Witcher *createWorldModel(const Common::UString &model);

void destroyModel(Graphics::Aurora::Model_Witcher *model);

} // End of namespace TheWitcher

} // End of namespace Engines

#endif // ENGINES_THEWITCHER_MODEL_H
68 changes: 67 additions & 1 deletion src/engines/thewitcher/thewitcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
#include "aurora/error.h"

#include "graphics/cursorman.h"
#include "graphics/cameraman.h"

#include "graphics/aurora/sceneman.h"
#include "graphics/aurora/model_witcher.h"

#include "sound/sound.h"

Expand All @@ -46,6 +50,7 @@
#include "engines/aurora/resources.h"

#include "engines/thewitcher/thewitcher.h"
#include "engines/thewitcher/model.h"

namespace Engines {

Expand Down Expand Up @@ -124,11 +129,70 @@ void TheWitcherEngine::run(const Common::UString &target) {
if (EventMan.quitRequested())
return;

playSound("m1_axem00020005", Sound::kSoundTypeVoice);
playSound("menu", Sound::kSoundTypeMusic, true);

CameraMan.setPosition(0.0, 0.5, 0.0);

Graphics::Aurora::Model_Witcher *model = createWorldModel("an_cat");

model->rotate(Common::deg2rad(225), 0.0, 0.0, 1.0);
model->setPosition(0.0, 0.0, -2.0);
model->setVisible(true);

EventMan.enableKeyRepeat();

while (!EventMan.quitRequested()) {
Events::Event event;

while (EventMan.pollEvent(event)) {
if (event.type == Events::kEventMouseMove) {
if (event.motion.state & SDL_BUTTON(2)) {
CameraMan.pitch(-Common::deg2rad(0.5) * event.motion.yrel);
CameraMan.rotate(-Common::deg2rad(0.5) * event.motion.xrel, 0.0, 1.0, 0.0);
}
} else if (event.type == Events::kEventKeyDown) {
float speed = (event.key.keysym.mod & KMOD_SHIFT) ? 1.0 : 0.5;

if (event.key.keysym.sym == SDLK_UP)
CameraMan.moveRelative(0.0, 0.0, -speed);
else if (event.key.keysym.sym == SDLK_DOWN)
CameraMan.moveRelative(0.0, 0.0, speed);
else if (event.key.keysym.sym == SDLK_RIGHT)
CameraMan.rotate(Common::deg2rad(-5), 0.0, 1.0, 0.0);
else if (event.key.keysym.sym == SDLK_LEFT)
CameraMan.rotate(Common::deg2rad( 5), 0.0, 1.0, 0.0);
else if (event.key.keysym.scancode == SDL_SCANCODE_W)
CameraMan.moveRelative(0.0, 0.0, -speed);
else if (event.key.keysym.scancode == SDL_SCANCODE_S)
CameraMan.moveRelative(0.0, 0.0, speed);
else if (event.key.keysym.scancode == SDL_SCANCODE_D)
CameraMan.rotate(Common::deg2rad(-5), 0.0, 1.0, 0.0);
else if (event.key.keysym.scancode == SDL_SCANCODE_A)
CameraMan.rotate(Common::deg2rad( 5), 0.0, 1.0, 0.0);
else if (event.key.keysym.scancode == SDL_SCANCODE_E)
CameraMan.moveRelative( speed, 0.0, 0.0);
else if (event.key.keysym.scancode == SDL_SCANCODE_Q)
CameraMan.moveRelative(-speed, 0.0, 0.0);
else if (event.key.keysym.sym == SDLK_INSERT)
CameraMan.moveRelative(0.0, speed, 0.0);
else if (event.key.keysym.sym == SDLK_DELETE)
CameraMan.moveRelative(0.0, -speed, 0.0);
else if (event.key.keysym.sym == SDLK_PAGEUP)
CameraMan.pitch(Common::deg2rad(5));
else if (event.key.keysym.sym == SDLK_PAGEDOWN)
CameraMan.pitch(Common::deg2rad(-5));
else if (event.key.keysym.sym == SDLK_END) {
float x, y, z;
CameraMan.getDirection(x, y, z);
CameraMan.setDirection(x, 0.0, z);
}
}
}

EventMan.delay(10);
}

destroyModel(model);
}

void TheWitcherEngine::init() {
Expand Down Expand Up @@ -173,6 +237,8 @@ void TheWitcherEngine::init() {

status("Indexing override files");
indexOptionalDirectory("data/override", 0, 0, 50);

SceneMan.registerModelType(Graphics::Aurora::kModelTypeTheWitcher);
}

void TheWitcherEngine::initCursors() {
Expand Down

0 comments on commit cde898f

Please sign in to comment.