CG programming for non-programmers, lesson 14

In lesson 14 we start to use one of tne of the most powerful constructs in programming. The if statement operates pretty much the way the word “if” works in English: “If this thing is true, then do that thing.”

In this case, we will make the red disk appear to be in front of the green disk. We do this by checking to see whether we are inside the red disk. If we are, then we won’t show the green disk.

Look for the following lines near the end of the program:

 
  if (c1 == 1.0)  // IF INSIDE THE RED DISK,
      c2 = 0.0;   // DON'T SHOW THE GREEN DISK.
 

These lines have the effect of making it look as though the red disk is blocking the green disk from our view. In other words, it looks as though the red disk is in front of the green disk.

You can see this lesson by CLICKING HERE.

Leave a Reply

Your email address will not be published. Required fields are marked *