#### Archived

This topic is now archived and is closed to further replies.

# Need some help understanding Lesson 9

## Recommended Posts

Hi, I''m having some trouble getting to grips and understanding some code in lesson 9. I assume this is what you call billboarding for particles. in his DrawGLScene function. he does the following:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer

glBindTexture(GL_TEXTURE_2D, texture[0]);		// Select Our Texture

for (loop=0; loop<num; loop++)				// Loop Through All The Stars

{
glLoadIdentity();				// Reset The View Before We Draw Each Star

glTranslatef(0.0f,0.0f,zoom);			// Zoom Into The Screen (Using The Value In ''zoom'')

glRotatef(tilt,1.0f,0.0f,0.0f);			// Tilt The View (Using The Value In ''tilt'')

glRotatef(star[loop].angle,0.0f,1.0f,0.0f);	// Rotate To The Current Stars Angle

glTranslatef(star[loop].dist,0.0f,0.0f);	// Move Forward On The X Plane

glRotatef(-star[loop].angle,0.0f,1.0f,0.0f);	// Cancel The Current Stars Angle

glRotatef(-tilt,1.0f,0.0f,0.0f);		// Cancel The Screen Tilt


Wouldn''t cancelling out the tilt and rotation effectively produce a null effect and rotating the screen would be useless? If someone could explain this to me in different terms please, I would appreciate it.

##### Share on other sites
Hello,

You have to remember that those rotation commands are going to affect the translate command. If there were no rotate calls first then making a translation would put the star wherever the translate command specified, but with rotation calls first(assuming the angle rotated isn''t 0) the star will be translated in the direction that is the combined result of the rotations and translation. After the star has been translated, the "unrotation" commands will just make sure that the star is now facing the proper orientation towards the viewer.

• ### Forum Statistics

• Total Topics
628320
• Total Posts
2982072

• 21
• 9
• 9
• 13
• 11