00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #include "WinMainSelector.h"
00025 #if defined COMPILE_DEMO3D
00026
00027 #include "..\AEngine\AEngine.h"
00028
00029 namespace {
00030 AMesh tankMesh = NULL;
00031 AMesh turretMesh = NULL;
00032 ATexture tankTexture = NULL;
00033
00034 AMesh tankHMesh = NULL;
00035 AMesh turretHMesh = NULL;
00036 ATexture tankHTexture = NULL;
00037
00038 AMesh launcherMesh = NULL;
00039 ATexture launcherTexture = NULL;
00040
00041 AMesh artilleryMesh = NULL;
00042 AMesh artilleryTurretMesh = NULL;
00043 ATexture artilleryTexture = NULL;
00044
00045 AMesh jetMesh = NULL;
00046 ATexture jetTexture = NULL;
00047
00048 int showNum = 0;
00049 const string names[5] = { "(0) Light Tank", "(1) Heavy Tank", "(2) Launcher", "(3) Artillery", "(4) Jet" };
00050
00051 FLOAT camTheta, camRadius, camHeight;
00052 Vec3D tankPos;
00053 FLOAT tankTheta, turretTheta;
00054 }
00055
00056
00057 void init()
00058 {
00059 sys_showConsole(false);
00060
00061 tankTexture = load_texture("textures\\units\\tank_light.tga");
00062 tankMesh = load_mesh("models\\parts\\tank_light_chasis.obj");
00063 turretMesh = load_mesh("models\\parts\\tank_light_turret.obj");
00064
00065 tankHTexture = load_texture("textures\\units\\tank_heavy.tga");
00066 tankHMesh = load_mesh("models\\parts\\tank_heavy_chasis.obj");
00067 turretHMesh = load_mesh("models\\parts\\tank_heavy_turret.obj");
00068
00069 launcherMesh = load_mesh("models\\parts\\launcher.obj" );
00070 launcherTexture = load_texture("textures\\units\\launcher.tga");
00071
00072 artilleryMesh = load_mesh("models\\parts\\artillery_chasis.obj");
00073 artilleryTurretMesh = load_mesh("models\\parts\\artillery_turret.obj");
00074 artilleryTexture = load_texture("textures\\units\\artillery.tga");
00075
00076 jetMesh = load_mesh("models\\parts\\jet.obj" );
00077 jetTexture = load_texture("textures\\units\\jet.tga");
00078
00079 camTheta = 0.0f;
00080 camRadius = 30.0f;
00081 camHeight = 10.0f;
00082
00083 tankPos = Vec3D(0.0f,0.0f,0.0f);
00084 tankTheta = turretTheta = 0.0f;
00085
00086 sys_setSkipRate(2);
00087 }
00088
00089 void update()
00090 {
00091 Vec3D camPos( cosf(camTheta)*camRadius, sinf(camTheta)*camRadius, camHeight );
00092 const Vec3D origin(0.0f,0.0f,0.0f);
00093 camera_set( camPos, origin, 0.1f );
00094
00095
00096 if( input_isKeyDown(KeyCodes::key_LEFT) ) camTheta -= 0.05f;
00097 if( input_isKeyDown(KeyCodes::key_RIGHT) ) camTheta += 0.05f;
00098 if( input_isKeyDown(KeyCodes::key_UP) ) camRadius -= 0.3f;
00099 if( input_isKeyDown(KeyCodes::key_DOWN) ) camRadius += 0.3f;
00100 if( input_isKeyDown(KeyCodes::key_PRIOR) ) camHeight += 0.3f;
00101 if( input_isKeyDown(KeyCodes::key_NEXT) ) camHeight -= 0.3f;
00102
00103
00104 if( input_isKeyPressed(KeyCodes::key_N) ) showNum = (showNum+1) % 5;
00105 if( input_isKeyPressed(KeyCodes::key_P) ) showNum = (showNum+4) % 5;
00106
00107
00108 if( input_isKeyDown(KeyCodes::key_A) ) tankTheta -= 2.0f;
00109 if( input_isKeyDown(KeyCodes::key_D) ) tankTheta += 2.0f;
00110 FLOAT radian = D3DXToRadian(tankTheta);
00111 if( input_isKeyDown(KeyCodes::key_W) ) tankPos += 0.1f*Vec3D(cosf(radian),sinf(radian),0);
00112 if( input_isKeyDown(KeyCodes::key_S) ) tankPos -= 0.1f*Vec3D(cosf(radian),sinf(radian),0);
00113
00114
00115 if( input_isKeyDown(KeyCodes::key_Q) ) turretTheta -= 1.5f;
00116 if( input_isKeyDown(KeyCodes::key_E) ) turretTheta += 1.5f;
00117 }
00118
00119 void render()
00120 {
00121 overlay_text() << "Use the arrow keys and the PgUp/PgDown to control CAMERA" << endl;
00122 overlay_text() << "Use W/S/A/D to control TANK" << endl;
00123 overlay_text() << "Use Q/E to control TURRET" << endl << endl;
00124 overlay_text() << "Use P/N to select previous/next unit to show" << endl;
00125 overlay_text() << "Currently showing : " << names[showNum];
00126 overlay_textOut( Vec2D(0.0f,0.0f), 1.0f );
00127
00128 if(showNum==0)
00129 {
00130 const Vec3D tankSize( 4.0f, 2.0f, 1.0f );
00131 const Vec3D turretSize( 3.7f, 1.7f, 1.1f );
00132 mesh_render( tankMesh, tankPos, tankSize, Vec3D(tankTheta,90.0f,0.0f), tankTexture );
00133 mesh_render( turretMesh, tankPos, turretSize, Vec3D(tankTheta+turretTheta,90.0f,0.0f), tankTexture );
00134 }
00135
00136 if(showNum==1)
00137 {
00138 const Vec3D tankSize( 6.0f, 2.5f, 1.25f );
00139 const Vec3D turretSize( 4.63f, 2.22f, 1.7f );
00140 mesh_render( tankHMesh, tankPos, tankSize, Vec3D(tankTheta,90.0f,0.0f), tankHTexture );
00141 mesh_render( turretHMesh, tankPos, turretSize, Vec3D(tankTheta+turretTheta,90.0f,0.0f), tankHTexture );
00142 }
00143
00144 if(showNum==2)
00145 {
00146 const Vec3D tankSize( 4.6f, 2.2f, 2.5f );
00147 mesh_render( launcherMesh, tankPos, tankSize, Vec3D(tankTheta,90.0f,0.0f), launcherTexture );
00148 }
00149
00150 if(showNum==3)
00151 {
00152 const Vec3D tankSize( 5.3f, 2.2f, 1.3f );
00153 const Vec3D turretSize( 4.0f, 0.4f, 3.8f );
00154 mesh_render( artilleryMesh, tankPos, tankSize, Vec3D(tankTheta,90.0f,0.0f), artilleryTexture );
00155 mesh_render( artilleryTurretMesh, tankPos, turretSize, Vec3D(tankTheta+turretTheta,90.0f,0.0f), artilleryTexture );
00156 }
00157
00158 if(showNum==4)
00159 {
00160 const Vec3D tankSize( 4.6f, 4.2f, 1.5f );
00161 mesh_render( jetMesh, tankPos, tankSize, Vec3D(tankTheta,90.0f,0.0f), jetTexture );
00162 }
00163 }
00164
00165 INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR, INT )
00166 {
00167 sys_init(hInst,800,600,32,false);
00168 sys_setInitFunc(init);
00169 sys_setUpdateFunc(update);
00170 sys_setRenderFunc(render);
00171 sys_go();
00172 return 0;
00173 }
00174
00175 #endif