Skip to content
This repository was archived by the owner on Aug 2, 2020. It is now read-only.

Commit fe67dec

Browse files
Big Commit
Updated Boost, Lua And ASSIMP Submodules Renamed The Main Solution To "Engine Projects" Fixed Support Dll XINPUT For Win 7 Fixed Loggin Information To File Added SDKInterface To Hardcoded UI (Not To Load From File Like Dynamic Load) Rework DebugDraw (Now Under-Construction) Refactoring In CLua Class (See The CutScene.lua Script) Added To Camera_Control (Aka Jump), CScene (Cut-Scene) And SimpleLogic Depend On CPU Time (Delta Time) Fixed/Clean UP UI Class
1 parent a85db10 commit fe67dec

File tree

1,255 files changed

+55452
-19631
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,255 files changed

+55452
-19631
lines changed

Engine/Actor.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@ void Actor::Render(float Time)
2828
{
2929
Update(Time);
3030

31-
auto P = Vector2::SmoothStep(Vector2(1.f, 0.f), Number, 10.f).x;
31+
auto P = Vector2::SmoothStep(Vector2(Application->getframeTime(), 0.f), Number, 15.f).x;
3232
Application->getCamera()->SetProjParams(P,
3333
((float)Application->getWorkAreaSize(Application->GetHWND()).x /
3434
(float)Application->getWorkAreaSize(Application->GetHWND()).y), 0.1f, 1000.f);
3535

3636
auto PosCCT = Application->getCamera()->GetCCT();
37-
if (PosCCT.operator bool() && DrawCamSphere)
37+
if (PosCCT.operator bool() && DrawCamSphere && Application->getDebugDraw())
3838
{
39-
BoundingSphere sphere(ToExtended(PosCCT->getController()->getPosition()), PosCCT->getController()->getRadius());
40-
Application->getDebugDraw()->Draw(sphere, (Vector4)Colors::DarkSlateBlue);
39+
//BoundingSphere sphere(ToExtended(PosCCT->getController()->getPosition()), PosCCT->getController()->getRadius());
40+
//Application->getDebugDraw()->Draw(sphere, (Vector4)Colors::DarkSlateBlue);
4141
}
4242

43-
Number.Clamp(Vector2(0.1f, 0.f), Vector2(1.f, 0.f));
44-
if (GetAsyncKeyState(0xBB))
43+
Number.Clamp(Vector2(0.2f, 0.f), Vector2(1.f, 0.f));
44+
if (Application->getKeyboard()->GetState().OemPlus)
4545
{
46-
Number.x += 0.005f;
46+
Number.x -= 0.01f;
4747
return;
4848
}
49-
else if (GetAsyncKeyState(0xBD))
49+
else if (Application->getKeyboard()->GetState().OemMinus)
5050
{
51-
Number.x -= 0.005f;
51+
Number.x += 0.01f;
5252
return;
5353
}
5454
}
@@ -59,7 +59,8 @@ HRESULT Actor::Init()
5959
Application->getCamera()->SetResetCursorAfterMove(true);
6060
Application->getCamera()->SetFreeMoveCam(true);
6161
Application->getCamera()->SetDrag(true);
62-
Application->getCamera()->Teleport(Vector3(5.5, 1.5, 0), Vector3(6, 0, 0));
62+
Application->getCamera()->SetScalers();
63+
//Application->getCamera()->Teleport(Vector3(5.5, 1.5, 0), Vector3(6, 0, 0));
6364

6465
InitClass = true;
6566
return S_OK;

Engine/Audio.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ vector<unique_ptr<Audio::AudioFile>> Audio::AFiles;
1717
XAUDIO2_VOICE_DETAILS Audio::VOICE_Details;
1818
XAUDIO2_DEVICE_DETAILS Audio::DEVICE_Details;
1919

