From EDukeWiki
Revision as of 02:17, 20 February 2020 by Fox (talk | contribs) (→‎Examples)
Jump to navigation Jump to search

showview <x> <y> <z> <angle> <horiz> <sector> <scrn_x1> <scrn_y1> <scrn_x2> <scrn_y2>
showviewunbiased <x> <y> <z> <angle> <horiz> <sector> <scrn_x1> <scrn_y1> <scrn_x2> <scrn_y2>

Displays on-screen the view from in-game coordinates (<x>,<y>,<z>), looking at angle <angle> and with z-angle (up and down) <horiz>, between screen coordinates (<scrn_x1>,<scrn_y1>) and (<scrn_x2>,<scrn_y2>).

<sector> is the sector that contains the in-game coordinates.

The on-screen coordinates can be in any shape; they do not have to be in the same x-y ratio as the screen resolution. However, the aspect ratio at which the scene is drawn in the sub-viewport is unspecified and may differ between renderers and settings of r_usenewaspect. (For example, different ratios may result in warping or graphical glitches in the view.)

Their permissible range is 0 to 319 for the screen x coordinate, and 0 to 199 for the screen y coordinate, both inclusive.


These normalized coordinates are transformed to actual screen coordinates depending on the command used:

For showview, the scaling biases them towards zero, so that the whole screen can never be covered in any other resolution than 320x200:

real_scrn_x = round_towards_zero((<scrn_x>*xdim)/320)
real_scrn_y = round_towards_zero((<scrn_y>*ydim)/200)

On the other hand, showviewunbiased transforms them such that the greatest permissible normalized value will be mapped to the greates actual screen coordinate:

real_scrn_x = round_towards_zero((<scrn_x>*(xdim-1))/319)
real_scrn_y = round_towards_zero((<scrn_y>*(ydim-1))/199)

The resulting coordinates are 0-based with the origin being the upper left corner and denote an inclusive range of pixels in the x or y direction in the classic renderer.

For example, the command

showview x y z a h s  0 0  31 0

draws the view in a one-pixel high line covering about one tenth of the screen length from the left, and

showview x y z a h s  0 0  0 19

a one-pixel wide line covering approximately one tenth of the height from above.

The command

showview x y z a h s  0 0  0 0

would use exactly the upper left pixel in the classic renderer. (Polymost currently behaves differently, but this may be subject to change.)

Keep in mind when using this command that the game will have to completely redraw everything from the specified perspective, which can produce a sizeable framerate hit.


The correct way of drawing to the whole screen is

showviewunbiased x y z a h s 0 0 319 199

This will embed a small version of the player's view near the top left corner of the screen:

getplayer[THISACTOR].posx x
getplayer[THISACTOR].posy y
getplayer[THISACTOR].posz z
getplayer[THISACTOR].ang ang
getplayer[THISACTOR].horiz horiz
getplayer[THISACTOR].horizoff temp
addvarvar horiz temp
updatesectorz x y z sect
showviewunbiased x y z ang horiz sect 16 8 56 39