som more stuff
created another version of Quaternion to Angular Axis conversion.
This commit is contained in:
parent
c1d63a1477
commit
c85cecd05a
|
@ -121,8 +121,8 @@ void LanMenuState::ChangeState( ClientState next )
|
||||||
{
|
{
|
||||||
case GameClientState::ClientState_Lobby:
|
case GameClientState::ClientState_Lobby:
|
||||||
// attempt to connect to lobby
|
// attempt to connect to lobby
|
||||||
if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) )
|
//if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) )
|
||||||
return;
|
// return; // TODO: temporary commented out
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ void OnButtonInteract_Connect( Oyster::Event::ButtonEvent<LanMenuState*>& e )
|
||||||
switch( e.state )
|
switch( e.state )
|
||||||
{
|
{
|
||||||
case ButtonState_Released:
|
case ButtonState_Released:
|
||||||
e.owner->ChangeState( GameClientState::ClientState_LobbyCreate );
|
e.owner->ChangeState( GameClientState::ClientState_Lobby );
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ bool LobbyState::Init(NetworkClient* nwClient)
|
||||||
// create buttons
|
// create buttons
|
||||||
ButtonRectangle<LobbyState*> *button;
|
ButtonRectangle<LobbyState*> *button;
|
||||||
|
|
||||||
button = new ButtonRectangle<LobbyState*>( L"earth_md.png", L"", Float3(1.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
|
button = new ButtonRectangle<LobbyState*>( L"earth_md.png", L"Ready", Float3(1.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
|
||||||
this->privData->guiElements.AddButton( button );
|
this->privData->guiElements.AddButton( button );
|
||||||
|
|
||||||
// bind button collection to the singleton eventhandler
|
// bind button collection to the singleton eventhandler
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "NetLoadState.h"
|
#include "NetLoadState.h"
|
||||||
#include "NetworkClient.h"
|
#include "NetworkClient.h"
|
||||||
|
#include "../Game/GameProtocols/ProtocolIdentificationID.h"
|
||||||
|
|
||||||
using namespace ::DanBias::Client;
|
using namespace ::DanBias::Client;
|
||||||
using namespace ::Oyster;
|
using namespace ::Oyster;
|
||||||
|
@ -10,7 +11,7 @@ struct NetLoadState::MyData
|
||||||
MyData() {}
|
MyData() {}
|
||||||
|
|
||||||
GameClientState::ClientState nextState;
|
GameClientState::ClientState nextState;
|
||||||
NetworkClient *nwClient;
|
//NetworkClient *nwClient; needed?
|
||||||
};
|
};
|
||||||
|
|
||||||
NetLoadState::NetLoadState(void) {}
|
NetLoadState::NetLoadState(void) {}
|
||||||
|
@ -26,9 +27,12 @@ bool NetLoadState::Init( NetworkClient* nwClient )
|
||||||
this->privData = new MyData();
|
this->privData = new MyData();
|
||||||
|
|
||||||
this->privData->nextState = GameClientState::ClientState_Same;
|
this->privData->nextState = GameClientState::ClientState_Same;
|
||||||
this->privData->nwClient = nwClient;
|
//this->privData->nwClient = nwClient; needed?
|
||||||
|
|
||||||
|
// we may assume that nwClient is properly connected to the server
|
||||||
|
|
||||||
|
|
||||||
|
this->privData->nextState = GameClientState::ClientState_Main;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -56,3 +60,27 @@ void NetLoadState::ChangeState( ClientState next )
|
||||||
{
|
{
|
||||||
this->privData->nextState = next;
|
this->privData->nextState = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetLoadState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
|
||||||
|
{
|
||||||
|
CustomNetProtocol data = e.args.data.protocol;
|
||||||
|
short ID = data[0].value.netShort; // fetching the id data.
|
||||||
|
|
||||||
|
//if( ProtocolIsGameplay(ID) )
|
||||||
|
//{
|
||||||
|
// switch(ID)
|
||||||
|
// {
|
||||||
|
// //case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */
|
||||||
|
// default: break;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//else if( ProtocolIsGeneral(ID) )
|
||||||
|
//{
|
||||||
|
// switch( ID )
|
||||||
|
// {
|
||||||
|
// case protocol_General_Status: break; /** @todo TODO: implement */
|
||||||
|
// case protocol_General_Text: break; /** @todo TODO: implement */
|
||||||
|
// default: break;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
|
@ -10,9 +10,6 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
class NetLoadState : public GameClientState
|
class NetLoadState : public GameClientState
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
struct MyData;
|
|
||||||
::Utility::DynamicMemory::UniquePointer<MyData> privData;
|
|
||||||
public:
|
public:
|
||||||
NetLoadState( );
|
NetLoadState( );
|
||||||
virtual ~NetLoadState( );
|
virtual ~NetLoadState( );
|
||||||
|
@ -23,6 +20,12 @@ namespace DanBias
|
||||||
bool Render();
|
bool Render();
|
||||||
bool Release();
|
bool Release();
|
||||||
void ChangeState( ClientState next );
|
void ChangeState( ClientState next );
|
||||||
|
|
||||||
|
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct MyData;
|
||||||
|
::Utility::DynamicMemory::UniquePointer<MyData> privData;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,6 +373,14 @@ namespace LinearAlgebra3D
|
||||||
return (rotation*localAxis*rotation.GetConjugate()).imaginary;
|
return (rotation*localAxis*rotation.GetConjugate()).imaginary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Vector3<ScalarType> AngularAxis( const ::LinearAlgebra::Quaternion<ScalarType> &rotation )
|
||||||
|
{
|
||||||
|
ScalarType angle = ScalarType(2) * (ScalarType)::std::acos( rotation.real ),
|
||||||
|
multiplier = angle / (ScalarType)::std::sqrt( rotation.real );
|
||||||
|
return multiplier * rotation.imaginary;
|
||||||
|
}
|
||||||
|
|
||||||
// All Matrix to AngularAxis conversions here is incorrect
|
// All Matrix to AngularAxis conversions here is incorrect
|
||||||
//template<typename ScalarType>
|
//template<typename ScalarType>
|
||||||
//inline ::LinearAlgebra::Vector4<ScalarType> AngularAxis( const ::LinearAlgebra::Matrix3x3<ScalarType> &rotationMatrix )
|
//inline ::LinearAlgebra::Vector4<ScalarType> AngularAxis( const ::LinearAlgebra::Matrix3x3<ScalarType> &rotationMatrix )
|
||||||
|
|
|
@ -81,6 +81,12 @@ namespace Oyster { namespace Math2D
|
||||||
|
|
||||||
namespace Oyster { namespace Math3D
|
namespace Oyster { namespace Math3D
|
||||||
{
|
{
|
||||||
|
//! Converts a rotationQuaternion to an angularAxis
|
||||||
|
Float3 AngularAxis( const Quaternion &rotation )
|
||||||
|
{
|
||||||
|
return ::LinearAlgebra3D::AngularAxis( rotation );
|
||||||
|
}
|
||||||
|
|
||||||
//Float4 AngularAxis( const Float3x3 &rotationMatrix )
|
//Float4 AngularAxis( const Float3x3 &rotationMatrix )
|
||||||
//{
|
//{
|
||||||
// return ::LinearAlgebra3D::AngularAxis( rotationMatrix );
|
// return ::LinearAlgebra3D::AngularAxis( rotationMatrix );
|
||||||
|
|
|
@ -140,6 +140,9 @@ namespace Oyster { namespace Math3D //! Oyster's native math library specialized
|
||||||
{
|
{
|
||||||
using namespace ::Oyster::Math; // deliberate inheritance from ::Oyster::Math namespace
|
using namespace ::Oyster::Math; // deliberate inheritance from ::Oyster::Math namespace
|
||||||
|
|
||||||
|
//! Converts a rotationQuaternion to an angularAxis
|
||||||
|
Float3 AngularAxis( const Quaternion &rotation );
|
||||||
|
|
||||||
//! Extracts the angularAxis from rotationMatrix
|
//! Extracts the angularAxis from rotationMatrix
|
||||||
//Float4 AngularAxis( const Float3x3 &rotationMatrix );
|
//Float4 AngularAxis( const Float3x3 &rotationMatrix );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue