Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: Jorge Freitas Newsgroups: scea.yaroze.programming.3d_graphics Subject: Creating a TMD on the fly Date: Wed, 28 May 1997 07:59:19 -0400 Organization: SCEA Net Yaroze News Lines: 154 Message-ID: <338C1E17.60C8@netcom.ca> Reply-To: jfreitas@netcom.ca NNTP-Posting-Host: trt-on1-28.netcom.ca Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0 (Win95; I) I'm trying to create a TMD object in memory, with the intention of creating a landscape object on the fly. I have no difficulty displaying objects comverted using RSDLINK, but I can't get this TMD code to work. The code is supposed to create a single triangle, flat shaded. I've used tables to store some of the information, expecting the compiler to place them sequencially in RAM without any padding, and I've set the FIXP flag in the header FLAGs denoting a real address for the Object pointers. The description of the TMD File Format is a bit confusing, the order of the items is shown as MSB and LSB of 32 bit data (what the document calls a WORD(?) ), so the ordering of the all the structures might be reversed? I'm not sure if the library calls expect the primitives, vertecies, and normals tables to appear sequencially, or if the library code uses the pointers in the Object structure to reference the tables (which would seem correct )? After examining a TMD of a single triangle I created using RSDLINK, I duplicated the TMD in Build_TMD(). I tried reversing the order of the vertex indecies in the Primitive, reversing the normal, patting my head and jumping up and down on one foot, and nothing seems to help. Hopefully I've simply forgotten to set a FLAG or something, I don't think my structures or concept is flawed? Jorge jfreitas@netcom.ca -------------------------------- Here's the code and structures -------------------------------- typedef struct { long int ID; long int FLAGS; long int NOBJ; }TMD_Header; typedef struct { TMD_Header header; //remove this for multiple object TMD unsigned long int *vert_top; unsigned long int n_vert; unsigned long int *normal_top; unsigned long int n_normal; unsigned long int *primitive_top; unsigned long int n_primitive; long int scale; }TMD_Object; typedef struct { char olen; char ilen; char flag; char mode; }TMD_Primitive; typedef struct //specifically for flat shaded triangle { unsigned char r; unsigned char g; unsigned char b; unsigned char pad; unsigned short int n; unsigned short int v0; unsigned short int v1; unsigned short int v2; }TMD_Packet; typedef struct { short int vx; short int vy; short int vz; short int pad; }TMD_Vertex; typedef struct { short int nx; short int ny; short int nz; short int pad; }TMD_Normal; // // // TMD_Object Test_Object; TMD_Primitive Primitive_Table[ 1 ]; //packets must appear directly after TMD_Packet Packet_Table[ 1 ]; //the primitive table, and the tables TMD_Vertex Vertex_Table[ 3 ]; //are sized so as to appear immediately TMD_Normal Normal_Table[ 1 ]; //one after the other in memory /************ * Build_TMD * ************/ void Build_TMD( void ) { Test_Object.header.ID = 0x41; Test_Object.header.FLAGS = 1; Test_Object.header.NOBJ = 1; Test_Object.vert_top = (unsigned long int *)&Vertex_Table; Test_Object.n_vert = 3; Test_Object.normal_top = (unsigned long int *)&Normal_Table; Test_Object.n_normal = 1; Test_Object.primitive_top = (unsigned long int *)&Primitive_Table; Test_Object.n_primitive = 1; Test_Object.scale = 0; Vertex_Table[ 0 ].vx = 0; Vertex_Table[ 0 ].vy = -1; Vertex_Table[ 0 ].vz = 0; Vertex_Table[ 0 ].pad = 0; Vertex_Table[ 1 ].vx = -1; Vertex_Table[ 1 ].vy = 1; Vertex_Table[ 1 ].vz = 0; Vertex_Table[ 1 ].pad = 0; Vertex_Table[ 2 ].vx = 1; Vertex_Table[ 2 ].vy = 1; Vertex_Table[ 2 ].vz = 0; Vertex_Table[ 2 ].pad = 0; Normal_Table[ 0 ].nx = 0; Normal_Table[ 0 ].ny = 0; Normal_Table[ 0 ].nz = -1; Normal_Table[ 0 ].pad = 0; Primitive_Table[ 0 ].olen = 4; Primitive_Table[ 0 ].ilen = 3; Primitive_Table[ 0 ].flag = 0; Primitive_Table[ 0 ].mode = 0x20; Packet_Table[ 0 ].r = 0xc8; Packet_Table[ 0 ].g = 0xc8; Packet_Table[ 0 ].b = 0xc8; Packet_Table[ 0 ].pad = 0; Packet_Table[ 0 ].n = 0; Packet_Table[ 0 ].v0 = 0; Packet_Table[ 0 ].v1 = 2; Packet_Table[ 0 ].v2 = 1; }