Path: chuka.playstation.co.uk!news From: James Russell Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: 2d sprites in a 3d world Date: Mon, 23 Nov 1998 21:37:53 +0000 Organization: Sony Computer Entertainment Europe Lines: 46 Message-ID: <3659D5B1.41EB5140@scee.sony.co.uk> References: <3659BEF7.663E@mdx.ac.uk> NNTP-Posting-Host: mailgate.scee.sony.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.5b2 [en] (Win95; I) X-Accept-Language: en "Harvey.C" wrote: > > I'm currently writing a 3d racing game (being my first attempt at 3d), > and I was wondering how you go about treating 2d sprites as 3d objects. > For example, games like duke nukem 3d or vrally (with its track side > detail). To put a sprite in a 3D world, you must have figured out its world coordinates. Once you've got these, you transform them using the standard 3D transformation equations to get the X and Y screen coordinates, and the OT priority. Assuming you've set your World->Screen Matrix up (as you do when you call GsSetRefView2), then you need to do the following: H is your projection distance that you set with GsSetProjectionDistance(); extern MATRIX GsMATRIX; VECTOR spritePosition,transformedPosition; spritePosition.vx = sprite's X position in world coords spritePosition.vy = sprite's Y position in world coords spritePosition.vz = sprite's Z position in world coords ApplyMatrixLV(&GsMATRIX,&spritePosition, &transformedPosition); if(transformedPosition.vz >= 0) { // If less than 0, then it's behind the camera sprite.x = transformedPosition.vx * H / transformedPosition.vz; sprite.y = transformedPosition.vy * H / transformedPosition.vz; priority = transformedPosition.vz >> (14 - OTLENGTH); // Where OTLENGTH is from 1 to 14, remember GsSortSprite(&sprite,&myOT[GsActiveBuff()], priority); } Erm.. That's all off the top of my head though - let me know if it works! Cheers, James -- == James_Russell@scee.sony.co.uk +44 (171) 447-1626 == Developer Support Engineer - Sony Computer Entertainment Europe C++ programmers do it with private members and public objects.