CS465 Program 4: Modeller
Usage Information
- Camera Motion: If the perspective camera is selected, alt-dragging in an orthographic
view will move the camera's look-at point.
- Camera Motion: If the perspective camera is selected, dragging in an orthographic view
will move the camera's eye point.
- General Editing: If a light is selected, dragging in an orthographic view will move the
light.
- General Editing: Double clicking on any primitive in the hierarchy will track and dolly
the perspective view so that the look at point centers on the object.
- General Editing: Double clicking on any view will maximize that view. Double clicking
again will return it to its regular size.
- General Editing: There is an OpenGL enforced 8 light limit.
- File IO: You can save and load scenes for easier testing. The writte file is in ASCII
format. Be careful if you hand edit it, as the resulting scene might not be readable by
the program afterwards (ie - if you break some assumptions about how many lights exist,
where the perspective camera is in the hierarchy, etc.).
- Spline Editing: In the spline editor, ctrl-dragging will track the view.
- Spline Editing: In the spline editor, alt-dragging will zoom the view.
- Spline Editing: In the spline editor, pressing spacebar will cycle through different
debug views. These will do things like display the normals, etc.
- Spline Editing: Right clicking on the control points between two segments will disconnect
the tangents at those two segments. Right clicking again will reconnect the tangents.
- Spline Editing: Shift-clicking on the polygon will add new points.
- Spline Editing: Shift-clicking on the control points between two segments will join those
two segments together, effectively deleting a BezierSegment.
FAQ
- 12:30 pm, 15 November 2004: I'm observing some strange
behavior with my rotation transformations. They are doing things like blowing
up primitives when the length of the axis is greater than 1, or completely
removing them in some cases.
A: The
Matrix4f#setRotation(AxisAngle4f)
method is the one used to set the
underlying Matrix4f object inside of the Transformation
.
This is incorrect, the framework code should have been using the
Matrix4f#set(AxisAngle4f)
method. As an acceptable workaround, try
using GL#glRotate(float angle, float x, float y, float z)
in the
Transformation#apply(GL)
method. The posted code does not have this
problem anymore.
- 12:30 pm, 15 November 2004: I think there is still a bug
with the general transformation reading. It seems to be reading the transpose of
the matrix I wrote out.
A: Yes, the new code I just posted
fixed that, although you could change line 187 of TreeSerializer.java from
transform.getMatrix().setElement(xCtr, yCtr, readFloat(br));
to
transform.getMatrix().setElement(yCtr, xCtr, readFloat(br));
.
- 10:15 pm, 13 November 2004: What am I supposed to do
when collapsing transformations: combine them with the children or
introduce new nodes?
A: When you push a transformation down, you should combine
it with any child transformations (resulting in a general transformation)
and create a new transformation above any child Shapes. For example, the
hierarchy
upon collapsing the rotation would become
- 10:00 pm, 13 November 2004: What should I do about
that human figure model that's mentioned only in the first section of the
handout?
A: Oops! We meant to leave that out of the assignment;
it will be part of a future homework instead.
- 10:00 pm, 13 November 2004: I'm confused about what
exactly is supposed to happen when the user edits a nonuniform scale. The
handout is kind of vague, and the comment in the code is confusing
too.
A: A nonuniform scale has a scale factor along
each of the three axes of the coordinate system in which it is applied.
We need to take a mouse motion vector and convert it into these three
scale factors. The rule you should use: a mouse motion should scale along
the axis that is closest to the same 3D direction as the mouse motion,
interpreting the mouse motion as a vector on the image plane. That is, if
we consider the three scaling axes in world space, the scale should happen
only along one axis, and that axis should be the one that has the smallest
angle to the mouse motion vector. Consider this FAQ entry to supersede
those other two sources.
- 7:30 pm, 13 November 2004: There seems to be a problem with the framework
code in regards to reading in General Transformations.
A: There sure is. Its
been fixed in the newest version of the code. Whatever saved files you had created will still
work fine.
- 12:30 pm, 12 November 2004: I'm confused in general - the framework code
is enormous.
A: We have added javadoc comments above all of the methods that
you need to be filling in. This should provide a quick "sound and completeness" check.
- 12:30 pm, 12 November 2004: The handout says that the framework code
should have fully working orthographic camera views, but they seem to be unimplemented
A: In order to leave in some of the thinking necessary to move the
PerspectiveCamera
, we had to pull out some of the code for OrthoCamera
and leave it broken. To fix this, write the method Camera#convertMotion(Vector2f, Vector3f)
- 12:30 pm, 12 November 2004: How should I write the
Camera#converMotion(
Vector2f, Vector3f)
method in order to make it work like it should for the
OrthoCamera
?
A: You should interpret a mouse motion of [x, y] as
being magnitudes of motion in the direction of the up and right vector. Both x and y range from
[-2, 2], where -2 indicates moving all the way from the top of the canvas to the bottom, or from
right to left. Positive motion indicates moving from the bottom/left to the top/right. As a result,
you should probably take into account the height and aspect ratio of the camera.
- 12:30 pm, 12 November 2004: How many triangle strips should we use in our sphere?
How many triangles per triangle strip? Do we have to cache the points?
A: Variable,
variable, and no. You should make it easy to change the number of divisions in either direction for
the sphere, as well as the cylinder, by altering the code. A single class variable at the top will
suffice. Caching the points is not required by any means, re-evaluating the points each time is
plenty fast.
- 12:30 pm, 12 November 2004: I can't get the vertical mouse motion to quite work
out just right. The objects almost follow the mouse, but not quite.
A: This is a
bug in the solution code. The newest code has the fix, or you can just change lines 416 and 417 of
GLView.java from "int w = getWidth(); int h = getHeight();" to "int w =
canvas.getWidth(); int h = canvas.getHeight();".
OpenGL Information
OpenGL is a big industry standard used to abstract away the use of graphics hardware
for the programmer. Because it crosses such a large abstraction range (from machine
instructions up to high level languages like Java and C++), OpenGL code in those
languages never quite fits into whatever the dominant paradigm is. OpenGL does
do a very nice job of rendering in harware though. Regardless, OpenGL is different than
much that you are likely to have seen before. We have posted some links that should help
get you started in your OpenGL coding.
If you find a site particularly helpful, let us know and we'll post it here.
Setup Information
See the pipeline project for setup information. The same rules apply as we'll be
using the JOGL implementation of OpenGL again.
Cornell CS465 Fall 2004 (cs465-staff-l@cs.cornell.edu)