From eb649a80fbb272eee260e1fb3f58a5da77191522 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 2 Mar 2008 12:51:53 +0000 Subject: better working .map reader --- src/game/game.cc | 12 ++++++++++-- src/render/model.cc | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/game/game.cc b/src/game/game.cc index 5157270..cf9f496 100644 --- a/src/game/game.cc +++ b/src/game/game.cc @@ -83,8 +83,8 @@ void Game::init() cube->entity_shape = core::Entity::Cube; cube->entity_color = Color(0.0f, 0.8f, 0.0f); cube->entity_location = Vector3f(24.0f, 0.0f, -24.0f); - cube->entity_name ="cube: Borg cube green"; - cube->entity_modelname = "cube"; + cube->entity_name ="ccube: Borg cube green"; + cube->entity_modelname = "ccube"; cube->entity_moduletypeid = cube_enttype; // the red cube @@ -96,6 +96,14 @@ void Game::init() cube->entity_modelname = "cube"; cube->entity_moduletypeid = cube_enttype; + // diamond + cube = new core::Entity(core::Entity::Solid & core::Entity::Static); + cube->entity_shape = core::Entity::Diamond; + cube->entity_color = Color(0.5f, 1.0f, 5.0f); + cube->entity_location = Vector3f(16.0f, 0.0f, -20.0f); + cube->entity_name = "diamond: big bucks"; + cube->entity_modelname = "ship"; + // the yellow sphere core::Entity *sphere = new core::Entity(core::Entity::Solid & core::Entity::Static); sphere->entity_shape = core::Entity::Sphere; diff --git a/src/render/model.cc b/src/render/model.cc index f048b7f..5019c7e 100644 --- a/src/render/model.cc +++ b/src/render/model.cc @@ -135,7 +135,7 @@ Model::Model(std::string const & name) : ifs.close(); - con_debug << "Loaded model " << name << " with " << model_face.size() << " polygons\n"; + con_debug << " maps/" << name << ".map " << model_face.size() << " polygons\n"; } Model::~Model() @@ -165,10 +165,10 @@ void Model::make_face(math::Plane3f *face, std::vector & planes vl.push_back(new math::Vector3f(0, -MAX_BOUNDS, MAX_BOUNDS)); vl.push_back(new math::Vector3f(0, MAX_BOUNDS, MAX_BOUNDS)); vl.push_back(new math::Vector3f(0, MAX_BOUNDS, -MAX_BOUNDS)); - + // calculate the x coordinate of each face vertex for (std::vector::iterator it = vl.begin(); it != vl.end(); it++) { - (*it)->x = ( face->d() - + (*it)->x = ( -face->d() - face->normal().z * (*it)->z - face->normal().y * (*it)->y ) / face->normal().x; @@ -185,7 +185,7 @@ void Model::make_face(math::Plane3f *face, std::vector & planes // calculate the x coordinate of each face vertex for (std::vector::iterator it = vl.begin(); it != vl.end(); it++) { - (*it)->y = ( face->d() - + (*it)->y = ( -face->d() - face->normal().z * (*it)->z - face->normal().x * (*it)->x ) / face->normal().y; @@ -202,7 +202,7 @@ void Model::make_face(math::Plane3f *face, std::vector & planes // calculate the x coordinate of each face vertex for (std::vector::iterator it = vl.begin(); it != vl.end(); it++) { - (*it)->z = ( face->d() - + (*it)->z = ( -face->d() - face->normal().x * (*it)->x - face->normal().y * (*it)->y ) / face->normal().z; @@ -289,10 +289,10 @@ void Model::make_face(math::Plane3f *face, std::vector & planes // calculate intersection // calculate intersection - float t1 = -plane->normal().x * next.x - plane->normal().y * next.y - plane->normal().z * next.z -plane->d(); - float t2 = (plane->normal().x * v.x - plane->normal().x * next.x + - plane->normal().y * v.y - plane->normal().y * next.y + - plane->normal().z * v.z - plane->normal().z * next.z); + float t1 = -plane->normal().x * v.x - plane->normal().y * v.y - plane->normal().z * v.z -plane->d(); + float t2 = (plane->normal().x * next.x - plane->normal().x * v.x + + plane->normal().y * next.y - plane->normal().y * v.y + + plane->normal().z * next.z - plane->normal().z * v.z); //cout << "next t2 " << t2 << std::endl; Vector3f *s = new Vector3f; @@ -300,7 +300,7 @@ void Model::make_face(math::Plane3f *face, std::vector & planes *s = v; } else { for (int j = 0; j < 3; j++) - (*s)[j] = next [j] + t1 * ( v[j] - next[j]) / t2; + (*s)[j] = v [j] + t1 * ( next[j] - v[j]) / t2; } //cout << " added " << *s << std::endl; -- cgit v1.2.3