luv

Workshop wiki

surveyor.lisp

mcclim/surveyor.lisp

system luvcraft/mcclim · 15 definitions · on GitHub

A compact terrain instrument whose state is sampled from a live luvcraft session and whose presentation is ordinary McCLIM drawing and gadgets.

in-package#:mcluv
defclasssurveyor-map-snapshot
center-x:initarg:center-x:readersurveyor-snapshot-center-x
center-z:initarg:center-z:readersurveyor-snapshot-center-z
width:initarg:width:readersurveyor-snapshot-width
depth:initarg:depth:readersurveyor-snapshot-depth
heights:initarg:heights:readersurveyor-snapshot-heights
materials:initarg:materials:readersurveyor-snapshot-materials
lights:initarg:lights:readersurveyor-snapshot-lights
minimum-height:initarg:minimum-height:readersurveyor-snapshot-minimum-height
maximum-height:initarg:maximum-height:readersurveyor-snapshot-maximum-height
defunsurveyor-snapshot-offset
snapshotcolumnrow
+column
*row
surveyor-snapshot-widthsnapshot
defunsurveyor-generated-surface
worldsourcexz
if
let*
multiple-value-bind
residentstatus
valuesheight
if
and
eqstatus:resident
resident
residentgenerated
loopforyfrom31downto0do
multiple-value-bind
blockstatus
when
and
eqstatus:resident
block
return
valuesyblock
finally
return
values0nil
defuncapture-surveyor-map-snapshot
session&key
depth28

Capture one dense inspector-scale terrain product around session's player.

