Skip to content

Commit

Permalink
transformer split and merged curve editor layer (broken)
Browse files Browse the repository at this point in the history
  • Loading branch information
adafcaefc committed Dec 5, 2024
1 parent d7b515b commit 97f1dd6
Show file tree
Hide file tree
Showing 26 changed files with 887 additions and 621 deletions.
20 changes: 18 additions & 2 deletions Geome3Dash/Geome3Dash.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@
<ClCompile Include="src\CocosShaderProgram.cpp" />
<ClCompile Include="src\GameObjectModel.cpp" />
<ClCompile Include="src\game\component\G3DProgressBar.cpp" />
<ClCompile Include="src\game\editor\G3DCurveEditorLayer.cpp" />
<ClCompile Include="src\game\editor\G3DCurveEditorLoader.cpp" />
<ClCompile Include="src\game\editor\G3DCurveEditorPopup.cpp" />
<ClCompile Include="src\game\planet\G3DPlanetPopup.cpp" />
<ClCompile Include="src\helper\Easing.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
Expand Down Expand Up @@ -158,6 +159,13 @@
<ClCompile Include="src\Entries.cpp" />
<ClCompile Include="src\LevelEditorImGui.cpp" />
<ClCompile Include="src\PlanetStateManager.cpp" />
<ClCompile Include="src\PlayerObjectModel.cpp" />
<ClCompile Include="src\transformer\AnimationGameObjectModelTransformer.cpp" />
<ClCompile Include="src\transformer\BezierCameraPlayerObjectModelTransformer.cpp" />
<ClCompile Include="src\transformer\BezierGameObjectModelTransformer.cpp" />
<ClCompile Include="src\transformer\DefaultGameObjectModelTransformer.cpp" />
<ClCompile Include="src\transformer\FadeGameObjectModelTransformer.cpp" />
<ClCompile Include="src\transformer\GameObjectModelTransformer.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="lib\imgui-cocos\imconfig.h" />
Expand Down Expand Up @@ -201,7 +209,8 @@
<ClInclude Include="src\delegate\CustomTouch.h" />
<ClInclude Include="src\GameObjectModel.h" />
<ClInclude Include="src\game\component\G3DProgressBar.h" />
<ClInclude Include="src\game\editor\G3DCurveEditorLayer.h" />
<ClInclude Include="src\game\editor\G3DCurveEditorLoader.h" />
<ClInclude Include="src\game\editor\G3DCurveEditorPopup.h" />
<ClInclude Include="src\game\planet\G3DPlanetPopup.h" />
<ClInclude Include="src\helper\Easing.h" />
<ClInclude Include="src\engine\sus3d\Mesh.h" />
Expand All @@ -227,6 +236,13 @@
<ClInclude Include="src\LevelDataManager.h" />
<ClInclude Include="src\LevelEditorImGui.h" />
<ClInclude Include="src\PlanetStateManager.h" />
<ClInclude Include="src\PlayerObjectModel.h" />
<ClInclude Include="src\transformer\AnimationGameObjectModelTransformer.h" />
<ClInclude Include="src\transformer\BezierCameraPlayerObjectModelTransformer.h" />
<ClInclude Include="src\transformer\BezierGameObjectModelTransformer.h" />
<ClInclude Include="src\transformer\DefaultGameObjectModelTransformer.h" />
<ClInclude Include="src\transformer\FadeGameObjectModelTransformer.h" />
<ClInclude Include="src\transformer\GameObjectModelTransformer.h" />
</ItemGroup>
<ItemGroup>
<None Include=".gitignore" />
Expand Down
52 changes: 50 additions & 2 deletions Geome3Dash/Geome3Dash.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,36 @@
<ClCompile Include="lib\terrain\utils\Time.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\game\editor\G3DCurveEditorLayer.cpp">
<ClCompile Include="src\game\editor\G3DCurveEditorPopup.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\GameObjectModel.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\game\editor\G3DCurveEditorLoader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\transformer\GameObjectModelTransformer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\transformer\AnimationGameObjectModelTransformer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\transformer\BezierCameraPlayerObjectModelTransformer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\transformer\BezierGameObjectModelTransformer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\transformer\DefaultGameObjectModelTransformer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\transformer\FadeGameObjectModelTransformer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\PlayerObjectModel.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
Expand Down Expand Up @@ -440,12 +464,36 @@
<ClInclude Include="lib\terrain\utils\Time.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\game\editor\G3DCurveEditorLayer.h">
<ClInclude Include="src\game\editor\G3DCurveEditorPopup.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\GameObjectModel.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\game\editor\G3DCurveEditorLoader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\transformer\GameObjectModelTransformer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\transformer\AnimationGameObjectModelTransformer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\transformer\BezierCameraPlayerObjectModelTransformer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\transformer\BezierGameObjectModelTransformer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\transformer\DefaultGameObjectModelTransformer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\transformer\FadeGameObjectModelTransformer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\PlayerObjectModel.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include=".gitignore" />
Expand Down
117 changes: 1 addition & 116 deletions Geome3Dash/src/GameObjectModel.cpp
Original file line number Diff line number Diff line change
@@ -1,125 +1,9 @@
#include "pch.h"

