Skip to content

Commit b6d8ae2

Browse files
committed
FPCharacter object[1]
1 parent 10cc47d commit b6d8ae2

28 files changed

Lines changed: 426 additions & 111 deletions

3DRadSpace/3DRadSpace_AngelscriptPlugin/AngelscriptWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <format>
99

1010
#include <Engine3DRadSpace\3DRadSpace.hpp>
11-
#include <Engine3DRadSpace\Scripting\Legacy.hpp>
11+
#include "Legacy.hpp"
1212

1313
using namespace Engine3DRadSpace::Angelscript;
1414
using namespace Engine3DRadSpace::Logging;

3DRadSpace/3DRadSpace_AngelscriptPlugin/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ target_link_libraries(3DRadSpace.AngelScript PRIVATE 3DRadSpace.Reflection)
3636
target_link_libraries(3DRadSpace.AngelScript PRIVATE 3DRadSpace.Games)
3737
target_link_libraries(3DRadSpace.AngelScript PRIVATE 3DRadSpace.Objects)
3838
target_link_libraries(3DRadSpace.AngelScript PRIVATE 3DRadSpace.Scripting)
39+
target_link_libraries(3DRadSpace.AngelScript PRIVATE 3DRadSpace.Projects)
3940
target_include_directories(3DRadSpace.AngelScript PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../)
4041

4142
#Add Angelscript

3DRadSpace/3DRadSpace_AngelscriptPlugin/Legacy.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#include "Legacy.hpp"
2-
#include "../Objects/Impl/Objects.hpp"
2+
#include <Engine3DRadSpace/Objects/Impl/Objects.hpp>
3+
#include <Engine3DRadSpace/Objects/Impl/TextPrint.hpp>
4+
#include <Engine3DRadSpace/Objects/ObjectList.hpp>
5+
#include <Engine3DRadSpace/Physics/Objects/RigidDynamic.hpp>
6+
#include <Engine3DRadSpace/Physics/Objects/RigidStatic.hpp>
7+
#include <Engine3DRadSpace/Projects/Serialization.hpp>
38

49
using namespace Engine3DRadSpace;
510
using namespace Engine3DRadSpace::Math;
@@ -281,7 +286,6 @@ void iObjectParamSet(unsigned obj_x, int index, float t)
281286

282287
auto refl = Internal::GetReflDataFromUUID(uuid);
283288
if (refl->NumFields() > index) return;
284-
//if (refl == nullptr) throw std::exception("??? This exception indicates a severe bug with object reflection metadata not being registered.");
285289
if (refl == nullptr) return;
286290

287291
auto field = refl->operator[](index);

3DRadSpace/3DRadSpace_AngelscriptPlugin/Legacy.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22
#include "../Engine3DRadSpace/Math/Vector3.hpp"
33
#include "../Engine3DRadSpace/Math/Quaternion.hpp"
4+
#include "../Engine3DRadSpace/Objects/ObjectList.hpp"
45

