Troy Lopez

Projects from Introduction to Graphics

Updated throughout the term!


Here is a collection of my work from cs450 introduction to graphics. I figured I'd upload examples here for fun, this isn't anything groundbreaking.

Project 1 - "Draw something cool in 3d

The background stars were made with 5000 spheres randomly distributed on the face of a 20-unit sphere. This was done with the code below, using a modified version of the pythagorean theorem to garuntee a minimum distance from the origin. Then, extra distance was added to space stars out more randomly to create realistic-looking size differences.The UFO was created with an OSUSphere for the dome, and a series of `GL_TRIANGLE_FAN` circles with offset center points to form basic cones for the body and tractor beam.


    // stars!
    for (int i = 0; i < 5000; i++) {
        float r = Ranf(0.7, 1.0);
        float g = Ranf(0.7, 1.0);
        float b = Ranf(0.7, 1.0);

        glColor3f(r, g, b);

        float x = Ranf(-1.f, 1.f);
        float y = Ranf(-1.f, 1.f);
        float z = Ranf(-1.f, 1.f);

        float norm = std::sqrt(x * x + y * y + z * z);
        x = STARRADIUS * x / norm;
        y = STARRADIUS * y / norm;
        z = STARRADIUS * z / norm;

        STARRADIUS += 0.05;
        
        glPushMatrix();
        glTranslatef(x, y, z);
        OsuSphere(0.1, 10, 10);
        glPopMatrix();
    }
    

10/06/2025