#include "GameObjectModel.h"
#include "game/playing/G3DPlayLayer.h"

namespace g3d
{
void BezierCameraPlayerObjectModelTransformer::transform(GameObjectModel* gom)
{
if (auto pom = dynamic_cast<PlayerObjectModel*>(gom))
{
auto playerPos = pom->getPosition();
auto newR = pom->getRotation();
auto playerYaw = newR.y;
auto playerYawR = -glm::radians(playerYaw);
const auto playerCameraOffset = playLayer3d->playerCameraOffset;
const auto playerCameraYawOffset = playLayer3d->playerCameraYawOffset;
const auto playerCameraPitchOffset = playLayer3d->playerCameraPitchOffset;

glm::vec3 rotatedOffset =
{
playerCameraOffset.x * std::cos(playerYawR) - playerCameraOffset.z * std::sin(playerYawR),
playerCameraOffset.y,
playerCameraOffset.x * std::sin(playerYawR) + playerCameraOffset.z * std::cos(playerYawR)
};

playLayer3d->camera.setPosition(playerPos + rotatedOffset);
// Clamp pitch to prevent flipping
playLayer3d->camera.setYaw(playerCameraYawOffset - playerYaw);
auto pitch = std::clamp(static_cast<float>(playerCameraPitchOffset), -89.0f, 89.0f);
playLayer3d->camera.setPitch(pitch);
}
}

void FadeGameObjectModelTransformer::transform(GameObjectModel* gom)
{
auto obj = gom->getGameObject();
auto distance = std::abs(gameLayer->m_player1->m_position.x - obj->getPositionX());
if (distance > maxRender) {
gom->setVisible(false);
gom->setOpacity(0);
}
else if (distance > startFade) {
auto scale = gom->getScale();
double tNormal = (distance - startFade) / (maxRender - startFade);
gom->setScale(ease::easeNormal<glm::vec3>(easing, tNormal, scale, target));
}
}

void BezierGameObjectModelTransformer::transform(GameObjectModel* gom)
{
auto bCoordinate = BezierManager::transformIntoBezierCoordinate(
bezier,
gom->getPositionX(), gom->getPositionY(), gom->getPositionZ(),
bezierSegmentCount, bezierSegmentMultiplier);
gom->setPosition(bCoordinate.position);
gom->setRotationY(360 - bCoordinate.rotation);
}

void PlayerObjectModel::update()
{
model = cube;
if (playerObject->m_isShip) {
model = ship;
}
else if (playerObject->m_isBall) {
model = ball;
}
else if (playerObject->m_isBird) {
model = bird;
}
else if (playerObject->m_isDart) {
model = dart;
}
else if (playerObject->m_isRobot) {
model = robot;
}
else if (playerObject->m_isSpider) {
model = spider;
}
else if (playerObject->m_isSwing) {
model = swing;
}
this->setPositionX(playerObject->m_position.x * 0.05);
this->setPositionY(playerObject->m_position.y * 0.05);
this->setPositionZ(20.f);
this->setScale(glm::vec3(0.75) * glm::vec3(playerObject->getScale()));
this->setScaleY(std::abs(this->getScaleY()) * (playerObject->m_isUpsideDown ? -1.f : 1.f));
this->setRotationZ(360 - playerObject->getRotation());
}

void PlayerObjectModel::loadPlayerModels()
{
loadPlayerModel(&cube, "cube", GameManager::get()->getPlayerFrame());
loadPlayerModel(&ship, "ship", GameManager::get()->getPlayerShip());
loadPlayerModel(&ball, "ball", GameManager::get()->getPlayerBall());
loadPlayerModel(&bird, "bird", GameManager::get()->getPlayerBird());
loadPlayerModel(&dart, "dart", GameManager::get()->getPlayerDart());
loadPlayerModel(&robot, "robot", GameManager::get()->getPlayerRobot());
loadPlayerModel(&spider, "spider", GameManager::get()->getPlayerSpider());
loadPlayerModel(&swing, "swing", GameManager::get()->getPlayerSwing());
model = cube;
}

std::filesystem::path PlayerObjectModel::getPlayerModelPath(const std::string& type, const int id)
{
return BlockModelStorage::get()->getBP() / "player" / type / std::to_string(id) / "model.obj";
}

std::filesystem::path PlayerObjectModel::getFixedPlayerModelPath(const std::string& type, const int id)
{
const auto path = getPlayerModelPath(type, id);
return std::filesystem::exists(path)
? path
: getPlayerModelPath(type, 0);
}

void PlayerObjectModel::loadPlayerModel(sus3d::Model** model, const std::string& type, const int id)
{
*model = BlockModelStorage::get()->loadAndParseMtl(getFixedPlayerModelPath(type, id));
}

void GameObjectModel::update()
{
this->setPosition(glm::vec3(
Expand Down Expand Up @@ -151,6 +35,7 @@ namespace g3d
this->applyTransformation();

//if (!this->getVisible()) { return; }
if (this->opacity == 0.f || this->scale == glm::vec3(0.f)) { return; }

auto tScale = model->getScale();
auto tPos = model->getPosition();
Expand Down
Loading

0 comments on commit 97f1dd6

Please sign in to comment.