• Create Account

We're offering banner ads on our site from just \$5!

Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!

### #ActualBrother Bob

Posted 22 July 2013 - 12:13 PM

You don't have both models isolated with the glPushMatrix(); and glPopMatrix calls.  Because of this, your cube transformations are being applied to the fish as well.  If you move the cube back, the fish moves back as well.   I'm not sure why you define the cube's Z-axis to be 297.5 but this is a huge number compared to the other sizes and will draw your cube roughly 300 units towards the screen, this is kind of like setting the cube's position to be in your neighbors house behind you.  Also the fish has no glTranslate call so this also prevents it from moving independent of the cube.  If you want to move them separately, they should look like the following.

//===============================================================================================================================

glPushMatrix(); glTranslatef(0.0f, 0.0f, -300.0f); //Now this call will move only the cube.     glEnable(GL_DEPTH_TEST);   //Rectangle   glBegin(GL_POLYGON);   glColor4f(0.0,  0.0, 1.0, 1.0);   glVertex3f(-0.8, 0.5, 297.5 );   glVertex3f(0.9, 0.5, 297.5 );   glVertex3f(0.9, -0.2, 297.5 );   glVertex3f(-0.8, -0.2, 297.5 ); glEnd();

glPopMatrix();  This isolates the cube transforms from the fish

//====================================================================================================================

//Fish  glPushMatrix(); glTranslatef(0.0f, 0.0f, moveFish_Z); This call will allow you to move the fish   glRotatef(-300.0, 0.0f, 1.0, 0.166); //_Because the X,Y,Z axis values are proportional to one another, what I've entered here is equivalent. I divided 50/300 to get this.    glScalef(0.3, 0.3, 0.3); glColor3f(1.0f, 0.0f, 0.0f);

glEnable(GL_TEXTURE_2D);   glBindTexture (GL_TEXTURE_2D,texId1);   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);             glCallList(displayList1);     glDisable(GL_TEXTURE_2D);  glPopMatrix();   // glPopMatrix(); This has been moved up before the fish draw routines and highlighted blue

//===============================================================================================================================

Also, the values entered as following will cause you problems-> glRotatef(-300.0, 0.0f, 300.0f, 50.0f);  The values that I've highlighted with red should be within the 0.0 to 1.0 range, at least until you fully understand them.  Making one of these values much bigger has the same effect as making the other ones much smaller.  They are weighted values that control which axis the rotation takes place about, they are proportional to one another.  It might help to think of them as having behavior similar to booleans even though they are floats.  For example.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

In this first example: glRotatef(-300.0, 1.0, 0.0, 0.0); , The angle is 300 degrees.  The X_AXIS is 1.0 so it is 'ON'.  But there is a catch here, this rotate function is not perfect. And these values are weighted against one another.  The X_Axis would still be 'ON' even if the X value were only 0.001, so long as the others are 0.0.

The following would be equivalent: glRotatef(-300.0, 0.0001, 0.0, 0.0);  You will still have a rotation of -300 degrees about the X_Axis, but only until you change the values of Y and Z.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

In this second example: glRotatef(-300.0, 1.0, 0.5, 0.0);

Here you would expect that the rotation should be

X_Axis: 300 degrees.  //Since the X_Axis is at 1.0, we'd expect this to be 100% rotation about the X_axis

Y_Axis 150 degrees. //Since the Y_Axis is at 0.5, we'd expect this to be 50% rotation about the Y_axis

Unfortunately it does not work like this.  This is why I say that these values are 'weighted'.  Increasing one of them, decreases the power of the others.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Setting these values much higher than 1.0 should be avoided until you fully grasp what's taking place here.  You will introduce 'bugs', you won't damage anything but you will now get odd behavior from the other axis values.

For example, if you set the rotate function as follows glRotatef(-300.0, 10000.0, 10.0, 0.0);  All of the rotation will be around the X_Value, The Y_Axis value will have absolutely no visual effect, it may as well be zero since the X_Value is so high. It would be equivalent to having glRotatef(-300.0, 1.0, 0.001, 0.0);

Now if you try to add rotation about another axis, you will have to increase the other axis values to a super large number as well to see any effect.  This is why I said to keep them around 0.0 to 1.0.

