first version of IM ready for PR

This commit is contained in:
mushgunAX 2022-09-25 16:39:01 +08:00
parent ef36ae462e
commit 8ab5afd3c4
3 changed files with 31 additions and 0 deletions

View File

@ -23,6 +23,7 @@
#include "Graphics/MiddleEnd/Interface/SHRenderable.h" #include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Scene/SHSceneManager.h" #include "Scene/SHSceneManager.h"
#include "Math/Transform/SHTransformSystem.h" #include "Math/Transform/SHTransformSystem.h"
#include "Input/SHInputManagerSystem.h"
#include "Scenes/SBTestScene.h" #include "Scenes/SBTestScene.h"
#include "Math/Transform/SHTransformComponent.h" #include "Math/Transform/SHTransformComponent.h"
@ -52,6 +53,7 @@ namespace Sandbox
SHADE::SHSystemManager::CreateSystem<SHADE::SHTransformSystem>(); SHADE::SHSystemManager::CreateSystem<SHADE::SHTransformSystem>();
SHADE::SHSystemManager::CreateSystem<SHADE::SHGraphicsSystem>(); SHADE::SHSystemManager::CreateSystem<SHADE::SHGraphicsSystem>();
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>()); SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
SHADE::SHSystemManager::CreateSystem<SHADE::SHInputManagerSystem>();
// Create Routines // Create Routines
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHScriptEngine, SHADE::SHScriptEngine::FrameSetUpRoutine>(); SHADE::SHSystemManager::RegisterRoutine<SHADE::SHScriptEngine, SHADE::SHScriptEngine::FrameSetUpRoutine>();
@ -72,6 +74,8 @@ namespace Sandbox
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHRenderable>(); SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHRenderable>();
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHTransformComponent>(); SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHTransformComponent>();
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHInputManagerSystem, SHADE::SHInputManagerSystem::InputManagerRoutine>();
// Set up graphics system and windows // Set up graphics system and windows
graphicsSystem->SetWindow(&window); graphicsSystem->SetWindow(&window);
sdlWindow = SDL_CreateWindowFrom(window.GetHWND()); sdlWindow = SDL_CreateWindowFrom(window.GetHWND());

View File

@ -35,6 +35,8 @@ namespace SHADE
int SHInputManagerSystem::mouseScreenY = 0; int SHInputManagerSystem::mouseScreenY = 0;
int SHInputManagerSystem::mouseScreenXLast = 0; int SHInputManagerSystem::mouseScreenXLast = 0;
int SHInputManagerSystem::mouseScreenYLast = 0; int SHInputManagerSystem::mouseScreenYLast = 0;
double SHInputManagerSystem::mouseVelocityX = 0;
double SHInputManagerSystem::mouseVelocityY = 0;
int SHInputManagerSystem::mouseWheelVerticalDelta = 0; int SHInputManagerSystem::mouseWheelVerticalDelta = 0;
int SHInputManagerSystem::mouseWheelVerticalDeltaPoll = 0; int SHInputManagerSystem::mouseWheelVerticalDeltaPoll = 0;
@ -126,6 +128,10 @@ namespace SHADE
//Mouse Positioning///////////////////////////////////// //Mouse Positioning/////////////////////////////////////
//https://stackoverflow.com/a/6423739 //https://stackoverflow.com/a/6423739
//Set last positioning
mouseScreenXLast = mouseScreenX;
mouseScreenYLast = mouseScreenY;
//Get cursor position, even when it is outside window //Get cursor position, even when it is outside window
POINT p; POINT p;
GetCursorPos(&p); GetCursorPos(&p);

View File

@ -420,6 +420,16 @@ namespace SHADE
if (y) *y = mouseScreenY; if (y) *y = mouseScreenY;
} }
//Get the mouse velocity
//Two output parameters for x and y velocitites
//In pixels per second for both
static inline void GetMouseVelocity(double* x = nullptr,
double* y = nullptr) noexcept
{
if (x) *x = mouseVelocityX;
if (y) *y = mouseVelocityY;
}
//Get the mouse wheel vertical delta //Get the mouse wheel vertical delta
static inline int GetMouseWheelVerticalDelta() noexcept static inline int GetMouseWheelVerticalDelta() noexcept
{ {
@ -529,15 +539,26 @@ namespace SHADE
//MOUSE VARIABLES/////////////////////////////////////////////////////////// //MOUSE VARIABLES///////////////////////////////////////////////////////////
//Present horizontal positioning of the mouse WRT the screen //Present horizontal positioning of the mouse WRT the screen
//Increasing rightwards
static int mouseScreenX; static int mouseScreenX;
//Present vertical positioning of the mouse WRT the screen //Present vertical positioning of the mouse WRT the screen
//Increasing downwards
static int mouseScreenY; static int mouseScreenY;
//Horizontal positioning of the mouse WRT screen in last frame //Horizontal positioning of the mouse WRT screen in last frame
//Increasing rightwards
static int mouseScreenXLast; static int mouseScreenXLast;
//Vertical positioning of the mouse WRT screen in the last frame //Vertical positioning of the mouse WRT screen in the last frame
//Increasing downwards
static int mouseScreenYLast; static int mouseScreenYLast;
//The velocity at which the mouse is being moved horizontally (px/s)
//Rightwards is positive
static double mouseVelocityX;
//The velocity at which the mouse is being moved vertically (px/s)
//Downwards is positive
static double mouseVelocityY;
//For polling mouse wheel events, not to be read //For polling mouse wheel events, not to be read
static int mouseWheelVerticalDeltaPoll; static int mouseWheelVerticalDeltaPoll;
//Mouse wheel vertical rotation speed. Positive is rotation AWAY from user //Mouse wheel vertical rotation speed. Positive is rotation AWAY from user