Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-04-16 19:36:15 +0000
committerStijn Buys <ingar@osirion.org>2009-04-16 19:36:15 +0000
commit6ab4021827e91303ac6fe2276f5567810b7e0496 (patch)
tree82c50c5a4bdc63da51c5bee9c122d165fd872aa6 /src
parenta95028547981614e06ea7a6d22b853b85418cea3 (diff)
updated a few help messages, added 3d modelview to the buy menu
Diffstat (limited to 'src')
-rw-r--r--src/client/buymenu.cc16
-rw-r--r--src/client/buymenu.h3
-rw-r--r--src/core/commandbuffer.cc2
-rw-r--r--src/core/info.cc4
-rw-r--r--src/core/loader.cc2
-rw-r--r--src/render/camera.cc24
-rw-r--r--src/render/camera.h9
-rw-r--r--src/render/draw.cc6
-rw-r--r--src/render/draw.h5
-rwxr-xr-xsrc/ui/modelview.cc45
-rwxr-xr-xsrc/ui/modelview.h7
11 files changed, 104 insertions, 19 deletions
diff --git a/src/client/buymenu.cc b/src/client/buymenu.cc
index b0a0b48..fecf4e0 100644
--- a/src/client/buymenu.cc
+++ b/src/client/buymenu.cc
@@ -30,7 +30,12 @@ BuyMenu::BuyMenu(ui::Widget *parent, const char * label) : ui::Window(parent)
menu_modelpane->set_border(true);
menu_closebutton = new ui::Button(menu_modelpane, "Close","view hide");
-
+
+ menu_modelview = new ui::ModelView(menu_modelpane);
+ menu_modelview->set_label("modelview");
+ menu_modelview->set_background(false);
+ menu_modelview->set_border(true);
+
// text pane (right)
menu_textpane = new ui::Window(this);
menu_textpane->set_label("textpane");
@@ -52,6 +57,7 @@ BuyMenu::BuyMenu(ui::Widget *parent, const char * label) : ui::Window(parent)
menu_infotimestamp = 0;
menu_inforecord = 0;
+ menu_modelpane->raise(); // DEBUG
hide();
}
@@ -73,10 +79,13 @@ void BuyMenu::set_item(std::string const & itemtype, std::string const & itemnam
menu_infotext.clear();
menu_namelabel->set_text(0);
+ menu_modelview->set_modelname(0);
core::Info *info = core::game()->info(itemtype+'/'+itemname);
if (info) {
menu_namelabel->set_text(info->name());
+ menu_modelview->set_modelname(info->modelname());
+
for (core::Info::Text::iterator it = info->text().begin(); it != info->text().end(); it++) {
menu_infotext.push_back((*it));
}
@@ -103,6 +112,9 @@ void BuyMenu::resize()
menu_closebutton->set_location((menu_modelpane->width() - menu_closebutton->width()) * 0.5f,
menu_modelpane->height() - menu_closebutton->height() - ui::UI::elementsize.height() * 0.5f);
+ menu_modelview->set_size(menu_modelpane->width()-8, menu_modelpane->width()-8);
+ menu_modelview->set_location(4, 4);
+
// reposition text pane (right)
menu_textpane->set_size(width() - smallmargin * 3.0f - menu_modelpane->width(), height() - smallmargin * 4.0f);
menu_textpane->set_location(smallmargin * 2.0f + menu_modelpane->width(), smallmargin * 2.0f);
@@ -124,8 +136,6 @@ void BuyMenu::draw()
// update content if necessary
if (menu_infotimestamp && (menu_infotimestamp != menu_inforecord->timestamp()))
set_item(menu_itemtype, menu_itemname);
-
- ui::Window::draw();
}
}
diff --git a/src/client/buymenu.h b/src/client/buymenu.h
index 81a87bd..44517cf 100644
--- a/src/client/buymenu.h
+++ b/src/client/buymenu.h
@@ -11,6 +11,7 @@
#include "ui/container.h"
#include "ui/button.h"
#include "ui/label.h"
+#include "ui/modelview.h"
#include "ui/window.h"
#include "ui/scrollpane.h"
@@ -44,6 +45,8 @@ private:
ui::Button *menu_closebutton;
ui::Button *menu_buybutton;
+ ui::ModelView *menu_modelview;
+
std::string menu_itemtype;
std::string menu_itemname;
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc
index 84b63be..e288b0f 100644
--- a/src/core/commandbuffer.cc
+++ b/src/core/commandbuffer.cc
@@ -189,7 +189,7 @@ void CommandBuffer::init()
func->set_info("list functions");
func = Func::add("list_info", (FuncPtr)func_list_info);
- func->set_info("list infos");
+ func->set_info("list info records");
func = Func::add("list_var", (FuncPtr)func_list_var);
func->set_info("list variables");
diff --git a/src/core/info.cc b/src/core/info.cc
index fc10fe5..5f31569 100644
--- a/src/core/info.cc
+++ b/src/core/info.cc
@@ -122,7 +122,7 @@ Info::~Info()
void Info::print() const
{
- con_print << "label: ^B" << label() << " ^Nname: ^B" << name() << "^N" << std::endl;
+ con_print << "label: ^B" << label() << " ^Nname: ^B" << name() << " ^Nmodel: ^B" << modelname() << "^N" << std::endl;
for (Text::const_iterator it = info_text.begin(); it != info_text.end(); it++) {
con_print << " " << (*it) << std::endl;
@@ -176,7 +176,7 @@ void Info::list()
Info *info = (*it).second;;
con_print << info->label() << std::endl;
}
- con_print << registry.size() << " registered infos" << std::endl;
+ con_print << registry.size() << " registered info " << aux::plural("record", registry.size()) << std::endl;
}
}
diff --git a/src/core/loader.cc b/src/core/loader.cc
index 46e0990..4070c2b 100644
--- a/src/core/loader.cc
+++ b/src/core/loader.cc
@@ -84,7 +84,7 @@ void Loader::list()
}
con_print << loaderlist << std::endl;
- con_print << loader_registry.size() << " registered " << aux::plural("modules", loader_registry.size()) << std::endl;
+ con_print << loader_registry.size() << " registered " << aux::plural("module", loader_registry.size()) << std::endl;
}
diff --git a/src/render/camera.cc b/src/render/camera.cc
index ba056d0..092cc26 100644
--- a/src/render/camera.cc
+++ b/src/render/camera.cc
@@ -374,6 +374,30 @@ void Camera::frustum()
gl::translate(-1.0f * camera_eye);
}
+void Camera::frustum_default(float distance, float cx, float cy)
+{
+ // Change to the projection matrix and set our viewing volume large enough for the skysphere
+ gl::matrixmode(GL_PROJECTION);
+ gl::loadidentity();
+
+ // note: the factor 2.0f probably has to be 1.0f/frustum_size
+ gl::translate(2.0f*(-State::width() * 0.5f + cx)/State::width() , 2.0f*(State::height() * 0.5f - cy)/State::height(), 0.0f);
+
+ gl::frustum(-camera_frustum_size, camera_frustum_size, -camera_frustum_size/State::aspect(), camera_frustum_size/State::aspect(), camera_frustum_front, 1023.0f);
+
+ gl::matrixmode(GL_MODELVIEW);
+ gl::loadidentity();
+
+ // map world coordinates to opengl coordinates
+ gl::rotate(90.0f, 0.0f, 1.0f, 0.0f);
+ gl::rotate(-90.0f, 1.0f , 0.0f, 0.0f);
+
+ gl::translate(distance+1.0f, 0.0f, 0.0f);
+
+ // extra model rotation
+ gl::rotate(-core::application()->time() / 8.0f *360.0f , 0.0f, 0.0f, 1.0f);
+}
+
void Camera::ortho()
{
// switch to orthographic projection
diff --git a/src/render/camera.h b/src/render/camera.h
index 400c4b0..349aef8 100644
--- a/src/render/camera.h
+++ b/src/render/camera.h
@@ -43,11 +43,16 @@ public:
/// progress the camera
static void frame(float elapsed);
- /// enable frustum projection
- /** The frustum projection is used to draw the world
+ /// enable camera frustum projection
+ /** The camera frustum projection is used to draw the world
*/
static void frustum();
+ /// enable default frustum projection
+ /** The default frustum projection is used to draw Gui 3D models
+ */
+ static void frustum_default(float distance, float cx, float cy);
+
/// enable orthographic projection
/** The ortographic projetion is used to draw the user interface
*/
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 6762b64..5784347 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -539,12 +539,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 = true, const bool power = true, const float thrust = 0.0f)
+ const bool detail, const bool power, const float thrust)
{
-
- if (!model)
- return;
-
// default material, lighted and geometry color
const model::Material *material = 0;
bool use_light = true; // gl::disable(GL_LIGHTING) is set
diff --git a/src/render/draw.h b/src/render/draw.h
index bb42067..14a9767 100644
--- a/src/render/draw.h
+++ b/src/render/draw.h
@@ -26,6 +26,11 @@ void reset();
/// draw a sphere
void draw_sphere(math::Color const & color, float radius);
+/// draw a model
+void draw_model_fragments(model::Model *model,
+ const math::Color & color_primary, const math::Color & color_secondary,
+ const bool detail = true, const bool power = true, const float thrust = 0.0f);
+
class Stats {
public:
static void clear();
diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc
index a07922a..11dd318 100755
--- a/src/ui/modelview.cc
+++ b/src/ui/modelview.cc
@@ -11,6 +11,7 @@
#include "render/camera.h"
#include "render/draw.h"
#include "render/render.h"
+
namespace ui
{
@@ -55,18 +56,56 @@ void ModelView::draw()
if (!modelview_modelname.size())
return;
+ model::Model *model = model::Model::find(modelview_modelname);
+ if (!model)
+ return;
+
math ::Vector2f center(global_location());
center.x += width() * 0.5f;
center.y += height() * 0.5f;
-
- //model::Model *model = model::Model::find(modelview_modelname);
+
+ gl::clear(GL_DEPTH_BUFFER_BIT);
// gl 3d mode
+ render::Camera::frustum_default(model->radius(), center.x, center.y);
+
+ gl::disable(GL_BLEND);
+ gl::depthmask(GL_TRUE); // enable writing to the depth buffer
+ gl::enable(GL_DEPTH_TEST);
+
+ gl::enable(GL_CULL_FACE); // enable culling
+ gl::enable(GL_COLOR_MATERIAL); // enable color tracking
+ gl::enable(GL_LIGHTING);
+
+ // enable vertex arrays
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_NORMAL_ARRAY);
+
+ render::draw_model_fragments(model, core::localplayer()->color(), core::localplayer()->color_second(), true, true, 0);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+
+ gl::disable(GL_LIGHTING);
+ 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::enable(GL_BLEND);
// gl 2d mode
- //render::Camera::ortho();
+ render::Camera::ortho();
+}
+
+void ModelView::draw_border()
+{
+ paint::color(palette()->foreground());
+ paint::border(global_location(), size());
}
}
diff --git a/src/ui/modelview.h b/src/ui/modelview.h
index 2abeb01..1fbb4d9 100755
--- a/src/ui/modelview.h
+++ b/src/ui/modelview.h
@@ -35,9 +35,12 @@ public:
virtual void print(const size_t indent) const;
protected:
- /// draw the model
+ /// draw the widget
virtual void draw();
-
+
+ /// draw border
+ void draw_border();
+
private:
std::string modelview_modelname;
math::Color modelview_color;