### #10marcClintDion

Posted 22 July 2013 - 03:11 AM

There is far too much arrogance and out right abuse by site moderators, they are teaching other people to behave this way.  The posts I've made will all be shorty removed and replaced with this notice.  Game development is not the only thing being taught here, bad behavior is being taught as well.

### #9marcClintDion

Posted 29 June 2013 - 02:46 AM

You don't have both models isolated with the glPushMatrix(); and glPopMatrix calls.  Because of this, your cube transformations are being applied to the fish as well.  If you move the cube back, the fish moves back as well.   I'm not sure why you define the cube's Z-axis to be 297.5 but this is a huge number compared to the other sizes and will draw your cube roughly 300 units towards the screen, this is kind of like setting the cube's position to be in your neighbors house behind you.  Also the fish has no glTranslate call so this also prevents it from moving independent of the cube.  If you want to move them separately, they should look like the following.

//===============================================================================================================================

glPushMatrix();
glTranslatef(0.0f, 0.0f, -300.0f); //Now this call will move only the cube.
glEnable(GL_DEPTH_TEST);

//Rectangle
glBegin(GL_POLYGON);
glColor4f(0.0,  0.0, 1.0, 1.0);
glVertex3f(-0.8, 0.5, 297.5 );
glVertex3f(0.9, 0.5, 297.5 );
glVertex3f(0.9, -0.2, 297.5 );
glVertex3f(-0.8, -0.2, 297.5 );
glEnd();

glPopMatrix();  This isolates the cube transforms from the fish

//====================================================================================================================

//Fish
glPushMatrix();
glTranslatef(0.0f, 0.0f, moveFish_Z); This call will allow you to move the fish
glRotatef(-300.0, 0.0f, 1.0, 0.166); //_Because the X,Y,Z axis values are proportional to one another, what I've entered here is equivalent. I divided 50/300 to get this.
glScalef(0.3, 0.3, 0.3);
glColor3f(1.0f, 0.0f, 0.0f);