let*
world
luvcraft:luvcraft-session-worldsession
source
luvcraft:block-world-sourceworld
player
luvcraft:luvcraft-session-playersession
count
*widthdepth
heights
make-arraycount:element-type'
unsigned-byte8
materials
make-arraycount:initial-elementnil
lights
make-arraycount:element-type'
unsigned-byte8
minimum-height255
maximum-height0
dotimes
rowdepth
dotimes
columnwidth
let*
offset
+column
x
+center-xcolumn
z
+center-zrow
-
floordepth2
multiple-value-bind
heightmaterial
multiple-value-bind
skyblockignored-state
declare
ignoreignored-state
setf
arefheightsoffset
height
arefmaterialsoffset
material
areflightsoffset
maxskyblock
minimum-height
minminimum-heightheight
maximum-height
maxmaximum-heightheight
make-instance'surveyor-map-snapshot:center-xcenter-x:center-zcenter-z:widthwidth:depthdepth:heightsheights:materialsmaterials:lightslights:minimum-heightminimum-height:maximum-heightmaximum-height
defclasssurveyor-mode-button-pane
mode:initarg:mode:readersurveyor-button-mode
defmethodhandle-repaint
declare
ignoreregion
with-slots
climi::armedclimi::pressedp
pane
let*
frame
gadget-clientpane
active-p
eq
surveyor-button-modepane
surveyor-map-modeframe
repaint-relief-buttonpane
andclimi::armedclimi::pressedp
ifactive-p
make-rgb-color0.050.680.65
make-rgb-color0.230.270.27
define-application-framesurveyor-map
session:initarg:session:readersurveyor-map-session
snapshot:initarg:snapshot:accessorsurveyor-map-snapshot
mode:initarg:mode:initform:terrain:accessorsurveyor-map-mode
:menu-barnil
:panes
terrain-mode
make-pane'surveyor-mode-button-pane:label"TERRAIN":mode:terrain:activate-callback'activate-surveyor-mode
material-mode
make-pane'surveyor-mode-button-pane:label"MATERIAL":mode:material:activate-callback'activate-surveyor-mode
light-mode
make-pane'surveyor-mode-button-pane:label"LIGHT":mode:light:activate-callback'activate-surveyor-mode
height-mode
make-pane'surveyor-mode-button-pane:label"HEIGHT":mode:height:activate-callback'activate-surveyor-mode
map:application:display-function'display-surveyor-map:scroll-barsnil
details:application:display-function'display-surveyor-details:scroll-barsnil
refresh
make-pane'relief-button-pane:label"SURVEY":activate-callback'refresh-surveyor-map
:layouts
default
vertically
:width760:height520:spacing8
1/8
horizontally
:spacing8
terrain-modematerial-modelight-modeheight-mode
7/8
horizontally
:spacing10
3/4map
1/4
vertically
:spacing10
4/5details
1/5refresh
defunactivate-surveyor-mode
gadget
let
frame
gadget-clientgadget
setf
surveyor-map-modeframe
surveyor-button-modegadget
redisplay-frame-panesframe:force-pt
defunrefresh-surveyor-map
gadget
let
frame
gadget-clientgadget
redisplay-frame-panesframe:force-pt
defunsurveyor-material-color
material
ifmaterial
luvcraft:block-kind-display-colormaterial
'
0.080.120.14
defunsurveyor-cell-color
snapshotoffsetmode
let*
height
aref
surveyor-snapshot-heightssnapshot
offset
minimum
surveyor-snapshot-minimum-heightsnapshot
span
max1
-
surveyor-snapshot-maximum-heightsnapshot
minimum
height-reading
/
-heightminimum
span
material
aref
surveyor-snapshot-materialssnapshot
offset
light
/
aref
surveyor-snapshot-lightssnapshot
offset
15.0
destructuring-bind
redgreenblue
ecasemode
:material
:terrain
let
shade
+0.68
*0.42height-reading
mapcar
lambda
component
min1.0
*componentshade
base
:height
list
+0.10
*0.72height-reading
+0.18
*0.68height-reading
+0.24
*0.52height-reading
:light
list
+0.03
*0.22light
+0.08
*0.72light
+0.10
*0.82light
make-rgb-colorredgreenblue
defundisplay-surveyor-map
framestream
let
with-bounding-rectangle*
lefttoprightbottom
stream
draw-rectangle*streamlefttoprightbottom:ink
make-rgb-color0.0450.0650.07
let*
margin12
map-left
+leftmargin
map-top
+topmargin
map-right
-rightmargin
map-bottom
-bottommargin
cell-width
/
-map-rightmap-left
surveyor-snapshot-widthsnapshot
cell-height
/
-map-bottommap-top
surveyor-snapshot-depthsnapshot
dotimes
row
surveyor-snapshot-depthsnapshot
dotimes
column
surveyor-snapshot-widthsnapshot
let
x1
+map-left
*columncell-width
y1
+map-top
*rowcell-height
draw-rectangle*streamx1y1
+x1cell-width0.5
+y1cell-height0.5
:ink
surveyor-cell-colorsnapshot
surveyor-snapshot-offsetsnapshotcolumnrow
surveyor-map-modeframe
loopforcolumnfrom0to
surveyor-snapshot-widthsnapshot
by5forx=
+map-left
*columncell-width
do
draw-line*streamxmap-topxmap-bottom:ink
make-rgb-color0.100.580.60
loopforrowfrom0to
surveyor-snapshot-depthsnapshot
by5fory=
+map-top
*rowcell-height
do
draw-line*streammap-leftymap-righty:ink
make-rgb-color0.100.580.60
let
center-x
/
+map-leftmap-right
2
center-y
/
+map-topmap-bottom
2
draw-circle*streamcenter-xcenter-y10:fillednil:line-thickness3:ink
make-rgb-color0.900.980.92
draw-line*stream
-center-x17
center-y
+center-x17
center-y:line-thickness2:ink
make-rgb-color0.900.980.92
draw-line*streamcenter-x
-center-y17
center-x
+center-y17
:line-thickness2:ink
make-rgb-color0.900.980.92
defundisplay-surveyor-details
framestream
let*
session
surveyor-map-sessionframe
player
luvcraft:luvcraft-session-playersession
with-bounding-rectangle*
lefttoprightbottom
stream
draw-rectangle*streamlefttoprightbottom:ink
make-rgb-color0.0650.080.085
draw-text*stream"SURVEYOR"
+left18
+top34
:text-size20:ink
make-rgb-color0.200.900.87
loopfortextin
list
formatnil"X ~D"x
formatnil"Y ~D"y
formatnil"Z ~D"z
formatnil"MODE ~A"
surveyor-map-modeframe
formatnil"SPAN ~D x ~D"
surveyor-snapshot-widthsnapshot
surveyor-snapshot-depthsnapshot
formatnil"HEIGHT ~D..~D"
surveyor-snapshot-minimum-heightsnapshot
surveyor-snapshot-maximum-heightsnapshot
forlinefrom0do
draw-text*streamtext
+left18
+top76
*line29
:text-size15:ink
make-rgb-color0.860.900.88
draw-text*stream"live terrain product"
+left18
-bottom24
:text-size12:ink
make-rgb-color0.480.580.57
defunopen-surveyor-map
session&key
server-path'
:luv-gpu
title"surveyor map"
targetcontextdevice

Create and enable a surveyor instrument sampled from session.

when
andtarget
error":TARGET requires the shared :CONTEXT and :DEVICE."
let*
port
find-port:server-pathserver-path
manager
or
first
climi::frame-managersport
make-instance'luv-frame-manager:portport
frame
let
make-application-frame'surveyor-map:frame-managermanager:enablet:sessionsession:snapshot
setf
frame-pretty-nameframe
title
frame
defunclose-surveyor-map
unless
eq:disowned
frame-stateframe
destroy-frameframe
nil