20+
ToDo("Error Hanging!")
2021
HRESULT Audio::AudioFile::loadWAVFile(string filename, WAVEFORMATEXTENSIBLE &wfx, XAUDIO2_BUFFER &buffer)
2122
{
2223
mmio = mmioOpenA(const_cast<LPSTR>(filename.c_str()), NULL, MMIO_READ);
@@ -27,15 +28,19 @@ HRESULT Audio::AudioFile::loadWAVFile(string filename, WAVEFORMATEXTENSIBLE &wfx
2728
riff.fccType = mmioFOURCC('W', 'A', 'V', 'E');
2829
if (mmioDescend(mmio, &riff, NULL, MMIO_FINDRIFF) != MMSYSERR_NOERROR)
2930
{
30-
MessageBoxA(NULL, "This File Isn't a WAV File", "Error", MB_OK);
31+
Engine::LogError("Audio: " + filename + ": Isn't a WAV File",
32+
filename + ": Isn't a WAV File",
33+
"Something is wrong with Audio: " + filename + ": Isn't a WAV File");
3134
return HRESULT_FROM_WIN32(GetLastError());
3235
}
3336

3437
fmt.ckid = mmioFOURCC('f', 'm', 't', ' ');
3538

3639
if (mmioDescend(mmio, &fmt, &riff, MMIO_FINDCHUNK) != MMSYSERR_NOERROR)
3740
{
38-
MessageBoxA(NULL, "This File Hasn't FMT", "Error", MB_OK);
41+
Engine::LogError("Audio: " + filename + ": Hasn't a FMT",
42+
filename + ": Hasn't a FMT",
43+
"Something is wrong with Audio: " + filename + ": Hasn't a FMT");
3944
return HRESULT_FROM_WIN32(GetLastError());
4045
}
4146

@@ -54,7 +59,6 @@ HRESULT Audio::AudioFile::loadWAVFile(string filename, WAVEFORMATEXTENSIBLE &wfx
5459
MessageBoxA(NULL, "DEF_FMT", "Error", MB_OK);
5560
return false;
5661
}
57-
5862
}
5963

6064
mmioAscend(mmio, &fmt, SEEK_SET);
@@ -64,15 +68,15 @@ HRESULT Audio::AudioFile::loadWAVFile(string filename, WAVEFORMATEXTENSIBLE &wfx
6468
if (mmioDescend(mmio, &data, &riff, MMIO_FINDCHUNK) != MMSYSERR_NOERROR)
6569
Engine::LogError((boost::format("Audio::LoadWAV()-> This File: %s Has a Bad Data.")
6670
% filename.c_str()).str(),
67-
"Audio::LoadWAV() failed!!!", "Sound: Something is wrong with Load WAV File!");
71+
"Audio::LoadWAV() failed!!!", "Sound: Something is wrong with Load WAV File! It Has a Bad Data");
6872

6973
pDataBuffer.resize(data.cksize);
7074

7175
if (mmioRead(
7276
mmio,
7377
reinterpret_cast<HPSTR>(&pDataBuffer[0]), data.cksize) != (signed)data.cksize)
7478
Engine::LogError((boost::format("Audio::LoadWAV()-> This File: %s Isn't a WAV File.") % filename).str(),
75-
"Audio::LoadWAV() failed!!!", "Sound: Something is wrong with Load WAV File!");
79+
"Audio::LoadWAV() failed!!!", "Sound: Something is wrong with Load WAV File! It Isn't a WAV File");
7680

7781
mmioClose(mmio, MMIO_FHOPEN);
7882

@@ -199,8 +203,8 @@ void Audio::Update()
199203

200204
for (size_t i = 0; i < AFiles.size(); i++)
201205
{
202-
AFiles.at(i)->Update(pos, X3DInstance, Listener, Emitter, EmitterCone, DSPSettings,
203-
dwCalcFlags);
206+
AFiles.at(i)->Update(Vector3(pos.x, pos.y, pos.z), X3DInstance, Listener, Emitter, EmitterCone,
207+
DSPSettings, dwCalcFlags);
204208
}
205209
}
206210

Engine/Audio.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
#include "pch.h"
55

66
#include "DXSDKAudio2.h"
7-
#include <X3DAudio.h>
8-
#include <mmsystem.h>
7+
#include "X3DAudio.h"
98

