Jump to content
  • Advertisement
Sign in to follow this  
Pracka

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

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!