CAP5937 - Realtime Graphics for Simulation and Games

Lecture 1: Introduction to the Course

and A Quick Introduction to Visual C++

J. Michael Moshell

Professor of Computer Science

Normally these notes will consist primarily of queries. Today, since this is the first day of class, I have to actually TELL you some stuff. There is also a diagnostic quiz included in this lecture.

1) Go read the Syllabus. I'll obviously talk to you about those issues, first.

2) To answer these queries, you will need to consult your lecture notes as well as Chapter I of the Trujillo text. Note: "Answering the query" does NOT mean copying a sentence or a paragraph from the textbook. You must read the text, close it, and write an answer in your own words. I will try to ask queries that don't correspond exactly to the text, and will certainly do this on the final exam!

Since it will take a few days to get your texts, I'm providing you with photocopies of Chapters 1 through 3. You need to order the texts TODAY from www.amazon.com. If you don't have a credit card, find a classmate who does and give them some cash.

I will also provide 4 copies of the Trujillo text's CD. You will need to form into groups to share these CDs, passing them from one to another until all your home machines are equipped.

Query 1.1. What is an SDK? What is MFC?

Query 1.2.  Consider the WINMAIN function in terms of threads of execution. Which of the following models is valid?

a) WINMAIN loops all the time, 'polling' to see if any messages have arrived.
b) WINMAIN wakes up when a message (event) arrives, and dispatches it.

What happens if a new event occurs while a previous one is being handled?

Query 1.3. Contrast WINMAIN with a synchronous simulation MAIN program, as discussed in class. List the important differences.

ANSWER:

a) A synchronous simulation loop runs continually and must restsart at the frame rate F frames per second.
b) Any subtask Ti spawned by the main loop must consume at most a fixed amount Ri of time.
c) If the time spent in the code of the main loop itself is L,
d) Then L+ SUM(Ri) must be <1/F

WHEREAS:

a) WINMAN only runs when an event is generated by a hardware interrupt or software trap;
b) There is no built-in limit to how long a subtask may take;
c) the time taken by WINMAIN itself is trivial; but GetMessage is blocking;
d) so constraint d cannot be met.

So, the only logical conclusion must be that the functions of a realtime simulation loop must be somehow "embedded" in the Windows event mechanism, for computer based games. THIS IS NOT TRUE for video games, where the OS is typically a simple real-time oriented system not much bigger than a BIOS. The user's own program may have most of the OS' functionality built into it, in fact.

/ANSWER

Query 1.4. Describe the relationship between Event Handlers and Messages. What is a Message in symbolic space (i. e. from the viewpoint of the compiler?) What is a message in object space (i. e. when the compiled code encounters the message as a data object?)

ANSWER:

a) When the message is in symbolic space, it's a token in a symbol table. There are many pre-defined messages like WM_KEYDOWN. You can add handlers for specific pre-defined messages via a Message Map.

b) In the object space, the message is just a number. Its sole function is to select an element in a case statement.

Query 1.5. What is an AppWizard and what does it do for you?

The following exercise will need to be done with the D3D software that's on the Trujillo CD. You can do this in the Lab, or at home if you have borrowed one of the copies of the CD.

Query 1.6.  Install the Trujillo software. If you got it from the CD with the book, you will also need to get the updated AppWizard. That's right here.

If you're using the CD copies which I provided, I've put the correct AppWizard in place already.

In either case, the AppWizard is found in a directory called awx. It should be installed into the following directory:

Microsoft Visual Studio/Common/MSdev98/template

If you don't see the D3DAppWizard when you get to that point in the Trujillo Chapter 1 tutorial, it's probably not installed in the right place. Exit from Visual C++, drag the wizard file from the CD to the correct directory, and restart.

