00001 #include "ScreenNetTester.h"
00002 #include "MercuryInput.h"
00003 #include "MercuryDisplay.h"
00004 #include "MercuryTheme.h"
00005
00006 KeyMappingWithCode( button_a, "0-97" );
00007 KeyMappingWithCode( button_s, "0-115" );
00008 KeyMappingWithCode( button_d, "0-100" );
00009 KeyMappingWithCode( button_w, "0-119" );
00010
00011 KeyMappingWithCode( button_c, "0-99" );
00012 KeyMappingWithCode( button_b, "0-98" );
00013
00014 REGISTER_SCREEN_CLASS( ScreenNetTester )
00015
00016 ScreenNetTester::~ScreenNetTester()
00017 {
00018 }
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 void ScreenNetTester::Init()
00030 {
00031 MercuryScreen::Init();
00032
00033 MercuryINI pINI;
00034 pINI.Open( GET_FILE_BY_NAME( "IniFile" ) );
00035
00036 m_pWorldClient.Init();
00037 m_pWorldClient.LoadFromINI( pINI, THEME.GetMetricS( m_name, "WorldName" ) );
00038 m_pWorldClient.SetX( 80 );
00039 AddPerspObject( &m_pWorldClient );
00040
00041 m_pWorldServer.Init();
00042 m_pWorldServer.LoadFromINI( pINI, THEME.GetMetricS( m_name, "WorldName" ) );
00043 m_pWorldServer.SetX( -80 );
00044 AddPerspObject( &m_pWorldServer );
00045
00046 m_pCamera = new MercuryCamera;
00047 m_pCamera->SetName( "Camera" );
00048 m_pCamera->Init();
00049 m_pCamera->SetPosition( MercuryPoint( 0,170,330) );
00050 m_pCamera->SetUp(MercuryPoint(0,0,1));
00051 AddObject( m_pCamera );
00052
00053 m_light.Init();
00054 m_light.SetY(100);
00055 m_light.SetX(-100);
00056 m_light.SetZ(110);
00057 m_light.SetAttenuation(0.001f, Attenuation::LINEAR);
00058 m_light.SetStatic(true);
00059 DISPLAY->AddLight(&m_light);
00060
00061 m_conServer.LinkODE( &m_pWorldServer );
00062 m_conServer.BindAndListen( 1099 );
00063
00064 m_conClient.LinkODE( &m_pWorldClient );
00065 m_conClient.Connect( "127.0.0.1", 1099 );
00066 }
00067
00068 void ScreenNetTester::Update( const float dTime )
00069 {
00070 m_conClient.Update( dTime );
00071 MercuryScreen::Update( dTime );
00072 m_conServer.Update( dTime );
00073
00074 MercuryODEObject * z = m_pWorldServer.GetODEObjectByName( "Control" );
00075
00076 int dx=0;
00077 int dy=0;
00078 if ( INPUTMAN->IsButtonDown( button_d ) )
00079 dx -= 5;
00080 if ( INPUTMAN->IsButtonDown( button_a ) )
00081 dx += 5;
00082 if ( INPUTMAN->IsButtonDown( button_w ) )
00083 dy -= 5;
00084 if ( INPUTMAN->IsButtonDown( button_s ) )
00085 dy += 5;
00086
00087 dBodyEnable( z->m_oBody );
00088
00089
00090 if( dx != 0 || dy != 0 )
00091 dBodySetAngularVel( z->m_oBody, -dy,dx,0);
00092
00093 m_conServer.UpdateODE( "Control" );
00094
00095 }
00096
00097 void ScreenNetTester::Draw()
00098 {
00099 MercuryScreen::Draw( );
00100 }