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

DemoTerrain.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_DEMOTERRAIN
00026 
00027 #include "..\AEngine\AEngine.h"
00028 
00029 
00030 AMesh           skyMesh;
00031 ATexture        skyTexture;
00032 ATexture        texLow, texHigh, texNormal;
00033 FLOAT           camTheta, camRadius, camHeight;
00034 ATerrain        terrain;
00035 
00036 //------------------------------------------------------------------------------------
00037 void init()
00038 {       
00039         sys_showConsole(false);
00040         
00041         texLow    = load_texture("textures\\environment\\terrainDryLand.dds");
00042         texHigh   = load_texture("textures\\environment\\terrainRockyMoss.dds");
00043         
00044         texNormal = load_texture("textures\\environment\\terrainBump.dds");
00045 
00046         skyMesh = load_mesh("models\\parts\\sky.obj");
00047         skyTexture = load_texture("textures\\environment\\sky_plain.tga");
00048 
00049         camTheta = 0.0f;
00050         camRadius = 30.0f;
00051         camHeight = 30.0f;
00052 
00053         sys_setSkipRate(0);
00054 
00055         terrain = load_terrain("maps\\map1.tga", 300.0f, 300.0f, 65.0f );
00056 }
00057 //------------------------------------------------------------------------------------
00058 void update()
00059 {
00060         Vec3D camPos( cosf(camTheta)*camRadius, sinf(camTheta)*camRadius, camHeight );
00061         const Vec3D origin(0.0f,0.0f,0.0f);
00062         camera_set( camPos, origin, 0.1f );
00063         
00064         // camera control
00065         if( input_isKeyDown(KeyCodes::key_LEFT) )       camTheta -= 0.05f;
00066         if( input_isKeyDown(KeyCodes::key_RIGHT) )      camTheta += 0.05f;
00067         if( input_isKeyDown(KeyCodes::key_UP) )         camRadius -= 0.3f;
00068         if( input_isKeyDown(KeyCodes::key_DOWN) )       camRadius += 0.3f;
00069         if( input_isKeyDown(KeyCodes::key_PRIOR) )      camHeight += 1.3f;
00070         if( input_isKeyDown(KeyCodes::key_NEXT) )       camHeight -= 1.3f;
00071 }
00072 //------------------------------------------------------------------------------------
00073 void render()
00074 {
00075         terrain_render(terrain,texLow,texHigh,texNormal);
00076 
00077         mesh_render( skyMesh, Vec3D(0.0f,0.0f,0.0f), Vec3D(300.0f,300.0f,150.0f), Vec3D(0.0f,0.0f,0.0f), skyTexture );
00078 
00079         overlay_text() << "Use the arrow keys and the PgUp/PgDown to control CAMERA" << endl;   
00080         overlay_textOut( Vec2D(0.0f,0.0f), 1.0f );
00081 }
00082 //------------------------------------------------------------------------------------
00083 INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR, INT )
00084 {
00085         sys_init(hInst,800,600,32,false);
00086         sys_setInitFunc(init);
00087         sys_setUpdateFunc(update);
00088         sys_setRenderFunc(render);
00089         sys_go();
00090         return 0;
00091 }
00092 //------------------------------------------------------------------------------------
00093 #endif

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