home *** CD-ROM | disk | FTP | other *** search
/ Altsys Virtuoso 2.0K / virtuoso_20k.iso / DemoApps / Graphics / 2D_3D / Tester3D / Source / TesterApp.m < prev    next >
Encoding:
Text File  |  1990-07-18  |  1.9 KB  |  87 lines

  1. /* TesterApp.m */
  2.  
  3. #import "TesterApp.h"
  4. #import "Cube.h"
  5. #import "Context3D.h"
  6. #import "Linear3D.h"
  7. #import <objc/List.h>
  8.  
  9. @implementation TesterApp
  10.  
  11. - setTheContext:anObject
  12. {
  13.     int ctr;
  14.     id newCube,transform,temptransform;
  15.     NXRect bounds;
  16.     
  17.     theContext = anObject;
  18.     
  19.    
  20.    [theContext getBounds:&bounds];
  21.    [theContext setDrawOrigin:-bounds.size.width/2.0:-bounds.size.height/2.0];
  22.    
  23.    temptransform=[Linear3D new];
  24.    for(ctr=0;ctr<4;++ctr) {
  25.           newCube=[Cube new];
  26.        transform=[Linear3D new];
  27.     
  28.        [transform scaling:5.0:5.0:5.0];
  29.        [temptransform translation:ctr * 3.5: ctr * 5.5
  30.            : - ctr * 10.0];  
  31.         [transform concatBefore:temptransform];
  32.         
  33.         [newCube setTransformation:transform];
  34.         [[theContext contentView] addSubView:newCube];
  35.     }
  36.     transform=[Linear3D new];
  37.     [transform translation:0.0: 0.0 : -40.0];
  38.     [[theContext contentView] setTransformation:transform];
  39.     [temptransform free];
  40.    return self;
  41. }
  42.  
  43.  
  44. - rotateCubes:sender
  45. {
  46.     unsigned ctr,count;
  47.     id transform,theViewList;
  48.     theViewList=[[theContext contentView] subviews];
  49.     count=[theViewList count];
  50.     transform=[Linear3D new];
  51.     for(ctr=0;ctr<count;++ctr) {
  52.         [transform rotation:L3D_X_AXIS:(float)(ctr+1)];
  53.         [[[theViewList objectAt:ctr] transformation] concatAfter:transform];
  54.     }
  55.     for(ctr=0;ctr<count;++ctr) {
  56.         [transform rotation:L3D_Y_AXIS:(float)(ctr+1)*2.0];
  57.         [[[theViewList objectAt:ctr] transformation] concatAfter:transform];
  58.     }
  59.     [transform free];
  60.     [[theContext window] display];
  61.     return self;
  62. }
  63.  
  64. - closer:sender
  65. {
  66.     id transform;
  67.     transform=[Linear3D new];
  68.     [transform translation:0.0: 0.0 : 1.0];
  69.     [[[theContext contentView] transformation] concatBefore:transform];
  70.     [transform free];
  71.     [[theContext window] display];
  72.     return self;
  73. }
  74.  
  75. - farther:sender
  76. {
  77.     id transform;
  78.     transform=[Linear3D new];
  79.     [transform translation:0.0: 0.0 : -1.0];
  80.     [[[theContext contentView] transformation] concatBefore:transform];
  81.     [transform free];
  82.     [[theContext window] display];
  83.     return self;
  84. }
  85.  
  86. @end
  87.