home *** CD-ROM | disk | FTP | other *** search
- /*
- * FILE: ringpict.c
- * AUTHOR: R. Gonzalez
- * CREATED: November 7, 1990
- *
- * Sample pict application. Includes main() function.
- *
- * ASSOCIATED FILES:
- * ringpict.h,class.c,class.h,screen.c,screen.h,,coord.c,coord.h,
- * frame.c,frame.h,color.h,error.c,error.h,trans.c,trans.h,oops.h,
- * camera.c,camera.h,project.c,project.h,segment.c,segment.h,
- * line.c,line.h,cube.c,cube.h,ring.c,ring.h,backdrop.c,
- * backdrop.h,pict.c,pict.h, several ANSI and system-specific
- * headers (used in screen.c and class.c).
- *
- * PROJECT CONTENTS (Think C):
- * above-listed source (.c) files, MacTraps, ANSI or ANSI-881,
- * oops library.
- *
- * COMPILATION (Think C):
- * 68881 code generation if ANSI-881 is used.
- */
-
- # include "ringpict.h"
- # include "ring.h"
-
- /******************************************************************
- * initialize
- ******************************************************************/
- boolean Ring_Pict::init(void)
- {
- Rotation_X *rotx;
- Translation *transl;
- Transformation *combination;
-
- Generic_Pict::init();
-
- projector1 = new(Projector);
- projector1->init();
- projector1->set_background_color(BLUE);
- projector1->set_cropping_frame(0.,-.05,1.,.5);
- projector1->set_projection_frame(-.2,0.,1.4,.7);
-
- projector2 = new(Corner_Projector);
- projector2->init();
-
- projector3 = new(Projector);
- projector3->init();
- projector3->set_background_color(YELLOW);
- projector3->set_cropping_frame(0.,-.05,1.,.5);
- projector3->set_projection_frame(.8,.15,.3,.8);
-
- projector1->set_screen(screen);
- projector2->set_screen(screen);
- projector3->set_screen(screen);
-
- camera1 = new(Camera);
- camera1->init();
- camera2 = new(Camera);
- camera2->init();
- camera2->set_position(0.,10.,10.,0.,PI/2.,0.);
-
- rotx = new(Rotation_X);
- rotx->init();
- rotx->set(-PI/12.);
- transl = new(Translation);
- transl->init();
- transl->set(0.,0.,10.);
- combination = new(Transformation);
- combination->init();
- combination->combine(rotx,transl);
-
- segment = new(Ring);
- segment->init();
- segment->move(combination);
-
- rotx->destroy();
- delete(rotx);
- transl->destroy();
- delete(transl);
- combination->destroy();
- delete(combination);
-
- return TRUE;
- }
-
- /******************************************************************
- * run
- ******************************************************************/
- void Ring_Pict::run(void)
- {
- Transformation *identity;
-
- identity = new(Transformation);
- identity->init();
-
- segment->set_color(CYAN);
- segment->draw(camera1,projector1,identity);
- segment->set_color(GREEN);
- segment->draw(camera2,projector2,identity);
- segment->set_color(RED);
- segment->draw(camera1,projector3,identity);
-
- screen->wait();
-
- identity->destroy();
- delete(identity);
- }
-
- /******************************************************************
- * destroy
- ******************************************************************/
- boolean Ring_Pict::destroy(void)
- {
- projector1->destroy();
- delete(projector1);
- projector2->destroy();
- delete(projector2);
- projector3->destroy();
- delete(projector3);
-
- camera1->destroy();
- delete(camera1);
- camera2->destroy();
- delete(camera2);
-
- segment->destroy();
- delete(segment);
-
- return Generic_Pict::destroy();
- }
-
- /******************************************************************
- * main function
- ******************************************************************/
- main()
- {
- Generic_Pict *pict;
-
- pict = new(Ring_Pict);
- pict->init();
- pict->run();
- pict->destroy();
- delete(pict);
- }
-
-
-