#!/bin/sh
#\
exec ${GOOD_ROOT_DIR}/bin/vr_scene $0 $*

# LAST EDIT: Wed Nov 30 18:12:52 1994 by ekki(@prakinf.tu-ilmenau.de)

VR_position { 0 0 20}

VR_msg {You're now in front of a labyrinth. Try to pick other guys. Note: some of the things are solid.}

Tcl_Primitive Block {} {wi no} {n w c} {String Double Color} {Create a new block {ARG 1 object} with specified {ARG 2 Width} and {ARG 3 Color}. } {
    set $THIS->wi $w
    set $THIS->no 0

    $THIS -ambient $c -diffuse $c -pickmode 2
    set w2 [expr $w*0.5]
    Polyline $THIS.pl 5 "{-$w2 3 0} {$w2 3 0} {$w2 0 0} {-$w2 0 0} {-$w2 3 0}" {} {}
    $THIS.pl -father $THIS -gnormal { 0 0 1} -pickmode 2
}

Tcl_Method Block -solid {fr to} {Double Double} {Create a solid block from {ARG 1 y1} to {ARG 2 y2}. y1 must be greater y2} {
    set no [incr $THIS->no]
    set w2 [expr [set $THIS->wi]*0.5]

    Polygon $THIS.po$no 4 "{-$w2 $fr 0} {$w2 $fr 0} {$w2 $to 0} {-$w2 $to 0} " {} {}
    $THIS.po$no -father $THIS -gnormal { 0 0 1} -pickmode 2
}  

sc -insert [Top w1]

[Block w1.1 3 {1 0 1}] -father w1 -translate {-8.5 0 10}
w1.1 -solid 3 2
w1.1 -solid 2 1.1
[Block w1.2 2 {0 1 0.4}] -father w1 -translate {-6 0 10} 
w1.2 -solid 2.9 0
[Block w1.3 4.5 {0 0 1}] -father w1 -translate {-2.75 0 10} 
[Block w1.4 3.5 {1 1 0.4}] -father w1 -translate {1.25 0 10} 
w1.4 -solid 3 0
[Block w1.5 7 {0.1 0.1 0.1}] -father w1 -translate {6.5 0 10} 

sc -insert [Top w2]

[Block w2.1 1 {1 0 0 }] -father w2 -translate {-9.5 0 7}  
w2.1 -solid 2.5 1
w2.1 -solid 1 0.5
[Block w2.2 2 {0.5 0.4 0 }] -father w2 -translate {-4 0 7}  
w2.2 -solid 3 2
[Block w2.3 4 {1 1 0.5 }] -father w2 -translate {-1 0 7}  
w2.3 -solid 2 1
[Block w2.4 6.4 {0.2 1 0.5 }] -father w2 -translate {6.8 0 7}  
w2.4 -solid 1.3 0

sc -insert [Top w3]

[Block w3.1 3.5 {0.4 0.4 0 }] -father w3 -translate {-8.25 0 4}  
[Block w3.2 4.5 {1 0 0.2}] -father w3 -translate {-4.25 0 4}  
w3.2 -solid 3 2
[Block w3.3 8 {0 1 0}] -father w3 -translate {2 0 4}  
w3.3 -solid 1.5 0
[Block w3.4 4 {0 1 1}] -father w3 -translate {8 0 4}  
w3.4 -solid 3 1.5

foreach o [sc -get_objects] {
    if [$o -isA Primitive] { $o -fillstyle 0}
}

proc VR_pick {uid obj} {
    set puid [VR_getIDOfPrimitive $obj]
    if {$puid == ""} {
	VR_sendText2user $uid "You picked the wall."
	return
    }
    if {$uid == $puid} return	
    VR_sendText2user $uid "Yeah! You picked [VR_getUserByID $puid]!"
    VR_sendText2user $puid "Dammned! You were by picked [VR_getUserByID $uid]!"
}
