My ball is rotating badly a it has bad shape why?

Started by
3 comments, last by Pracka 17 years ago
Hi please look at this video.(0.3mb avi) you can see my simple ball which Iam using as the main hero in my game. I've 2 problems: 1.After i add normal vectors my ball has changed its shape(it was nicely rounded) and I dont know why. 2.Look how its rotating, not realistic. I'am doing by simple glrotatef for example:

if(isRightArrowDown) // when player push right arrow, player is going right
{
    angle+= 0.5f
}



Render method:

some code
.
.
.
glRotatef(angle,0,0,1);



[Edited by - Pracka on March 25, 2007 8:47:20 AM]
Advertisement
Hi Pracka,

I followed your previous thread about your lighting problem too.

Can you post the code you used to modify the normals, to see how that has effected the ball.

I recall from the previous thread it was a round ball yes.

So show us whats changed, I doubt it has anything to do with rotation.
----------------------------------------Now just hit that link that says 'Rate This User' [wink]
The normals was added directly on models by graphics editor.
Btw that rotation is different problem you see how non -realistic is that ball bowling ?
The problem with the incorrect rotations is a result from the order of rotations performed.
From the fragment of code for rendering, I assume that you have 3 calls to glRotatef, each for a different axis resulting in a rotation matrix of Rz*Ry*Rx.

However, since matrices isn't commutative, when you just increase the rotation in a certain direction you will gain a rotational matrix in the form Rz'*Rz*Ry'*Ry*Rx'*Rx which is not the same as applying a new rotation to the existing one. I.e (Rz'*Ry'*Rx')*(Rz*Ry*Rx)

To solve the problem you can either choose to store the rotation as a matrix, or perform the matrix rotations and extract the axis rotations from it.
Trully my render code looks like :
public void render(){GL11.glPushMatrix();GL11.glTranslatef(positionX,positionY,0.0f);GL11.glScalef(0.0055f, 0.0055f, 0.0055f);GL11.glRotatef(xRot, 0, 0, 1);GL11.glRotatef(yRot, 1, 0, 0);textura.bind();model.render();GL11.glPopMatrix();}


Depends on what key player pushes a xRot or yRot are increased.

This topic is closed to new replies.

Advertisement