109
class Audio
1110
{
@@ -62,8 +61,8 @@ class Audio
6261
static void changeSoundVol(float Vol);
6362
void changeSoundPan(float Pan);
6463

65-
void changeSoundPos(Vector3 pos) { this->pos = pos; }
66-
Vector3 getSoundPosition() { return pos; }
64+
void changeSoundPos(Vector3 pos) { this->pos = X3DAUDIO_VECTOR{ pos.x, pos.y, pos.z }; }
65+
Vector3 getSoundPosition() { return Vector3(pos.x, pos.y, pos.z); }
6766
Audio() {}
6867
~Audio() {}
6968

@@ -80,7 +79,7 @@ class Audio
8079
static XAUDIO2_DEVICE_DETAILS DEVICE_Details;
8180

8281
X3DAUDIO_HANDLE X3DInstance;
83-
X3DAUDIO_LISTENER Listener = { XMFLOAT3(0,0,0) };
82+
X3DAUDIO_LISTENER Listener = { };
8483
X3DAUDIO_CONE Listener_DirectionalCone;
8584

8685
X3DAUDIO_EMITTER Emitter;
@@ -89,7 +88,7 @@ class Audio
8988

9089
X3DAUDIO_DSP_SETTINGS DSPSettings;
9190

92-
Vector3 pos = Vector3::Zero;
91+
X3DAUDIO_VECTOR pos = {};
9392

9493
DWORD dwCalcFlags = X3DAUDIO_CALCULATE_MATRIX | X3DAUDIO_CALCULATE_DOPPLER
9594
| X3DAUDIO_CALCULATE_LPF_DIRECT /*| X3DAUDIO_CALCULATE_LPF_REVERB

Engine/CCommands.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ void Commands::ExecCommand(shared_ptr<dialogs> &Console, shared_ptr<Command> &cm
107107
Console->getComponents()->FindComponentChild("ConsoleText")->getComponents().front()->
108108
FindComponentUText("##CText")->ClearBuffer();
109109
File_system::ClearLogs();
110+
History.push_back(cmd->TypedCmd);
110111
return;
111112
}
112113
else if (contains(CMD, "dotorque"))

Engine/CLua.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ void CLua::Init()
1919
LuaState.open_libraries(lib::base, lib::package);
2020

2121
// Log Funtions (Console) !!!
22-
LuaState["Engine"].get_or_create<table>().new_usertype<Console>("Console", "AddCmd",
23-
&Console::AddCmd, "LogError", &Console::LogError, "LogInfo", &Console::LogInfo,
22+
LuaState["Engine"].get_or_create<table>().new_usertype<Console>("Console", "PushCMD",
23+
&Console::PushCMD, "LogError", &Console::LogError, "LogInfo", &Console::LogInfo,
2424
"LogNormal", &Console::LogNormal);
2525

2626
// Audio System !!!
@@ -38,28 +38,31 @@ void CLua::Init()
3838
// CutScene !!!
3939
LuaState["Engine"].get_or_create<table>().new_usertype<CutScene>("CutScene", constructors<CutScene()>(),
4040
//CutScene(Vector3, Vector3, float)>(),
41-
"AddPoint", &CutScene::AddNewPoint, "Start", &CutScene::Start, "Update", &CutScene::Update);
41+
"AddPoint", &CutScene::AddNewPoint, "Start", &CutScene::Start, "Update", &CutScene::Update,
42+
"DeletePoints", &CutScene::Reset);
4243

4344
LuaState.new_usertype<Vector3>("vec3", constructors<Vector3(), Vector3(float, float, float),
4445
void(float, float, float)>());
4546

46-
//// Keyboard !!!
47-
//LuaState["Engine"].get_or_create<table>().new_usertype<Keyboard>("Keyboard", "IsKeyDown", &Engine::IsKeyboardDown,
48-
// "IsKeyUp", &Engine::IsKeyboardUp);
47+
// Keyboard !!!
48+
LuaState["Engine"].get_or_create<table>().new_usertype<Keyboard>("Keyboard", "IsKeyDown", &Engine::IsKeyboardDown,
49+
"IsKeyUp", &Engine::IsKeyboardUp);
50+
51+
// Mouse !!!
52+
LuaState["Engine"].get_or_create<table>().new_usertype<Mouse>("Mouse", "IsLeft", &Engine::IsMouseLeft,
53+
"IsRight", &Engine::IsMouseRight, "SetVisible", &ShowCursor);
4954

50-
//// Mouse !!!
51-
//Table_Engine.new_usertype<Mouse::>("Mouse", "IsKeyDown", &Engine::IsKeyDown,
52-
// "IsKeyUp", &Engine::IsKeyUp, "SetVisible", &Engine::SetVisibleMouse);
5355
const string package_path = LuaState["package"]["path"];
5456
LuaState["package"]["path"] = package_path + (!package_path.empty() ? ";" : "")
5557
+ Application->getFS()->getPathFromType(_TypeOfFile::SCRIPTS) + "?.lua";
5658

57-
Reinit();
59+
callFunction("main.lua", "initEverything", "");
5860
}
5961

6062
void CLua::Reinit()
6163
{
6264
callFunction("main.lua", "initEverything", "");
65+
//Application->setCScene(make_shared<CutScene>(LuaState["CutScene_instance"]));
6366
}
6467

6568
void CLua::Update()
@@ -91,7 +94,7 @@ void CLua::callFunction(string FileName, string Function, string params)
9194
Console::LogError(string("Lua error: File: \"") + FileName + string("\" Doesn't Exist!"));
9295
return;
9396
}
94-
LuaState.script_file(File);
97+
LuaState.safe_script_file(File);
9598
LuaState.get<sol::function>(Function.c_str()).template call<void>(params);
9699
}
97100
catch (error e)

Engine/Camera.cpp

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,37 @@ HRESULT Camera::Init(float W, float H, float FOV)
2121
return S_OK;
2222
}
2323

24+
XMMATRIX XMMatrixLookToLH_New(FXMVECTOR EyePosition, FXMVECTOR EyeDirectionOld, FXMVECTOR UpDirection)
25+
{
26+
XMVECTOR EyeDirection = XMVectorSubtract(EyeDirectionOld, EyePosition);
27+
28+
assert(!XMVector3IsInfinite(EyeDirection));
29+
assert(!XMVector3IsInfinite(UpDirection));
30+
31+
XMVECTOR R2 = XMVector3Normalize(EyeDirection);
32+
33+
XMVECTOR R0 = XMVector3Cross(UpDirection, R2);
34+
R0 = XMVector3Normalize(R0);
35+
36+
XMVECTOR R1 = XMVector3Cross(R2, R0);
37+
38+
XMVECTOR NegEyePosition = XMVectorNegate(EyePosition);
39+
40+
XMVECTOR D0 = XMVector3Dot(R0, NegEyePosition);
41+
XMVECTOR D1 = XMVector3Dot(R1, NegEyePosition);
42+
XMVECTOR D2 = XMVector3Dot(R2, NegEyePosition);
43+
44+
XMMATRIX M;
45+
M.r[0] = XMVectorSelect(D0, R0, g_XMSelect1110.v);
46+
M.r[1] = XMVectorSelect(D1, R1, g_XMSelect1110.v);
47+
M.r[2] = XMVectorSelect(D2, R2, g_XMSelect1110.v);
48+
M.r[3] = g_XMIdentityR3.v;
49+
50+
M = XMMatrixTranspose(M);
51+
52+
return M;
53+
}
54+
2455
void Camera::SetViewParams(Vector3 vEyePt, Vector3 vLookatPt)
2556
{
2657
XMStoreFloat3(&m_vEye, vEyePt);
@@ -32,7 +63,7 @@ void Camera::SetViewParams(Vector3 vEyePt, Vector3 vLookatPt)
3263
XMStoreFloat3(&m_vDefaultLookAt, vLookatPt);
3364
}
3465
// Calc the view matrix
35-
m_mView = XMMatrixLookAtLH(vEyePt, vLookatPt, Vector3::Up);
66+
m_mView = XMMatrixLookToLH_New(vEyePt, vLookatPt, Vector3::Up);
3667

3768
Vector3 zBasis;
3869
zBasis = vLookatPt;
@@ -57,8 +88,7 @@ void Camera::Teleport(Vector3 NewPos, Vector3 NewLook, bool NoTPPhysx)
5788
if (C_CT.operator bool() && !NoTPPhysx && (NewPos != Vector3::Zero))
5889
C_CT->getController()->setPosition(PxExtendedVec3(NewPos.x, NewPos.y, NewPos.z));
5990

60-
if (NewPos != Vector3::Zero)
61-
SetViewParams(NewPos, NewLook);
91+
SetViewParams(NewPos, NewLook);
6292
}
6393

6494
void Camera::SetNumberOfFramesToSmoothMouseData(int nFrames)
@@ -97,11 +127,16 @@ float Camera::GetFarClip() const
97127
return m_fFarPlane;
98128
}
99129

100-
float Camera::getMoveScale() const
130+
float Camera::getMoveScale()
101131
{
102132
return m_fMoveScaler;
103133
}
104134

135+
float Camera::getRotateScale()
136+
{
137+
return m_fRotationScaler;
138+
}
139+
105140
#include "Console.h"
106141
void Camera::GetInput(bool bGetKeyboardInput, bool bGetGamepadInput)
107142
{
@@ -199,7 +234,7 @@ void Camera::UpdateVelocity(float fElapsedTime)
199234
vAccel = XMVector3Normalize(vAccel);
200235

201236
// Scale the acceleration vector
202-
vAccel *= m_fMoveScaler;
237+
vAccel *= (Application->getKeyboard()->GetState().LeftShift ? m_fMoveScaler + 15.f : m_fMoveScaler);
203238

204239
if (m_bMovementDrag)
205240
{
@@ -240,18 +275,6 @@ void Camera::Reset()
240275

241276
void Camera::FrameMove(float fElapsedTime)
242277
{
243-
if (Application->getKeyboard()->GetState().LeftShift)
244-
#if defined (DEBUG)
245-
SetScalers(0.010f, 6.0f * 15.0f);
246-
#else
247-
SetScalers(0.0005f, 6.0f * 15.0f);
248-
#endif
249-
else
250-
#if defined (DEBUG)
251-
SetScalers(0.010f, 6.0f);
252-
#else
253-
SetScalers(0.0005f, 6.0f);
254-
#endif
255278
if (Application->getKeyboard()->GetState().IsKeyDown(Keyboard::Keys::Home))
256279
Reset();
257280

@@ -308,7 +331,7 @@ void Camera::FrameMove(float fElapsedTime)
308331
m_vLookAt = vEye + vWorldAhead;
309332

310333
// Update the view matrix
311-
m_mView = XMMatrixLookAtLH(vEye, m_vLookAt, vWorldUp);
334+
m_mView = XMMatrixLookToLH_New(vEye, m_vLookAt, vWorldUp);
312335

313336
m_mCameraWorld = m_mView.Invert();
314337
}

Engine/Camera.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Camera: public Camera_Control
3636
m_vMinBoundary = pvMinBoundary;
3737
m_vMaxBoundary = pvMaxBoundary;
3838
}
39-
void SetScalers(float fRotationScaler = 0.01f, float fMoveScaler = 5.0f)
39+
void SetScalers(float fRotationScaler = 0.001f, float fMoveScaler = 6.0f)
4040
{
4141
m_fRotationScaler = fRotationScaler;
4242
m_fMoveScaler = fMoveScaler;
@@ -51,7 +51,8 @@ class Camera: public Camera_Control
5151
Vector3 GetLookAtPt() const;
5252
float GetNearClip() const;
5353
float GetFarClip() const;
54-
float getMoveScale() const;
54+
float getMoveScale();
55+
float getRotateScale();
5556
protected:
5657
void UpdateMouseDelta();
5758
void UpdateVelocity(float fElapsedTime);

0 commit comments

Comments
 (0)