Skip to content

Commit

Permalink
fixed cam button and popup
Browse files Browse the repository at this point in the history
  • Loading branch information
adafcaefc committed Dec 6, 2024
1 parent 7513dc7 commit 1e1a040
Show file tree
Hide file tree
Showing 11 changed files with 289 additions and 404 deletions.
89 changes: 0 additions & 89 deletions Geome3Dash/Geome3Dash.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,72 +26,6 @@
<ClCompile Include="lib\imgui-cocos\imgui_widgets.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\App.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\external_files\stb_image.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\external_files\tiny_obj_loader.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\graphics\ObjContainer.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\graphics\SceneCalculations.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\graphics\ShaderTerrainLib.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\graphics\Shape.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\graphics\Viewer.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\scene\Fire.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\scene\Fountain.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\scene\MirrorBox.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\scene\ObjInstanced.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\scene\ObjSingle.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\scene\Player.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\scene\SceneComponent.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\scene\Skybox.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\scene\Terrain.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\utils\FileUtils.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\utils\Logger.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\utils\Random.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\utils\Sound.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\terrain\utils\Time.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="lib\tinyfiledialogs\tinyfiledialogs.c">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
Expand Down Expand Up @@ -181,29 +115,6 @@
<ClInclude Include="lib\imgui-cocos\imstb_rectpack.h" />
<ClInclude Include="lib\imgui-cocos\imstb_textedit.h" />
<ClInclude Include="lib\imgui-cocos\imstb_truetype.h" />
<ClInclude Include="lib\terrain\App.h" />
<ClInclude Include="lib\terrain\external_files\stb_image.h" />
<ClInclude Include="lib\terrain\external_files\tiny_obj_loader.h" />
<ClInclude Include="lib\terrain\graphics\InputState.h" />
<ClInclude Include="lib\terrain\graphics\ObjContainer.h" />
<ClInclude Include="lib\terrain\graphics\SceneCalculations.h" />
<ClInclude Include="lib\terrain\graphics\Shader.h" />
<ClInclude Include="lib\terrain\graphics\Shape.h" />
<ClInclude Include="lib\terrain\graphics\Viewer.h" />
<ClInclude Include="lib\terrain\scene\Fire.h" />
<ClInclude Include="lib\terrain\scene\Fountain.h" />
<ClInclude Include="lib\terrain\scene\MirrorBox.h" />
<ClInclude Include="lib\terrain\scene\ObjInstanced.h" />
<ClInclude Include="lib\terrain\scene\ObjSingle.h" />
<ClInclude Include="lib\terrain\scene\Player.h" />
<ClInclude Include="lib\terrain\scene\SceneComponent.h" />
<ClInclude Include="lib\terrain\scene\Skybox.h" />
<ClInclude Include="lib\terrain\scene\Terrain.h" />
<ClInclude Include="lib\terrain\utils\FileUtils.h" />
<ClInclude Include="lib\terrain\utils\Logger.h" />
<ClInclude Include="lib\terrain\utils\Random.h" />
<ClInclude Include="lib\terrain\utils\Sound.h" />
<ClInclude Include="lib\terrain\utils\Time.h" />
<ClInclude Include="lib\tinyfiledialogs\tinyfiledialogs.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="src\BezierManager.h" />
Expand Down
135 changes: 0 additions & 135 deletions Geome3Dash/Geome3Dash.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -171,72 +171,6 @@
<ClCompile Include="lib\tinyfiledialogs\tinyfiledialogs.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\App.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\graphics\ObjContainer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\graphics\SceneCalculations.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\graphics\ShaderTerrainLib.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\graphics\Shape.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\graphics\Viewer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\external_files\stb_image.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\external_files\tiny_obj_loader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\scene\Fire.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\scene\Fountain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\scene\MirrorBox.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\scene\ObjInstanced.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\scene\ObjSingle.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\scene\Player.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\scene\SceneComponent.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\scene\Skybox.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\scene\Terrain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\utils\FileUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\utils\Logger.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\utils\Random.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\utils\Sound.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lib\terrain\utils\Time.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\game\editor\G3DCurveEditorPopup.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -413,75 +347,6 @@
<ClInclude Include="lib\tinyfiledialogs\tinyfiledialogs.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\App.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\graphics\InputState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\graphics\ObjContainer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\graphics\SceneCalculations.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\graphics\Shader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\graphics\Shape.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\graphics\Viewer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\external_files\stb_image.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\external_files\tiny_obj_loader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\scene\Fire.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\scene\Fountain.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\scene\MirrorBox.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\scene\ObjInstanced.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\scene\ObjSingle.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\scene\Player.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\scene\SceneComponent.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\scene\Skybox.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\scene\Terrain.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\utils\FileUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\utils\Logger.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\utils\Random.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\utils\Sound.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\terrain\utils\Time.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\game\editor\G3DCurveEditorPopup.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
16 changes: 8 additions & 8 deletions Geome3Dash/src/LevelDataManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class GJBaseGameLayer;

