Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

DemoMassive.cpp

Go to the documentation of this file.
00001 /*
00002 CS Senior Project 2003
00003 Team : Leftfield
00004 Project : ModernWarfare
00005 Members :
00006 - Russ Christensen              <rchriste@cs.utah.edu>
00007 - Todd Smith                    <tcsmith@cs.utah.edu>
00008 - Usit Duongsaa                 <duongsaa@cs.utah.edu>
00009 Copyright 2003 Russ Christensen, Usit Duongsaa, and Todd Smith. All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
00012 
00013 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
00014 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 
00015 THIS SOFTWARE IS PROVIDED BY RUSS CHRISTENSEN, USIT DUONGSAA, AND TODD SMITH ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RUSS, USIT, TODD OR OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00016 */
00017 
00018 
00024 #include "WinMainSelector.h"
00025 #if defined COMPILE_DEMOMASSIVE
00026 
00027 #include "..\AEngine\AEngine.h"
00028 
00029 
00030 ATexture        tankTexture = NULL;
00031 AMesh           tankMesh        = NULL;
00032 AMesh           turretMesh  = NULL;
00033 FLOAT           camTheta, camRadius, camHeight;
00034 Vec3D           tankPos;
00035 FLOAT           tankTheta, turretTheta;
00036 
00037 //------------------------------------------------------------------------------------
00038 void init()
00039 {       
00040         sys_showConsole(true);
00041 
00042         tankTexture = load_texture("textures\\units\\tank_light.tga");
00043         tankMesh    = load_mesh("models\\parts\\tank_light_chasis.obj");
00044         turretMesh  = load_mesh("models\\parts\\tank_light_turret.obj");
00045         
00046         camTheta = 0.0f;
00047         camRadius = 30.0f;
00048         camHeight = 10.0f;
00049 
00050         tankPos = Vec3D(0.0f,0.0f,0.0f);
00051         tankTheta = turretTheta = 0.0f;
00052 }
00053 //------------------------------------------------------------------------------------
00054 void update()
00055 {
00056         Vec3D camPos( cosf(camTheta)*camRadius, sinf(camTheta)*camRadius, camHeight );
00057         const Vec3D origin(0.0f,0.0f,0.0f);
00058         camera_set( camPos, origin, 0.1f );
00059         
00060         // camera control
00061         if( input_isKeyDown(KeyCodes::key_LEFT) )       camTheta -= 0.05f;
00062         if( input_isKeyDown(KeyCodes::key_RIGHT) )      camTheta += 0.05f;
00063         if( input_isKeyDown(KeyCodes::key_UP) )         camRadius -= 0.3f;
00064         if( input_isKeyDown(KeyCodes::key_DOWN) )       camRadius += 0.3f;
00065         if( input_isKeyDown(KeyCodes::key_PRIOR) )      camHeight += 0.3f;
00066         if( input_isKeyDown(KeyCodes::key_NEXT) )       camHeight -= 0.3f;
00067 
00068         // tank control
00069         if( input_isKeyDown(KeyCodes::key_A) )  tankTheta -= 2.0f;
00070         if( input_isKeyDown(KeyCodes::key_D) )  tankTheta += 2.0f;
00071         FLOAT radian = D3DXToRadian(tankTheta);
00072         if( input_isKeyDown(KeyCodes::key_W) )  tankPos += 0.1f*Vec3D(cosf(radian),sinf(radian),0);
00073         if( input_isKeyDown(KeyCodes::key_S) )  tankPos -= 0.1f*Vec3D(cosf(radian),sinf(radian),0);
00074 
00075         // turret control
00076         if( input_isKeyDown(KeyCodes::key_Q) )  turretTheta -= 1.5f;
00077         if( input_isKeyDown(KeyCodes::key_E) )  turretTheta += 1.5f;
00078 }
00079 //------------------------------------------------------------------------------------
00080 void render()
00081 {
00082         overlay_text() << "Use the arrow keys and the PgUp/PgDown to control CAMERA" << endl;
00083         overlay_text() << "Use W/S/A/D to control TANK" << endl;
00084         overlay_text() << "Use Q/E to control TURRET";
00085         overlay_textOut( Vec2D(0.0f,0.0f), 1.0f );
00086 
00087         const Vec3D tankSize( 4.0f, 2.0f, 1.0f );
00088         const Vec3D turretSize( 3.7f, 1.7f, 1.1f );
00089 
00090         int n = 25;
00091         int N = n*n;
00092         Vec3D p;
00093 
00094         for( int i=0; i<N; i++ )
00095         {
00096                 p = tankPos + 5.0f*Vec3D( (FLOAT)(i/n), (FLOAT)(i%n), 0.0f );
00097                 mesh_render( tankMesh, p, tankSize, Vec3D(tankTheta,90.0f,0.0f), tankTexture );
00098                 mesh_render( turretMesh, p, turretSize, Vec3D(tankTheta+turretTheta,90.0f,0.0f), tankTexture );
00099         }
00100 }
00101 //------------------------------------------------------------------------------------
00102 INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR, INT )
00103 {
00104         sys_init(hInst,800,600,32,false);
00105         sys_setInitFunc(init);
00106         sys_setUpdateFunc(update);
00107         sys_setRenderFunc(render);
00108         sys_go();
00109         return 0;
00110 }
00111 //------------------------------------------------------------------------------------
00112 #endif

Generated on Wed Apr 23 05:50:15 2003 for Modern Warfare by doxygen1.3-rc2