home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Virtual Reality Zone
/
VRZONE.ISO
/
mac
/
PC
/
MISC3D
/
EEDEMO
/
TEST3.BOB
< prev
next >
Wrap
Text File
|
1993-08-13
|
2KB
|
143 lines
class Task //the base task class
{
tsk;
nframes;
obj;
func;
period;
}
Task::Task( ob, fn, per )
{
nframes = 0;
tsk = 0;
obj = ob;
func = fn;
period = per;
return this;
}
Task::Start()
{
if( !tsk )
tsk = ScheduleTask( this, obj, func, period );
}
Task::Kill()
{
if( tsk ) {
DeleteTask( tsk );
tsk = 0;
}
}
class c6 : Task
{
x; y; z;
}
c6::c6( obj, fn, p )
{
x = -50;
Task(obj, fn, p);
return this;
}
c6::spinner()
{
Rotate( 0, 15, 0 );
if( nframes++ == 30 ) {
Kill();
func = "mover";
period = 30;
Start();
nframes = 0;
}
}
c6::mover()
{
if(nframes++ == 100) {
Kill();
func = "spinner";
Start();
x *= -1;
nframes = 0;
}
Move( x, 0, 0 );
}
moveit() //the variables used in this function are globals
{ //which were created in main()
if((nFrame % 30) == 0)
dy *= -1;
if((nFrame++ % 20) == 0)
dx *= -1;
Move( dx, dy, dz );
}
spinner()
{
Rotate( 0, -15, 0 );
}
class Vmove : Task
{
xo, cmcnt, cdx;
}
Vmove::Vmove(obj, fn, p)
{
xo = 0;
cdx = 400;
Task( obj, fn,p );
return this;
}
Vmove::turn(angle;a,i,n)
{
a=3;
n = angle/a;
if (n<0) n *= -1; //watch out for neg angles
for( i=0; i<n; i++ ) {
TurnCamera( 0, a, 0 );
EventLoop(); //refresh display and collect user input
}
}
Vmove::move(;area)
{
if( nframes++ == 60)
Kill();
if( (xo < 4500) && (xo > -5500) ) {
MoveCamera(cdx,0,0);
xo += cdx;
}
else {
turn(180);
//cdx *= -1;
area = GetArea(); //a little test
PopMsg(area);
GetKey();
xo = 0;
}
}
main(;conetsk,cmtsk)
{
// Global Variables
dx = 60;
dy = 10;
dz = 0;
nFrame = 0;
// call ScheduleTask with 0 as first parameter when you use
// a normal function instead of a class object.
conetsk = ScheduleTask(0,"cone1", "moveit", 80);
cmtsk = ScheduleTask(0,"mh", "spinner", 10);
// c6tsk is an instance of the c6 class, which inherits from Task...
c6tsk = new c6("c6", "spinner", 50);
// if your Task doesn't manipulate any objects in space, then pass
// a bogus name, like "null"
vm = new Vmove("null","move",30);
// calls the virtual function from base class Task...
c6tsk->Start();
vm->Start();
}