fysxasteroids/engine/VisualEntityBase.cc

73 lines
1.5 KiB
C++
Raw Permalink Normal View History

2010-04-05 23:38:59 +02:00
#include "EntityBase.h"
#include <GL/gl.h>
namespace Engine {
void EntityVisualState::Draw () {
if (mBaseType == EntityBaseTypeActor) {
int i, segments;
segments = 20;
double x, z, rad, drad;
drad = (M_PI * 2) / segments;
glBegin (GL_TRIANGLE_FAN);
glVertex3f (0., 0., 0.);
for (i = 0; i <= segments; i++) {
rad = drad * i;
sincos (rad, &z, &x);
glVertex3f (x * mRadius, 0., -z * mRadius);
}
glEnd ();
glDisable (GL_DEPTH_TEST);
glColor3f (0.8, 0., 0.2);
glBegin (GL_TRIANGLES);
glVertex3f (mRadius, 0., 0.);
glVertex3f (0., 0., -mRadius * 0.3);
glVertex3f (0., 0., mRadius * 0.3);
glEnd ();
glEnable (GL_DEPTH_TEST);
return;
} else if (mBaseType == EntityBaseTypeBlock) {
glBegin (GL_QUADS);
glVertex3f (-0.5, 0., 0.5);
glVertex3f (0.5, 0., 0.5);
glVertex3f (0.5, 0., -0.5);
glVertex3f (-0.5, 0., -0.5);
glEnd ();
} else if (mBaseType == EntityBaseTypeParticle) {
int i, segments;
segments = 20;
double x, z, rad, drad;
drad = (M_PI * 2) / segments;
glDisable (GL_DEPTH_TEST);
glColor3f (0., 0.8, 0.1);
glBegin (GL_TRIANGLE_FAN);
glVertex3f (0., 0., 0.);
for (i = 0; i <= segments; i++) {
rad = drad * i;
sincos (rad, &z, &x);
glVertex3f (x * mRadius, 0., -z * mRadius);
}
glEnd ();
glColor3f (0.8, 0., 0.2);
glBegin (GL_TRIANGLES);
glVertex3f (mRadius, 0., 0.);
glVertex3f (0., 0., -mRadius * 0.3);
glVertex3f (0., 0., mRadius * 0.3);
glEnd ();
glEnable (GL_DEPTH_TEST);
return;
}
}
}