Path: chuka.playstation.co.uk!news From: byron@snsys.com (Byron) Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: 3d sprites solved! Date: Tue, 01 Dec 1998 11:38:43 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 65 Message-ID: <3663d498.3137321@www.netyaroze-europe.com> References: <36619C02.1961@mdx.ac.uk> NNTP-Posting-Host: byron.snsys.com X-Newsreader: Forte Free Agent 1.11/32.235 On Sun, 29 Nov 1998 19:09:54 +0000, "Harvey.C" wrote: >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 Hi, Another slant on this.... For years I have always wanted to write a Space Harrier type game. I have been toying with the idea of using 3D Sprites for a while and the above code reduces a considerable amount of work that I have to do (thank god!) so cheers! Any ideas on using the above code to work out a relative scaling factor - i.e. when a sprite is in the distance it will be small and get larger as it approaches you? Byron. Byron@SNSYS.COM