Query 1.7. Run through the MFC Application tutorial (to check out your Visual C++ system and make sure it's working.) Then continue through the D3D Appwizard tests, to get the spiral widget working.

Query 1.8. Even though we aren't ready to explore the code in detail, let's do a little hacking about to show it who's the boss.

In the ClassView window, double-click on Sample1Win, then on CreateScene. You will find the code which loads in a file called 'swirl.x'. Let's comment out the error handler as follows, and stick in our own little signpost. Then compile (F7) and run (F5) the code.

/*
 if (r!=D3DRM_OK)
 {
  CString msg;
  msg.Format( "Failed to load file '%s'\n", meshname );
  AfxMessageBox( msg );
  return FALSE;
 }
*/

  CString msg;
  msg.Format( "Hi Mom! I didn't load '%s'\n", meshname );
  AfxMessageBox( msg );
  return FALSE;

This should get you an error box (after the black screen opens), with "Hi Mom! I didn't load swirl.x". followed immediately by "CreatScene Failed".

You may explore this code if you want to. You know how to get a fresh copy if you mess this one up.

Query 1.9. The existence of this swirl.x file leads one to conclude that there is a data format for Direct3D graphics files. If you go exploring, you can find swirl.x (it's in the obvious place, in your newly created Sample3D project folder). Curiously, you double click the file to see what happens.

If you're lucky (and installed the Trujillo stuff correctly) you will encounter an application provided by Trujillo, called "Xpose". It allows you to view X objects. Play with its rendering and shading options, load some texture maps onto the objects you find. Fun stuff, eh?

For Thursday: Read Chapter 2. Go to the Web Site for the course. Work through the Queries for Chapter 2, write down your answers, and be ready to present the answers in class! Randomly during the semester I will take up all the written answers and grade them, so BE READY.

Diagnostic Quiz

The purpose of this quiz is to help you (and me) know if you have enough background knowledge of 3d computer graphics to benefit from this course. We don't have the time to teach basic concepts over again. Chapter 2 reviews some of these concepts - but it's quite superficial and in no way substitutes for having had CAP5725, CAP4021, one of the machine vision courses, or substantial self-taught experience.

There are 5 questions worth 20 points each. (These points don't affect the course grade; they're just for our diagnostic purposes.) I expect this quiz to take about 30 minutes. You should score 70% or better on this quiz, to participate in the course. Write your answers on a plain piece of paper (not on these notes.)

1. Modeling Transformation. A simple graphical object model is represented as a set of 3d points, which are used to specify graphical primitives such as lines, polygons or solid shapes. What is a modeling transformation? Name three basic modeling transformations. Describe one of them mathematically in terms of its effects on a point (x,y,z).

2. Projection. To see a graphical object requires a projection, which is a mapping from one kind of space (or coordinate system)  to another: from what kind of space, and to what kind of space? Name the two most common kinds of projections used in graphics.

3. Homogenous Coordinates. Apply the following homogenous matrix transform to a data point (1,0,0,1)t and tell me the result. Describe the graphical meaning of what you just did. (The little 't' means "Transposed" because I want the vector to be a column vector. But I don't know how to make the t go up, like a superscipt, in HTML!")
 

    1  0  0  4
M=  0  1  0  2
    0  0  1  0
    0  0  0  1  
4. Lighting and Shading. If I hand you a picture of a computer-drawn 3d object and ask you if it's Gouraud or flat shaded,

(a) how would you tell the difference?
(b) Could you tell the difference even it the object was a single polygon?
(c) Could you tell the difference if the only light source was ambient? Why or why not?

5. Algorithms. Write a few sentences that describes an algorithm, selected from one of the following classes of algorithms. Tell me

(a) what problem the algorithm solves,
(b) what input parameters the algorithm needs, and
(c) any extra facts you might know about the algorithm (e. g. other ways of doing the same thing; advantages of this approach, etc.)

Bresenham's line drawing algorithms
Polygon scan conversion
Flood filling of bounded regions
clipping
perspective texture correction

---------------

Ya see-a, see-a see-a, That's all, folks!

(5 extra points: what famous individual from the graphics industry said that?)

To the syllabus
To lecture 2