[csu540-f05-rpf] Some notes on my approach to SP1 w. suggestions
for you
Robert Futrelle
futrelle at ccs.neu.edu
Thu Oct 27 18:17:48 EDT 2005
Overall design notes for ray tracing triangulated models.
R P Futrelle, Oct 26, 2005
This version is matched to the requirements of SP1.
It may not be in full accordance with what I then wrote
and described in class on 10/27, but the general ideas
match OK.
I wrote some of this code 10/26 and went over most of
it in class, 10/27, esp. the constructor in class OneCone that
actually created an entire cone, in 20 lines of Java,
and that includes the methods createFirstTriangle() and
replicateTriangles().
General advice: Create lots of methods that will do your
work for you. Please try to use Color, as I described
in class - for distant source, reflectivity, and ambient source.
Create a driver program that, in order, does
Show intro screen
Build model(s)
Compute shading.
Ray trace(s)
Sets up display screens which then render
The Intro is just to tell the user that model and image building
through tracing is going on. Dispensable.
Model building creates one or more models to shade.
Shading for SP1 is uniform for each triangle.
The ray tracer(s) builds color arrays, orthographic is just fine.
Display screens portion would call on ray trace results
and could also do wire frames.
------ Breaking this down further ------
Intro screen can be closed when display screens start up.
Model building:
Build model in standard position from triangles.
Transform model.
Compute normals.
Shade the model using one or more light sources plus ambient.
Color of triangles and color of light sources could be used.
Ray trace each model, building color arrays from them.
This requires, for each ray, iterating across all triangles,
computing t values for every triangle hit and selecting the one
with the smallest t value. The shaded color of the selected
triangle is written to the color array.
Writing the color arrays to the screen(s) is straightforward.
Wire frame option
For a given screen, possibly already filled from the
ray trace array, use Java 2D line drawing commands to
draw the edges of *all* triangles, whether closest or not.
This could allow an initial display of the model without
doing any ray tracing, without even setting it up.
------ Development strategy ------
Empty methods, stubs, could be written along with their javadoc,
to document the overall design.
Writing tests into virtually every class is useful, even
in the early stages. The fact that the system is display
based is no inhibitor of testing, since the model building
and tracing or algorithmic in nature. There is no need to
test user interaction handling; that can be more difficult.
My package suggestions:
SPOne for the driver and Intro
Model for the model itself
Geometry for vecs, matrices, triangles
RayTrace for ray tracing
WireFrame for wire frame.
Display for the display screens.
Could do all this in Eclipse and Java 5, I did.
Packages I chose, so far:
wireframe
spOne
raytrace
model
geometry
display
More information about the csu540-f05-rpf
mailing list