home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Virtual Reality Homebrewer's Handbook
/
vr.iso
/
vroom
/
toyfac.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-03-19
|
15KB
|
507 lines
program toyfac;
uses swoop, swoop_discrete, swoop_vr, vroom, store, cyberman;
var bodystore, wheelstore, paintstore : vbar;
source_car1, source_car2, source_carbody, source_wheel1, source_wheel2, source_carwheel, source_box : file_object3d;
bodyslicemach, wheelslicemach, body_here, wheel_here, worker : resource;
body_stamp, wheel_stamp, arm, body_spray : resource3d;
body_stampb, wheel_stampb, floor : file_object3d;
body_worker, body_worker_box, wheel_worker, wheel_worker_box, crate_worker : file_object3d;
boxslicemachpic, wheelslicemachpic, armb, cratingpic, sprayb, spraypic1, spraypic2 : file_object3d;
s1,s2,dw : process;
b : array[1..37] of process;
w : array[1..45] of process;
bw,ww : array[1..6] of process;
p : array[1..5] of process;
i, c : integer;
t, paint_out, paint_in : real;
paint : statevar;
manual_control, mouse, cyberm : boolean;
{$F+}
procedure Calculate;
begin
if paint.state>15 then paint_in:=0;
if not(manual_control) and (paint.state<2) then paint_in:=1;
paint.dot:=-paint_out+paint_in;
end;
procedure Update_Screen;
var junk1 : boolean;
begin
if abs(paintstore.value-(paint.state-1))>0.1 then paintstore.update(paint.state-1);
if mouse then junk1:=Mouse_Check;
if cyberm then junk1:=Cyberman_Check;
junk1:=KeyBoard_Check;
redraw_scene;
end;
function My_KeyCheck(key : char) : boolean;
var f : text;
begin
if (key='t') and manual_control then if paint_in>0 then paint_in:=0 else paint_in:=2;
if key='m' then manual_control:=not(manual_control);
end;
procedure wheel_to_stamp;
var temppic : object3d_ptr;
begin
simulation.thisentity^.ChangeTime(simulation.TIME+8);
temppic:=simulation.thisentity^.picture;
temppic^.MoveTo(85,80,0);
temppic^.Timed_MoveTo(85,95,0,now,2);
temppic^.Timed_RotateZ_About(-90,105,95,0,now+2,5);
end;
procedure body_stamp_proc(f_ob,b_ob : object3d_ptr);
begin
b_ob^.Timed_Translate(0,0,-40,now,2.5);
b_ob^.Timed_Translate(0,0,40,now+2.5,2.5);
end;
procedure wheel_stamp_proc(f_ob,b_ob : object3d_ptr);
begin
b_ob^.Timed_Translate(0,0,-40,now,2);
b_ob^.Timed_Translate(0,0,40,now+2,2);
end;
procedure seize_arm_proc(f_ob,b_ob : object3d_ptr);
begin
b_ob^.Timed_RotateZ(180,now,2);
b_ob^.Timed_RotateZ(-180,now+2,2)
end;
procedure body_worker_in;
begin
simulation.thisentity^.ChangeTime(simulation.TIME+30);
body_worker.Show;
body_worker_box.Show;
body_worker.Timed_MoveTo(35,-16,0,now,30);
end;
procedure add_body_to_store;
var n : integer;
temp : entityptr;
begin
simulation.thisentity^.ChangeTime(simulation.TIME+3);
n:=random(5)+5;
for i:=1 to n do temp:=new(entityptr,Init(simulation.time,b[1]));
bodystore.Update(bodystore.value+n);
body_worker_box.Hide;
end;
procedure body_worker_out;
begin
simulation.thisentity^.ChangeTime(simulation.TIME+30);
body_worker.Timed_RotateZ(180,now,3);
body_worker.Timed_MoveTo(35,-300,0,now+3,27);
end;
procedure body_worker_hide;
begin
body_worker.RotateZ(180);
body_worker.Hide;
end;
procedure shrink_body_store;
begin
bodystore.update(bodystore.value-1);
end;
procedure wheel_worker_in;
begin
simulation.thisentity^.ChangeTime(simulation.TIME+30);
wheel_worker.Show;
wheel_worker_box.Show;
wheel_worker.Timed_MoveTo(85,-10,0,now,30);
end;
procedure add_wheel_to_store;
var n,i : integer;
temp : entityptr;
begin
simulation.thisentity^.ChangeTime(simulation.TIME+3);
n:=(random(5)+5)*2;
for i:=1 to n do temp:=new(entityptr,Init(simulation.time,w[1]));
wheelstore.Update(wheelstore.value+n);
wheel_worker_box.Hide;
end;
procedure wheel_worker_out;
begin
simulation.thisentity^.ChangeTime(simulation.TIME+30);
wheel_worker.Timed_RotateZ(180,now,3);
wheel_worker.Timed_MoveTo(85,-300,0,now+3,27);
end;
procedure wheel_worker_hide;
begin
wheel_worker.RotateZ(180);
wheel_worker.Hide;
end;
procedure shrink_wheel_store;
begin
wheelstore.update(wheelstore.value-1);
end;
procedure crate_to_worker;
var temppic : object3d_ptr;
begin
simulation.thisentity^.ChangeTime(simulation.TIME+5);
temppic:=simulation.thisentity^.picture;
temppic^.Timed_RotateZ_About(90,240,40,0,now,5);
end;
procedure crate_worker_away;
var t : real;
begin
crate_worker.Timed_RotateZ(180,now,3);
t:=normal(50,10,0);
crate_worker.Timed_MoveTo(240,-1000,0,now+3,t);
simulation.thisentity^.ChangeTime(simulation.TIME+3+t);
end;
procedure crate_worker_back;
var t : real;
begin
crate_worker.RotateZ(180);
t:=normal(50,10,0);
crate_worker.Timed_MoveTo(240,-3.5,0,now,t);
simulation.thisentity^.ChangeTime(simulation.TIME+t);
end;
procedure start_spray;
begin
paint_out:=0.1;
end;
procedure stop_spray;
begin
paint_out:=0;
end;
procedure no_paint;
begin
body_spray.first_resource_item^.screen_position^.busypic:=nil;
end;
procedure paint_again;
begin
body_spray.first_resource_item^.screen_position^.busypic:=@sprayb;
end;
{$F-}
begin
cyberm:=false;
mouse:=false;
if Cyberman_Available then
begin
writeln('Cyberman found');
cyberm:=true;
end
else
if mouse_available then
begin
writeln('Mouse found');
mouse:=true;
end;
simulation.Init;
init_system;
set_for_swoop;
graphics_time:=@simulation.time;
Set_Ambient_Intensity(0.5);
Set_Light(0.75,0,-1,-0.75);
Set_View(-700,1500,350,119.5,-12,0);
Store_Settings;
Set_View(140,80,2000,-90,-90,0);
Set_Window(-20,-15,20,15);
User_KeyCheck_Proc(My_KeyCheck);
simulation.Continuous(0.1,0.1,0,Calculate);
simulation.Integrate_Method(Euler);
simulation.Run_Time(Update_Screen);
s1:=create(constant,0.1,0,0,1);
s2:=delay(constant,0.1,0,0);
s1^.Link(s2);
s2^.Link(s2);
manual_control:=false;
source_car1.Init('car1.3d');
source_car1.Set_Reference_Point(5.5,7.5,0);
source_car1.Hide;
source_car2.Init('car2.3d');
source_car2.Set_Reference_Point(5.5,2.5,0);
source_car2.Hide;
source_carbody.Init('carbody.3d');
source_carbody.Set_Reference_Point(0.725,1.8,0);
source_carbody.RotateZ(90);
source_carbody.Hide;
source_wheel1.Init('carw1.3d');
source_wheel1.Set_Reference_Point(-0.725,-1.5,0);
source_wheel1.Hide;
source_wheel2.Init('carw2.3d');
source_wheel2.Set_Reference_Point(-0.725,-1.5,0);
source_wheel2.Hide;
source_carwheel.Init('carwheel.3d');
source_carwheel.Set_Reference_Point(0.725,1.5,0);
source_carwheel.RotateZ(90);
source_carwheel.Hide;
source_box.Init('box.3d');
source_box.Set_Reference_Point(5,5,0);
source_box.Change_Colour(5,1);
source_box.Scale(0.5,0.5,0.5);
source_box.Hide;
body_stampb.Init('Hex1.3d');
body_stampb.Scale(2,2,2);
body_stampb.RotateX(-90);
wheel_stampb.Init('Hex1.3d');
wheel_stampb.Scale(1.5,1.5,1.5);
wheel_stampb.RotateX(-90);
armb.Init('Arm.3d');
armb.Scale(0.8,0.8,0.8);
armb.RotateZ(90);
bodyslicemach.Set_Capacity(1);
wheelslicemach.Set_Capacity(1);
body_stamp.Set_Capacity(1);
body_stamp.Add_Position(90,155,40,@body_stampb,@body_stampb);
sprayb.Init('spray.3d');
body_stamp.Add_Seize_Procedure(body_stamp_proc);
body_spray.Set_Capacity(1);
body_spray.Add_Position(135,160,2.5,nil,@sprayb);
body_here.Set_Capacity(0);
arm.Set_Capacity(1);
arm.Add_Position(165,135,-25,@armb,@armb);
arm.Add_Seize_Procedure(seize_arm_proc);
wheel_stamp.Set_Capacity(1);
wheel_stamp.Add_Position(115,115,40,@wheel_stampb,@wheel_stampb);
wheel_stamp.Add_Seize_Procedure(wheel_stamp_proc);
wheel_here.Set_Capacity(1);
worker.Set_Capacity(1);
boxslicemachpic.Init('box.3d');
boxslicemachpic.Set_Reference_Point(5,5,0);
boxslicemachpic.Scale(1.7,1.5,1);
boxslicemachpic.Change_Colour(10,1);
boxslicemachpic.MoveTo(35,100,-0.1);
wheelslicemachpic.Init('box.3d');
wheelslicemachpic.Set_Reference_Point(5,5,0);
wheelslicemachpic.Scale(0.5,0.7,0.5);
wheelslicemachpic.Change_Colour(10,1);
wheelslicemachpic.MoveTo(85,80,-0.1);
cratingpic.Init('box.3d');
cratingpic.Set_Reference_Point(5,5,0);
cratingpic.Change_Colour(12,1);
cratingpic.MoveTo(200,115,0);
spraypic1.Init('box.3d');
spraypic1.Set_Reference_Point(5,5,0);
spraypic1.Change_Colour(9,1);
spraypic1.Scale(0.75,0.5,0.5);
spraypic1.MoveTo(135,162.5,0);
spraypic2.Init('box.3d');
spraypic2.Set_Reference_Point(5,5,0);
spraypic2.Change_Colour(9,1);
spraypic2.Scale(0.75,0.5,0.5);
spraypic2.MoveTo(135,147.5,0);
body_worker.Init('worker.3d');
body_worker.Set_Reference_Point(-1,0,6);
body_worker.MoveTo(35,-300,0);
body_worker.RotateZ(90);
body_worker.Hide;
body_worker_box.Init('Box.3d');
body_worker_box.Change_Colour(0,1);
body_worker_box.Set_Reference_Point(5,5,5);
body_worker_box.Scale(1.1,1.5,0.5);
body_worker.AddChild(@body_worker_box);
body_worker_box.MoveTo(35,-291.5,2.5);
body_worker_box.Hide;
wheel_worker.Init('worker.3d');
wheel_worker.Set_Reference_Point(-1,0,6);
wheel_worker.MoveTo(85,-300,0);
wheel_worker.RotateZ(90);
wheel_worker.Hide;
wheel_worker_box.Init('Box.3d');
wheel_worker_box.Change_Colour(4,1);
wheel_worker_box.Set_Reference_Point(5,5,5);
wheel_worker_box.Scale(0.15,0.3,0.2);
wheel_worker.AddChild(@wheel_worker_box);
wheel_worker_box.MoveTo(85,-296,2.5);
wheel_worker_box.Hide;
crate_worker.Init('worker.3d');
crate_worker.Set_Reference_Point(-1,0,6);
crate_worker.MoveTo(240,-3.5,0);
crate_worker.RotateZ(90);
bodystore.Init(0.5);
bodystore.Update(0);
wheelstore.Init(0.5);
wheelstore.Update(0);
paintstore.Init(1);
paintstore.Change_Colour(1,1);
paint.Initial_Value(10);
paint.dot:=0;
paint_out:=0;
paint_in:=0;
paintstore.Update(paint.state-1);
bodystore.moveTo(35,15,0);
wheelstore.moveto(85,15,0);
paintstore.Scale(0.5,0.5,1);
paintstore.moveto(135,180,0);
bw[1]:=create(uniform,60,120,0,1);
bw[2]:=userproc(body_worker_in);
bw[3]:=userproc(add_body_to_store);
bw[4]:=userproc(body_worker_out);
bw[5]:=userproc(body_worker_hide);
bw[6]:=delay(uniform,150,250,0);
ww[1]:=create(uniform,0,60,0,1);
ww[2]:=userproc(wheel_worker_in);
ww[3]:=userproc(add_wheel_to_store);
ww[4]:=userproc(wheel_worker_out);
ww[5]:=userproc(wheel_worker_hide);
ww[6]:=delay(uniform,100,130,0);
b[1]:=seize(@bodyslicemach,infinity,1);
b[2]:=userproc(shrink_body_store);
b[3]:=copy_picture3d(@source_car1);
b[4]:=route3d(constant,5,0,0,35,37.5,0,35,100,0);
b[5]:=destroy_picture3d;
b[6]:=delay(constant,5,0,0);
b[7]:=replicate;
b[8]:=delay(constant,5,0,0);
b[9]:=replicate;
b[10]:=delay(constant,5,0,0);
b[11]:=release(@bodyslicemach);
b[12]:=copy_picture3d(@source_car2);
b[13]:=route3d(constant,5,0,0,35,100,0,35,155,0);
b[14]:=route3d(constant,4,0,0,35,155,0,70,155,0);
b[15]:=drawn_seize3d(@body_stamp,infinity,1,70,155,0,70,255,0);
b[16]:=route3d(constant,2.5,0,0,70,155,0,90,155,0);
b[17]:=destroy_picture3d;
b[18]:=copy_picture3d(@source_carbody);
b[19]:=route3d(constant,2.5,0,0,90,155,0,120,155,0);
b[20]:=release(@body_stamp);
b[21]:=drawn_seize3d(@body_spray,infinity,1,120,155,0,120,255,0);
b[22]:=userproc(start_spray);
b[23]:=route3d(constant,2.5,0,0,120,155,0,135,155,0);
b[24]:=change_picture3d_colour(1,1);
b[25]:=route3d(constant,5,0,0,135,155,0,165,155,0);
b[26]:=release(@body_spray);
b[27]:=userproc(stop_spray);
b[28]:=drawn_seize3d(@body_here,infinity,1,165,155,0,165,255,0);
b[29]:=decrease_capacity(@body_here);
b[30]:=seize(@arm,infinity,1);
b[31]:=delay(constant,2,0,0);
b[32]:=translate_picture3d(0,0,0.6);
b[33]:=Add_As_Child_To(@armb);
b[34]:=delay(constant,2,0,0);
b[35]:=Remove_As_Child_From(@armb);
b[36]:=release(@arm);
b[37]:=release(@body_here);
w[1]:=seize(@wheelslicemach,infinity,1);
w[2]:=userproc(shrink_wheel_store);
w[3]:=copy_picture3d(@source_wheel1);
w[4]:=route3d(constant,5,0,0,85,37.5,0,85,80,0);
w[5]:=destroy_picture3d;
w[6]:=delay(constant,5,0,0);
w[7]:=copy_picture3d(@source_wheel2);
w[8]:=release(@wheelslicemach);
w[9]:=userproc(wheel_to_stamp);
w[10]:=drawn_seize3d(@wheel_stamp,infinity,1,105,115,0,105,15,0);
w[11]:=route3d(constant,2,0,0,105,115,0,115,115,0);
w[12]:=destroy_picture3d;
w[13]:=copy_picture3d(@source_carwheel);
w[14]:=route3d(constant,2,0,0,115,115,0,125,115,0);
w[15]:=release(@wheel_stamp);
w[16]:=route3d(constant,5,0,0,125,115,0,150,115,0);
w[17]:=drawn_seize3d(@wheel_here,infinity,1,150,115,0,150,15,0);
w[18]:=route3d(constant,5,0,0,150,115,0,165,115,0);
w[19]:=increase_capacity(@body_here);
w[20]:=group3d;
w[21]:=route3d(constant,2,0,0,165,115,0,180,115,0);
w[22]:=release(@wheel_here);
w[23]:=route3d(constant,5,0,0,180,115,0,200,115,0);
w[24]:=split3d;
w[25]:=destroy_picture3d;
w[26]:=group;
w[27]:=group;
w[28]:=group;
w[29]:=split;
w[30]:=split;
w[31]:=split;
w[32]:=split;
w[33]:=split;
w[34]:=split;
w[35]:=split;
w[36]:=copy_picture3d(@source_box);
w[37]:=route3d(constant,5,0,0,200,115,0,200,40,0);
w[38]:=userproc(crate_to_worker);
w[39]:=drawn_seize3d(@worker,infinity,1,240,0,0,240,150,0);
w[40]:=Add_As_Child_To(@crate_worker);
w[41]:=userproc(crate_worker_away);
w[42]:=Remove_As_Child_From(@crate_worker);
w[43]:=destroy_picture3d;
w[44]:=userproc(crate_worker_back);
w[45]:=release(@worker);
p[1]:=create(constant,0,0,0,1);
p[2]:=delay_until(@paint.state,lt,0.8,0.1,2);
p[3]:=decrease_capacity(@body_spray);
p[4]:=delay_until(@paint.state,gt,5,0.1,2);
p[5]:=increase_capacity(@body_spray);
dw:=destroy_picture3d;
for i:=1 to 36 do b[i]^.Link(b[i+1]);
for i:=1 to 44 do w[i]^.Link(w[i+1]);
for i:=1 to 5 do bw[i]^.Link(bw[i+1]);
for i:=1 to 5 do ww[i]^.Link(ww[i+1]);
for i:=1 to 4 do p[i]^.Link(p[i+1]);
b[7]^.Link2(b[12]);
b[9]^.Link2(b[12]);
w[24]^.Link2(dw);
b[37]^.Link(w[20]);
bw[6]^.Link(bw[2]);
ww[6]^.Link(ww[2]);
p[5]^.Link(p[1]);
Redraw_Scene;
simulation.Execute(10000);
stop_graphics;
writeln('Simulation finished');
end.