Showview: Difference between revisions
No edit summary |
No edit summary |
||
| Line 43: | Line 43: | ||
gamevar sv_ang 0 0 | gamevar sv_ang 0 0 | ||
gamevar sv_horiz 0 0 | gamevar sv_horiz 0 0 | ||
state sv_playerview | |||
getplayer[THISACTOR].posx sv_x | |||
getplayer[THISACTOR].posy sv_y | |||
getplayer[THISACTOR].posz sv_z | |||
subvar sv_z 512 | |||
updatesectorz sv_x sv_y sv_z sv_sect | |||
ends | |||
onevent EVENT_DISPLAYREST { | onevent EVENT_DISPLAYREST { | ||
//get coords | //get coords | ||
| Line 68: | Line 75: | ||
subvarvar sv_temp1 sv_horiz | subvarvar sv_temp1 sv_horiz | ||
shiftvarl sv_temp1 11 | shiftvarl sv_temp1 11 | ||
hitscan sv_hitx sv_hity sv_hitz sv_temp2 sv_cos sv_sin sv_temp1 | hitscan sv_hitx sv_hity sv_hitz sv_temp2 sv_cos sv_sin sv_temp1 sv_temp2 sv_temp1 sv_temp1 sv_hitx sv_hity sv_hitz CLIPMASK1 | ||
getplayer[THISACTOR].horiz sv_temp1 | getplayer[THISACTOR].horiz sv_temp1 | ||
| Line 85: | Line 92: | ||
sqrt sv_x sv_x | sqrt sv_x sv_x | ||
ifvarl sv_x 768 | ifvarl sv_x 768 state sv_playerview //if dist < 768, just show the player's view | ||
else { //otherwise, move camera 768 units back from hitscan location on x-y plane and adjust z accordingly | else { //otherwise, move camera 768 units back from hitscan location on x-y plane and adjust z accordingly | ||
subvarvar sv_z sv_hitz | subvarvar sv_z sv_hitz | ||
| Line 108: | Line 110: | ||
//if the calculated position isn't in a sector (this does happen) then just show the player's view | //if the calculated position isn't in a sector (this does happen) then just show the player's view | ||
updatesectorz sv_x sv_y sv_z sv_sect | updatesectorz sv_x sv_y sv_z sv_sect | ||
ifvare sv_sect -1 | ifvare sv_sect -1 state sv_playerview | ||
//make sure the camera can still see the hitscan location | |||
cansee sv_x sv_y sv_z sv_sect sv_hitx sv_hity sv_hitz sv_temp2 sv_temp1 | |||
ifvare sv_temp1 0 state sv_playerview | |||
} | } | ||
//check again to make sure we're in a sector | //check again to make sure we're in a sector | ||
Revision as of 03:05, 16 February 2007
showview <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 <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, different ratios can result in warping or graphical glitches in the view. The on-screen coordinates are in 320x200 scale.
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.
This example 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].angle ang getplayer[THISACTOR].horiz horiz getplayer[THISACTOR].horizoff temp addvarvar horiz temp updatesectorz x y z sect showview x y z ang horiz sect 16 8 56 39
This lengthy example will create a "gun camera" that shows a closeup view of wherever the player is currently aiming. In addition to showview and basic EDuke commands, it also uses updatesectorz, myos, and hitscan, as well as the event EVENT_DISPLAYREST.
gamevar sv_scrnx1 0 0
gamevar sv_scrny1 0 0
gamevar sv_scrnx2 0 0
gamevar sv_scrny2 0 0
gamevar sv_sect 0 0
gamevar sv_temp1 0 0
gamevar sv_temp2 0 0
gamevar sv_x 0 0
gamevar sv_y 0 0
gamevar sv_z 0 0
gamevar sv_hitx 0 0
gamevar sv_hity 0 0
gamevar sv_hitz 0 0
gamevar sv_cos 0 0
gamevar sv_sin 0 0
gamevar sv_ang 0 0
gamevar sv_horiz 0 0
state sv_playerview
getplayer[THISACTOR].posx sv_x
getplayer[THISACTOR].posy sv_y
getplayer[THISACTOR].posz sv_z
subvar sv_z 512
updatesectorz sv_x sv_y sv_z sv_sect
ends
onevent EVENT_DISPLAYREST {
//get coords
setvar sv_scrnx1 23
setvar sv_scrny1 16
setvarvar sv_scrnx2 sv_scrnx1 addvar sv_scrnx2 50
setvarvar sv_scrny2 sv_scrny1 addvar sv_scrny2 47 // 31 for correct ratio
//display frame
setvarvar sv_temp1 sv_scrnx1 subvar sv_temp1 7
setvarvar sv_temp2 sv_scrny1 subvar sv_temp2 8
myos sv_temp1 sv_temp2 SCREENBREAK6 0 16
//do the hitscan
getplayer[THISACTOR].ang sv_ang
getplayer[THISACTOR].horiz sv_horiz
getplayer[THISACTOR].posx sv_hitx
getplayer[THISACTOR].posy sv_hity
getplayer[THISACTOR].posz sv_hitz
getplayer[THISACTOR].cursectnum sv_temp2
subvar sv_hitz 512
cos sv_cos sv_ang
sin sv_sin sv_ang
setvar sv_temp1 100
subvarvar sv_temp1 sv_horiz
getplayer[THISACTOR].horizoff sv_horiz
subvarvar sv_temp1 sv_horiz
shiftvarl sv_temp1 11
hitscan sv_hitx sv_hity sv_hitz sv_temp2 sv_cos sv_sin sv_temp1 sv_temp2 sv_temp1 sv_temp1 sv_hitx sv_hity sv_hitz CLIPMASK1
getplayer[THISACTOR].horiz sv_temp1
getplayer[THISACTOR].horizoff sv_horiz
addvarvar sv_horiz sv_temp1
//get distance between player and hitscan location
getplayer[THISACTOR].posx sv_x
getplayer[THISACTOR].posy sv_y
getplayer[THISACTOR].posz sv_z
subvarvar sv_x sv_hitx
mulvarvar sv_x sv_x
subvarvar sv_y sv_hity
mulvarvar sv_y sv_y
addvarvar sv_x sv_y
sqrt sv_x sv_x
ifvarl sv_x 768 state sv_playerview //if dist < 768, just show the player's view
else { //otherwise, move camera 768 units back from hitscan location on x-y plane and adjust z accordingly
subvarvar sv_z sv_hitz
mulvar sv_z 768
ifvare sv_x 0 setvar sv_x 1
divvarvar sv_z sv_x
addvarvar sv_z sv_hitz
setvarvar sv_x sv_hitx
setvarvar sv_y sv_hity
mulvar sv_cos -768
mulvar sv_sin -768
divvar sv_cos 16384
divvar sv_sin 16384
addvarvar sv_x sv_cos
addvarvar sv_y sv_sin
subvar sv_z 512
//if the calculated position isn't in a sector (this does happen) then just show the player's view
updatesectorz sv_x sv_y sv_z sv_sect
ifvare sv_sect -1 state sv_playerview
//make sure the camera can still see the hitscan location
cansee sv_x sv_y sv_z sv_sect sv_hitx sv_hity sv_hitz sv_temp2 sv_temp1
ifvare sv_temp1 0 state sv_playerview
}
//check again to make sure we're in a sector
ifvarn sv_sect -1 {
//x y z ang horiz sect scrn_x scrn_y scrn_x2 scrn_y2
showview sv_x sv_y sv_z sv_ang sv_horiz sv_sect sv_scrnx1 sv_scrny1 sv_scrnx2 sv_scrny2
}
//display crosshair
addvarvar sv_scrnx1 sv_scrnx2 divvar sv_scrnx1 2
addvarvar sv_scrny1 sv_scrny2 divvar sv_scrny1 2
myos sv_scrnx1 sv_scrny1 CROSSHAIR 0 0
}
endevent