namespace g3d
{
struct CameraActionLD : public CameraAction
{
NLOHMANN_DEFINE_TYPE_INTRUSIVE(CameraActionLD, x, y, z, yaw, pitch, time, triggerAt);
};
//struct CameraActionLD : public CameraAction
//{
// NLOHMANN_DEFINE_TYPE_INTRUSIVE(CameraActionLD, x, y, z, yaw, pitch, time, triggerAt);
//};

struct CubicBezierLD : public CubicBezier
{
NLOHMANN_DEFINE_TYPE_INTRUSIVE(CubicBezier, x0, y0, cx1, cy1, cx2, cy2, x1, y1);
};
//struct CubicBezierLD : public CubicBezier
//{
// NLOHMANN_DEFINE_TYPE_INTRUSIVE(CubicBezier, x0, y0, cx1, cy1, cx2, cy2, x1, y1);
//};

struct LevelData
{
Expand Down
67 changes: 57 additions & 10 deletions Geome3Dash/src/game/editor/CameraKeyframeEditorPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ namespace g3d
ckel->layer3d->camera.setPosition(
ckel->layer3d->camera.getPosition() +
deltaY * sensitivity * localUp +
deltaX * -sensitivity * side
);
deltaX * -sensitivity * side);
}
else {
float sensitivity = 0.05f;
Expand Down Expand Up @@ -107,16 +106,35 @@ namespace g3d

ckel->keyframeBuffer = currentLevelData.keyframe;
ckel->spline = currentLevelData.spline;
if (ckel->keyframeBuffer.keyframes.empty()) { ckel->keyframeBuffer.setKeyframe(0, glm::vec3(0), glm::vec3(0)); }
ckel->updateLevel();
ckel->spline.updateParameterList();

glm::vec3 newFront;
newFront.x = cos(glm::radians(currentLevelData.yaw)) * cos(glm::radians(currentLevelData.pitch));
newFront.y = sin(glm::radians(currentLevelData.pitch));
newFront.z = sin(glm::radians(currentLevelData.yaw)) * cos(glm::radians(currentLevelData.pitch));
const auto front = glm::normalize(newFront);
ckel->keyframeBuffer.setKeyframe(0, glm::vec3(currentLevelData.x, currentLevelData.y, currentLevelData.z) * glm::vec3(ckel->lengthScaleFactor * 16 / 9), newFront);
//auto& cld = currentLevelData;
//auto data = ckel->spline.findClosestByLength(cld.x * ckel->lengthScaleFactor * 20);
//auto pos = data.value;
//auto normal = glm::normalize(ckel->spline.normal(data.t));
//auto offset = pos + (normal * ckel->lengthScaleFactor * (static_cast<float>(cld.y * 20) - 110));
//offset.z += cld.z * 20;

//glm::vec3 newFront;
//newFront.x = cos(glm::radians(cld.yaw)) * cos(glm::radians(cld.pitch));
//newFront.y = sin(glm::radians(cld.pitch));
//newFront.z = sin(glm::radians(cld.yaw)) * cos(glm::radians(cld.pitch));
//const auto front = glm::normalize(newFront);
//ckel->keyframeBuffer.setKeyframe(0, offset, front);

auto& cld = currentLevelData;
sus3d::Camera fakeCamera;
fakeCamera.setPitch(cld.pitch);
fakeCamera.setYaw(cld.yaw);
fakeCamera.setPosition(glm::vec3(cld.x, cld.y, cld.z));
const auto kfcopy = ckel->keyframeBuffer.keyframes;
ckel->keyframeBuffer.keyframes.clear();
for (auto& kf : kfcopy)
{
if (kf.playersXpos != 0.f) { ckel->keyframeBuffer.keyframes.push_back(kf); }
}
ckel->keyframeBuffer.setKeyframe(0, fakeCamera.getPosition() * glm::vec3(ckel->lengthScaleFactor * 20), fakeCamera.getFront());

// need to delete this on destructor (later)
splineTr = new SplineGameObjectTransformer(&ckel->spline, &ckel->lengthScaleFactor);
Expand Down Expand Up @@ -186,7 +204,21 @@ namespace g3d
}

void CameraKeyframeEditorPopup::onClose(CCObject* obj) {
if (ckel->keyframeBuffer.keyframes.empty()) { ckel->keyframeBuffer.setKeyframe(0, glm::vec3(0), glm::vec3(0)); }
if (ckel->keyframeBuffer.keyframes.empty())
{
auto& cld = currentLevelData;
sus3d::Camera fakeCamera;
fakeCamera.setPitch(cld.pitch);
fakeCamera.setYaw(cld.yaw);
fakeCamera.setPosition(glm::vec3(cld.x, cld.y, cld.z));
const auto kfcopy = ckel->keyframeBuffer.keyframes;
ckel->keyframeBuffer.keyframes.clear();
for (auto& kf : kfcopy)
{
if (kf.playersXpos != 0.f) { ckel->keyframeBuffer.keyframes.push_back(kf); }
}
ckel->keyframeBuffer.setKeyframe(0, fakeCamera.getPosition() * glm::vec3(ckel->lengthScaleFactor * 20), fakeCamera.getFront());
}
currentLevelData.keyframe = ckel->keyframeBuffer;
setLevelData(LevelEditorLayer::get(), currentLevelData);
this->setMouseEnabled(false);
Expand All @@ -212,6 +244,21 @@ namespace g3d
}
void CameraKeyframeEditorPopup::onRemoveLast(CCObject*) {
ckel->keyframeBuffer.removeLastKeyframe();
if (ckel->keyframeBuffer.keyframes.empty())
{
auto& cld = currentLevelData;
sus3d::Camera fakeCamera;
fakeCamera.setPitch(cld.pitch);
fakeCamera.setYaw(cld.yaw);
fakeCamera.setPosition(glm::vec3(cld.x, cld.y, cld.z));
const auto kfcopy = ckel->keyframeBuffer.keyframes;
ckel->keyframeBuffer.keyframes.clear();
for (auto& kf : kfcopy)
{
if (kf.playersXpos != 0.f) { ckel->keyframeBuffer.keyframes.push_back(kf); }
}
ckel->keyframeBuffer.setKeyframe(0, fakeCamera.getPosition() * glm::vec3(ckel->lengthScaleFactor * 20), fakeCamera.getFront());
}
}

void CameraKeyframeEditorPopup::draw()
Expand Down
Loading

0 comments on commit 1e1a040

Please sign in to comment.