Skip to content

Commit

Permalink
NWN2: Hook up model loading again
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Jan 21, 2014
1 parent fb2c3df commit 0917153
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/engines/nwn2/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ noinst_LTLIBRARIES = libnwn2.la

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

libnwn2_la_SOURCES = \
nwn2.cpp \
model.cpp \
$(EMPTY)
55 changes: 55 additions & 0 deletions src/engines/nwn2/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/nwn2/model.cpp
* Utility functions for Neverwinter Nights models.
*/

#include "common/maths.h"

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

#include "engines/nwn2/model.h"

namespace Engines {

namespace NWN2 {

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

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

return modelInstance;
}

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

} // End of namespace NWN2

} // End of namespace Engines
51 changes: 51 additions & 0 deletions src/engines/nwn2/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/nwn2/model.h
* Utility functions for Neverwinter Nights 2 models.
*/

#ifndef ENGINES_NWN2_MODEL_H
#define ENGINES_NWN2_MODEL_H

namespace Graphics {
namespace Aurora {
class Model_NWN2;
}
}

namespace Engines {

namespace NWN2 {

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

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

} // End of namespace NWN2

} // End of namespace Engines

#endif // ENGINES_NWN2_MODEL_H
65 changes: 65 additions & 0 deletions src/engines/nwn2/nwn2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
#include "aurora/error.h"

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

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

#include "sound/sound.h"

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

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

namespace Engines {

Expand Down Expand Up @@ -131,9 +136,67 @@ void NWN2Engine::run(const Common::UString &target) {
SoundMan.startChannel(channel);
}

CameraMan.setPosition(0.0, 2.0, 0.0);

Graphics::Aurora::Model_NWN2 *model = createWorldModel("plc_br_mulsantirhouse05");

model->setPosition(0.0, 0.0, -20.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 NWN2Engine::init() {
Expand Down Expand Up @@ -229,6 +292,8 @@ void NWN2Engine::init() {

status("Indexing override files");
indexOptionalDirectory("override", 0, 0, 100);

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

void NWN2Engine::initCursors() {
Expand Down

0 comments on commit 0917153

Please sign in to comment.