| Netbeans makes it possible for you to automatically generate a number of JOGL examples.
In this part of the lab, you are to generate the Simple JOGL Application as follows. In Netbeans, go to the menu
File; New Project. Under "Categories" choose Java. Under "Projects" choose JOGL Application. Click the "Next" button
and continue as usual to create a new project. Run the program and look through the code. Your job is to try to understand what each part of the code is doing.
We will go over it in class as well.
If you have netbeans on your own computer, you can install JOGL by downloading the Netbeans OpenGL Pack. Once you down load it, unzip it. Then, in Netbeans, go to the Tools->Plugins, choose the "Downloaded" tab. Click on the "Add Plugins" button. Browse for the files you just unzipped and select them all. Then in the Plugins tool, check them all and click "Install". Some of them may not work (e.g. GLSL Editor). If so, just skip them. If you are missing the java docs for Jogl, here they are: jogl-1.1.1-docs.zip. For those of you who are not using Netbeans, here is the code that Netbeans generates: SimpleJOGLApp.java. I believe you will need the libraries jogl.jar and glugen-rt.jar. |
| To explore what the code is doing, try experimenting by making small changes. For example:
|
The goal in this part of the lab is to understand 1) the structure of the code 2) how to specify the camera projection, 3) how to move the camera and objects, and 4) how to create objects (geometry and color) using glut or glBegin/glEnd. Note, there are no lights - we will discuss lighting later on. Without lights, solid glut objects will appear flat. It is easier to see the 3d structure if you use wireframe objects rather than solid.
To illustrate your understanding of the above, create a simple scene using multiple built-in objects and/or simple shapes you create by specifying vertices with glBegin/glEnd.
Optional: Speed is critical when it comes to computer graphics. Create a simple scene such as a large plane with lots of teapots either randomly placed around the plane (don't worry about intersections) or placed in a grid arrangement. Have the entire scene rotate around the y axis. How many teapots do you have to include before the rotation starts to slow down? What if the teapots are replaced with rectangles?
Heads-up: Specifying vertices using glBegin/glEnd is called immediate mode. While very convenient and easy to understand, immediate mode is very, very slow and is being deprecated (along with lots of other useful things) in the later versions of opengGL (e.g. 4.1). To compare other ways of specifying vertices, we will look at generating a cube. The code is here. We will look at it in class. At this point, you do not need to understand all the details of this code but but you should be aware that things using OpenGL is becoming more complicated because many simple (but slow) features are going away ... Of course, many really cool features are being added.
Part 1 Deliverables: By class time on Sept 28, be prepared to demo several sample images of what you generated and at least one animation. Nothing will be collected. This lab will graded as pass/fail - you will get credit if you can demo a program that demonstrates your basic understanding of the above items.
|
Download and run WaveJOGL.zip. It shows how one can plot a function of 2 variables. This program loops over an (x,y) grid to calculate the height z = f(x,y) and then plots (x,y,z) (actually, at each iteration, 4 points forming a square are calculated). What happens if you comment out gl.glEnable(GL.GL_DEPTH_TEST); Once you understand the wave program, do one of the following projects: |
![]() Steiner's Roman Surface |
Project 1: Plotting an Algebraic Surface: The wave program loops over an (x,y) grid to calculate the height z = f(x,y) and plot the point (x,y,z). In this part, you are to extend this idea by looping over a grid of parameters (e.g. r,t) and at each r,t calculate the xyz value. For example, look at Steiner's Roman Surface on the web page discussing affine trig parameterization of the surfaces at Steiner Surfaces. Create a wireframe to start, then experiment with using different ways of representing the vertices (points, quads, etc). If you use quads, you will have to play around with the color so that you can see detail. |
![]() Somewhere in Colorado |
Project 2: Digital Elevation Models:
Read in either an ascii or image dem map. Sample ascii data is here.
The first two numbers are the number of columns and rows. A snippet of code for reading in this file is given
here. Note, this is not complete code - it includes the necessary imports and a method for reading the ascii file.
Depending on how comfortable you are with java, you might want to read in a DEM image (e.g. see the image for Salem) and plot that. This is challenging and if you aren't careful, will result in memory overflows. One should really use Vertex Arrays rather than Immediate Mode. |
Optional: Following the cube example (see Heads-up in part 1), convert the above code to Vertex Arrays or Vertex Buffer Objects.
Part 2 Deliverables: By class time on Oct 5, submit your code (with a working jar file) to wise. You will be evaluated based on the readability of your code as well as what the code does.
|
In class we will see how to create and implement the scene graph for a simple solar system and a robotic arm. In this part of the lab, you are to model an object of your choice. It should be built of multiple components and have only a few moveable parts. It's movement should be hierarchical. For example, the top of the robot arm automatically moves when the middle part or the arm moves. The object you create might be a simple humanoid with moving legs, a car with moving wheels and a door that opens, or a helicoptor that can move forward/backwards and has moving rotors. Once you decide on your object, follow the steps below. |
|
Process for Modeling Hierarchical Structure:
|
Part 3 Deliverables: By classtime on Oct 16, Submit your Netbeans project to Wise. Be sure to include a working jar file. Also include as attachments, both the object design and the scene graph. If you drew them on paper, you can scan them or turn in the paper copy. You will be evaluated based on the organization of your scene graph, its clean implementation in the code, and the complexity of what you create.