#include "CoreEngine.h"
#include "DynamicCity.h"
#include "EffectTest.h"
#include "GLApplication.h"
#include "GPUFire.h"
#include "GPUWater.h"
#include "Light.h"
#include "LightShader.h"
#include "MathUtils.h"
#include "Mesh.h"
#include "MeshModel.h"
#include "MeshFactory.h"
#include "Octree.h"
#include "ParticleSystem.h"
#include "Quadtree.h"
#include "SingleTexturedMesh.h"
#include "SGFFile.h"
#include "SGFMeshModel.h"
#include "SGFMeshModelFactory.h"
#include "SkyBox.h"
#include "Terrain.h"
#include "TextureDatabase.h"
#include "Vector3f.h"
#include "World.h"
#include "XMLDocument.h"
#include <stdlib.h>
Include dependency graph for main.cpp:
Go to the source code of this file.
Functions | |
void | createGrass (Vector3f bottomCenter, float width, float height, Triangle *tr0, Triangle *tr1, Triangle *tr2, Triangle *tr3) |
MeshModel * | createGrass (MeshModel *terrain, float startX, float startZ, float width, float depth) |
void | addModels (World *world, MeshModel *terrain, float startX, float startZ, float width, float depth, int num) |
int | main (int argc, char *argv[]) |
|
Definition at line 145 of file main.cpp. References pge::World::addRenderableObject(), and pge::MeshModel::getHeightAt().
00145 { 00146 int i; 00147 float endX = startX + width; 00148 float endZ = startZ + depth; 00149 float x; 00150 float z; 00151 float y; 00152 00153 SGFFile file("../data/models/test.sgf"); 00154 00155 00156 for(i = 0; i < num; i++) { 00157 x = 0.0f;//mathutils::random(startX, endX); 00158 z = 0.0f;//mathutils::random(startZ, endZ); 00159 y = terrain->getHeightAt(x, z); 00160 00161 SGFMeshModel *model = new SGFMeshModel(&file, Vector3f(x, y, z), 1.0f); 00162 world->addRenderableObject(model); 00163 } 00164 } |
Here is the call graph for this function:
|
Definition at line 91 of file main.cpp. References pge::MeshModel::addMesh(), pge::Mesh::addTriangle(), and pge::SingleTexturedMesh::setTexture().
00091 { 00092 float endX = startX + width; 00093 float endZ = startZ + depth; 00094 float diffX = mathutils::absf(endX - startX); 00095 float diffZ = mathutils::absf(endZ - startZ); 00096 float sx; 00097 float sz; 00098 int grassNum; 00099 int tileX; 00100 int tileZ; 00101 MeshModel *model; 00102 00103 00104 tileX = 10; 00105 tileZ = 10; 00106 grassNum = 30; 00107 00108 model = new MeshModel(); 00109 00110 Texture *tex = TextureDatabase::getInstance()->addTexture("grass_0.bmp", "grass", true, true); 00111 00112 for(int z = 0; z < tileZ; z++) { 00113 for(int x = 0; x < tileX; x++) { 00114 sx = startX + (float)x * (diffX / tileX); 00115 sz = startZ + (float)z * (diffZ / tileZ); 00116 00117 // Create one grass mesh. 00118 SingleTexturedMesh *mesh = new SingleTexturedMesh(true); 00119 00120 for(int i = 0; i < grassNum; i++) { 00121 float gx = sx + (mathutils::random() * (diffX / tileX)); 00122 float gz = sz + (mathutils::random() * (diffZ / tileZ)); 00123 float height = 0.9f + mathutils::random() * 0.2f; 00124 00125 Triangle tr0; 00126 Triangle tr1; 00127 Triangle tr2; 00128 Triangle tr3; 00129 00130 createGrass(Vector3f(gx, /*terrain->getHeightAt(gx, gz)*/ 0.0f, gz), height, height, &tr0, &tr1, &tr2, &tr3); 00131 mesh->addTriangle(tr0); 00132 mesh->addTriangle(tr1); 00133 mesh->addTriangle(tr2); 00134 mesh->addTriangle(tr3); 00135 } 00136 00137 mesh->setTexture(tex); 00138 model->addMesh(mesh); 00139 } 00140 } 00141 return model; 00142 } |
Here is the call graph for this function:
|
Definition at line 38 of file main.cpp. References pge::Triangle::m_texCoords, pge::Vector3f::m_v, and pge::Triangle::m_vertices.
00039 { 00040 00041 float halfWidth = width / 2.0f; 00042 00043 Vector3f topLeft = Vector3f(bottomCenter.m_v[0] - halfWidth, bottomCenter.m_v[1] + height, 00044 bottomCenter.m_v[2]); 00045 Vector3f bottomLeft = Vector3f(bottomCenter.m_v[0] - halfWidth, bottomCenter.m_v[1], 00046 bottomCenter.m_v[2]); 00047 Vector3f bottomRight = Vector3f(bottomCenter.m_v[0] + halfWidth, bottomCenter.m_v[1], 00048 bottomCenter.m_v[2]); 00049 Vector3f topRight = Vector3f(bottomCenter.m_v[0] + halfWidth, bottomCenter.m_v[1] + height, 00050 bottomCenter.m_v[2]); 00051 00052 00053 tr0->m_vertices[0] = topLeft; 00054 tr0->m_vertices[1] = bottomLeft; 00055 tr0->m_vertices[2] = bottomRight; 00056 tr0->m_texCoords[0] = Vector2f(0.0f, 0.0f); 00057 tr0->m_texCoords[1] = Vector2f(0.0f, 1.0f); 00058 tr0->m_texCoords[2] = Vector2f(1.0f, 1.0f); 00059 00060 tr1->m_vertices[0] = topLeft; 00061 tr1->m_vertices[1] = bottomRight; 00062 tr1->m_vertices[2] = topRight; 00063 tr1->m_texCoords[0] = Vector2f(0.0f, 0.0f); 00064 tr1->m_texCoords[1] = Vector2f(1.0f, 1.0f); 00065 tr1->m_texCoords[2] = Vector2f(1.0f, 0.0f); 00066 00067 topLeft = Vector3f(bottomCenter.m_v[0], bottomCenter.m_v[1] + height, bottomCenter.m_v[2] - halfWidth); 00068 bottomLeft = Vector3f(bottomCenter.m_v[0], bottomCenter.m_v[1], bottomCenter.m_v[2] - halfWidth); 00069 bottomRight = Vector3f(bottomCenter.m_v[0], bottomCenter.m_v[1], bottomCenter.m_v[2] + halfWidth); 00070 topRight = Vector3f(bottomCenter.m_v[0], bottomCenter.m_v[1] + height, bottomCenter.m_v[2] + halfWidth); 00071 00072 tr2->m_vertices[0] = topLeft; 00073 tr2->m_vertices[1] = bottomLeft; 00074 tr2->m_vertices[2] = bottomRight; 00075 tr2->m_texCoords[0] = Vector2f(0.0f, 0.0f); 00076 tr2->m_texCoords[1] = Vector2f(0.0f, 1.0f); 00077 tr2->m_texCoords[2] = Vector2f(1.0f, 1.0f); 00078 00079 tr3->m_vertices[0] = topLeft; 00080 tr3->m_vertices[1] = bottomRight; 00081 tr3->m_vertices[2] = topRight; 00082 tr3->m_texCoords[0] = Vector2f(0.0f, 0.0f); 00083 tr3->m_texCoords[1] = Vector2f(1.0f, 1.0f); 00084 tr3->m_texCoords[2] = Vector2f(1.0f, 0.0f); 00085 } |
|
Definition at line 170 of file main.cpp. References pge::ParticleSystem::activate(), pge::MeshModel::addMeshModel(), pge::World::addRenderableObject(), pge::MeshModel::getBoundingBox(), pge::MeshModel::getHeightAt(), pge::EffectTest::setBoundingBox(), pge::ParticleSystem::setDistribution(), pge::ParticleSystem::setFadeOutEnabled(), pge::ParticleSystem::setFadeOutEnd(), pge::ParticleSystem::setFadeOutStart(), pge::ParticleSystem::setLifeDegeneration(), pge::World::setSky(), and pge::ParticleSystem::setVelocity().
00170 { 00171 // 00172 // Variables 00173 // 00174 GLApplication *glApp; 00175 World *world; 00176 00177 00178 xmlInitParser(); 00179 LIBXML_TEST_VERSION 00180 00181 00182 glApp = new GLApplication(800, 600, 24, true, "World Of Phobos"); 00183 if(!glApp->isWindowOpened()) { 00184 exit(0); 00185 } 00186 00187 world = new World(); 00188 CoreEngine::getInstance()->setCurrentWorld(world); 00189 00190 00192 // CONTENT DOWN HERE 00194 // ADD LIGHTS FIRST! 00195 // This line adds the lights! 00196 EffectTest *lightEffects = new EffectTest(); 00197 00198 // Sky. 00199 SkyBox *sky = new SkyBox("sky", 10.0f); 00200 world->setSky(sky); 00201 00202 // Terrain. 00203 Terrain *terrain = new Terrain("../data/textures/heightmap.tga", "gras_4_dl.tga", Vector3f(-400.0f, -20.0f, -400.0f), 0.1f, 100, 100, 800.0f, 800.0f); 00204 Quadtree *terrainTree = new Quadtree(terrain, 10, false); 00205 world->addRenderableObject(terrainTree, true); 00206 00207 // Water. 00208 GPUWater *water = new GPUWater(Vector3f(-1500.0f, -10.0f, -1500.0f), 3000.0f, 3000.0f); 00209 world->addRenderableObject(water, true); 00210 00211 // The world model which contains all structures in the world. 00212 MeshModel *worldModel = new MeshModel(); 00213 00214 SGFMeshModel *model0 = sgfmeshmodelfactory::createSGFMeshModel("../data/models/wall.sgf", Vector3f(0.0f, terrain->getHeightAt(0.0f, 0.0f), 0.0f), 1.0f); 00215 SGFMeshModel *model1 = sgfmeshmodelfactory::createSGFMeshModel("../data/models/house.sgf", Vector3f(0.0f, terrain->getHeightAt(0.0f, 0.0f), 0.0f), 1.0f); 00216 SGFMeshModel *model2 = sgfmeshmodelfactory::createSGFMeshModel("../data/models/well.sgf", Vector3f(10.0f, terrain->getHeightAt(0.0f, 0.0f), 10.0f), 0.5f); 00217 SGFMeshModel *model3 = sgfmeshmodelfactory::createSGFMeshModel("../data/models/fountain.sgf", Vector3f(-10.0f, terrain->getHeightAt(0.0f, 0.0f), 20.0f), 0.6f); 00218 00219 SGFMeshModel *model4 = sgfmeshmodelfactory::createSGFMeshModel("../data/models/house.sgf", Vector3f(10.0f, terrain->getHeightAt(0.0f, 0.0f), -10.0f), 1.0f); 00220 SGFMeshModel *model5 = sgfmeshmodelfactory::createSGFMeshModel("../data/models/house.sgf", Vector3f(20.0f, terrain->getHeightAt(0.0f, 0.0f), 20.0f), 1.0f); 00221 SGFMeshModel *model6 = sgfmeshmodelfactory::createSGFMeshModel("../data/models/house.sgf", Vector3f(10.0f, terrain->getHeightAt(0.0f, 0.0f), 20.0f), 1.0f); 00222 SGFMeshModel *model7 = sgfmeshmodelfactory::createSGFMeshModel("../data/models/house.sgf", Vector3f(-20.0f, terrain->getHeightAt(0.0f, 0.0f), 20.0f), 1.0f); 00223 SGFMeshModel *model8 = sgfmeshmodelfactory::createSGFMeshModel("../data/models/house.sgf", Vector3f(-20.0f, terrain->getHeightAt(0.0f, 0.0f), -15.0f), 1.0f); 00224 SGFMeshModel *model9 = sgfmeshmodelfactory::createSGFMeshModel("../data/models/house.sgf", Vector3f(-20.0f, terrain->getHeightAt(0.0f, 0.0f), -25.0f), 1.0f); 00225 00226 SGFMeshModel *model10 = sgfmeshmodelfactory::createSGFMeshModel("../data/models/tower.sgf", Vector3f(30.0f, terrain->getHeightAt(0.0f, 0.0f), -30.0f), 1.0f); 00227 00228 SGFMeshModel *model11 = sgfmeshmodelfactory::createSGFMeshModel("../data/models/fireplace.sgf", Vector3f(20.0f, terrain->getHeightAt(0.0f, 0.0f) + 0.01f, 5.0f), 0.4f); 00229 00230 worldModel->addMeshModel(model0); 00231 worldModel->addMeshModel(model1); 00232 worldModel->addMeshModel(model2); 00233 worldModel->addMeshModel(model3); 00234 worldModel->addMeshModel(model4); 00235 worldModel->addMeshModel(model5); 00236 worldModel->addMeshModel(model6); 00237 worldModel->addMeshModel(model7); 00238 worldModel->addMeshModel(model8); 00239 worldModel->addMeshModel(model9); 00240 worldModel->addMeshModel(model10); 00241 worldModel->addMeshModel(model11); 00242 00243 Octree *worldTree = new Octree(worldModel, 10, false); 00244 world->addRenderableObject(worldTree); 00245 00246 // Fire for the fireplace. 00247 GPUFire *fire = new GPUFire(Vector3f(20.5f, -0.5f, 5.7f), 1.0f); 00248 world->addRenderableObject(fire); 00249 00250 00251 ParticleSystem *p = new ParticleSystem("waterparticle_0.tga", Vector3f(-10.0f, 2.5f, 20.0f), Vector3f(0.1f, 1.0f, 0.1f), 1000); 00252 p->setLifeDegeneration(0.04f); 00253 p->setVelocity(0.005f); 00254 p->setDistribution(100); 00255 //p->setGravity(Vector3f(0.0f, 1.0f, 0.0f)); 00256 p->setFadeOutEnabled(true); 00257 p->setFadeOutStart(Vector3f(-10.0f, 2.0f, 20.0f)); 00258 p->setFadeOutEnd(Vector3f(-10.0f, 1.0f, 20.0f)); 00259 p->activate(); 00260 world->addRenderableObject(p); 00261 00262 // Add the rendering of the lights at last. 00263 lightEffects->setBoundingBox(worldModel->getBoundingBox()); 00264 world->addRenderableObject(lightEffects); 00265 00266 glApp->execute(); 00267 00268 if(glApp != NULL) { 00269 delete glApp; 00270 } 00271 00272 xmlCleanupParser(); 00273 00274 return 0; 00275 } |
Here is the call graph for this function: