http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gameprogrammer] Re: Constraining a line to a rectangle



On Tuesday 13 April 2004 06.35, Kevin Jenkins wrote:
> In my game I have a series of lines.  For each line, it is possible
> that one or both of the endpoints is outside the viewport, which is
> smaller than the screen.  Given the endpoints of the line, I want
> to modify these endpoints so I when I render a line between the two
> endpoints, all rendering is done inside the viewport.
[...]

It's usually called clipping, and it should be easy to find tons of 
papers and code examples on various techniques. Try searching for 
"computer graphics clipping lines" (without the quotes) or something 
on your search engine of choice.

Or just try Cohen-Sutherland:
	
http://www.cc.gatech.edu/grads/h/Hao-wei.Hsieh/Haowei.Hsieh/mm.html#sec2_3


//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
|  Free/Open Source audio engine for games and multimedia.  |
| MIDI, modular synthesis, real time effects, scripting,... |
`-----------------------------------> http://audiality.org -'
   --- http://olofson.net --- http://www.reologica.se ---