• Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

We're also offering banner ads on our site from just \$5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.

### #Actual3TATUK2

Posted 27 September 2013 - 08:19 PM

well I am only doing what tatuk was suggesting

Not exactly. I meant something like this:

void DrawShip(float x, float y, float z, float rotation) { // rotation in degrees
glPushMatrix();

float radr = 0.017453292519943295 * rotatation; // convert rotation from degrees to radians

float temp = x;
x = x * cosf( radr ) - y * sinf( radr );
y = temp * sinf( radr ) + y * cosf( radr );

// First translate to the wanted position
glTranslatef(x, y, z);

// Then render the shape of the object, you have already translated and rotated it to the right place
glBegin(GL_LINE_LOOP);
glVertex3f(0.0f,-0.25f,0.0f);
glVertex3f(-0.25f,-0.5f,0.0f);
glVertex3f(-0.5f,-0.5f,0.0f);
glVertex3f(-0.0f,0.5f,0.0f);
glVertex3f(0.5f,-0.5f,0.0f);
glVertex3f(0.25f,-0.5f,0.0f);
glVertex3f(0.0f,-0.25f,0.0f);
glEnd();
glPopMatrix();


### #13TATUK2

Posted 27 September 2013 - 08:18 PM

well I am only doing what tatuk was suggesting

Not exactly. I meant something like this:

void DrawShip(float x, float y, float z, float rotation) {
glPushMatrix();

float radr = 0.017453292519943295 * rotatation;

float temp = x;
x = x * cosf( radr ) - y * sinf( radr );
y = temp * sinf( radr ) + y * cosf( radr );

// First translate to the wanted position
glTranslatef(x, y, z);

// Then rotate it
glRotatef(rotation, 0.0f, 0.0f, 1.0f);

// Then render the shape of the object, you have already translated and rotated it to the right place
glBegin(GL_LINE_LOOP);
glVertex3f(0.0f,-0.25f,0.0f);
glVertex3f(-0.25f,-0.5f,0.0f);
glVertex3f(-0.5f,-0.5f,0.0f);
glVertex3f(-0.0f,0.5f,0.0f);
glVertex3f(0.5f,-0.5f,0.0f);
glVertex3f(0.25f,-0.5f,0.0f);
glVertex3f(0.0f,-0.25f,0.0f);
glEnd();
glPopMatrix();


PARTNERS