56
/*
67
Set of legacy functions from the old engine. Source: https://3drad.boards.net/page/script-reference

3DRadSpace/Engine3DRadSpace/Core/IGame.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace Engine3DRadSpace
3333
template<typename T>
3434
T* RequireService(Tag<T> dummy)
3535
{
36-
return RequireService(typeid(T));
36+
return static_cast<T*>(RequireService(typeid(T)));
3737
}
3838

3939
virtual void Exit() = 0;

3DRadSpace/Engine3DRadSpace/Math/Vector2.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,9 @@ Vector2 Vector2::Transform(const Vector2& v, const Matrix3x3& m)
210210
v.X * m.M11 + v.Y * m.M12 + m.M13,
211211
v.X * m.M21 + v.Y * m.M22 + m.M23
212212
};
213+
}
214+
215+
Vector2 Vector2::YX() const noexcept
216+
{
217+
return Vector2(Y, X);
213218
}

3DRadSpace/Engine3DRadSpace/Math/Vector2.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ namespace Engine3DRadSpace::Math
5555

5656
Vector2& Transform(const Matrix3x3& m);
5757
static Vector2 Transform(const Vector2& v, const Matrix3x3& m);
58+
59+
Vector2 YX() const noexcept;
5860
};
5961

6062
Vector2 E3DRSP_MATH_EXPORT operator*(float s, const Vector2& v);

3DRadSpace/Engine3DRadSpace/Math/Vector3.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "Vector3.hpp"
22
#include "Quaternion.hpp"
33
#include "Matrix4x4.hpp"
4+
#include "Vector2.hpp"
45

56
using namespace Engine3DRadSpace::Math;
67

@@ -259,3 +260,48 @@ Vector3 Engine3DRadSpace::Math::operator/(float s, const Vector3 &v)
259260
{
260261
return Vector3{ s / v.X, s / v.Y, s / v.Z };
261262
}
263+
264+
Vector2 Vector3::XX() const noexcept
265+
{
266+
return Vector2(X, X);
267+
}
268+
269+
Vector2 Vector3::XY() const noexcept
270+
{
271+
return Vector2(X, Y);
272+
}
273+
274+
Vector2 Vector3::XZ() const noexcept
275+
{
276+
return Vector2(X, Z);
277+
}
278+
279+
Vector2 Vector3::YX() const noexcept
280+
{
281+
return Vector2(Y, X);
282+
}
283+
284+
Vector2 Vector3::YY() const noexcept
285+
{
286+
return Vector2(Y, Y);
287+
}
288+
289+
Vector2 Vector3::YZ() const noexcept
290+
{
291+
return Vector2(Y, Z);
292+
}
293+
294+
Vector2 Vector3::ZX() const noexcept
295+
{
296+
return Vector2(Z, X);
297+
}
298+
299+
Vector2 Vector3::ZY() const noexcept
300+
{
301+
return Vector2(Z, Y);
302+
}
303+
304+
Vector2 Vector3::ZZ() const noexcept
305+
{
306+
return Vector2(Z, Z);
307+
}

3DRadSpace/Engine3DRadSpace/Math/Vector3.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace Engine3DRadSpace::Math
55
{
66
struct Quaternion;
77
struct Matrix4x4;
8+
struct Vector2;
89

910
struct E3DRSP_MATH_EXPORT Vector3
1011
{
@@ -64,6 +65,16 @@ namespace Engine3DRadSpace::Math
6465
//Element wise product
6566
static Vector3 Hadamard(const Vector3& a, const Vector3& b);
6667

68+
Vector2 XX() const noexcept;
69+
Vector2 XY() const noexcept;
70+
Vector2 XZ() const noexcept;
71+
Vector2 YX() const noexcept;
72+
Vector2 YY() const noexcept;
73+
Vector2 YZ() const noexcept;
74+
Vector2 ZX() const noexcept;
75+
Vector2 ZY() const noexcept;
76+
Vector2 ZZ() const noexcept;
77+
6778
auto operator <=>(const Vector3& v) const = default;
6879
};
6980

3DRadSpace/Engine3DRadSpace/Objects/Impl/FreeCam.cpp

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,29 @@ using namespace Engine3DRadSpace;
88
using namespace Engine3DRadSpace::Math;
99
using namespace Engine3DRadSpace::Objects;
1010

11-
FreeCam::FreeCam() : Camera("FreeCam")
11+
FreeCam::FreeCam(
12+
const std::string& name,
13+
bool enabled,
14+
const Vector3& pos,
15+
const Quaternion& rotation,
16+
const Vector3& up,
17+
float aspectRatio,
18+
float fov,
19+
float npd,
20+
float fpd
21+
) : Camera(name, enabled, pos, rotation, up, aspectRatio, fov, npd, fpd),
22+
_camCoords(rotation.ToYawPitchRoll().XY())
1223
{
1324
}
1425

1526
void FreeCam::Update()
1627
{
1728
if(Enabled) return;
29+
if (Frozen)
30+
{
31+
Camera::Update();
32+
return;
33+
}
1834

1935
auto game = static_cast<Game*>(_game);
2036
float dt = game->Update_dt;
@@ -39,19 +55,20 @@ void FreeCam::Update()
3955

4056
auto &kb = game->Keyboard;
4157

42-
Vector3 mv;
58+
if(kb.IsKeyDown(Forward)) _dir += _fwd;
59+
if(kb.IsKeyDown(Backward)) _dir -= _fwd;
60+
if(kb.IsKeyDown(Left)) _dir -= right;
61+
if(kb.IsKeyDown(Right)) _dir += right;
4362

44-
if(kb.IsKeyDown(Forward)) mv += _fwd;
45-
if(kb.IsKeyDown(Backward)) mv -= _fwd;
46-
if(kb.IsKeyDown(Left)) mv -= right;
47-
if(kb.IsKeyDown(Right)) mv += right;
63+
if (EnableElevation)
64+
{
65+
if (kb.IsKeyDown(Elevate)) _dir += Normal;
66+
if (kb.IsKeyDown(Descend)) _dir -= Normal;
67+
}
4868

49-
if(kb.IsKeyDown(Elevate)) mv += Normal;
50-
if(kb.IsKeyDown(Descend)) mv -= Normal;
69+
if(_dir.LengthSquared() > 0) _dir.Normalize();
5170

52-
if(mv.LengthSquared() > 0) mv.Normalize();
53-
54-
Position += mv * MovementSpeed * dt;
71+
Position += _dir * MovementSpeed * dt;
5572

5673
Camera::Update();
5774
}

0 commit comments

Comments
 (0)