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

This topic is 4252 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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]

##### Share on other sites
Hi Pracka,

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.

##### Share on other sites
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 ?

##### Share on other sites
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.

##### Share on other sites
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.

1. 1
Rutin
22
2. 2
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633308
• Total Posts
3011293
• ### Who's Online (See full list)

There are no registered users currently online

×