Showview: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
Fox (talk | contribs)
No edit summary
Line 1: Line 1:
'''''showview''''' <x> <y> <z> <angle> <horiz> <sector> <scrn_x1> <scrn_y1> <scrn_x2> <scrn_y2><br/>
'''''showview''''' <x> <y> <z> <angle> <horiz> <sector> <scrn_x1> <scrn_y1> <scrn_x2> <scrn_y2><br/>
'''''showviewunbiased''''' <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><br>
'''''showviewq16''''' <x> <y> <z> <Q16 angle> <Q16 horiz> <sector> <scrn_x1> <scrn_y1> <scrn_x2> <scrn_y2><br>
'''''showviewq16unbiased''''' <x> <y> <z> <Q16 angle> <Q16 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>).
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>).
Line 9: Line 11:


Their permissible range is 0 to 319 for the screen x coordinate, and 0 to 199 for the screen y coordinate, both inclusive.
Their permissible range is 0 to 319 for the screen x coordinate, and 0 to 199 for the screen y coordinate, both inclusive.
"Q16" variants exist to provide extra 16 bits of floating point precision beyond the usual limitations of player's horiz and angle, any non-Q16 input values must be bit shifted higher by 16 bits when used as-is.<br>
When tied to the player, you can use <code>cameraq16horiz</code> and <code>cameraq16ang</code> for ready to use high precision input.<br>
This function is also software renderer compatible and any extra precision will simply be truncated there.


== Coordinates ==
== Coordinates ==
Line 50: Line 56:
  updatesectorz x y z sect
  updatesectorz x y z sect
  '''showviewunbiased''' x y z ang horiz sect 16 8 56 39
  '''showviewunbiased''' x y z ang horiz sect 16 8 56 39
When using q16 variants, you can also use:
camerax
cameray
cameraz
camerasect
cameraq16horiz
cameraq16ang
Note that "camera" coordinates also change when viewing 3rd person mode


[[Category:EDuke32 specific commands]]
[[Category:EDuke32 specific commands]]
[[Category:Screen drawing commands]]
[[Category:Screen drawing commands]]

Revision as of 09:07, 5 July 2025

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>
showviewq16 <x> <y> <z> <Q16 angle> <Q16 horiz> <sector> <scrn_x1> <scrn_y1> <scrn_x2> <scrn_y2>
showviewq16unbiased <x> <y> <z> <Q16 angle> <Q16 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.

"Q16" variants exist to provide extra 16 bits of floating point precision beyond the usual limitations of player's horiz and angle, any non-Q16 input values must be bit shifted higher by 16 bits when used as-is.
When tied to the player, you can use cameraq16horiz and cameraq16ang for ready to use high precision input.
This function is also software renderer compatible and any extra precision will simply be truncated there.

Coordinates

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.

Examples

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

When using q16 variants, you can also use:

camerax
cameray
cameraz
camerasect
cameraq16horiz
cameraq16ang

Note that "camera" coordinates also change when viewing 3rd person mode