som more stuff

created another version of Quaternion to Angular Axis conversion.
This commit is contained in:
Dander7BD 2014-02-14 15:19:10 +01:00
parent c1d63a1477
commit c85cecd05a
7 changed files with 57 additions and 9 deletions

View File

@ -121,8 +121,8 @@ void LanMenuState::ChangeState( ClientState next )
{
case GameClientState::ClientState_Lobby:
// attempt to connect to lobby
if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) )
return;
//if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) )
// return; // TODO: temporary commented out
break;
default: break;
}
@ -135,7 +135,7 @@ void OnButtonInteract_Connect( Oyster::Event::ButtonEvent<LanMenuState*>& e )
switch( e.state )
{
case ButtonState_Released:
e.owner->ChangeState( GameClientState::ClientState_LobbyCreate );
e.owner->ChangeState( GameClientState::ClientState_Lobby );
break;
default: break;
}

View File

@ -48,7 +48,7 @@ bool LobbyState::Init(NetworkClient* nwClient)
// create buttons
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 );
// bind button collection to the singleton eventhandler

View File

@ -1,5 +1,6 @@
#include "NetLoadState.h"
#include "NetworkClient.h"
#include "../Game/GameProtocols/ProtocolIdentificationID.h"
using namespace ::DanBias::Client;
using namespace ::Oyster;
@ -10,7 +11,7 @@ struct NetLoadState::MyData
MyData() {}
GameClientState::ClientState nextState;
NetworkClient *nwClient;
//NetworkClient *nwClient; needed?
};
NetLoadState::NetLoadState(void) {}
@ -26,9 +27,12 @@ bool NetLoadState::Init( NetworkClient* nwClient )
this->privData = new MyData();
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;
}
@ -56,3 +60,27 @@ void NetLoadState::ChangeState( ClientState 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;
// }
//}
}

View File

@ -10,9 +10,6 @@ namespace DanBias
{
class NetLoadState : public GameClientState
{
private:
struct MyData;
::Utility::DynamicMemory::UniquePointer<MyData> privData;
public:
NetLoadState( );
virtual ~NetLoadState( );
@ -23,6 +20,12 @@ namespace DanBias
bool Render();
bool Release();
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;
};
}
}

View File

@ -373,6 +373,14 @@ namespace LinearAlgebra3D
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
//template<typename ScalarType>
//inline ::LinearAlgebra::Vector4<ScalarType> AngularAxis( const ::LinearAlgebra::Matrix3x3<ScalarType> &rotationMatrix )

View File

@ -81,6 +81,12 @@ namespace Oyster { namespace Math2D
namespace Oyster { namespace Math3D
{
//! Converts a rotationQuaternion to an angularAxis
Float3 AngularAxis( const Quaternion &rotation )
{
return ::LinearAlgebra3D::AngularAxis( rotation );
}
//Float4 AngularAxis( const Float3x3 &rotationMatrix )
//{
// return ::LinearAlgebra3D::AngularAxis( rotationMatrix );

View File

@ -140,6 +140,9 @@ namespace Oyster { namespace Math3D //! Oyster's native math library specialized
{
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
//Float4 AngularAxis( const Float3x3 &rotationMatrix );