Skip to content

Commit

Permalink
KOTOR: Add the subscene for the character generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius authored and DrMcCoy committed Nov 15, 2017
1 parent 0eba2ef commit d7d5c1f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/engines/kotor/gui/chargen/charactergeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ namespace Engines {

namespace KotOR {

CharacterGenerationMenu::CharacterGenerationMenu(Module *module, CharacterGenerationInfo *pc,
Console *console) : GUI(console), _module(module), _pc(pc), _step(0) {
CharacterGenerationMenu::CharacterGenerationMenu(Module *module, CharacterGenerationInfo *pc, Console *console) :
GUI(console), _module(module), _pc(pc), _step(0), _charSubScene(new Graphics::Aurora::SubSceneQuad) {

load("maincg");

Expand Down Expand Up @@ -78,6 +78,31 @@ CharacterGenerationMenu::CharacterGenerationMenu(Module *module, CharacterGenera
getWidget("LBL_LEVEL_VAL")->setInvisible(true);
getWidget("LBL_LEVEL")->setInvisible(true);

float subSceneWidth = getLabel("MODEL_LBL")->getWidth();
float subSceneHeight = getLabel("MODEL_LBL")->getHeight();

Common::Matrix4x4 projection;
projection.perspective(22.72f, subSceneWidth/subSceneHeight, 0.1f, 10.0f);

/*
* TODO: These values are extracted using apitrace from the original game.
* They should be replaced with a more straight forward matrix transformation expression.
*/
float modelView[] = {
0.000900542, 0.0176735, 0.999843, 0,
0.999999, 0.000900542, -0.00091657, 0,
-0.00091657, 0.999843, -0.0176727, 0,
0, 0, 0, 1
};
Common::Matrix4x4 transformation(modelView);
transformation.translate(-4.87251f, 0.0f, -0.776371f);
transformation.rotate(-90.0f, 0.0f, 0.0f, 1.0f);

getLabel("MODEL_LBL")->setSubScene(_charSubScene.get());
_charSubScene->add(_pc->getModel());
_charSubScene->setProjectionMatrix(projection);
_charSubScene->setGlobalTransformationMatrix(transformation);

showQuickOrCustom();
}

Expand Down
2 changes: 2 additions & 0 deletions src/engines/kotor/gui/chargen/charactergeneration.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class CharacterGenerationMenu : public GUI {
Common::ScopedPtr<GUI> _customChar;

Common::ScopedPtr<CharacterGenerationBaseMenu> _charGenMenu;

Common::ScopedPtr<Graphics::Aurora::SubSceneQuad> _charSubScene;
};

} // End of namespace KotOR
Expand Down

0 comments on commit d7d5c1f

Please sign in to comment.