glEnable(GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D,texId1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glCallList(displayList1);
glDisable(GL_TEXTURE_2D);
glPopMatrix();

// glPopMatrix(); This has been moved up before the fish draw routines and highlighted blue

//===============================================================================================================================

Also, the values entered as following will cause you problems-> glRotatef(-300.0, 0.0f, 300.0f, 50.0f);  The values that I've highlighted with red should be within the 0.0 to 1.0 range, at least until you fully understand them.  Making one of these values much bigger has the same effect as making the other ones much smaller.  They are weighted values that control which axis the rotation takes place about, they are proportional to one another.  It might help to think of them as having behavior similar to booleans even though they are floats.  For example.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

In this first example: glRotatef(-300.0, 1.0, 0.0, 0.0); , The angle is 300 degrees.  The X_AXIS is 1.0 so it is 'ON'.  But there is a catch here, this rotate function is not perfect. And these values are weighted against one another.  The X_Axis would still be 'ON' even if the X value were only 0.001, so long as the others are 0.0.

The following would be equivalent: glRotatef(-300.0, 0.0001, 0.0, 0.0);  You will still have a rotation of -300 degrees about the X_Axis, but only until you change the values of Y and Z.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

In this second example: glRotatef(-300.0, 1.0, 0.5, 0.0);

Here you would expect that the rotation should be

X_Axis: 300 degrees.  //Since the X_Axis is at 1.0, we'd expect this to be 100% rotation about the X_axis

Y_Axis 150 degrees.   //Since the Y_Axis is at 0.5, we'd expect this to be 50%   rotation about the Y_axis

Unfortunately it does not work like this.  This is why I say that these values are 'weighted'.  Increasing one of them, decreases the power of the others.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Setting these values much higher than 1.0 should be avoided until you fully grasp what's taking place here.  You will introduce 'bugs', you won't damage anything but you will now get odd behavior from the other axis values.

For example, if you set the rotate function as follows glRotatef(-300.0, 10000.0, 10.0, 0.0);  All of the rotation will be around the X_Value, The Y_Axis value will have absolutely no visual effect, it may as well be zero since the X_Value is so high. It would be equivalent to having glRotatef(-300.0, 1.0, 0.001, 0.0);

Now if you try to add rotation about another axis, you will have to increase the other axis values to a super large number as well to see any effect.  This is why I said to keep them around 0.0 to 1.0.

### #8marcClintDion

Posted 29 June 2013 - 02:46 AM

You don't have both models isolated with the glPushMatrix(); and glPopMatrix calls.  Because of this, your cube transformations are being applied to the fish as well.  If you move the cube back, the fish moves back as well.   I'm not sure why you define the cube's Z-axis to be 297.5 but this is a huge number compared to the other sizes and will draw your cube roughly 300 units towards the screen, this is kind of like setting the cube's position to be in your neighbors house behind you.  Also the fish has no glTranslate call so this also prevents it from moving independent of the cube.  If you want to move them separately, they should look like the following.

//===============================================================================================================================

glPushMatrix();
glTranslatef(0.0f, 0.0f, -300.0f); //Now this call will move only the cube.
glEnable(GL_DEPTH_TEST);

//Rectangle
glBegin(GL_POLYGON);
glColor4f(0.0,  0.0, 1.0, 1.0);
glVertex3f(-0.8, 0.5, 297.5 );
glVertex3f(0.9, 0.5, 297.5 );
glVertex3f(0.9, -0.2, 297.5 );
glVertex3f(-0.8, -0.2, 297.5 );
glEnd();

glPopMatrix();  This isolates the cube transforms from the fish

//====================================================================================================================

//Fish
glPushMatrix();
glTranslatef(0.0f, 0.0f, moveFish_Z); This call will allow you to move the fish
glRotatef(-300.0, 0.0f, 1.0, 0.166); //_Because the X,Y,Z axis values are proportional to one another, what I've entered here is equivalent. I divided 50/300 to get this.
glScalef(0.3, 0.3, 0.3);
glColor3f(1.0f, 0.0f, 0.0f);

glEnable(GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D,texId1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glCallList(displayList1);
glDisable(GL_TEXTURE_2D);
glPopMatrix();

// glPopMatrix(); This has been moved up before the fish draw routines and highlighted blue

//===============================================================================================================================

Also, the values entered as following will cause you problems-> glRotatef(-300.0, 0.0f, 300.0f, 50.0f);  The values that I've highlighted with red should be within the 0.0 to 1.0 range, at least until you fully understand them.  Making one of these values much bigger has the same effect as making the other ones much smaller.  They are weighted values that control which axis the rotation takes place about, they are proportional to one another.  It might help to think of them as having behavior similar to booleans even though they are floats.  For example.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

In this first example: glRotatef(-300.0, 1.0, 0.0, 0.0); , The angle is 300 degrees.  The X_AXIS is 1.0 so it is 'ON'.  But there is a catch here, this rotate function is not perfect. And these values are weighted against one another.  The X_Axis would still be 'ON' even if the X value were only 0.001, so long as the others are 0.0.

The following would be equivalent: glRotatef(-300.0, 0.0001, 0.0, 0.0);  You will still have a rotation of -300 degrees about the X_Axis, but only until you change the values of Y and Z.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

In this second example: glRotatef(-300.0, 1.0, 0.5, 0.0);

Here you would expect that the rotation should be

X_Axis: 300 degrees.  //Since the X_Axis is at 1.0, we'd expect this to be 100% rotation about the X_axis

Y_Axis 150 degrees.   //Since the Y_Axis is at 0.5, we'd expect this to be 50%   rotation about the Y_axis

Unfortunately it does not work like this.  This is why I say that these values are 'weighted'.  Increasing one of them, decreases the power of the others.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Setting these values much higher than 1.0 should be avoided until you fully grasp what's taking place here.  You will introduce 'bugs', you won't damage anything but you will now get odd behavior from the other axis values.

For example, if you set the rotate function as follows glRotatef(-300.0, 10000.0, 10.0, 1.0);  All of the rotation will be around the X_Value, The Y_Axis value will have absolutely no visual effect, it may as well be zero since the X_Value is so high. It would be equivalent to having glRotatef(-300.0, 1.0, 0.001, 1.0);

Now if you try to add rotation about another axis, you will have to increase the other axis values to a super large number as well to see any effect.  This is why I said to keep them around 0.0 to 1.0.

### #7marcClintDion

Posted 28 June 2013 - 12:26 PM

You don't have both models isolated with the glPushMatrix(); and glPopMatrix calls.  Because of this, your cube transformations are being applied to the fish as well.  If you move the cube back, the fish moves back as well.   I'm not sure why you define the cube's Z-axis to be 297.5 but this is a huge number compared to the other sizes and will draw your cube roughly 300 units towards the screen, this is kind of like setting the cube's position to be in your neighbors house behind you.  Also the fish has no glTranslate call so this also prevents it from moving independent of the cube.  If you want to move them separately, they should look like the following.

//===============================================================================================================================

glPushMatrix();
glTranslatef(0.0f, 0.0f, -300.0f); //Now this call will move only the cube.
glEnable(GL_DEPTH_TEST);

//Rectangle
glBegin(GL_POLYGON);
glColor4f(0.0,  0.0, 1.0, 1.0);
glVertex3f(-0.8, 0.5, 297.5 );
glVertex3f(0.9, 0.5, 297.5 );
glVertex3f(0.9, -0.2, 297.5 );
glVertex3f(-0.8, -0.2, 297.5 );
glEnd();

glPopMatrix();  This isolates the cube transforms from the fish

//====================================================================================================================

//Fish
glPushMatrix();
glTranslatef(0.0f, 0.0f, moveFish_Z); This call will allow you to move the fish
glRotatef(-300.0, 0.0f, 1.0, 0.166); //_Because the X,Y,Z axis values are proportional to one another, what I've entered here is equivalent. I divided 50/300 to get this.
glScalef(0.3, 0.3, 0.3);
glColor3f(1.0f, 0.0f, 0.0f);

glEnable(GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D,texId1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glCallList(displayList1);
glDisable(GL_TEXTURE_2D);
glPopMatrix();

// glPopMatrix(); This has been moved up before the fish draw routines and highlighted blue

//===============================================================================================================================

Also, the values entered as following will cause you problems-> glRotatef(-300.0, 0.0f, 300.0f, 50.0f);  The values that I've highlighted with red should be within the 0.0 to 1.0 range, at least until you fully understand them.  Making one of these values much bigger has the same effect as making the other ones much smaller.  They are weighted values that control which axis the rotation takes place about, they are proportional to one another.  It might help to think of them as having behavior similar to booleans even though they are floats.  For example.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

In this first example: glRotatef(-300.0, 1.0, 0.0, 0.0); , The angle is 300 degrees.  The X_AXIS is 1.0 so it is 'ON'.  But there is a catch here, this rotate function is not perfect. And these values are weighted against one another.  The X_Axis would still be 'ON' even if the X value were only 0.001, so long as the others are 0.0.

The following would be equivalent: glRotatef(-300.0, 0.0001, 0.0, 0.0);  You will still have a rotation of -300 degrees about the X_Axis, but only until you change the values of Y and Z.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

In this second example: glRotatef(-300.0, 1.0, 0.5, 0.0);

Here you would expect that the rotation should be

X_Axis: 300 degrees.  //Since the X_Axis is at 1.0, we'd expect this to be 100% rotation about the X_axis

Y_Axis 150 degrees.   //Since the Y_Axis is at 0.5, we'd expect this to be 50%   rotation about the Y_axis

Unfortunately it does not work like this.  This is why I say that these values are 'weighted'.  Increasing one of them, decreases the power of the others.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Setting these values much higher than 1.0 should be avoided until you fully grasp what's taking place here.  You will introduce 'bugs', you won't damage anything but you will now get odd behavior from the other axis values.

For example, if you set the rotate function as follows glRotatef(-300.0, 10000.0, 10.0, 1.0);  All of the rotation will be around the X_Value, The Y_Axis value will have absolutely visual effect, it may as well be zero since the X_Value is so high. It would be equivalent to having glRotatef(-300.0, 1.0, 0.001, 1.0);

Now if you try to add rotation about another axis, you will have to increase the other axis values to a super large number as well to see any effect.  This is why I said to keep them around 0.0 to 1.0.

### #6marcClintDion

Posted 28 June 2013 - 12:23 PM

You don't have both models isolated with the glPushMatrix(); and glPopMatrix calls.  Because of this, your cube transformations are being applied to the fish as well.  If you move the cube back, the fish moves back as well.   I'm not sure why you define the cube's Z-axis to be 297.5 but this is a huge number compared to the other sizes and will draw your cube roughly 300 units towards the screen, this is kind of like setting the cube's position to be in your neighbors house behind you.  Also the fish has no glTranslate call so this also prevents it from moving independent of the cube.  If you want to move them separately, they should look like the following.

//===============================================================================================================================

glPushMatrix();
glTranslatef(0.0f, 0.0f, -300.0f); //Now this call will move only the cube.
glEnable(GL_DEPTH_TEST);

//Rectangle
glBegin(GL_POLYGON);
glColor4f(0.0,  0.0, 1.0, 1.0);
glVertex3f(-0.8, 0.5, 297.5 );
glVertex3f(0.9, 0.5, 297.5 );
glVertex3f(0.9, -0.2, 297.5 );
glVertex3f(-0.8, -0.2, 297.5 );
glEnd();

glPopMatrix();  This isolates the cube transforms from the fish

//====================================================================================================================

//Fish
glPushMatrix();
glColor3f(1.0f, 0.0f, 0.0f);

glTranslatef(0.0f, 0.0f, moveFish_Z); This call will allow you to move the fish
glRotatef(-300.0, 0.0f, 1.0, 0.166); //_Because the X,Y,Z axis values are proportional to one another, what I've entered here is equivalent. I divided 50/300 to get this.
glScalef(0.3, 0.3, 0.3);
glEnable(GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D,texId1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glCallList(displayList1);
glDisable(GL_TEXTURE_2D);
glPopMatrix();

// glPopMatrix(); This has been moved up before the fish draw routines and highlighted blue

//===============================================================================================================================

Also, the values entered as following will cause you problems-> glRotatef(-300.0, 0.0f, 300.0f, 50.0f);  The values that I've highlighted with red should be within the 0.0 to 1.0 range, at least until you fully understand them.  Making one of these values much bigger has the same effect as making the other ones much smaller.  They are weighted values that control which axis the rotation takes place about, they are proportional to one another.  It might help to think of them as having behavior similar to booleans even though they are floats.  For example.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

In this first example: glRotatef(-300.0, 1.0, 0.0, 0.0); , The angle is 300 degrees.  The X_AXIS is 1.0 so it is 'ON'.  But there is a catch here, this rotate function is not perfect. And these values are weighted against one another.  The X_Axis would still be 'ON' even if the X value were only 0.001, so long as the others are 0.0.

The following would be equivalent: glRotatef(-300.0, 0.0001, 0.0, 0.0);  You will still have a rotation of -300 degrees about the X_Axis, but only until you change the values of Y and Z.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

In this second example: glRotatef(-300.0, 1.0, 0.5, 0.0);

Here you would expect that the rotation should be

X_Axis: 300 degrees.  //Since the X_Axis is at 1.0, we'd expect this to be 100% rotation about the X_axis

Y_Axis 150 degrees.   //Since the Y_Axis is at 0.5, we'd expect this to be 50%   rotation about the Y_axis

Unfortunately it does not work like this.  This is why I say that these values are 'weighted'.  Increasing one of them, decreases the power of the others.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Setting these values much higher than 1.0 should be avoided until you fully grasp what's taking place here.  You will introduce 'bugs', you won't damage anything but you will now get odd behavior from the other axis values.

For example, if you set the rotate function as follows glRotatef(-300.0, 10000.0, 10.0, 1.0);  All of the rotation will be around the X_Value, The Y_Axis value will have absolutely visual effect, it may as well be zero since the X_Value is so high. It would be equivalent to having glRotatef(-300.0, 1.0, 0.001, 1.0);

Now if you try to add rotation about another axis, you will have to increase the other axis values to a super large number as well to see any effect.  This is why I said to keep them around 0.0 to 1.0.

PARTNERS