From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro sprite rotation wierdness Date: Sat, 25 Jan 1997 13:06:21 +0000 Organization: None Lines: 35 Distribution: world Message-ID: References: <5c6mh9$2c2k AT elmo DOT cadvision DOT com> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp frenchc writes: >wonderful, but does anybody know how to keep sprites from clipping when >you rotate them? I assume this is just a limitation (?feature) of the >asm routine or algo used (I don't really know rotational algos except You are right - its a bug/feature that results from the rotation algorithm I'm using. My technique is to map straight lines from the source bitmap onto other straight lines across the destination bitmap, and then trace along these lines copying each pixel (once you've set up the direction vectors, it's a simple linear interpolation). Logically I should trace horizontal lines through the source image, but this would result in some destination pixels being missed due to rounding errors, and would play havoc with SVGA bank switching efficiency. So instead I trace horizontal lines through the destination bitmap, mapping them onto arbitrary lines through the source. At the moment I just scan over an area of the destination the same size as the source image, so any parts of the source that get rotated outside this rectangle are missed. The way to fix this would be to expand the destination region covered by the scan, depending on the size of the source image. I _think_ this will be fairly easy to do - I'll have a play with it and see if I can make it work without too much overhead. I've also heard mention of a rotation algorithm based on shearing the image first horizontally and then vertically, which can rotate by up to 45 degrees (flips can then be used for the other 7 octants). I've never tried implementing this: does anyone have any experience of it? Could it be faster than my line-tracing method? /* * Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ * Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'. */