| Poster ||: Nimbyjester|
| Posts||: 3|
| Country ||: England|
| City||: Manchester|
|Posted by Nimbyjester on 03/10/2006 at 10:19:48|
|Have been playing around with the code in these tutorials (which has been extremely useful to me by the way) and came across a problem where half of my model seemed to be lit on the wrong side.|
The model in question was rotating around the X and Z-axis infinitely, by adding a small angle to the rotation each time. This I have found to be the cause of all my woes, as the angle quickly exceeds 360 degrees and messes up the objects normals, since this is used to generate them.
The following bit of code is what fixed it for me.
public float bind_to_360(float angle)
while ((angle > (2 * Math.PI)) || (angle < 0))
if (angle > (2 * Math.PI))
angle -= (float)(2 * Math.PI);
angle += (float)(2 * Math.PI);
The angle in question is in radians; I just feel happier saying 360 than 2pi.
Hope this helps anyone having a similar problem.