Path: chuka.playstation.co.uk!news From: "Harvey.C" Newsgroups: scee.yaroze.programming.3d_graphics Subject: 3d sprites solved! Date: Sun, 29 Nov 1998 19:09:54 +0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 43 Message-ID: <36619C02.1961@mdx.ac.uk> Reply-To: hc054@mdx.ac.uk NNTP-Posting-Host: dialup-99-194.barrysworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.04Gold (Win95; I) Woohoo! I'd like to say a big thankyou to James Russell. I've managed to turn 2d sprites into 3d objects for my game. Here is a little function I made based on the code given to me by James: void draw_3dsprite (GsSPRITE *sprite,long x,long y,long z,short precision) { VECTOR spritePosition,transformedPosition; // This is the position of your sprite in 3d space spritePosition.vx=x; spritePosition.vy=y; spritePosition.vz=z; ApplyMatrixLV(&GsWSMATRIX,&spritePosition,&transformedPosition); transformedPosition.vx+=GsWSMATRIX.t[0]; transformedPosition.vy+=GsWSMATRIX.t[1]; transformedPosition.vz+=GsWSMATRIX.t[2]; // Only draw tree sprite if its in front of the camera if (transformedPosition.vz>0) { // Scales the tree - 16777216=4096<<12 is a constant (works for me) sprite->scalex=sprite->scaley=16777216/transformedPosition.vz; sprite->x=transformedPosition.vx*250/transformedPosition.vz; sprite->y=transformedPosition.vy*250/transformedPosition.vz; GsSortSprite(&sprite,&OTable_Header[CurrentBuffer],transformedPosition.vz>>precision) } } I guess this must be trivial to most of you, but its all new to me. And before you scorn and reject using 2d sprites as 3d objects, I must say they are extremely effective and best of all - extremely fast! Many thanks. -- Regards | E-mail: hc054@mdx.ac.uk Harvey | ICQ: 4269478