6.837 - Project #4

A Complete Rendering Pipeline



Ground Rules for all projects:
In this project you will implement a complete graphics pipeline. Hopefully you will be able to reuse elements from previous programming projects. The following diagram outlines the additional work required:


Requirements:

Optional:
You can use the following object files and parser to debug your code. You now have at least a version of every file that I have written.
If you would like to compute vertex normals in order to try out the more complex illumination models. Before you try this, I advise you to get the basic requirements of your pipeline working first. Here is a small code fragment from another version of the parser which should help get you started.

                // This code fragment replaces corresponding code
                // in the ReadInput method of the Pipeline applet
                if (st.sval.equals("f")) {
                    int faceTris = 0;
                    int v0 = (int) getNumber(st);
                    int v1 = (int) getNumber(st);
                    while (st.nextToken() == StreamTokenizer.TT_NUMBER) {
                        st.pushBack();
                        int v2 = (int) getNumber(st);
                        if (v2 == v0) continue;
                        if (triangles == triList.length) growList();
                        triList[triangles] = new Triangle(v0, v1, v2);
                        float nx = (vertList[v1].z - vertList[v0].z) * (vertList[v2].y - vertList[v1].y)
                                 - (vertList[v1].y - vertList[v0].y) * (vertList[v2].z - vertList[v1].z);
                        float ny = (vertList[v1].x - vertList[v0].x) * (vertList[v2].z - vertList[v1].z)
                                 - (vertList[v1].z - vertList[v0].z) * (vertList[v2].x - vertList[v1].x);
                        float nz = (vertList[v1].y - vertList[v0].y) * (vertList[v2].x - vertList[v1].x)
                                 - (vertList[v1].x - vertList[v0].x) * (vertList[v2].y - vertList[v1].y);
                        if (faceTris == 0) {
                            // the normal could be computed here instead if all
                            // facets are planar... I'll just play it safe
                            vertList[v0].addNormal(nx, ny, nz);
                            vertList[v1].addNormal(nx, ny, nz);
                        }
                        if (surfaces == 0) {
                            surfaceList[surfaces] = new Surface(0.5f, 0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 5.0f);
                            surfaces += 1;
                        }
                        triList[triangles].setSurface(surfaceList[surfaces-1]);
                        vertList[v2].addNormal(nx, ny, nz);
                        v1 = v2;
                        faceTris += 1;
                        triangles += 1;
                    }
                    st.pushBack();
                } else

        // This code fragment appears in the
        // init method of the Pipeline applet
        for (int i = 0; i < vertices; i++) {
            vertList[i].averageNormals();
        }
You will need to make some modifications to the Vertex3D object you were given, but you should be able to figure those out for yourself.

Warning: This is by far the most time consuming project this semester.