🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #483

Re: Game libraries...

#483
From: Christopher Phillips
Date: Fri, 07 Aug 1992 15:44
51 lines
3151 bytes
ptran@watserv1.uwaterloo.ca (Phat H Tran) writes:

>Josh's program redraws the bitmap a raster at a time, using Bresenham's
>line algorithm to "tilt" each raster so that they all point to a 
>vanishing point.  Rotation can also be accomplished in a similar manner
>by drawing each raster with a tilt, but keeping them all parallel.

If that is what it does, then it could be considerably faster, as tilting
rasters plots as many as twice as many pixels as the area they cover.

Twas I who re-brought up this idea of scaling pixel columns.  A little more
detail for the confused:

Rather than scanning through the source image plotting pixels on the screen,
you should scan the screen area the image will cover, fetching pixels from
the source image.  This avoids plotting pixels multiple times over.
For vertical walls:
If you scan row by row, each pixel plot requires a division to work out where
to fetch the pixel from.  This is the way I was thinking about the problem 
for many years.  If you scan then image column by column, then each
column of pixels you plot on the screen will consist entirely of pixels
taken from one column of pixels in the source image.  There are two ways
(at least) of finding the source pixels to plot with any reasonable degree
of (speed) efficiency.  One is to use a Bresanham-like algorithm, where
one coordinate is in screen space and the other in source image space,
(ie maintain a the source Y position as a whole number and the numerator
of a fractional part, adding too it as you run down the screen pixels).
This is the approach I saw suggested in this group as a way of doing
wolfenstein3d style graphics.
The other way is much more memory intensive but faster, and it's the one
I use to get realtime update on a c64.  What you do, is for each possible
pixel column screen height, have a table mapping screen pixels to an
offset with which to index the source column of pixels.

Then, for first person perspective of a maze with texture-mapped walls, all
you need to do is find for each pixel column on the screen two things:

- which source pixel column to scale (find wall, then access a wall definition
	table indexed by intersection position within wall)
- how much to scale the pixel column by (find reciprocal of distance, then
	use that as an index to scaling table address)


Happy hacking!


--
Christopher Jam	__________________________________________________
'Another day, another try.  But remember, SHOOT OR DIE!' -turrican
phillips@swanee.ee.uwa.oz.au		c64 forever!!!!
------------------------------------------------------------------
Technical Details
Message-ID: <phillips.713202287@s12>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!uniwa!swanee.ee.uwa.oz.au!phillips
References: <1992Jul29.005516.57598@cc.usu.edu> <1992Aug5.172543.3507@esds.mdc.com> <1992Aug5.195205.5840@esds.mdc.com> <BsJrI8.A8v@watserv1.uwaterloo.ca>

Show Full Headers
Complete Article Headers
Newsgroups: rec.games.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!uniwa!swanee.ee.uwa.oz.au!phillips
From: phillips@uwa.oz.au (Christopher Phillips)
Subject: Re: Game libraries...
Message-ID: <phillips.713202287@s12>
Sender: news@swanee.ee.uwa.oz.au
Organization: Elec Eng, Univ of Western Australia
References: <1992Jul29.005516.57598@cc.usu.edu> <1992Aug5.172543.3507@esds.mdc.com> <1992Aug5.195205.5840@esds.mdc.com> <BsJrI8.A8v@watserv1.uwaterloo.ca>
Date:  7 Aug 92 15:44:47 GMT
Lines: 51