Commit 9537c476 authored by James Fulop's avatar James Fulop
Browse files

overview video

parent bae1736e
// FRAG SHADER ../source/code/shaders/mesh.metashader.h
#version 330
#define RECIEVE_SHADOWS
#define LIGHTING
in vec3 _Normal;
in vec4 _FragPosLightSpace;
#ifdef TEXTURE
in vec2 _TexCoord;
#endif
uniform vec4 ObjectColor;
uniform vec3 LightDir;
uniform vec3 LightColor;
uniform sampler2DShadow ShadowMapTexture;
#ifdef TEXTURE
uniform sampler2D Texture;
#endif
out vec4 OutColor;
float ShadowCalculations(vec4 FragPosLightSpace){
float CosTheta= clamp(dot(_Normal,LightDir),0,1);
float Bias=0.005* tan(acos(CosTheta));
Bias= clamp(Bias,0,0.01);
FragPosLightSpace.z-= Bias;
vec3 ProjCoords= FragPosLightSpace.xyz/ FragPosLightSpace.w;
ProjCoords= ProjCoords* 0.5f+ 0.5f;
float ClosestDepth= texture(ShadowMapTexture,ProjCoords);
float CurrentDepth= ProjCoords.z;
float Shadow=1;
Shadow-= ClosestDepth;
if(ProjCoords.z>1){
Shadow=1;
}
return Shadow;
}
void main(){
float AmbientStrength=0.15f;
vec3 Ambient= AmbientStrength* LightColor;
vec3 Norm= normalize(_Normal);
float Diff= max(dot(Norm,LightDir),0.0);
vec3 Diffuse= Diff* LightColor;
vec3 ViewDir= normalize(LightDir);
float Spec=0.0;
vec3 HalfwayDir= normalize(LightDir+ ViewDir);
Spec= pow(max(dot(Norm,HalfwayDir),0.0),64.0);
vec3 Specular= Spec* LightColor;
float InShadowAmount= ShadowCalculations(_FragPosLightSpace);
#ifdef TEXTURE
vec3 Result=(Ambient+ (1.0- InShadowAmount)* (Diffuse+ Specular))* (ObjectColor.xyz* texture(Texture,_TexCoord).xyz);
#else
vec3 Result=(Ambient+ (1.0- InShadowAmount)* (Diffuse+ Specular))* (ObjectColor.xyz);
#endif
OutColor= vec4(Result,ObjectColor.a);
}
// VERT SHADER ../source/code/shaders/mesh.metashader.h
#version 330
#define RECIEVE_SHADOWS
#define LIGHTING
layout(location=0)in vec3 PositionIn;
layout(location=1)in vec3 NormalIn;
#ifdef TEXTURE
layout(location=2)in vec2 TexCoordsIn;
#endif
uniform mat4 Model;
uniform mat4 View;
uniform mat4 Projection;
uniform mat4 LightSpaceMatrix;
out vec3 _Normal;
out vec4 _FragPosLightSpace;
#ifdef TEXTURE
out vec2 _TexCoord;
#endif
void main(){
gl_Position= Projection* View* Model* vec4(PositionIn,1.0);
_Normal= mat3(transpose(inverse(Model)))* NormalIn;
_FragPosLightSpace= LightSpaceMatrix* Model* vec4(PositionIn,1.0);
#ifdef TEXTURE
_TexCoord= TexCoordsIn;
#endif
}
// FRAG SHADER ../source/code/shaders/mesh.metashader.h
#version 330
#define TEXTURE
#define RECIEVE_SHADOWS
#define LIGHTING
in vec3 _Normal;
in vec4 _FragPosLightSpace;
#ifdef TEXTURE
in vec2 _TexCoord;
#endif
uniform vec4 ObjectColor;
uniform vec3 LightDir;
uniform vec3 LightColor;
uniform sampler2DShadow ShadowMapTexture;
#ifdef TEXTURE
uniform sampler2D Texture;
#endif
out vec4 OutColor;
float ShadowCalculations(vec4 FragPosLightSpace){
float CosTheta= clamp(dot(_Normal,LightDir),0,1);
float Bias=0.005* tan(acos(CosTheta));
Bias= clamp(Bias,0,0.01);
FragPosLightSpace.z-= Bias;
vec3 ProjCoords= FragPosLightSpace.xyz/ FragPosLightSpace.w;
ProjCoords= ProjCoords* 0.5f+ 0.5f;
float ClosestDepth= texture(ShadowMapTexture,ProjCoords);
float CurrentDepth= ProjCoords.z;
float Shadow=1;
Shadow-= ClosestDepth;
if(ProjCoords.z>1){
Shadow=1;
}
return Shadow;
}
void main(){
float AmbientStrength=0.15f;
vec3 Ambient= AmbientStrength* LightColor;
vec3 Norm= normalize(_Normal);
float Diff= max(dot(Norm,LightDir),0.0);
vec3 Diffuse= Diff* LightColor;
vec3 ViewDir= normalize(LightDir);
float Spec=0.0;
vec3 HalfwayDir= normalize(LightDir+ ViewDir);
Spec= pow(max(dot(Norm,HalfwayDir),0.0),64.0);
vec3 Specular= Spec* LightColor;
float InShadowAmount= ShadowCalculations(_FragPosLightSpace);
#ifdef TEXTURE
vec3 Result=(Ambient+ (1.0- InShadowAmount)* (Diffuse+ Specular))* (ObjectColor.xyz* texture(Texture,_TexCoord).xyz);
#else
vec3 Result=(Ambient+ (1.0- InShadowAmount)* (Diffuse+ Specular))* (ObjectColor.xyz);
#endif
OutColor= vec4(Result,ObjectColor.a);
}
// VERT SHADER ../source/code/shaders/mesh.metashader.h
#version 330
#define TEXTURE
#define RECIEVE_SHADOWS
#define LIGHTING
layout(location=0)in vec3 PositionIn;
layout(location=1)in vec3 NormalIn;
#ifdef TEXTURE
layout(location=2)in vec2 TexCoordsIn;
#endif
uniform mat4 Model;
uniform mat4 View;
uniform mat4 Projection;
uniform mat4 LightSpaceMatrix;
out vec3 _Normal;
out vec4 _FragPosLightSpace;
#ifdef TEXTURE
out vec2 _TexCoord;
#endif
void main(){
gl_Position= Projection* View* Model* vec4(PositionIn,1.0);
_Normal= mat3(transpose(inverse(Model)))* NormalIn;
_FragPosLightSpace= LightSpaceMatrix* Model* vec4(PositionIn,1.0);
#ifdef TEXTURE
_TexCoord= TexCoordsIn;
#endif
}
// VERT SHADER ../source/code/shaders/mesh.metashader.h
#version 330
#define RECIEVE_SHADOWS
#define LIGHTING
layout(location=0)in vec3 PositionIn;
layout(location=1)in vec3 NormalIn;
#ifdef TEXTURE
layout(location=2)in vec2 TexCoordsIn;
#endif
uniform mat4 Model;
uniform mat4 View;
uniform mat4 Projection;
uniform mat4 LightSpaceMatrix;
out vec3 _Normal;
out vec4 _FragPosLightSpace;
#ifdef TEXTURE
out vec2 _TexCoord;
#endif
void main(){
gl_Position= Projection* View* Model* vec4(PositionIn,1.0);
_Normal= mat3(transpose(inverse(Model)))* NormalIn;
_FragPosLightSpace= LightSpaceMatrix* Model* vec4(PositionIn,1.0);
#ifdef TEXTURE
_TexCoord= TexCoordsIn;
#endif
}
// FRAG SHADER ../source/code/shaders/mesh.metashader.h
#version 330
#define TEXTURE
#define RECIEVE_SHADOWS
#define LIGHTING
in vec3 _Normal;
in vec4 _FragPosLightSpace;
#ifdef TEXTURE
in vec2 _TexCoord;
uniform vec4 ObjectColor ;
uniform vec3 LightDir ;
uniform vec3 LightColor ;
uniform sampler2DShadow ShadowMapTexture ;
uniform sampler2D Texture ;
#endif
uniform vec4 ObjectColor;
uniform vec3 LightDir;
uniform vec3 LightColor;
uniform sampler2DShadow ShadowMapTexture;
#ifdef TEXTURE
uniform sampler2D Texture;
#endif
out vec4 OutColor;
float ShadowCalculations(vec4 FragPosLightSpace){
float CosTheta= clamp(dot(_Normal,LightDir),0,1);
float Bias=0.005* tan(acos(CosTheta));
Bias= clamp(Bias,0,0.01);
FragPosLightSpace.z-= Bias;
vec3 ProjCoords= FragPosLightSpace.xyz/ FragPosLightSpace.w;
ProjCoords= ProjCoords* 0.5f+ 0.5f;
float ClosestDepth= texture(ShadowMapTexture,ProjCoords);
float CurrentDepth= ProjCoords.z;
float Shadow=1;
Shadow-= ClosestDepth;
if(ProjCoords.z>1){
Shadow=1;
}
return Shadow;
}
void main(){
float AmbientStrength=0.15f;
vec3 Ambient= AmbientStrength* LightColor;
vec3 Norm= normalize(_Normal);
float Diff= max(dot(Norm,LightDir),0.0);
vec3 Diffuse= Diff* LightColor;
vec3 ViewDir= normalize(LightDir);
float Spec=0.0;
vec3 HalfwayDir= normalize(LightDir+ ViewDir);
Spec= pow(max(dot(Norm,HalfwayDir),0.0),64.0);
vec3 Specular= Spec* LightColor;
float InShadowAmount= ShadowCalculations(_FragPosLightSpace);
#ifdef TEXTURE
vec3 Result=(Ambient+ (1.0- InShadowAmount)* (Diffuse+ Specular))* (ObjectColor.xyz* texture(Texture,_TexCoord).xyz);
#else
vec3 Result=(Ambient+ (1.0- InShadowAmount)* (Diffuse+ Specular))* (ObjectColor.xyz);
#endif
OutColor= vec4(Result,ObjectColor.a);
}
// VERT SHADER ../source/code/shaders/mesh.metashader.h
#version 330
layout ( location = 0 ) in vec3 PositionIn ;
layout ( location = 1 ) in vec3 NormalIn ;
layout ( location = 2 ) in vec2 TexCoordsIn ;
uniform mat4 Model ;
uniform mat4 View ;
uniform mat4 Projection ;
uniform mat4 LightSpaceMatrix ;
#define TEXTURE
#define RECIEVE_SHADOWS
#define LIGHTING
layout(location=0)in vec3 PositionIn;
layout(location=1)in vec3 NormalIn;
#ifdef TEXTURE
layout(location=2)in vec2 TexCoordsIn;
#endif
uniform mat4 Model;
uniform mat4 View;
uniform mat4 Projection;
uniform mat4 LightSpaceMatrix;
out vec3 _Normal;
out vec4 _FragPosLightSpace;
#ifdef TEXTURE
out vec2 _TexCoord;
void main{
gl_Position =Projection *View *Model *vec4 (PositionIn ,1.0);
_Normal =mat3 (transpose (inverse (Model )))*NormalIn ;
_FragPosLightSpace =LightSpaceMatrix *vec4 (FragPos ,1.0);
_TexCoord =TexCoordsIn ;
#endif
void main(){
gl_Position= Projection* View* Model* vec4(PositionIn,1.0);
_Normal= mat3(transpose(inverse(Model)))* NormalIn;
_FragPosLightSpace= LightSpaceMatrix* Model* vec4(PositionIn,1.0);
#ifdef TEXTURE
_TexCoord= TexCoordsIn;
#endif
}
......@@ -10,6 +10,8 @@ REM fmod libs followed by an L have logging enabled. We should probably switch t
REM using fbxsdk adds a full second to compilation time
REM switching to explicit linking did not reduce linking time with fmod
set FBX_INCLUDE=0
REM wd4201 - nonstandard extension used: nameless struct/union
REM wd4100 - unreferenced formal parameter
REM wd4189 - local variable is initialized but not referenced
......@@ -19,21 +21,23 @@ REM wd4244 - conversion from type to type has possible loss of data
REM wd4800 - forcing value to a bool, need this for converting bool32 to bool to pass to ImGui
set WarningFlags= -WX -W3 -wd4201 -wd4100 -wd4189 -wd4505 -wd4127 -wd4244 -wd4800
set ClientFlag=1
set ServerFlag=0
set CommonCompilerFlags=-Od -MTd -nologo -fp:fast -fp:except- -Gm- -GR- -EHa- -Zo -Oi -FC -Z7 -EHsc -cgthreads4
set CommonCompilerFlags=-DYAMGINE_WIN32=1 -DYAMGINE_DEBUG=1 -D_ITERATOR_DEBUG_LEVEL=2 %WarningFlags% %CommonCompilerFlags%
set CommonCompilerFlags=/I"..\source\FMOD Studio API Windows\api\lowlevel\inc" %CommonCompilerFlags%
set CommonCompilerFlags=/I"..\source\FMOD Studio API Windows\api\studio\inc" %CommonCompilerFlags%
IF %FBX_INCLUDE%==1 (
set CommonCompilerFlags=/I"..\source\Autodesk\FBX\FBX SDK\2015.1\include" %CommonCompilerFlags%
)
set CommonCompilerFlags=/I"..\source\iprof" %CommonCompilerFlags%
set CommonCompilerFlags=/I"..\source\imgui" %CommonCompilerFlags%
REM set CommonCompilerFlags=/I"..\source\libyojimbo" %CommonCompilerFlags%
REM YOJIMBO LIBS === yojimbo.lib sodium-debug.lib mbedcrypto-debug.lib mbedtls-debug.lib mbedx509-debug.lib
set CommonLinkerFlags= -incremental:no -opt:ref user32.lib gdi32.lib winmm.lib opengl32.lib fmodstudioL64_vc.lib fmodL64_vc.lib /LIBPATH:"..\source\FMOD Studio API Windows\api\studio\lib" /LIBPATH:"..\source\FMOD Studio API Windows\api\lowlevel\lib"
set CommonLinkerFlags= -incremental:no -opt:ref user32.lib gdi32.lib winmm.lib opengl32.lib fmodstudioL64_vc.lib fmodL64_vc.lib libfbxsdk.lib /LIBPATH:"..\source\FMOD Studio API Windows\api\studio\lib" /LIBPATH:"..\source\FMOD Studio API Windows\api\lowlevel\lib" /LIBPATH:"..\source\Autodesk\FBX\FBX SDK\2015.1\lib\vs2013\x64\release"
IF %FBX_INCLUDE%==1 (
set CommonLinkerFlags=%CommonLinkerFlags% libfbxsdk.lib /LIBPATH:"..\source\Autodesk\FBX\FBX SDK\2015.1\lib\vs2013\x64\release"
)
IF NOT EXIST ..\..\build mkdir ..\..\build
pushd ..\..\build
......@@ -42,12 +46,10 @@ REM 32-bit build
REM cl %CommonCommonCompilerFlags% ..\source\code\platform_win32.cpp /link -subsystem:windows,5.1 %CommonLinkerFlags%
REM 64-bit build
del yamgine_client_*.pdb > NUL 2> NUL
del yamgine_server_*.pdb > NUL 2> NUL
del yamgine_*.pdb > NUL 2> NUL
del renderer_opengl_*.pdb > NUL 2> NUL
del yamgine_client_*.dll > NUL 2> NUL
del yamgine_server_*.dll > NUL 2> NUL
del yamgine_*.dll > NUL 2> NUL
del renderer_opengl_*.dll > NUL 2> NUL
REM Optimization switches /wO2
......@@ -63,29 +65,11 @@ echo WAITING FOR GL PDB > gl_lock.tmp
cl %CommonCompilerFlags% ..\source\code\renderer_opengl.cpp -Fmrenderer_opengl.map -LD /link -PDB:renderer_opengl_%random%.pdb -EXPORT:OpenGLInit -EXPORT:OpenGLExit -EXPORT:OpenGLImGuiLoadFonts -EXPORT:OpenGLRenderCommands -EXPORT:OpenGLAllocateMesh -EXPORT:OpenGLAllocateTexture %CommonLinkerFlags%
del gl_lock.tmp
IF %ClientFlag%==1 (
echo WAITING FOR PDB > lock.tmp
cl %CommonCompilerFlags% -DCLIENT=%ClientFlag% -DSERVER=%ServerFlag% -Feyamgine_client ..\source\code\game.cpp -Fmyamgine_client.map -LD /link -PDB:yamgine_client_%random%.pdb -EXPORT:GameUpdateAndRender %CommonLinkerFlags%
del lock.tmp
cl %CommonCompilerFlags% -DCLIENT=%ClientFlag% -DSERVER=%ServerFlag% -Feclient ..\source\code\platform_win32.cpp -Fmclient.map ..\source\code\resources.res /link %CommonLinkerFlags%
)
set ClientFlag=0
set ServerFlag=0
IF %ServerFlag%==1 (
echo WAITING FOR PDB > lock.tmp
cl %CommonCompilerFlags% -DCLIENT=%ClientFlag% -DSERVER=%ServerFlag% -Feyamgine_server ..\source\code\game.cpp -Fmyamgine_client.map -LD /link -PDB:yamgine_server_%random%.pdb -EXPORT:GameUpdateAndRender %CommonLinkerFlags%
cl %CommonCompilerFlags% -Feyamgine ..\source\code\game.cpp -Fmyamgine.map -LD /link -PDB:yamgine_%random%.pdb -EXPORT:GameUpdateAndRender %CommonLinkerFlags%
del lock.tmp
cl %CommonCompilerFlags% -DCLIENT=%ClientFlag% -DSERVER=%ServerFlag% -Feserver ..\source\code\platform_win32.cpp -Fmserver.map ..\source\code\resources.res /link %CommonLinkerFlags%
)
cl %CommonCompilerFlags% -Feyamgine_app ..\source\code\platform_win32.cpp -Fmyamgine_app.map ..\source\code\resources.res /link %CommonLinkerFlags%
REM Compile Time Checker
cl %CommonCompilerFlags% ..\source\code\compile_time_tests.cpp /link %CommonLinkerFlags%
......@@ -95,8 +79,6 @@ popd
popd
set LastError=%ERRORLEVEL%
REM ..\..\tools\ctime\ctime -end ..\..\tools\ctime\platform.ctm %LastError%
......
......@@ -7,7 +7,7 @@
#include "prof_process.c"
#include "imgui.cpp"
#include "imgui_draw.cpp"
#include "imgui_demo.cpp" // NOTE(james): this console depends on shit in here
#include "imgui_demo.cpp" // NOTE(james): this console depends on stuff in here
// For the console example, here we are using a more C++ like approach of declaring a class to hold the data and the functions.
struct YamgineConsole
{
......@@ -349,7 +349,7 @@ void UpdateInputAxis(game_controller* Controller)
}
}
#define LOAD_FBX
//#define LOAD_FBX
#ifdef LOAD_FBX
#include "yamgine_fbx_loading.cpp"
......@@ -365,22 +365,21 @@ void LoadCustomAssets(render_assets* Assets, memory_arena* AssetArena, platform_
TODO(james): sword_original.fbx doesn't work because the geometric translation is being handled correctly
TODO(james): exporting from Blender with Forward: Z+ doesn't load right. Check out sword_blender_zpos.fbx
*/
LoadModel(MyFbxManager, &LoadedAssets->Sword, "media/sword_blender_zpos_working.fbx", 0.1f,
LoadModel(MyFbxManager, &LoadedAssets->Sword, "media/sword_blender_zpos_working.fbx", 0.01f,
AssetArena, PlatformAPI);
LoadModel(MyFbxManager, &LoadedAssets->Cractus, "media/cactus/cactus.fbx", 1,
AssetArena, PlatformAPI);
//SerializeModel(&LoadedAssets->Sword, PlatformAPI);
LoadModel(MyFbxManager, &LoadedAssets->Sphere, "media/sphere_control_point_normals.fbx", 0.01f,
AssetArena, PlatformAPI);
SerializeModel(&LoadedAssets->Sword, PlatformAPI);
SerializeModel(&LoadedAssets->Sphere, PlatformAPI);
SerializeModel(&LoadedAssets->Cractus, PlatformAPI);
#endif
//DeserializeModel("serialization/models/sword_blender_exported", &LoadedAssets->Sword,
// AssetArena, PlatformAPI);
DeserializeModel("serialization/models/sword", &LoadedAssets->Sword,
DeserializeModel("serialization/models/sword_blender_zpos_working", &LoadedAssets->Sword,
AssetArena, PlatformAPI);
DeserializeModel("serialization/models/cactus", &LoadedAssets->Cractus,
AssetArena, PlatformAPI);
......@@ -476,7 +475,7 @@ void ImGuiNewFrame(v2 ScreenDim, game_controller* Controller, float DeltaTime)
void SaveGameState(game_and_editor_memory* Memory)
{
Copy(sizeof(Memory->EntityMaster.EntityMemory), &Memory->EntityMaster.EntityMemory, &Memory->PreservedEntityMaster.EntityMemory);
Copy(sizeof(Memory->EntityMaster), &Memory->EntityMaster, &Memory->PreservedEntityMaster);
Memory->PreservedGameState = Memory->GameState;
}
......@@ -484,7 +483,7 @@ void SaveGameState(game_and_editor_memory* Memory)
void LoadGameState(game_and_editor_memory* Memory)
{
entity KeepEditorCamera = *Memory->EditorState.EditorCamera;
Copy(sizeof(Memory->EntityMaster.EntityMemory), &Memory->PreservedEntityMaster.EntityMemory, &Memory->EntityMaster.EntityMemory);
Copy(sizeof(Memory->EntityMaster), &Memory->PreservedEntityMaster, &Memory->EntityMaster);
*Memory->EditorState.EditorCamera = KeepEditorCamera;
Memory->GameState = Memory->PreservedGameState;
}
......@@ -567,7 +566,7 @@ void GameMode(game_and_editor_memory* Memory, memory_arena* TransientArena,
// TODO(james): loop all entities, pushing any with collision stuff
Clear(RenderList,V4(0.15f,0.15f,0.15f,1));
Clear(RenderList,V4(0.2f,0.2f,1,1));
if (Memory->GamePlaying)
{
......@@ -582,52 +581,7 @@ void GameMode(game_and_editor_memory* Memory, memory_arena* TransientArena,
(bool32)GameState->DrawBroadphaseViz, (bool32)GameState->DrawNarrowphaseViz,
GameState->EntityMaster);
#if CLIENT && NETWORKING
if (Memory->Client->CanSendMessage())
{
#if 0 // string message example
GameStringMessage* NewMessage =
(GameStringMessage*)Memory->Client->CreateMessage(GAME_STRING_MESSAGE);
AppendString(NewMessage->messageData, "ASDF", 255);
NewMessage->messageSize = StringLength(NewMessage->messageData);
Memory->Client->SendGameStringMessage(NewMessage);
#endif
GamePlayerStateUpdateMessage* NewMessage =
(GamePlayerStateUpdateMessage*)Memory->Client->CreateMessage(GAME_PLAYER_STATE_UPDATE_MESSAGE);
NewMessage->playerStateUpdate.ForwardAxis = Input->Controllers[0].MoveForwardAxis;
NewMessage->playerStateUpdate.HorizontalAxis = Input->Controllers[0].MoveHorizontalAxis;
NewMessage->playerStateUpdate.PlayerRotation = GameState->Player->LocalRotation;
NewMessage->playerStateUpdate.CameraRotation = GameState->PlayerCamera->LocalRotation;
Memory->Client->SendPlayerStateUpdateMessage(NewMessage);
}
Memory->Client->SendPackets();
Memory->ClientTransport->WritePackets();
Memory->ClientTransport->ReadPackets();
Memory->Client->ReceivePackets();
Memory->Client->CheckForTimeOut();
if ( Memory->Client->IsDisconnected() )
MyConsole.AddLog("Disconnected");
Memory->Client->AdvanceTime( Memory->ElapsedTimeSinceAppStart );
Memory->ClientTransport->AdvanceTime( Memory->ElapsedTimeSinceAppStart );
if ( Memory->Client->ConnectionFailed() )
MyConsole.AddLog("Connection Failed");
#endif
}
if (Input->IsPlayingBack)
......@@ -652,7 +606,6 @@ void GameMode(game_and_editor_memory* Memory, memory_arena* TransientArena,
{
if (!Entity->EditorOnly)
{
Entity->Material.Texture = GameState->TestDxt;
DrawEntity(RenderList, Entity, GameState->Player);
}
......@@ -692,10 +645,10 @@ void GameMode(game_and_editor_memory* Memory, memory_arena* TransientArena,
ResolveLocalToWorld(Bullet);
AddColliderMesh(&GameState->CollisionGroup, Bullet, GameState->RenderAssets.StandardAssets.Cube,
true, false, CollisionLayer_bullet);
SetLinearVelocity(Bullet, Bullet->Forward);
false, false, CollisionLayer_bullet);
SetLinearVelocity(Bullet, -Bullet->Forward * 10);
Bullet->LockRotation = true;
Bullet->CoefficientOfRestitution = 0.2f;
Bullet->CoefficientOfRestitution = 1;
GameState->LastShootTime = GameState->ElapsedTime;
}
......@@ -714,118 +667,6 @@ void GameMode(game_and_editor_memory* Memory, memory_arena* TransientArena,
//ERRCHECK( FMOD_Studio_System_Update(FmodState->StudioSystem) );
}
#if SERVER
void ServerMode(game_and_editor_memory* Memory, memory_arena* TransientArena,
fmod_state* FmodState, platform_api* PlatformAPI,
render_list* EditorList, render_list* RenderList,
game_input* Input)
{
game_state* GameState = &Memory->GameState;
//
// INPUT
//
Memory->ServerTransport->ReadPackets();
Memory->Server->ReceivePackets();
int ClientCount = Memory->Server->GetNumConnectedClients();
for (int32 ClientIndex = 0;
ClientIndex < ClientCount;
++ClientIndex)
{
while (true)
{
Message* Message = Memory->Server->ReceiveMessage(ClientIndex);
if (!Message)
break;
switch(Message->GetType())
{
case GAME_STRING_MESSAGE:{
GameStringMessage* StringMessage = (GameStringMessage*)Message;
MyConsole.AddLog(StringMessage->messageData);
}break;
case GAME_PLAYER_STATE_UPDATE_MESSAGE:{
GamePlayerStateUpdateMessage* PlayerStateUpdateMessage = (GamePlayerStateUpdateMessage*)Message;
//MyConsole.AddLog("Forward Axis: %f",
//PlayerStateUpdateMessage->playerStateUpdate.ForwardAxis);
GameState->NetworkPlayerUpdates[ClientIndex] = PlayerStateUpdateMessage->playerStateUpdate;
}break;
}
Memory->Server->ReleaseMessage(ClientIndex, Message);
}
}
//
// Simulation
//
for (uint32 PlayerIndex = 0;
PlayerIndex < MAX_PLAYERS;
++PlayerIndex)
{
if (GameState->Players[PlayerIndex] != NULL)
{
// TODO(james): forward and right are not derived correctly in LocalToWorld,
// so we calculate it correctly here
v3 Forward = {};
Forward.x = Cos(GameState->Players[PlayerIndex]->Camera->LocalRotation.y) * Cos(GameState->Players[PlayerIndex]->Camera->LocalRotation.x);
Forward.y = Sin(GameState->Players[PlayerIndex]->Camera->LocalRotation.x);
Forward.z = Sin(GameState->Players[PlayerIndex]->Camera->LocalRotation.y) * Cos(GameState->Players[PlayerIndex]->Camera->LocalRotation.x);
Forward = Normalize(Forward);
v3 Right = {};
Right.x = Sin(GameState-&g