not compilable
This commit is contained in:
Dander7BD 2014-02-10 16:30:47 +01:00
parent b435818567
commit 1e70640d6e
5 changed files with 61 additions and 39 deletions

View File

@ -116,7 +116,7 @@ void Camera_FPS::PitchUp( Float radian )
void Camera_FPS::PitchDown( Float radian ) void Camera_FPS::PitchDown( Float radian )
{ {
this->PitchDown( -radian ); this->PitchUp( -radian );
} }
void Camera_FPS::YawRight( Float radian ) void Camera_FPS::YawRight( Float radian )

View File

@ -4,23 +4,22 @@
#include "C_obj/C_DynamicObj.h" #include "C_obj/C_DynamicObj.h"
#include <Protocols.h> #include <Protocols.h>
#include "NetworkClient.h" #include "NetworkClient.h"
#include "Camera.h" //#include "Camera.h"
#include <GameServerAPI.h> #include <GameServerAPI.h>
using namespace DanBias::Client; using namespace DanBias::Client;
using namespace ::Oyster::Math3D;
struct GameState::myData struct GameState::myData
{ {
myData(){} myData(){}
Oyster::Math3D::Float4x4 view; //Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj; //Oyster::Math3D::Float4x4 proj;
std::vector<C_Object*> object; std::vector<C_Object*> object;
int modelCount; int modelCount;
Oyster::Network::NetworkClient* nwClient; Oyster::Network::NetworkClient* nwClient;
gameStateState state; gameStateState state;
} privData;
}privData;
GameState::GameState(void) GameState::GameState(void)
{ {
@ -38,12 +37,12 @@ GameState::~GameState(void)
bool GameState::Init(Oyster::Network::NetworkClient* nwClient) bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
{ {
// load models // load models
camera = new Camera; //camera = new Camera;
privData = new myData(); privData = new myData();
privData->state = gameStateState_loading; privData->state = gameStateState_loading;
privData->nwClient = nwClient; privData->nwClient = nwClient;
privData->state = LoadGame(); privData->state = LoadGame();
pitch = 0; //pitch = 0;
return true; return true;
} }
GameState::gameStateState GameState::LoadGame() GameState::gameStateState GameState::LoadGame()
@ -203,29 +202,37 @@ bool GameState::LoadModels(std::wstring mapFile)
return true; return true;
} }
bool GameState::InitCamera(Oyster::Math::Float3 startPos) bool GameState::InitCamera( Oyster::Math::Float3 startPos )
{ {
Oyster::Math::Float3 dir = Oyster::Math::Float3(0,0,1); camera.SetHeadOffset( Float3(0.0f, 1.0f, -2.0f) );
Oyster::Math::Float3 up =Oyster::Math::Float3(0,1,0);
Oyster::Math::Float3 pos = Oyster::Math::Float3(0, 0, 20);
camera->LookAt(pos, dir, up); //Oyster::Math::Float3 dir = Oyster::Math::Float3(0,0,1);
camera->SetLens(3.14f/2, 1024/768, 1, 1000); //Oyster::Math::Float3 up =Oyster::Math::Float3(0,1,0);
//Oyster::Math::Float3 pos = Oyster::Math::Float3(0, 0, 20);
privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1024.0f/768.0f,.1f,1000); camera.SetPerspectiveProjection( Oyster::Math::pi/2.0f, 1024.0f/768.0f, 1.0f, 1000.0f );
Oyster::Graphics::API::SetProjection( Float4x4(camera.GetProjectionMatrix()) ); // TODO: remove copy wrapper when no longer needed
//camera->LookAt(pos, dir, up);
//camera->SetLens(3.14f/2, 1024/768, 1, 1000);
//privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1024.0f/768.0f,.1f,1000);
//privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000); //privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
Oyster::Graphics::API::SetProjection(privData->proj); //Oyster::Graphics::API::SetProjection( privData->proj );
camera->UpdateViewMatrix();
privData->view = camera->View(); //camera->UpdateViewMatrix();
privData->view = Oyster::Math3D::ViewMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos); //privData->view = camera->View();
privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos); //privData->view = Oyster::Math3D::ViewMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view); //privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
//privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
return true; return true;
} }
void GameState::setClientId(int id) void GameState::setClientId(int id)
{ {
myId = id; myId = id;
} }
GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput) GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput)
{ {
switch (privData->state) switch (privData->state)
@ -246,7 +253,8 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
// update objects // update objects
{ {
readKeyInput(KeyInput); readKeyInput(KeyInput);
camera->UpdateViewMatrix(); camera.UpdateOrientation();
//camera->UpdateViewMatrix();
} }
break; break;
@ -262,10 +270,13 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
} }
bool GameState::Render() bool GameState::Render()
{ {
Oyster::Graphics::API::SetView(camera->View()); Oyster::Graphics::API::SetView( camera.GetViewMatrix() );
//Oyster::Graphics::API::SetView(camera->View());
//Oyster::Graphics::API::SetProjection(camera->Proj()); //Oyster::Graphics::API::SetProjection(camera->Proj());
//Oyster::Graphics::API::SetView(privData->view); //Oyster::Graphics::API::SetView(privData->view);
Oyster::Graphics::API::SetProjection(privData->proj); //Oyster::Graphics::API::SetProjection(privData->proj);
Oyster::Graphics::API::NewFrame(); Oyster::Graphics::API::NewFrame();
for (unsigned int i = 0; i < privData->object.size(); i++) for (unsigned int i = 0; i < privData->object.size(); i++)
{ {
@ -355,18 +366,23 @@ void GameState::readKeyInput(InputClass* KeyInput)
//send delta mouse movement //send delta mouse movement
if (KeyInput->IsMousePressed()) if (KeyInput->IsMousePressed())
{ {
camera->Yaw(-KeyInput->GetYaw()); camera.YawRight( KeyInput->GetYaw() );
camera->Pitch(KeyInput->GetPitch()); camera.PitchUp( KeyInput->GetPitch() );
pitch = KeyInput->GetPitch(); camera.UpdateOrientation();
camera->UpdateViewMatrix();
//camera->Yaw(-KeyInput->GetYaw());
//->Pitch(KeyInput->GetPitch());
//pitch = KeyInput->GetPitch();
//camera->UpdateViewMatrix();
GameLogic::Protocol_PlayerLook playerLookDir; GameLogic::Protocol_PlayerLook playerLookDir;
Oyster::Math::Float4 look = camera->GetLook(); Float4 look = Float4( camera.GetLook(), 0.0f );
//Float4 look = camera->GetLook();
playerLookDir.lookDirX = look.x; playerLookDir.lookDirX = look.x;
playerLookDir.lookDirY = look.y; playerLookDir.lookDirY = look.y;
playerLookDir.lookDirZ = look.z; playerLookDir.lookDirZ = look.z;
playerLookDir.deltaX = -KeyInput->GetYaw(); playerLookDir.deltaX = -KeyInput->GetYaw();
privData->nwClient->Send(playerLookDir); privData->nwClient->Send( playerLookDir );
} }
// shoot // shoot
@ -470,10 +486,8 @@ void GameState::Protocol( ObjPos* pos )
Oyster::Math::Float3 objForward = (Oyster::Math::Float3(world[8], world[9], world[10])); Oyster::Math::Float3 objForward = (Oyster::Math::Float3(world[8], world[9], world[10]));
Oyster::Math::Float3 pos = Oyster::Math::Float3(world[12], world[13], world[14]); Oyster::Math::Float3 pos = Oyster::Math::Float3(world[12], world[13], world[14]);
Oyster::Math::Float3 cameraLook = camera->GetLook(); //Oyster::Math::Float3 cameraLook = camera->GetLook();
Oyster::Math::Float3 cameraUp = camera->GetUp(); //Oyster::Math::Float3 cameraUp = camera->GetUp();
/*Oyster::Math::Float3 newUp = cameraUp.Dot(up); /*Oyster::Math::Float3 newUp = cameraUp.Dot(up);
up *= newUp; up *= newUp;
@ -481,6 +495,7 @@ void GameState::Protocol( ObjPos* pos )
Oyster::Math::Float3 newLook = up.Cross(right); Oyster::Math::Float3 newLook = up.Cross(right);
newLook.Normalize();*/ newLook.Normalize();*/
camera->setRight(right); camera->setRight(right);
camera->setUp(up); camera->setUp(up);
camera->setLook(objForward); camera->setLook(objForward);

View File

@ -3,7 +3,10 @@
#include "GameClientState.h" #include "GameClientState.h"
#include "OysterMath.h" #include "OysterMath.h"
#include <string> #include <string>
#include "Camera.h"
//#include "Camera.h"
#include "Camera_FPS.h"
namespace DanBias namespace DanBias
{ {
namespace Client namespace Client
@ -24,10 +27,11 @@ private:
bool key_strafeLeft; bool key_strafeLeft;
bool key_Shoot; bool key_Shoot;
bool key_Jump; bool key_Jump;
Camera* camera; Camera_FPS camera;
//Camera* camera;
int myId; int myId;
float pitch; //float pitch;
struct myData; struct myData;
myData* privData; myData* privData;
public: public:

View File

@ -200,6 +200,9 @@
<ProjectReference Include="..\..\OysterMath\OysterMath.vcxproj"> <ProjectReference Include="..\..\OysterMath\OysterMath.vcxproj">
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project> <Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\WindowManager\WindowManager.vcxproj">
<Project>{35aea3c0-e0a7-4e1e-88cd-514aa5a442b1}</Project>
</ProjectReference>
<ProjectReference Include="..\GameLogic\GameLogic.vcxproj"> <ProjectReference Include="..\GameLogic\GameLogic.vcxproj">
<Project>{b1195bb9-b3a5-47f0-906c-8dea384d1520}</Project> <Project>{b1195bb9-b3a5-47f0-906c-8dea384d1520}</Project>
</ProjectReference> </ProjectReference>

View File

@ -165,7 +165,7 @@ namespace Oyster { namespace Math3D //! Oyster's native math library specialized
Quaternion Rotation( const Float4 &angularAxis ); Quaternion Rotation( const Float4 &angularAxis );
/** @todo TODO: add doc */ /** @todo TODO: add doc */
Float3x3 & RotationMatrix( const Quaternion &rotationQuaternion, Float3x3 &targetMem = Float3x3() ); Float3x3 & RotationMatrix( const Quaternion &rotationQuaternion, Float3x3 &targetMem );
/** @todo TODO: add doc */ /** @todo TODO: add doc */
Float4x4 & RotationMatrix( const Quaternion &rotationQuaternion, Float4x4 &targetMem = Float4x4() ); Float4x4 & RotationMatrix( const Quaternion &rotationQuaternion, Float4x4 &targetMem = Float4x4() );