Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-09 17:48:16 +0000
committerStijn Buys <ingar@osirion.org>2008-02-09 17:48:16 +0000
commit48aa068b036f565d6b94d4207242066ba655afe4 (patch)
tree4b68cf169c7fcd4bc6f2eecc7c072830d91830f8 /src/client/draw.cc
parent23aee34002facf39b56d209320817375db3b6189 (diff)
entities, step 1
Diffstat (limited to 'src/client/draw.cc')
-rw-r--r--src/client/draw.cc128
1 files changed, 128 insertions, 0 deletions
diff --git a/src/client/draw.cc b/src/client/draw.cc
new file mode 100644
index 0000000..f907267
--- /dev/null
+++ b/src/client/draw.cc
@@ -0,0 +1,128 @@
+/*
+ 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
+*/
+
+// projet headers
+#include "render/render.h"
+#include "render/sphere.h"
+#include "render/box.h"
+#include "client/client.h"
+#include "client/draw.h"
+
+namespace client
+{
+
+render::Sphere sphere(math::Vector3f(0,0,0),1);
+
+void draw_star(game::Star *star, float elapsed)
+{
+ render::gl::color(star->color);
+ sphere.radius = star->radius;
+ sphere.draw();
+}
+
+math::Vector3f v0(1.0f, -1.0f, -1.0f);
+math::Vector3f v1(1.0f, 1.0f, -1.0f);
+math::Vector3f v2(1.0f, 1.0f, 1.0f);
+math::Vector3f v3(1.0f, -1.0f, 1.0f);
+
+math::Vector3f v4(-1.0f, -1.0f, -1.0f);
+math::Vector3f v5(-1.0f, 1.0f, -1.0f);
+math::Vector3f v6(-1.0f, 1.0f, 1.0f);
+math::Vector3f v7(-1.0f, -1.0f, 1.0f);
+float angle = 0;
+
+void draw_ship(game::Ship *ship, float elapsed)
+{
+ using math::Vector3f;
+ using math::Color;
+ using namespace render;
+
+ gl::rotate(ship->yaw(), 0.0f, 1.0f, 0.0f );
+
+ Vector3f tl(0.25, 0.125, 0.125);
+ Vector3f br(-0.25, -0.125, -0.125);
+
+ Box box(tl, br);
+ box.draw();
+
+ tl = Vector3f(0, 0.07, 0.25);
+ br = Vector3f(-0.5, -0.07, 0.125);
+ Box engine1(tl, br);
+ engine1.topcolor = Color(0.7, 0.7, 0.7);
+ engine1.bottomcolor = engine1.topcolor * 0.5;
+ engine1.draw();
+
+ tl = Vector3f(0, 0.07, -0.125);
+ br = Vector3f(-0.5, -0.07, -0.25);
+ Box engine2(tl, br);
+ engine2.topcolor = engine1.topcolor;
+ engine2.bottomcolor = engine1.bottomcolor;
+ engine2.draw();
+
+ tl = Vector3f(0.4, 0.07, 0.07);
+ br = Vector3f(0.25, -0.07, -0.07);
+ Box cockpit(tl, br);
+ cockpit.topcolor = engine1.topcolor;
+ cockpit.bottomcolor = engine1.bottomcolor;
+ cockpit.draw();
+
+ if(ship->thrust() > 0 ) {
+ gl::color(1.0f,0 ,0 );
+ gl::begin(gl::Lines);
+ gl::vertex(-0.5f, 0, 0.185);
+ gl::vertex(-0.5f-0.25f*ship->thrust(), 0, 0.185);
+
+ gl::vertex(-0.5f, 0, -0.185f);
+ gl::vertex(-0.5f-0.25f*ship->thrust(), 0, -0.185f);
+ gl::end();
+ }
+
+ // shield rotation
+ gl::rotate(angle, 0.0f, 1.0f, 0.0f );
+ angle += 180.0f * elapsed;
+ if( angle > 360.0f ) {
+ angle -= 360.0f;
+ }
+
+ // draw the shield
+ gl::color(Color(0.0f, 1.0f ,0.0f , 0.5f));
+
+ gl::begin(gl::LineStrip);
+ gl::vertex(v0);
+ gl::vertex(v1);
+ gl::vertex(v2);
+ gl::vertex(v3);
+ gl::vertex(v0);
+ gl::end();
+
+ gl::begin(gl::LineStrip);
+ gl::vertex(v4);
+ gl::vertex(v5);
+ gl::vertex(v6);
+ gl::vertex(v7);
+ gl::vertex(v4);
+ gl::end();
+}
+
+void draw_world(float elapsed)
+{
+ using namespace render;
+
+ // draw the ship
+ gl::push();
+ gl::translate(game.ship->location);
+ gl::scale(0.2f, 0.2f, 0.2f);
+ draw_ship(game.ship, elapsed);
+ gl::pop();
+
+ // draw the star
+ gl::push();
+ gl::translate(game.star->location);
+ draw_star(game.star, elapsed);
+ gl::pop();
+}
+
+}