Commit aad80b73 authored by Aloshi's avatar Aloshi

Made ViewController's launch animation to add current view's position to

center point.
Fixed clipping with a scaled camera matrix.
parent 5aeb2bc8
......@@ -87,7 +87,7 @@ void ViewController::onFileChanged(FileData* file, FileChangeType change)
}
}
void ViewController::launch(FileData* game, const Eigen::Vector3f& center)
void ViewController::launch(FileData* game, Eigen::Vector3f center)
{
if(game->getType() != GAME)
{
......@@ -99,6 +99,7 @@ void ViewController::launch(FileData* game, const Eigen::Vector3f& center)
game->getSystem()->getTheme()->playSound("gameSelectSound");
Eigen::Affine3f origCamera = mCamera;
center += mCurrentView->getPosition();
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 1500), [this, origCamera, center, game]
{
game->getSystem()->launchGame(mWindow, game);
......@@ -175,18 +176,19 @@ void ViewController::render(const Eigen::Affine3f& parentTrans)
{
Eigen::Affine3f trans = mCamera * parentTrans;
// camera position, position + size
Eigen::Vector3f viewStart = trans.inverse().translation();
Eigen::Vector3f viewEnd = trans.inverse() * Eigen::Vector3f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight(), 0);
// draw systems
for(auto it = mSystemViews.begin(); it != mSystemViews.end(); it++)
{
// clipping
Eigen::Vector3f pos = it->second->getPosition();
Eigen::Vector2f size = it->second->getSize();
Eigen::Vector3f camPos = -trans.translation();
Eigen::Vector2f camSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
Eigen::Vector3f guiStart = it->second->getPosition();
Eigen::Vector3f guiEnd = it->second->getPosition() + Eigen::Vector3f(it->second->getSize().x(), it->second->getSize().y(), 0);
if(pos.x() + size.x() >= camPos.x() && pos.y() + size.y() >= camPos.y() &&
pos.x() <= camPos.x() + camSize.x() && pos.y() <= camPos.y() + camSize.y())
if(guiEnd.x() >= viewStart.x() && guiEnd.y() >= viewStart.y() &&
guiStart.x() <= viewEnd.x() && guiStart.y() <= viewEnd.y())
it->second->render(trans);
}
......
......@@ -19,7 +19,7 @@ public:
// Plays a nice launch effect and launches the game at the end of it.
// Once the game terminates, plays a return effect.
void launch(FileData* game, const Eigen::Vector3f& centerCameraOn = Eigen::Vector3f(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f, 0));
void launch(FileData* game, Eigen::Vector3f centerCameraOn = Eigen::Vector3f(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f, 0));
bool input(InputConfig* config, Input input) override;
void update(int deltaTime) override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment