diff options
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/camera.cc | 4 | ||||
-rw-r--r-- | src/render/draw.cc | 41 | ||||
-rw-r--r-- | src/render/render.cc | 9 | ||||
-rw-r--r-- | src/render/render.h | 2 |
4 files changed, 52 insertions, 4 deletions
diff --git a/src/render/camera.cc b/src/render/camera.cc index ba82ea6..54c4547 100644 --- a/src/render/camera.cc +++ b/src/render/camera.cc @@ -59,7 +59,7 @@ void Camera::init() target_direction = 0.0f; distance = 0.4f; - camera_zoom = 1.0f; + camera_zoom = 2.0f; camera_mode = Overview; camera_previous_mode = Track; @@ -290,7 +290,7 @@ void Camera::frame(float seconds) if (core::localcontrol()->model()) { camera_target -= camera_axis.forward() * math::max(FRUSTUMFRONT / WORLDSCALE, core::localcontrol()->model()->maxbbox().x); - camera_target += camera_axis.up() * math::max(FRUSTUMFRONT / WORLDSCALE, core::localcontrol()->model()->maxbbox().z); + camera_target += camera_axis.up() * math::max(FRUSTUMFRONT / WORLDSCALE, core::localcontrol()->model()->maxbbox().z * 2.0f); } else { camera_target -= camera_axis.forward() * math::max (FRUSTUMFRONT / WORLDSCALE, FRUSTUMFRONT / WORLDSCALE + core::localcontrol()->radius()); camera_target += camera_axis.up() * math::max (FRUSTUMFRONT / WORLDSCALE, FRUSTUMFRONT / WORLDSCALE + core::localcontrol()->radius()); diff --git a/src/render/draw.cc b/src/render/draw.cc index 1884125..e9123cd 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -837,6 +837,7 @@ void draw_model_bbox(model::Model *model) gl::vertex(model->model_maxbbox.x, model->model_minbbox.y, model->model_minbbox.z); gl::end(); + // body gl::begin(gl::Lines); gl::vertex(model->model_maxbbox.x, model->model_maxbbox.y, model->model_maxbbox.z); gl::vertex(model->model_maxbbox.x, model->model_maxbbox.y, model->model_minbbox.z); @@ -846,6 +847,43 @@ void draw_model_bbox(model::Model *model) gl::vertex(model->model_minbbox.x, model->model_minbbox.y, model->model_minbbox.z); gl::vertex(model->model_maxbbox.x, model->model_minbbox.y, model->model_maxbbox.z); gl::vertex(model->model_maxbbox.x, model->model_minbbox.y, model->model_minbbox.z); + + gl::end(); +} + + +// draw entity axis +void draw_model_axis(const core::Entity *entity) +{ + // axis + const float r = entity->radius() * 1.5f; + + gl::begin(gl::Lines); + + gl::color(entity->color()); + + gl::vertex(-r, 0.0f, 0.0f); + gl::vertex(r, 0.0f, 0.0f); + + gl::vertex(0.0f, -r, 0.0f); + gl::vertex(0.0f, r, 0.0f); + + gl::vertex(0.0f, 0.0f, -r); + gl::vertex(0.0f, 0.0f, r); + + const math::Axis worldaxis(entity->axis().transpose()); + + gl::color(1.0f, 0.0f, 0.0f); + + gl::vertex(worldaxis.forward() * -1 * 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(); } @@ -866,6 +904,9 @@ void draw_pass_model_fragments() draw_model_bbox(entity->model()); } + if (r_axis->value()) { + draw_model_axis(entity); + } gl::pop(); } } diff --git a/src/render/render.cc b/src/render/render.cc index 27204f6..4ad2d84 100644 --- a/src/render/render.cc +++ b/src/render/render.cc @@ -26,6 +26,7 @@ namespace render { +core::Cvar *r_axis = 0; core::Cvar *r_bbox = 0; core::Cvar *r_grid = 0; core::Cvar *r_particles = 0; @@ -74,11 +75,14 @@ void init(int width, int height) r_normals->set_info("[bool] render face normals"); r_normalize = core::Cvar::get("r_normalize", "0", core::Cvar::Archive); - r_normalize->set_info("[bool] use GL_NORMALIZE instead of GL_RESCALE_NORMAL"); + r_normalize->set_info("[bool] use GL_NORMALIZE instead of GL_RESCALE_NORMAL (recommended off)"); r_grid = core::Cvar::get("r_grid", "0", core::Cvar::Archive); r_grid->set_info("[bool] render the space grid"); + r_axis = core::Cvar::get("r_axis", "0", core::Cvar::Archive); + r_axis->set_info("[bool] render entity axis"); + r_bbox = core::Cvar::get("r_bbox", "0", core::Cvar::Archive); r_bbox->set_info("[bool] render model bounding box"); @@ -99,9 +103,10 @@ void init(int width, int height) // hardware generate mipmaps r_mipmap = core::Cvar::get("r_mipmap", "1", core::Cvar::Archive); - r_mipmap->set_info("[bool] use hardware generated mipmaps"); + r_mipmap->set_info("[bool] use hardware generated mipmaps (recommended on)"); if (!State::has_generate_mipmaps()) { con_print << " no hardware generated mipmap support" << std::endl; + (*r_mipmap) = 0.0f; } Camera::init(); diff --git a/src/render/render.h b/src/render/render.h index c397c78..765e0f9 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -36,6 +36,8 @@ namespace render { /// resize viewport void resize(int width, int height); + /// render entity axis + extern core::Cvar *r_axis; /// render model bounding boxes extern core::Cvar *r_bbox; /// render the spacegrid |