Path: chuka.playstation.co.uk!news From: alex@teeth.demon.co.uk (Alex Amsel) Newsgroups: scee.yaroze.programming.gnu_compiler Subject: Re: Maybe useful titbits + memory notes + give us more work if you love us really Date: Thu, 21 Aug 1997 13:38:24 GMT Organization: Into Beyond Lines: 99 Message-ID: <33ff3629.7835315@news.playstation.co.uk> References: <33F2851D.2FD1@cobradev.demon.co.uk> <33fdfd81.2876030@news.playstation.co.uk> Reply-To: alex@teeth.demon.co.uk NNTP-Posting-Host: teeth.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Newsreader: Forte Agent .99g/32.335 Some people have had problems finding a way to encode actual texture information into TMDs without knowing all the TIM info beforehand. As usual, there is quite an easy solution but it does require a bit of work. Maybe I ought to do a proper tutorial with example code and stuff sometime!! Within TMD primitives is information on the CLUT and TEXTURE PAGE of the texture to use. Ordinarily this is filled in the TMD data file you download to the PS-X. However, perhaps you have just written a converter to convert 3ds scenes to TMD scenes. If you have kept the texture (or material) information you can build a list of all the textures used. e.g. Wood1 Wood2 Wood3 Metal1 In this example imagine our object uses the above 4 textures. If this list is saved out as an array we can think of them as texture[0], texture[1], texture[2] and texture[3]. When exporting the TMD data we can thus use the currently empty CLUT entry or TEXTURE PAGE entry in the primitive structure to store the index value of the texture to use on that primitive. To ensure these texture indices are useful we must ensure that the textures can stil be referenced by the same number. i.e. Texture 0 must still refer to Wood1. The easiest way is to simply download them to the Yaroze in this order, but it is not the only way. Now we have everything but the actual CLUT and TEXTURE PAGE information itself. Consider what we do have - we know the texture to be used on each primitive, we have loaded up the TIM file and have access to the usual GsIMAGE data, and we have GetClut and GetTPage calls. All that is needed is to parse through the primitive structure doing the following: * Load the texture index * Check the GsIMAGE structure for that texture * Call GetClut and fill the CLUT entry * Call GetTPage and fill the TPage entry * Adjust the u,v co-ordinates if your texture is not exactly on a boundary. This last bit is not so easy as you might think. You must take into account the colour depth of the image This later process can be time consuming to program as you must be able to deal with all sorts of different types of primitive, skipping the correct amount of data if appropriate. To make matters worse you must also remember to take account of the manner in which the TMD object is altered by the GsLinkObject call. I think details on this are covered in an earlier posting from Jim. Another important consideration is how to deal with objects that have already been 'remapped'. If you are like us and have to download a lot of data for your project, you'll also only be downloading the modified executable each time. Afterall, all your original gfx and suchlike will be in main ram unless you have overwritten them. However, if you try remapping an object that is already remapped, you'll run into all sorts of problems. One solution is to use a flag, similar to that used by Sony themselves in some cases. 3 cases should be considered: 1) Unmapped - the data needs remapping. This is the saved value 2) WIP - Work in Progress - some data has been amended - I use this incase I quit out the program due to an error. In this case I can tell the object is partially remapped and needs downloading again, hence I quit out with an appropriate error. 3) Remapped - the data has been remapped and needn't be touched again All the work is worth it however. No longer do you need to lose your texture information. No longer do you need to use any dodgy tools, DXF or RSD format. And you can quickly update and reposition all your textures without reference to your original TMD object. Regards, Alex Amsel + Tuna Technologies + Windows 95/NT, Console and Internet + + The PC/PS-X Game Tools and Game Development Specialists + + Flibbley flobble wab tiggle sa lable ly pibbley Obblers +