diff --git a/build.cpp b/build.cpp index 72ebc5d..46a3a59 100755 --- a/build.cpp +++ b/build.cpp @@ -41,6 +41,7 @@ DECLARE_BUILD_STAGE(install_game) filesystem2->CopyDirectory(CUtlString("%s/core/",szOutputDir.GetString()), "funnyassets/materials"); filesystem2->CopyDirectory(CUtlString("%s/core/",szOutputDir.GetString()), "funnyassets/textures"); filesystem2->CopyDirectory(CUtlString("%s/core/",szOutputDir.GetString()), "funnyassets/physics"); + filesystem2->CopyFile(CUtlString("%s/core/",szOutputDir.GetString()), "funnyassets/default.cfg"); filesystem2->CopyDirectory(CUtlString("%s/core/",szOutputDir.GetString()), "build/funnygame/assets/shaders"); if (Target_t::DefaultTarget().kernel == TARGET_KERNEL_WINDOWS) { diff --git a/engine/cvar.cpp b/engine/cvar.cpp index bc205bf..d828712 100644 --- a/engine/cvar.cpp +++ b/engine/cvar.cpp @@ -220,6 +220,8 @@ void IConsole_Exec( int argc, char **argv) if (argc != 2) return; + V_printf("exec %s\n", argv[1]); + IFileHandle *f = filesystem->Open(argv[1], FILEMODE_READ); if (!f) return; diff --git a/engine/engine.cpp b/engine/engine.cpp index 954febe..1439ccf 100644 --- a/engine/engine.cpp +++ b/engine/engine.cpp @@ -99,6 +99,7 @@ extern "C" void FunnyMain( int argc, char **argv ) } + Console()->Execute(); double fPrevious = Plat_GetTime(); for (;;) { #ifdef STEAM @@ -108,6 +109,7 @@ extern "C" void FunnyMain( int argc, char **argv ) double fDelta = fCurrent-fPrevious; fPrevious = fCurrent; + g_pHumanDeviceManager->Frame(); g_pServerGame->m_pBridge->Frame(fDelta); @@ -117,6 +119,8 @@ extern "C" void FunnyMain( int argc, char **argv ) g_pClientGame->m_pBridge->Frame(fDelta); g_pRenderContext->Frame(fDelta); } + + Console()->Execute(); }; diff --git a/funnyassets/shaders/mesh_raster.shader b/funnyassets/shaders/mesh_raster.shader index 5445c46..6eed28c 100644 --- a/funnyassets/shaders/mesh_raster.shader +++ b/funnyassets/shaders/mesh_raster.shader @@ -39,6 +39,7 @@ VS output.m_vScreenPosition, g_modelData[uInstance].m_matTranslation ); + output.m_vScreenPosition = mul( output.m_vScreenPosition, g_matViewProjection diff --git a/game/client/build.cpp b/game/client/build.cpp index 1238752..a6bb246 100644 --- a/game/client/build.cpp +++ b/game/client/build.cpp @@ -18,6 +18,7 @@ DECLARE_BUILD_STAGE(Client) "../shared/game.cpp", "game.cpp", + "userinput.cpp", "baseentity.cpp", "basemodelentity.cpp", diff --git a/game/client/game.cpp b/game/client/game.cpp index 4854701..a5fd226 100644 --- a/game/client/game.cpp +++ b/game/client/game.cpp @@ -6,10 +6,8 @@ #include "entitysystem.h" #include "baseentity.h" #include "game.h" -#include "cglm/mat4.h" -#include "cglm/cglm.h" -#include "inetworkclient.h" #include "netprotocol.h" +#include "userinput.h" #ifdef STEAM #include "steam/isteamgameserver.h" #include "steam/steam_gameserver.h" @@ -29,34 +27,6 @@ class CFunnyGameBridge: public IEngineBridge }; -class CFunnyInput: public IHumanDeviceInput -{ - - virtual EInputType GetInputType() override { return k_EInput_Game; }; - - virtual void OnGameButton( EInputDeviceType eDevice, EInputButton eScancode, bool bIsPressed ) override; - virtual void OnGameAxis( EInputDeviceType eDevice, EInputAxis eAxis, float fValue) override; - virtual void OnGameAxisDiff( EInputDeviceType eDevice, EInputAxis eAxis, float fValue ) override; - - virtual void OnButton( EInputDeviceType eDevice, EInputButton eScancode, bool bIsPressed ) override {}; - virtual void OnAxis( EInputDeviceType eDevice, EInputAxis eAxis, float fValue) override {}; - virtual void OnAxisDiff( EInputDeviceType eDevice, EInputAxis eAxis, float fValue ) override {}; - - virtual void OnTextWriteUTF8( uint32_t uCode ) override {}; -}; - -void CFunnyInput::OnGameButton( EInputDeviceType eDevice, EInputButton eScancode, bool bIsPressed ) -{ - -} -void CFunnyInput::OnGameAxis( EInputDeviceType eDevice, EInputAxis eAxis, float fValue) -{ - -} -void CFunnyInput::OnGameAxisDiff( EInputDeviceType eDevice, EInputAxis eAxis, float fValue ) -{ - -} IEngineBridge *EngineBridge() { @@ -66,10 +36,12 @@ IEngineBridge *EngineBridge() EXPOSE_INTERFACE_FN(EngineBridge, IEngineBridge, ENGINE_BRIDGE_INTERFACE_VERSION) -static CFunnyInput s_mainInput; void CFunnyGameBridge::Init() { + Console()->AddCommand("exec game/core/default.cfg\n"); + Console()->Execute(); + g_pWorldRenderer->Init(); #ifdef STEAM if (g_pEngineConstants->m_bIsSteam) @@ -95,7 +67,7 @@ void CFunnyGameBridge::Init() g_pPhysics = (IPhysics*)fnPhysicsFactory(PHYSICS_INTERFACE_VERSION, NULL); g_pPhysicsWorld = g_pPhysics->CreateWorld(); - g_pHumanDeviceManager->SetDefaultInput(&s_mainInput); + g_pHumanDeviceManager->SetDefaultInput(g_pMainInput); } void CFunnyGameBridge::Tick( float fDelta ) diff --git a/game/client/milmoba/player.cpp b/game/client/milmoba/player.cpp index 6698837..d628a68 100644 --- a/game/client/milmoba/player.cpp +++ b/game/client/milmoba/player.cpp @@ -13,19 +13,21 @@ void C_MOBAPlayer::Spawn() { BaseClass::Spawn(); SetThink(Think); + SetScale(1); }; void C_MOBAPlayer::Think( float fDelta ) { - BaseClass::Think(fDelta); C_MOBAPlayer *pEntity = (C_MOBAPlayer*)UTIL_GetLocalPlayer(); if (pEntity == this) { Vector vCameraPos = GetAbsOrigin(); - vCameraPos.z -= 20; + vCameraPos.z += -20; g_pWorldRenderer->SetCameraPosition(vCameraPos); + } + BaseClass::Think(fDelta); }; LINK_ENTITY_TO_CLASS(player, C_MOBAPlayer) @@ -39,16 +41,12 @@ IMPLEMENT_EMPTY_SEND_DT(C_MOBAPlayer) static void IN_ForwardDown( int c, char **v ) { + V_printf("+forward\n"); } static ConCommand startforward("+forward", IN_ForwardDown); static void IN_ForwardUp( int c, char **v ) { - C_MOBAPlayer *pEntity = (C_MOBAPlayer*)UTIL_GetLocalPlayer(); - if (pEntity) - { - - } - + V_printf("-forward\n"); } static ConCommand endforward("-forward", IN_ForwardUp); diff --git a/game/client/userinput.cpp b/game/client/userinput.cpp new file mode 100644 index 0000000..6ebffef --- /dev/null +++ b/game/client/userinput.cpp @@ -0,0 +1,168 @@ +#include "userinput.h" +#include "tier1/utlstring.h" +#include "game.h" + +class CFunnyInput: public IHumanDeviceInput +{ +public: + virtual EInputType GetInputType() override { return k_EInput_Game; }; + + virtual void OnGameButton( EInputDeviceType eDevice, EInputButton eScancode, bool bIsPressed ) override; + virtual void OnGameAxis( EInputDeviceType eDevice, EInputAxis eAxis, float fValue) override; + virtual void OnGameAxisDiff( EInputDeviceType eDevice, EInputAxis eAxis, float fValue ) override; + + virtual void OnButton( EInputDeviceType eDevice, EInputButton eScancode, bool bIsPressed ) override {}; + virtual void OnAxis( EInputDeviceType eDevice, EInputAxis eAxis, float fValue) override {}; + virtual void OnAxisDiff( EInputDeviceType eDevice, EInputAxis eAxis, float fValue ) override {}; + + virtual void OnTextWriteUTF8( uint32_t uCode ) override {}; + + CUtlString m_aszBindings[k_EInputButton_Count]; +}; + +static CFunnyInput s_mainInput; +IHumanDeviceInput *g_pMainInput = &s_mainInput; + +void CFunnyInput::OnGameButton( EInputDeviceType eDevice, EInputButton eScancode, bool bIsPressed ) +{ + if (bIsPressed) + { + Console()->AddCommand(m_aszBindings[eScancode]); + Console()->AddCommand("\n"); + } + else + { + auto binding = Console()->ParseCommandLine(m_aszBindings[eScancode]); + if (binding.GetSize()==0) + return; + if (binding[0].GetSize() == 0) + return; + if (binding[0][0].GetString()[0] == '+') + { + CUtlString &command = binding[0][0]; + command.GetString()[0] = '-'; + } + Console()->AddCommand(binding[0][0]); + Console()->AddCommand("\n"); + + } + +} +void CFunnyInput::OnGameAxis( EInputDeviceType eDevice, EInputAxis eAxis, float fValue) +{ + +} +void CFunnyInput::OnGameAxisDiff( EInputDeviceType eDevice, EInputAxis eAxis, float fValue ) +{ + +} + + + +struct KeyName_t { + const char *szName; + EInputButton eKey; +}; + +static KeyName_t s_keys[] = { + + {"ESCAPE",k_EInputButton_ESCAPE}, + {"ESC",k_EInputButton_ESCAPE}, + {"TAB",k_EInputButton_TAB}, + {"ENTER",k_EInputButton_ENTER}, + {"CTRL",k_EInputButton_CONTROL}, + {"CONTROL",k_EInputButton_CONTROL}, + {"SHIFT",k_EInputButton_SHIFT}, + {"ALT",k_EInputButton_ALT}, + {"SPACE",k_EInputButton_SPACE}, + + {"BACKSPACE",k_EInputButton_BACKSPACE}, + {"[",k_EInputButton_LBRACKET}, + {"]",k_EInputButton_RBRACKET}, + {"{",k_EInputButton_LBRACKET}, + {"}",k_EInputButton_RBRACKET}, + {"\\",k_EInputButton_BACKSLASH}, + {";",k_EInputButton_SEMICOLON}, + {":",k_EInputButton_SEMICOLON}, + {"\'",k_EInputButton_APOSTROPHE}, + {"\"",k_EInputButton_APOSTROPHE}, + + {"F1",k_EInputButton_F1}, + {"F2",k_EInputButton_F2}, + {"F3",k_EInputButton_F3}, + {"F4",k_EInputButton_F4}, + {"F5",k_EInputButton_F5}, + {"F6",k_EInputButton_F6}, + {"F7",k_EInputButton_F7}, + {"F8",k_EInputButton_F8}, + {"F9",k_EInputButton_F9}, + {"F10",k_EInputButton_F10}, + {"F11",k_EInputButton_F11}, + {"F12",k_EInputButton_F12}, + + {"1",k_EInputButton_1}, + {"2",k_EInputButton_2}, + {"3",k_EInputButton_3}, + {"4",k_EInputButton_4}, + {"5",k_EInputButton_5}, + {"6",k_EInputButton_6}, + {"7",k_EInputButton_7}, + {"8",k_EInputButton_8}, + {"9",k_EInputButton_9}, + {"0",k_EInputButton_0}, + + {"A",k_EInputButton_A}, + {"B",k_EInputButton_B}, + {"C",k_EInputButton_C}, + {"D",k_EInputButton_D}, + {"E",k_EInputButton_E}, + {"F",k_EInputButton_F}, + {"G",k_EInputButton_G}, + {"H",k_EInputButton_H}, + {"I",k_EInputButton_I}, + {"J",k_EInputButton_J}, + {"K",k_EInputButton_K}, + {"L",k_EInputButton_L}, + {"M",k_EInputButton_M}, + {"N",k_EInputButton_N}, + {"O",k_EInputButton_O}, + {"P",k_EInputButton_P}, + {"Q",k_EInputButton_Q}, + {"R",k_EInputButton_R}, + {"S",k_EInputButton_S}, + {"T",k_EInputButton_T}, + {"U",k_EInputButton_U}, + {"V",k_EInputButton_V}, + {"W",k_EInputButton_W}, + {"X",k_EInputButton_X}, + {"Y",k_EInputButton_Y}, + {"Z",k_EInputButton_Z}, +}; + +static EInputButton GetStringAsKey( char *psz ) +{ + for (uint32_t i = 0; iGetRenderWidth(); uint32_t uHeight = g_pMainWindow->GetRenderHeight(); mat4 matCamera; + mat4 matCamera2; + glm_mat4_identity(matCamera); + glm_mat4_identity(matCamera2); + glm_translate(matCamera2, m_vPos); glm_perspective(glm_rad(60), uWidth/(float)uHeight, 0.01, 10000, matCamera); - glm_translate(matCamera, m_vPos); + glm_mul(matCamera, matCamera2, matCamera); /* V_printf("%f %f %f %f\n", matCamera[0][0], matCamera[0][1], matCamera[0][2], matCamera[0][3]); V_printf("%f %f %f %f\n", matCamera[1][0], matCamera[1][1], matCamera[1][2], matCamera[1][3]); diff --git a/game/server/basemodelentity.h b/game/server/basemodelentity.h index df3c691..63432db 100644 --- a/game/server/basemodelentity.h +++ b/game/server/basemodelentity.h @@ -8,6 +8,7 @@ class CBaseModelEntity: public CBaseEntity { public: + DECLARE_CLASS(CBaseModelEntity, CBaseEntity); virtual void SetModel( const char *szName ); }; diff --git a/game/server/game.cpp b/game/server/game.cpp index 53e482b..788ff83 100644 --- a/game/server/game.cpp +++ b/game/server/game.cpp @@ -150,11 +150,9 @@ void NET_ProcessPacket( INetworkBase *pBase ) int iIndex = -1; V_printf("Hi %s\n",pPacket->m_playerJoined.m_szPlayerName); - for ( int i = 0; i < 2; i++ ) - { - pEntity = EntitySystem()->CreateByClassname("player", &iIndex); - pEntity->Spawn(); - } + + pEntity = EntitySystem()->CreateByClassname("player", &iIndex); + pEntity->Spawn(); SetLocalEntity_t stLocalEntity = { k_EMessage_PlayerSetLocalEntity, diff --git a/game/server/physicsprop.cpp b/game/server/physicsprop.cpp index 2467790..d58266d 100644 --- a/game/server/physicsprop.cpp +++ b/game/server/physicsprop.cpp @@ -15,8 +15,31 @@ void CPhysicsProp::Spawn() void CPhysicsProp::Think( float fDelta ) { - SetAbsOrigin(m_pBody->GetPosition()); - SetAbsAngles(m_pBody->GetRotation()); + BaseClass::SetAbsOrigin(m_pBody->GetPosition()); + BaseClass::SetAbsAngles(m_pBody->GetRotation()); +} + +void CPhysicsProp::SetAbsAngles( Quat vQuat ) +{ + + BaseClass::SetAbsAngles( vQuat ); + if (m_pBody) + m_pBody->SetRotation(m_pBody->GetRotation()); +} + +void CPhysicsProp::SetAbsQAngles( float fPitch, float fYaw, float fRoll ) +{ + + BaseClass::SetAbsQAngles( fPitch, fYaw, fRoll); + if (m_pBody) + m_pBody->SetRotation(m_pBody->GetRotation()); +} + +void CPhysicsProp::SetAbsOrigin( Vector origin ) +{ + BaseClass::SetAbsOrigin( origin ); + if (m_pBody) + m_pBody->SetPosition(m_pBody->GetPosition()); } void CPhysicsProp::SetModel( const char *szName ) diff --git a/game/server/physicsprop.h b/game/server/physicsprop.h index 4202d50..9ef277b 100644 --- a/game/server/physicsprop.h +++ b/game/server/physicsprop.h @@ -5,23 +5,28 @@ class CPhysicsProp: public CBaseModelEntity { +friend CBaseEntity; friend CBaseModelEntity; public: DECLARE_CLASS(CPhysicsProp, CBaseModelEntity); virtual void Spawn() override; virtual void Precache() override; + virtual void SetAbsAngles( Quat vQuat ) override; + virtual void SetAbsQAngles( float fPitch, float fYaw, float fRoll ) override; + virtual void SetAbsOrigin( Vector origin ) override; + virtual void SetModel( const char *szName ) override; virtual void EnableMovement(); virtual void DisableMovement(); void Think( float fDelta ); private: - HFunnyModel m_hModel; - FunnyModel_t *m_pModel; - FunnyPhysics_t *m_pPhysics; - HCollider m_hCollider; - IPhysicsBody *m_pBody; + HFunnyModel m_hModel = 0; + FunnyModel_t *m_pModel = NULL; + FunnyPhysics_t *m_pPhysics = NULL; + HCollider m_hCollider = 0; + IPhysicsBody *m_pBody = NULL; }; #endif diff --git a/rapier/physics.rs b/rapier/physics.rs index ae13914..3d6aaed 100644 --- a/rapier/physics.rs +++ b/rapier/physics.rs @@ -146,7 +146,7 @@ pub unsafe extern "C" fn CRapierPhysicsBody_GetRotation( this: *mut RapierPhysic #[no_mangle] pub unsafe extern "C" fn CRapierPhysicsWorld_Frame( this: *mut RapierWorld_t, fDelta: f32 ) { - let vGravity = vec3(0.0, -9.8, 0.0); + let vGravity = vec3(0.0, -0.0, 0.0); let mut integrationParameters = IntegrationParameters::default(); integrationParameters.dt = fDelta; let mut physicsPipeline = PhysicsPipeline::new();