[comp.sys.mac.programmer] Graf3D Library in MPW 3.0

oster@dewey.soe.berkeley.edu (David Phillip Oster) (02/12/90)

In article <9002100337.AA00663@cadman.nyu.edu> deragon@CADMAN.NYU.EDU (John Deragon) writes:
_>Hiya folks, has anyone used the Graf3D Library in MPW 3.0?
_>	I am having a problem with it.. What I am doing is:
_>			Port3D	port;
_>			Rect    vport;
_>			Fixed   t, l, b, r;
_>			....
_>			SetRect(&vport, 20, 20, 300, 300);
_>			t = 20; l = 20; b = 300; r = 300;
_>			InitGrf3D(port);
_>			ViewPort(vport);
_>			LookAt(t, l, b, r);
_>			ViewAngle(0) /*No Perspective */
_>			MoveTo3D(20,20,0);
_>			LineTo3D(100,100, 0);
_>What is wrong with this? I am doing something that is obviously wrong? I must
_>me missing something.. WHAT?!

Here is a fragment of a Graf3D program that works:
	Open3DPort(&myPort3D);

   /* put the image in this rect */
	ViewPort(&thePort->portRect);

   /* aim the camera into 3D space */
	LookAt(FixRatio(-100, 1), FixRatio(75, 1), FixRatio(100, 1), FixRatio(-75, 1));

   /* choose lens focal length */
	ViewAngle(FixRatio(30, 1));
	Identity();
	Roll(FixRatio(20, 1));
	Pitch(FixRatio(70, 1)); /* roll and pitch the plane */

As you can see, the previous, erroneous, code had the following problems:
	1.) It did not pass address to Open3DPort, and ViewPort.
	2.) It assumed the compiler would convert from integer to Fixed
automatically. The compiler won't. FixRatio(75, 1) is not the same as 75.
(It is the same as ((75L) << 16).)

--- David Phillip Oster            --  No, I come from Boston. I just work
Arpa: oster@dewey.soe.berkeley.edu --  in cyberspace.
Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu