3D Volleyball Animation by Tanja Sotto

            My project idea...

            Zion and I are thinking of making an animation of a volleyball 
            rolling across wooden floor and a net in the back.

            Depending on what we learn in class, our result is subject to change.
            

            We would like to use lighting, texture mapping, and OpenGL.

            10/10 Update:
            We are going to expand on this idea and put players on a court. 
             
             

            10/15:
            Progress: practicing with OpenGL and making a volleyball court.
            

            10/27:
            Thanks to Gordon, we got some helpful hints for our project. We have a couple of problems.
            1. The court lines are crooked and not aligned with the court texture. He suggested to do the lines on the texture itself + do quads for the court.
            2. The net is made of lines and looks very thin. He suggested to do a grid of quads with a texture that has an alpha channel so that the net looks more realistic. Additionally, he suggested to add physics so our net isn't rigid.
            3. The volleyball is made with glutSolidSphere, which does not allow texture mapping. He suggested to look at the bball framework. We should NOT use glUseSphere.
            4. The texture should be from our own photograph, not a stock image.
            
            The picture above showcases problem 2.

            11/3:
            Trying to figure out how to incorporate alpha channels in OpenGL for the net. My net texture already has an alpha channel and is a PNG, but I'm not sure how to prevent the background from being black.
        
            11/4:
            Fixed the issue where the court texture would load properly; upon pressing 2 then going back to the court by key press 1, it would turn black. I modified the init_texture function using the flag framework code.
            I also tried to implement the alpha channel for the net texture. Instead of using a transparent layer, I'm going to try to have green as shown below.
            

            I got the transparency to work using the rainforest lab code. I made it so that if green was the dominant color, it would be transparent. Then if there was black, make it opaque.
            unsigned char *buildAlphaData(Image *img)
            {
                int i;
                int a,b,c;
                unsigned char *newdata, *ptr;
                unsigned char *data = (unsigned char *)img->data;
                newdata = (unsigned char *)malloc(img->width * img->height * 4);
                ptr = newdata;
                for (i=0; iwidth * img->height * 3; i+=3) { 
                    a = *(data+0);
                    b = *(data+1);
                    c = *(data+2);
                    *(ptr+0) = a;
                    *(ptr+1) = b;
                    *(ptr+2) = c;

                    
                    if (b > 100 && b > a && b > c) {
                        *(ptr+3) = 0;
                    } else {
                        *(ptr+3) = 255;
                    }
                    //-----------------------------------------------
                    ptr += 4;
                    data += 3;
                }
                return newdata;
            }
            

            11/24:
            Worked on trying to figure out the physics of the net for a while. We bumped into a bunch of problems, like the net glitching.
            We also finally added our own court texture, and I made fixes to it so that it would fit into 4 quads. I put lines on the textures themselves.
            

            These are the textures I made using the SRC court and GIMP:
             
             

            11/26:
            I got the texture to be on each cell of the net grid so that when we zoom in, it isn't thin (like how we had it before with GL lines)
            

            12/1:
            Ultimately, this is what I was able to do for our project:
            - Made a volleyball court with our own texture
            - Made a net with a texture that has an alpha channel
            - Incorporate labs and framework code for things such as texture mapping, springs, forces, and rendering