Path: chuka.playstation.co.uk!news From: James Russell Newsgroups: scee.yaroze.beginners Subject: Re: Questions about Ordering Table Date: Wed, 19 Nov 1997 15:28:30 +1300 Organization: Peace Computers NZ Ltd Lines: 146 Message-ID: <34724ECE.6EEA@peace.co.nz> References: <34722911.C7EC3C06@freenet.fr> NNTP-Posting-Host: intro.peace.co.nz Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0Gold (X11; I; IRIX 6.2 IP22) TOUZALIN William wrote: > > > GsOT WorldOrderingTable[2]; > GsOT_TAG zsortTable[2][1< > WorldOrderingTable[0].length = OT_LENGTH; > WorldOrderingTable[1].length = OT_LENGTH; > WorldOrderingTable[0].org = zSortTable[0]; > WorldOrderingTable[1].org = zSortTable[1]; > > What's a Ordering Table ? To draw things on the screen, the Yaroze sends the Graphics Processor a list of commands, and it's the Graphics Processor that does the actual drawing. You can't affect the screen directly like on other machines. These commands are operations like "Draw Line" and "Clear Screen", or "Draw This Triangle with This Texture Map", and each command has a number or arguments (for instance, Draw Line's arguments specify the start and end points, and the colour of the line to be drawn). With traditional games, especially 3D ones, the way you render a scene is to draw the objects furthest away from you first, then work your way to the objects nearest to you. This is called the Painters Algorithm. The reason we do this is because if you draw something near, then draw something further back that overlap in an area on the screen, the object further back will cover or overlap the object that is supposed to be nearer, and your scene will look all wrong. With this appraoch, you have to sort out which objects will be drawn first, and which will be drawn last. This is where Ordering Tables come in. With ordering tables, you just work out what you want you object to look like (position, size and so on) and insert it (using GsSortSprite or GsSortObject) into the Ordering Table. The Graphics Library will automatically figure out where your object is supposed to be in amongst the other objects, so that when the GPU come to draw the scene, everything looks right. You don't have to worry about sorting objects, because the Ordering Tables do that for you. When you've put every object you want on the screen into the Ordering Table, you set the GPU off and it goes and draws everything for you. (The GsSortSprite and GsSortObject functions also create the Graphics Processor commands decribed above to draw your object. They put those commands in a Working area (These are the zSortTables in the code above) and you don't have to worry about those.) Ordering Tables are used by both 2D and 3D graphics, so you can mix sprites (2D graphics) with 3D objects. It may seem strange to think of 2D graphics as having an order, but if you can imagine a screen with a background, well, you'd want that to be 'behind' your main character, so it would be further back in the order. When you insert and object into an Ordering Table, you've got to specify how far back the object is. This 'distance' is called the objects 'priority'. The higher the priority, the further back it is (if this seems strange, think of higher priority as meaning it gets drawn sooner). This is where the 'length' comes in. A priority of 0 means it is drawn last (is closest to you). But what is the highest priority? Well, the highest priority will depend on your situation. If you've only got two or three objects to draw, then you only need two priorities maximum, so a maximum priority of 1 will do. If you've got a zillion 3D objects to draw, then you might need more. If you have complicated 3D objects, having a greater maximum priority can avoid some drawing errors. When you make an Ordering Table, you choose the maximum priority. Priorities start at 2 and go up in powers of 2 (up to 2^14). So you could have a maximum priority of 2-1 (1), 4-1 (3), 8-1 (7), .... 16384-1 (16383).The higher the maxmimum priority, the more memory is taken up though. This exponent is called the Ordering Table 'length'. The minimum length is 1 and the maximum length is 14 (I think, off the top of my head). Instead of having to remember these numbers, you just use the exponent of 2. Thus, if you have an Ordering Table with length 10, that means you've got a maximum priority of 2^10-1 = 1024-1 = 1023. 0 is always the lowest priority. The reason why there are two Ordering Tables are because there must be one for each frame of the Double Buffering (ie the Graphics Processor is busy drawing off one while you're drawing *into* the other). Every screen must have a "World" or "Master" Ordering Table. Eventually, everything ends up in this Ordering Table. It is possible to have more than one Ordering Table for a screen (this is done for speed reasons), but they all have to be merged into one big Ordering Table before you can draw the scene. An Ordering Table works via linked lists (I won't explain how those work). One important thing to remember is that if you insert an object using GsSortObject or GsSortSprite into an Ordering Table at, say, priority 6, then insert another object at priority 6, the object drawn first will be the last one inserted. Thusif you have the following objects and insert them in the following order at the following priorities (My 'length' is 4, so my maximum priority is 2^4-1 = 15): Aeroplane - priority 4 Wizard - priority 10 Moose wearing Wax Lips - priority 7 Postman Pat - priority 3 Thermonuclear Toaster - priority 7 Large Weasel with Contract - priority 10 They will be drawn by the GPU in the following order (remember, last to be drawn appears 'closest'): Large Weasel - 10 Wizard - 10 Toaster - 7 Moose - 7 Aeroplane - 4 Postman Pat - 3 So Postman Pat will appear in front of all the others. The next question usually is - "Do I have to use Ordering Tables?" and the answer is "Unless you wan't to go to a WHOLE lot of trouble, yes." > Can you explain the point "." between WorldOrderingTable[x] and length ( > ou org...) ? If you're asking what I think you're asking then you don't know about referencing structures (which in C are pretty Basic Things You Need To Know). I suggest getting a good book about C, in that case. Apologies if you're talking about something else. Cheers, James -- ==PEACE COMPUTERS ==James.Russell@peace.co.nz - 64(9)3730400 -Fax 64(9)3730401 Buffalo: Greeting between two nudists.