From f030154fe727e25a2afe1f78b3998c2d2dba95e4 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 18 Aug 2009 09:24:15 +0000 Subject: astyle cleanup, corrects not loading of material textures --- src/render/draw.cc | 369 +++++++++++++++++++++++++++-------------------------- 1 file changed, 189 insertions(+), 180 deletions(-) (limited to 'src/render/draw.cc') diff --git a/src/render/draw.cc b/src/render/draw.cc index 4dc6e53..dea24bc 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -1,7 +1,7 @@ /* render/draw.cc - This file is part of the Osirion project and is distributed under - the terms and conditions of the GNU General Public License version 2 + This file is part of the Osirion project and is distributed under + the terms and conditions of the GNU General Public License version 2 */ #include @@ -59,15 +59,15 @@ void pass_prepare(float seconds) using namespace model; // lighting settings for the default light GL_LIGHT0 - GLfloat light_position[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat light_position[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat ambient_light[] = { 0.01f, 0.01f, 0.01f, 1.0f }; GLfloat diffuse_light[] = { 0.2f, 0.2f, 0.2f, 1.0f }; GLfloat specular_light[] = { 0.2f, 0.2f, 0.2f, 1.0f }; - for (size_t i=0; i <3; i++) { - light_position[i] = Camera::eye()[i]; + for (size_t i = 0; i < 3; i++) { + light_position[i] = Camera::eye()[i]; } - + glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_light); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_light); @@ -86,14 +86,14 @@ void pass_prepare(float seconds) for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { core::Entity *entity = (*it); - + if (!ext_render(entity)) { new RenderExt(entity); } entity->extension((size_t) core::Extension::Render)->frame(seconds); // globes - if (entity->type() == core::Entity::Globe) { + if (entity->type() == core::Entity::Globe) { core::EntityGlobe *globe = static_cast(entity); // add the globe to the globes list @@ -109,14 +109,14 @@ void pass_prepare(float seconds) GLfloat ambient_light[] = { 0.0f, 0.0f, 0.0f, 1.0f }; GLfloat specular_light[] = { 0.2f, 0.2f, 0.2f, 1.0f }; - for (size_t i=0; i <3; i++) { + for (size_t i = 0; i < 3; i++) { zone_light[i] = globe->location()[i]; zone_color[i] = globe->color()[i]; diffuse_light[i] = globe->color()[i] * 0.4; } zone_light[3] = 1.0f; diffuse_light[3] = 1.0f; - + glLightfv(GL_LIGHT1, GL_POSITION, zone_light); glLightfv(GL_LIGHT1, GL_AMBIENT, ambient_light); glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse_light); @@ -132,18 +132,18 @@ void pass_prepare(float seconds) /* ----- Skybox ---------------------------------------------------- */ void draw_sphere_inside(math::Color const & color, float radius) -{ +{ gl::scale(radius, radius, radius); gl::color(color); - size_t index = (model::SPHERESEGMENTS) * (model::SPHERESEGMENTS-1); - size_t count = (model::SPHERESEGMENTS)*2; + size_t index = (model::SPHERESEGMENTS) * (model::SPHERESEGMENTS - 1); + size_t count = (model::SPHERESEGMENTS) * 2; // draw body - for (int j=0; j < (model::SPHERESEGMENTS-1)/2; j++) { + for (int j = 0; j < (model::SPHERESEGMENTS - 1) / 2; j++) { glDrawArrays(gl::QuadStrip, index, count); index += count; - Stats::quads += count/2-1; + Stats::quads += count / 2 - 1; } } @@ -175,7 +175,7 @@ void draw_pass_sky() gl::enable(GL_TEXTURE_2D); gl::push(); - gl::translate(Camera::eye()); + gl::translate(Camera::eye()); draw_sphere_inside(math::Color(), 1016.0f); gl::pop(); @@ -186,33 +186,33 @@ void draw_pass_sky() /* ---- Globes ----------------------------------------------------- */ void draw_sphere(math::Color const & color, float radius) -{ +{ gl::scale(radius, radius, radius); gl::color(color); size_t index = 0; - size_t count = (model::SPHERESEGMENTS)*2; + size_t count = (model::SPHERESEGMENTS) * 2; // draw body - for (int j=0; j < (model::SPHERESEGMENTS-1)/2; j++) { + for (int j = 0; j < (model::SPHERESEGMENTS - 1) / 2; j++) { glDrawArrays(gl::QuadStrip, index, count); index += count; - Stats::quads += count/2-1; + Stats::quads += count / 2 - 1; } } void draw_globe(const core::EntityGlobe* globe) { - /* + /* Globes have to be rendered distance sorted, closest last. Globes behind farplane are rescaled and repositioned. */ math::Vector3f location(globe->location()); float radius = globe->radius(); - if(globe->flag_is_set(core::Entity::Bright)) { + if (globe->flag_is_set(core::Entity::Bright)) { // bright globe, render fullbright - gl::disable(GL_LIGHTING); + gl::disable(GL_LIGHTING); } else { // disable camera light, level light only gl::disable(GL_LIGHT0); @@ -234,10 +234,10 @@ void draw_globe(const core::EntityGlobe* globe) if (has_zone_light) { // move zone light float fake_light[4]; - for (size_t i=0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { fake_light[i] = zone_light[i] + location[i] - globe->location()[i]; } - fake_light[3] = 1.0f; + fake_light[3] = 1.0f; glLightfv(GL_LIGHT1, GL_POSITION, fake_light); } } @@ -255,7 +255,7 @@ void draw_globe(const core::EntityGlobe* globe) gl::pop(); - if(globe->flag_is_set(core::Entity::Bright)) { + if (globe->flag_is_set(core::Entity::Bright)) { math::Vector3f v = globe->location() - Camera::eye(); v.normalize(); @@ -264,7 +264,7 @@ void draw_globe(const core::EntityGlobe* globe) // FIXME a corona is actually just a giant flare if (!globe->render_texture) { gl::enable(GL_TEXTURE_2D); - } + } Textures::bind("textures/fx/corona"); /* if (ext_render(globe)->distance() <= farplane) { @@ -274,23 +274,23 @@ void draw_globe(const core::EntityGlobe* globe) math::Color color(globe->color()); color.a = a - 0.1f; - + gl::color(color); - gl::enable(GL_BLEND); - + gl::enable(GL_BLEND); + gl::begin(gl::Quads); - glTexCoord2f(0,1); - gl::vertex(location+ (Camera::axis().up() - Camera::axis().left()) * radius * 4.0f); - glTexCoord2f(0,0); - gl::vertex(location+ (Camera::axis().up() + Camera::axis().left()) * radius * 4.0f); - glTexCoord2f(1,0); - gl::vertex(location+ (Camera::axis().up() * -1 + Camera::axis().left()) * radius * 4.0f); - glTexCoord2f(1,1); - gl::vertex(location+ (Camera::axis().up() * -1 - Camera::axis().left()) * radius * 4.0f); + glTexCoord2f(0, 1); + gl::vertex(location + (Camera::axis().up() - Camera::axis().left()) * radius * 4.0f); + glTexCoord2f(0, 0); + gl::vertex(location + (Camera::axis().up() + Camera::axis().left()) * radius * 4.0f); + glTexCoord2f(1, 0); + gl::vertex(location + (Camera::axis().up() * -1 + Camera::axis().left()) * radius * 4.0f); + glTexCoord2f(1, 1); + gl::vertex(location + (Camera::axis().up() * -1 - Camera::axis().left()) * radius * 4.0f); gl::end(); - + Stats::quads++; - + gl::disable(GL_BLEND); /* if (ext_render(globe)->distance() <= farplane) { @@ -316,11 +316,11 @@ void draw_globe(const core::EntityGlobe* globe) } if (globe->flag_is_set(core::Entity::Bright)) { - gl::enable(GL_LIGHTING); + gl::enable(GL_LIGHTING); } else { gl::enable(GL_LIGHT0); } - + if (globe->render_texture) { gl::disable(GL_TEXTURE_2D); } @@ -349,52 +349,52 @@ void draw_entity_cube(const core::Entity* entity) gl::color(entity->color()); gl::begin(gl::Quads); - + // top - gl::normal(0,0,1); + gl::normal(0, 0, 1); gl::vertex(v0); gl::vertex(v1); - gl::vertex(v2); + gl::vertex(v2); gl::vertex(v3); // bottom - gl::normal(0,0, -1); + gl::normal(0, 0, -1); gl::vertex(v7); gl::vertex(v6); - gl::vertex(v5); + gl::vertex(v5); gl::vertex(v4); - + // sides - gl::normal(1,0,0); + gl::normal(1, 0, 0); gl::vertex(v1); - gl::vertex(v0); - gl::vertex(v4); - gl::vertex(v5); + gl::vertex(v0); + gl::vertex(v4); + gl::vertex(v5); - gl::normal(-1,0,0); - gl::vertex(v3); - gl::vertex(v2); - gl::vertex(v6); - gl::vertex(v7); + gl::normal(-1, 0, 0); + gl::vertex(v3); + gl::vertex(v2); + gl::vertex(v6); + gl::vertex(v7); - gl::normal(0,1,0); + gl::normal(0, 1, 0); gl::vertex(v2); - gl::vertex(v1); - gl::vertex(v5); - gl::vertex(v6); + gl::vertex(v1); + gl::vertex(v5); + gl::vertex(v6); - gl::normal(0,-1,0); + gl::normal(0, -1, 0); gl::vertex(v0); - gl::vertex(v3); - gl::vertex(v7); - gl::vertex(v4); + gl::vertex(v3); + gl::vertex(v7); + gl::vertex(v4); gl::end(); } void draw_entity_diamond(const core::Entity* entity) { - float radius = entity->radius()/2; + float radius = entity->radius() / 2; /* ---- draw axis lines ---- */ gl::color(entity->color_second()); @@ -411,7 +411,7 @@ void draw_entity_diamond(const core::Entity* entity) gl::vertex(-1.25f * radius, 0, 0); gl::vertex(-2 * radius, 0, 0); - + gl::vertex(0, -1.25f * radius, 0); gl::vertex(0, -2 * radius, 0); @@ -421,7 +421,7 @@ void draw_entity_diamond(const core::Entity* entity) gl::end(); /* ---- draw rotating body lines ---- */ - float angle = (core::application()->time() + ext_render(entity)->fuzz() ) * 45.0f; + float angle = (core::application()->time() + ext_render(entity)->fuzz()) * 45.0f; angle = angle - 360.0f * floorf(angle / 360.0f); gl::rotate(angle, math::Vector3f::Zaxis()); @@ -430,19 +430,19 @@ void draw_entity_diamond(const core::Entity* entity) } gl::color(entity->color()); - gl::begin(gl::TriangleFan ); + gl::begin(gl::TriangleFan); gl::normal(0, 0 , 1); gl::vertex(0, 0, radius); - gl::normal(1, 0 ,0); + gl::normal(1, 0 , 0); gl::vertex(radius, 0.0f, 0.0f); gl::normal(0, 1, 0); gl::vertex(0.0f, radius, 0.0f); - gl::normal(-1, 0 ,0); + gl::normal(-1, 0 , 0); gl::vertex(-radius, 0.0f, 0.0f); gl::normal(0, -1, 0); gl::vertex(0.0f, -radius, 0.0f); - gl::normal(1, 0 ,0); + gl::normal(1, 0 , 0); gl::vertex(radius, 0.0f, 0.0f); gl::end(); @@ -450,20 +450,20 @@ void draw_entity_diamond(const core::Entity* entity) gl::begin(gl::TriangleFan); gl::normal(0, 0 , -1); gl::vertex(0, 0, -radius); - + gl::normal(1, 0, 0); gl::vertex(radius, 0.0f, 0.0f); gl::normal(0, -1, 0); gl::vertex(0.0f, -radius, 0.0f); - gl::normal(-1, 0 ,0); + gl::normal(-1, 0 , 0); gl::vertex(-radius, 0.0f, 0.0f); gl::normal(0, 1, 0); gl::vertex(0.0f, radius, 0.0f); - gl::normal(1, 0 ,0); + gl::normal(1, 0 , 0); gl::vertex(radius, 0.0f, 0.0f); gl::end(); @@ -478,16 +478,16 @@ void draw_entity_axis(const core::Entity* entity) gl::begin(gl::Lines); gl::color(entity->color_second()); - gl::vertex(r,0.0f,0.0f); + gl::vertex(r, 0.0f, 0.0f); gl::color(entity->color()); - gl::vertex(-r,0.0f,0.0f); + gl::vertex(-r, 0.0f, 0.0f); - gl::vertex(0.0f,r/2,0.0f); - gl::vertex(0.0f,-r/2,0.0f); + gl::vertex(0.0f, r / 2, 0.0f); + gl::vertex(0.0f, -r / 2, 0.0f); - gl::vertex(0.0f,0.0f,r); - gl::vertex(0.0f,0.0f,-r); - gl::end(); + gl::vertex(0.0f, 0.0f, r); + gl::vertex(0.0f, 0.0f, -r); + gl::end(); } void draw_pass_default() @@ -505,11 +505,11 @@ void draw_pass_default() gl::disable(GL_LIGHTING); } - switch(entity->shape()) { + switch (entity->shape()) { case core::Entity::Sphere: draw_entity_sphere(entity); break; - + case core::Entity::Diamond: draw_entity_diamond(entity); break; @@ -519,10 +519,10 @@ void draw_pass_default() break; case core::Entity::Cube: - - default: - draw_entity_cube(entity); - break; + + default: + draw_entity_cube(entity); + break; } if (entity->flag_is_set(core::Entity::Bright)) { @@ -557,7 +557,7 @@ void draw_fragment(model::Fragment *fragment, bool draw_details) } if (r_normals->value()) { - gl::begin(gl::Lines ); + gl::begin(gl::Lines); gl::color(1.0f, 0.0f, 0.0f); @@ -580,8 +580,8 @@ void draw_fragment(model::Fragment *fragment, bool draw_details) } void draw_model_fragments(model::Model *model, - const math::Color & color_primary, const math::Color & color_secondary, - const bool detail, const bool power, const float thrust) + const math::Color & color_primary, const math::Color & color_secondary, + const bool detail, const bool power, const float thrust) { // default material, lighted and geometry color const model::Material *material = 0; @@ -593,7 +593,7 @@ void draw_model_fragments(model::Model *model, // TODO this should probably be initialized somewhere else glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); for (model::Model::Groups::iterator git = model->groups().begin(); git != model->groups().end(); git++) { @@ -602,8 +602,8 @@ void draw_model_fragments(model::Model *model, if (group->transform()) { gl::push(); - - gl::translate(group->location()); + + gl::translate(group->location()); if (group->type() == model::FragmentGroup::Rotate) { float rotation_angle = math::degrees360f(core::application()->time() * group->speed()); @@ -611,57 +611,63 @@ void draw_model_fragments(model::Model *model, } else { gl::multmatrix(group->axis()); } - + const float s = group->scale(); if (s) gl::scale(s, s, s); } for (model::FragmentGroup::iterator fit = group->begin(); fit != group->end(); fit++) { - + model::Fragment *fragment = (*fit); - + if (fragment->material() != material) { material = fragment->material(); - + if (material) { if (material->flags() & model::Material::Engine) { - -/* if (use_color_array) { + + /* + if (use_color_array) { glDisableClientState(GL_COLOR_ARRAY); use_color_array = false; - }*/ - + } + */ color.assign(model->enginecolor() * thrust); - + } else if (material->flags() & model::Material::Tertiary) { -/* if (use_color_array) { + /* + if (use_color_array) { use_color_array = false; glDisableClientState(GL_COLOR_ARRAY); - }*/ - + } + */ + if ((material->flags() & model::Material::Tertiary) == model::Material::Tertiary) { for (size_t i = 0; i < 3; i++) color[i] = (color_primary[i] + color_secondary[i]) / 2; - + } else if ((material->flags() & model::Material::Secondary) == model::Material::Secondary) { color.assign(color_secondary); - - } if ((material->flags() & model::Material::Primary) == model::Material::Primary) { + + } + if ((material->flags() & model::Material::Primary) == model::Material::Primary) { color.assign(color_primary); } - + color.r *= material->color().r; color.g *= material->color().g; color.b *= material->color().b; } else { -/* if (!use_color_array) { + /* + if (!use_color_array) { glEnableClientState(GL_COLOR_ARRAY); use_color_array = true; - }*/ + } + */ color.assign(material->color()); } - + if (power && (material->flags() & model::Material::Bright)) { if (use_light) { gl::disable(GL_LIGHTING); @@ -691,7 +697,7 @@ void draw_model_fragments(model::Model *model, } if (material->flags() & model::Material::Environment) { - + if (!(material->flags() & model::Material::Texture)) { // use sky as envmap if the material defines no texture if (core::localplayer()->zone()->sky_texture()) { @@ -707,7 +713,7 @@ void draw_model_fragments(model::Model *model, if (!use_env) { // enable env mapping gl::enable(GL_TEXTURE_GEN_S); - gl::enable(GL_TEXTURE_GEN_T); + gl::enable(GL_TEXTURE_GEN_T); use_env = true; } @@ -716,7 +722,7 @@ void draw_model_fragments(model::Model *model, if (use_env) { // disable env mapping gl::disable(GL_TEXTURE_GEN_S); - gl::disable(GL_TEXTURE_GEN_T); + gl::disable(GL_TEXTURE_GEN_T); use_env = false; } } @@ -730,7 +736,6 @@ void draw_model_fragments(model::Model *model, } else { // material not found - if (use_light) { // disable lighting gl::disable(GL_LIGHTING); @@ -740,7 +745,7 @@ void draw_model_fragments(model::Model *model, if (use_env) { // disable env mapping gl::disable(GL_TEXTURE_GEN_S); - gl::disable(GL_TEXTURE_GEN_T); + gl::disable(GL_TEXTURE_GEN_T); use_env = false; } @@ -749,14 +754,16 @@ void draw_model_fragments(model::Model *model, use_texture = false; } -/* if (!use_color_array) { + /* + if (!use_color_array) { glEnableClientState(GL_COLOR_ARRAY); use_color_array = true; - }*/ + } + */ color.assign(1.0f, 0.0f, 1.0f); } } - + gl::color(color); draw_fragment(fragment, detail); } @@ -782,9 +789,11 @@ void draw_model_fragments(model::Model *model, use_texture = false; } -/* if (!use_color_array) { + /* + if (!use_color_array) { glEnableClientState(GL_COLOR_ARRAY); - }*/ + } + */ } void draw_model_fragments(core::Entity *entity) @@ -859,7 +868,7 @@ void draw_model_axis(const core::Entity *entity) const float r = entity->radius() * 1.5f; gl::begin(gl::Lines); - + gl::color(entity->color()); gl::vertex(-r, 0.0f, 0.0f); @@ -876,14 +885,14 @@ void draw_model_axis(const core::Entity *entity) gl::color(1.0f, 0.0f, 0.0f); gl::vertex(worldaxis.forward() * -1 * r); - gl::vertex(worldaxis.forward() * r); + gl::vertex(worldaxis.forward() * r); gl::vertex(worldaxis.left() * -1 * r); gl::vertex(worldaxis.left() * r); - + gl::vertex(worldaxis.up() * -1 * r); gl::vertex(worldaxis.up() * r); - + gl::end(); } @@ -929,7 +938,7 @@ void draw_pass_model_fx(float elapsed) for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { core::Entity *entity = (*it); - + power = true; if ((entity->type() == core::Entity::Controlable) || (entity->type() == core::Entity::Dynamic)) { @@ -942,17 +951,17 @@ void draw_pass_model_fx(float elapsed) if (entity->model() && ext_render(entity)->detailvisible() && power) { - // disable culling by default + // disable culling by default gl::disable(GL_CULL_FACE); model::Cull current_cull = model::CullNone; - + // default light texture size_t current_texture = Textures::bind("textures/fx/flare00"); gl::enable(GL_TEXTURE_2D); - + gl::begin(gl::Quads); - // draw model lights + // draw model lights for (model::Model::Lights::iterator lit = entity->model()->lights().begin(); lit != entity->model()->lights().end(); lit++) { model::Light *light = (*lit); @@ -992,7 +1001,7 @@ void draw_pass_model_fx(float elapsed) color.assign(light->color()); } color.a = a; - + location.assign(entity->location() + (entity->axis() * light->location())); light_size = 0.0625f * light->radius(); @@ -1005,19 +1014,19 @@ void draw_pass_model_fx(float elapsed) // draw the quad gl::color(color); - - glTexCoord2f(0,1); + + glTexCoord2f(0, 1); gl::vertex(location + (Camera::axis().up() - Camera::axis().left()) * light_size); - glTexCoord2f(0,0); + glTexCoord2f(0, 0); gl::vertex(location + (Camera::axis().up() + Camera::axis().left()) * light_size); - glTexCoord2f(1,0); + glTexCoord2f(1, 0); gl::vertex(location + (Camera::axis().up() * -1 + Camera::axis().left()) * light_size); - glTexCoord2f(1,1); + glTexCoord2f(1, 1); gl::vertex(location + (Camera::axis().up() * -1 - Camera::axis().left()) * light_size); Stats::quads++; - + } - + // draw flares for (model::Model::Flares::iterator flit = entity->model()->flares().begin(); flit != entity->model()->flares().end(); flit++) { model::Flare *flare = (*flit); @@ -1074,7 +1083,7 @@ void draw_pass_model_fx(float elapsed) gl::end(); if (current_texture != flare->texture()) { - current_texture = Textures::bind(flare->texture()); + current_texture = Textures::bind(flare->texture()); } if (current_cull != flare->cull()) { @@ -1101,14 +1110,14 @@ void draw_pass_model_fx(float elapsed) // draw the quad gl::color(color); - - glTexCoord2f(0,1); + + glTexCoord2f(0, 1); gl::vertex(location + (flare_axis.up() + flare_axis.left()) * light_size); - glTexCoord2f(0,0); + glTexCoord2f(0, 0); gl::vertex(location + (flare_axis.up() - flare_axis.left()) * light_size); - glTexCoord2f(1,0); + glTexCoord2f(1, 0); gl::vertex(location + (flare_axis.up() * -1 - flare_axis.left()) * light_size); - glTexCoord2f(1,1); + glTexCoord2f(1, 1); gl::vertex(location + (flare_axis.up() * -1 + flare_axis.left()) * light_size); Stats::quads++; @@ -1129,7 +1138,7 @@ void draw_pass_model_fx(float elapsed) if (current_cull == model::CullNone) { gl::enable(GL_CULL_FACE); } - + if (particlesystem->cull() == model::CullBack) { gl::cullface(GL_BACK); current_cull = model::CullBack; @@ -1185,26 +1194,26 @@ void draw_pass_spacegrid() gl::push(); gl::translate(Camera::target()); - gl::color(0,0, 1.0f); + gl::color(0, 0, 1.0f); gl::normal(0, 0, 1.0f); gl::begin(gl::Lines); - for (int i=-gridsize; i <= gridsize; i++) { - gl::color(0,0, 0, 0); - gl::vertex(i-dx, -gridsize-dy, z); - gl::color(0,0, (gridsize-abs(i))*s, (gridsize-abs(i))*s); - gl::vertex(i-dx, -dy, z ); - gl::vertex(i-dx, -dy ,z ); - gl::color(0,0, 0, 0); - gl::vertex(i-dx, gridsize-dy, z); - - gl::vertex(-gridsize-dx, i-dy, z ); - gl::color(0,0, (gridsize-abs(i))*s, (gridsize-abs(i))*s); - gl::vertex(-dx, i-dy, z); - gl::vertex(-dx, i-dy, z); - gl::color(0,0, 0, 0); - gl::vertex(gridsize-dx, i-dy, z); + for (int i = -gridsize; i <= gridsize; i++) { + gl::color(0, 0, 0, 0); + gl::vertex(i - dx, -gridsize - dy, z); + gl::color(0, 0, (gridsize - abs(i))*s, (gridsize - abs(i))*s); + gl::vertex(i - dx, -dy, z); + gl::vertex(i - dx, -dy , z); + gl::color(0, 0, 0, 0); + gl::vertex(i - dx, gridsize - dy, z); + + gl::vertex(-gridsize - dx, i - dy, z); + gl::color(0, 0, (gridsize - abs(i))*s, (gridsize - abs(i))*s); + gl::vertex(-dx, i - dy, z); + gl::vertex(-dx, i - dy, z); + gl::color(0, 0, 0, 0); + gl::vertex(gridsize - dx, i - dy, z); } gl::end(); @@ -1227,7 +1236,7 @@ void draw(float seconds) glPolygonMode(GL_FRONT, GL_FILL); } - // set vertex array pointers + // set vertex array pointers glVertexPointer(3, GL_FLOAT, 0, core::game()->vertexarray()->vertex()); glNormalPointer(GL_FLOAT, 0, core::game()->vertexarray()->normal()); glTexCoordPointer(3, GL_FLOAT, 0, core::game()->vertexarray()->texture()); @@ -1239,7 +1248,7 @@ void draw(float seconds) glEnableClientState(GL_NORMAL_ARRAY); // glDisableClientState(GL_COLOR_ARRAY); - gl::disable(GL_DEPTH_TEST); + gl::disable(GL_DEPTH_TEST); gl::depthmask(GL_FALSE); // disable depth buffer writing draw_pass_sky(); // draw the skysphere @@ -1259,7 +1268,7 @@ void draw(float seconds) } gl::enable(GL_LIGHTING); // enable lighting - + draw_pass_globes(); // draw globes draw_pass_default(); // draw entities without model @@ -1275,12 +1284,12 @@ void draw(float seconds) // disable resaling of normals gl::disable(GL_RESCALE_NORMAL); } - + gl::enable(GL_BLEND); gl::depthmask(GL_FALSE); // disable depth buffer writing - + draw_pass_spacegrid(); // draw the blue spacegrid - + if (!core::localplayer()->view()) { Dust::draw(zone_color); // draw spacedust } @@ -1299,10 +1308,10 @@ void draw(float seconds) gl::enable(GL_RESCALE_NORMAL); } - gl::enable(GL_LIGHTING); - + gl::enable(GL_LIGHTING); + draw_pass_model_radius(); - + gl::disable(GL_LIGHTING); if (r_normalize && r_normalize->value()) { @@ -1313,15 +1322,15 @@ void draw(float seconds) gl::disable(GL_RESCALE_NORMAL); } } - + glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); - + gl::disable(GL_COLOR_MATERIAL); // disable color tracking gl::disable(GL_CULL_FACE); // disable culling - + gl::depthmask(GL_TRUE); // enable depth buffer writing gl::disable(GL_DEPTH_TEST); // disable depth buffer testing // GL_BLEND must be enabled for the GUI @@ -1330,7 +1339,7 @@ void draw(float seconds) // draw HUD target world space geometry, like dock indicators void draw_target(core::Entity *entity) { - model::Model *model = entity->model(); + model::Model *model = entity->model(); if (!model) return; @@ -1347,13 +1356,13 @@ void draw_target(core::Entity *entity) gl::multmatrix(entity->axis()); gl::color(0, 1.0f, 1.0f, 1.0f); - + for (model::Model::Docks::iterator dit = model->docks().begin(); dit != model->docks().end(); dit++) { model::Dock *dock = (*dit); math::Vector3f maxbox(dock->location()); math::Vector3f minbox(dock->location()); - for (size_t i=0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { maxbox[i] += 0.025; minbox[i] -= 0.025; } @@ -1365,7 +1374,7 @@ void draw_target(core::Entity *entity) gl::vertex(minbox.x(), minbox.y(), maxbox.z()); gl::vertex(maxbox.x(), minbox.y(), maxbox.z()); gl::end(); - + // bottom gl::begin(gl::LineLoop); gl::vertex(maxbox.x(), maxbox.y(), minbox.z()); @@ -1373,7 +1382,7 @@ void draw_target(core::Entity *entity) gl::vertex(minbox.x(), minbox.y(), minbox.z()); gl::vertex(maxbox.x(), minbox.y(), minbox.z()); gl::end(); - + gl::begin(gl::Lines); gl::vertex(maxbox.x(), maxbox.y(), maxbox.z()); gl::vertex(maxbox.x(), maxbox.y(), minbox.z()); -- cgit v1.2.3