.nh .po 5 .ce TEST 1 - CS458 .nf Instructor Dr P Juell NAME_______________________ CLOSED BOOK Sep 25, 1996 100 points This sheet is to be turned in with the test .fi 1. (20) A $300 monitor can display 400 columns and 500 rows of pixels. Each pixel can display any of 16 current colors. The current colors are selected from a pallet table. Each entry in the pallet has 3 bits for red (R), 3 for green(G) and two for blue(B). A bigger version of the monitor works the same but has twice as many rows and columns. For the $300 monitor and the bigger monitor specify the number of BITS in: the frame buffer and the pallet. You can leave expressions in forms like 2x3+4. .nf .in +5 frame buffer pallet $300 bigger .in -5 .fi 2. (15) On a separate sheet is a VTK program. .br What does this program display? Can you interactively fly through the image? If you displayed in wire-frame mode, would there be: .br "MORE THAN" or "LESS THAN OR EQUAL TO" 15 endpoints of lines. 3. (15) Specify a set of points and polygons in the form expected in vtk. You are to specify a cube with each edge 2 units long. .sp 10 4. (20) Why is the Bresenham's line drawing routine more efficient than the routine based directly on the formula for a line? (note, there are several parts to this answer) .sp 10 Give a good reason why you might still use the line drawing routine based directly on the formula for a line? .sp 5 .bp 5. (20) The following is a copy of Bresenham's line algorithm presented in class. One line is missing. Specify that line. .sp .nf procedure bres_line(x1,y1,x2,y2: integer); var dx, dy, x, y, x_end, p, const1, const2: integer; begin dx := abs(x1 -x2); dy := abs(y1 -y2); p := 2 * dy - dx; const1 := 2 *dy; const2 := 2* (dy -dx); {determine which point to use as start, which as end} if x1 > x2 then begin x := x2; y := y2; x_end := x1 end {if x1 > x2} else begin x := x1; y := y1; x_end := x2 end; {if x1 <= x2} set_pixel(x,y); while x < x_end do begin x := x + 1; <<<<<<<<<<<<<<<MakeRenderer(); // create an actor and give it cone geometry cone = new vtkConeSource; cone->SetResolution(8); coneMapper = new vtkPolyMapper; coneMapper->SetInput(cone->GetOutput()); coneActor = new vtkActor; coneActor->SetMapper(coneMapper); // assign our actor to the renderer ren->AddActors(coneActor); // draw the resulting scene renWindow->Render(); // loop until key is pressed cout << "Press any key followed by to exit>> "; cin >> a; } .bp #include "vtk.hh" main () { vtkRenderMaster rm; vtkRenderWindow *renwin; vtkRenderer *aren; vtkCamera *camera1; vtkLight *light1; vtkActor *actor1; float foo = 0; vtkCubeSource *cube; vtkPolyMapper *mapper; renwin = rm.MakeRenderWindow(); aren = renwin->MakeRenderer(); cube = new vtkCubeSource(1,2,3); mapper = new vtkPolyMapper; mapper->SetInput(cube->GetOutput()); actor1 = new vtkActor; actor1->SetMapper(mapper); actor1->GetProperty()->SetColor(.6,1.0,.8); light1 = new vtkLight; camera1 = new vtkCamera; renwin->AddRenderers(aren); aren->SetActiveCamera(camera1); aren->AddLights(light1); aren->AddActors(actor1); aren->SetBackground(0.2,0.2,0.2); camera1->SetPosition(10,8,5); camera1->SetFocalPoint(0,0,0); camera1->CalcViewPlaneNormal(); /* make the light follow the camera */ light1->SetPosition(camera1->GetPosition()); light1->SetFocalPoint(camera1->GetFocalPoint()); for (float l=1; l<10; l+=2) { cube->SetXLength(l); for (float yl=2; yl<12; yl+=2) { cube->SetYLength(yl); renwin->Render(); } } }