From 3866f2b33313d891347f454537843befd295b78f Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 20 Oct 2007 10:02:51 +0000 Subject: Initial import. --- src/client/shipdrawer.cc | 108 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/client/shipdrawer.cc (limited to 'src/client/shipdrawer.cc') diff --git a/src/client/shipdrawer.cc b/src/client/shipdrawer.cc new file mode 100644 index 0000000..d889178 --- /dev/null +++ b/src/client/shipdrawer.cc @@ -0,0 +1,108 @@ +/* shipdrawer.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 +*/ + +#include + +// project headers +#include "gl/osiriongl.h" +#include "gl/box.h" + +#include "shipdrawer.h" + +Vector3f v0(1.0f, -1.0f, -1.0f); +Vector3f v1(1.0f, 1.0f, -1.0f); +Vector3f v2(1.0f, 1.0f, 1.0f); +Vector3f v3(1.0f, -1.0f, 1.0f); + +Vector3f v4(-1.0f, -1.0f, -1.0f); +Vector3f v5(-1.0f, 1.0f, -1.0f); +Vector3f v6(-1.0f, 1.0f, 1.0f); +Vector3f v7(-1.0f, -1.0f, 1.0f); + +ShipDrawer::ShipDrawer(Ship *s) +{ + angle = 0; + ship = s; +} + +ShipDrawer::~ShipDrawer() +{ +} + +void ShipDrawer::draw(float elapsed) +{ + using namespace gl; + + gl::push(); + + 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 ) { + color(1.0f,0 ,0 ); + begin(Lines); + vertex(-0.5f, 0, 0.185); + vertex(-0.5f-0.25f*ship->thrust, 0, 0.185); + + vertex(-0.5f, 0, -0.185f); + vertex(-0.5f-0.25f*ship->thrust, 0, -0.185f); + end(); + } + + // shield rotation + rotate(angle, 0.0f, 1.0f, 0.0f ); + angle += 180.0f * elapsed; + if( angle > 360.0f ) { + angle -= 360.0f; + } + + // draw the shield + color(Color(0.0f, 1.0f ,0.0f , 0.5f)); + + begin(LineStrip); + vertex(v0); + vertex(v1); + vertex(v2); + vertex(v3); + vertex(v0); + end(); + + begin(LineStrip); + vertex(v4); + vertex(v5); + vertex(v6); + vertex(v7); + vertex(v4); + end(); + + gl::pop(); +} -- cgit v1.2.3