• Create Account

Banner advertising on our site currently available from just \$5!

### #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