Changeset 362

Show
Ignore:
Timestamp:
04/08/07 02:10:15 (2 years ago)
Author:
cweider2
Message:

LaserLine: CPU Tick'd generators

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/LaserLine_2.0/Src/MainController.h

    r360 r362  
    2121- (IBAction)addAntiClock:(id)sender; 
    2222- (IBAction)add3DTorus:(id)sender; 
     23- (IBAction)addLissajous:(id)sender; 
     24- (IBAction)addSpirograph:(id)sender; 
    2325- (IBAction)addBeamEffect:(id)sender; 
    2426 
  • trunk/LaserLine_2.0/Src/MainController.m

    r360 r362  
    2525        if(self) { 
    2626                timeline = [[LZTimeline alloc] init]; 
    27                 layer = [[LZLayer alloc] initWithDuration:60]; 
     27                layer = [[LZLayer alloc] initWithDuration:5]; 
    2828                 
    2929                [timeline addTrack:[LZTrack track]]; 
     
    4545        [splitViewTop setColor:[NSColor blackColor]]; 
    4646         
     47        //[self addBeamEffect:self]; 
    4748        //[self addAntiClock:self]; 
    48         //[self add3DTorus:self]; 
    49         //[self addBeamEffect:self]; 
     49        [self add3DTorus:self]; 
     50        [self addLissajous:self]; 
     51        [self addSpirograph:self]; 
     52         
    5053        [[output frameNotificationCenter] addObserver:[[[LZDisplayDevice alloc] initWithView:renderView] autorelease]]; 
    5154} 
     
    9396} 
    9497 
     98- (IBAction)addLissajous:(id)sender { 
     99        [self addGenerator:[LZSinewave class]]; 
     100} 
     101 
     102- (IBAction)addSpirograph:(id)sender { 
     103        [self addGenerator:[LZSpirograph class]]; 
     104} 
     105 
    95106- (IBAction)addBeamEffect:(id)sender { 
    96107        [self addGenerator:[LZBeamEffect class]]; 
     
    99110- (void)addGenerator:(Class)generatorClass 
    100111  { 
    101   [self addSequence:[[[generatorClass alloc] init] autorelease] withLength:60]; 
     112  [self addSequence:[[[generatorClass alloc] init] autorelease] withLength:5]; 
    102113  } 
    103114 
     
    105116- (void)addSequence:(LZSequenceableElement *)sequenceElement withLength:(NSTimeInterval)time 
    106117  { 
    107   [layer insertElement:sequenceElement inTimeRange:LZMakeTimeRange([layer duration], time)]; 
     118  [layer appendElement:sequenceElement withLength:time]; 
    108119  } 
    109120 
  • trunk/LaserLine_2.0/Src/Sequencing/Generators/LZ3DTorus.h

    r339 r362  
    88 
    99#import <Cocoa/Cocoa.h> 
    10 #import <sys/time.h> 
    1110#import <RawTypes.h> 
    1211#import "LZSequenceableElement.h" 
  • trunk/LaserLine_2.0/Src/Sequencing/Generators/LZ3DTorus.m

    r360 r362  
    3232                w = 25; 
    3333                 
    34                 xs = 10
    35                 ys = 31
    36                 zs = 27
     34                xs = 10/35.
     35                ys = 31/35.
     36                zs = 27/35.
    3737        } 
    3838        return self; 
     
    4141- (RawFrame)renderAtPosition:(float)position 
    4242{ 
    43         struct timeval time; 
    44         gettimeofday(&time,NULL); 
    45          
    4643        unsigned pointCount = 500; 
    4744        RawPoint *points = malloc(sizeof(RawPoint)*pointCount); 
    4845        RawFrame frame = {points, pointCount}; 
    4946         
    50         float xrot = (time.tv_sec + time.tv_usec/1000000)/500000000*position * xs; 
    51         float yrot = (time.tv_sec + time.tv_usec/1000000)/500000000*position * ys; 
    52         float zrot = (time.tv_sec + time.tv_usec/1000000)/500000000*position * zs; 
     47        double normTime = (((double)clock())/CLOCKS_PER_SEC) * 2. * 3.141592653589793;  //one rotation per sec 
     48        float xrot = normTime * xs; 
     49        float yrot = normTime * ys; 
     50        float zrot = normTime * zs; 
    5351         
    5452        for (int p = 0 ; p <= pointCount ; p++) 
    5553        { 
    56                 float t = p * 2 * 3.14159/pointCount; 
     54                float t = p * 2 * 3.141592653589793/pointCount; 
    5755                 
    5856                float x0 = A*cosf(t)*(R+r*cosf(w*t)); 
  • trunk/LaserLine_2.0/Src/Sequencing/Generators/LZSinewave.h

    r333 r362  
    88 
    99#import <Cocoa/Cocoa.h> 
    10 #import <sys/time.h> 
    1110#import <RawTypes.h> 
    1211#import "LZSequenceableElement.h" 
  • trunk/LaserLine_2.0/Src/Sequencing/Generators/LZSinewave.m

    r341 r362  
    1717  if(self) 
    1818        { 
    19         freq_x = 1
    20         freq_y = 2.9955
     19        freq_x = 9
     20        freq_y = 8
    2121        } 
    2222  return self; 
     
    2626- (RawFrame)renderAtPosition:(float)position 
    2727  { 
    28   struct timeval time; 
    29   gettimeofday(&time,NULL); 
    30    
    3128  unsigned pointCount = 1000; 
    3229  RawPoint *points = malloc(sizeof(RawPoint)*pointCount); 
    3330  RawFrame frame = {points, pointCount}; 
    3431   
    35   float t = (time.tv_sec + time.tv_usec/1000000)/10000*position
     32  float t = (((double)clock())/CLOCKS_PER_SEC)*10
    3633   
    3734  unsigned i; 
    3835  for(i = 0; i < pointCount; i++) 
    3936        { 
    40         float t_p = (i/(float)pointCount)*2*3.14159*5+t
     37        float t_p = (i/((float)pointCount-1)) * 2. * 3.141592653589793
    4138         
    42         points[i].x = cos(freq_x*t_p)*32767; 
    43         points[i].y = sin(freq_y*t_p)*32767; 
     39        points[i].x = cos(freq_x*(t_p+t))*32767; 
     40        points[i].y = sin(freq_y*(t_p+t))*32767; 
    4441         
    45       points[i].r = 0xFF*i/pointCount; 
    46       points[i].g = 0xFF*i/pointCount; 
    47       points[i].b = 0xFF*i/pointCount; 
     42//    points[i].r = 0xFF*i/pointCount; 
     43//    points[i].g = 0xFF*i/pointCount; 
     44//    points[i].b = 0xFF*i/pointCount; 
    4845         
    49         points[i].r = 0xFF; 
    50         points[i].g = 0xFF; 
    51         points[i].b = 0xFF; 
     46        points[i].r = points[i].g = points[i].b = 0xFF; 
    5247        } 
     48   
     49  points[pointCount-1].r = points[pointCount-1].g = points[pointCount-1].b = 0; 
    5350   
    5451  return frame; 
  • trunk/LaserLine_2.0/Src/Sequencing/Generators/LZSpirograph.h

    r319 r362  
    88 
    99#import <Cocoa/Cocoa.h> 
    10 #import <sys/time.h> 
    1110#import <RawTypes.h> 
    1211#import "LZSequenceableElement.h" 
  • trunk/LaserLine_2.0/Src/Sequencing/Generators/LZSpirograph.m

    r320 r362  
    2727- (RawFrame)renderAtPosition:(float)position 
    2828  { 
    29   struct timeval time; 
    30   gettimeofday(&time,NULL); 
    31    
    3229  unsigned pointCount = 1000; 
    3330  RawPoint *points = malloc(sizeof(RawPoint)*pointCount); 
    3431  RawFrame frame = {points, pointCount}; 
    3532   
    36   float t = (time.tv_sec + time.tv_usec/1000000)/10000*position
     33  float t = (((double)clock())/CLOCKS_PER_SEC)
    3734   
    3835  unsigned i; 
    3936  for(i = 0; i < pointCount; i++) 
    4037        { 
    41         float t_p = (i/(float)pointCount)*2*3.14159*10+t; 
     38        float t_p = (i/((float)pointCount-1))*2*3.14159*10+t; 
    4239         
    4340        points[i].x = ((R+r)*cos(t_p) - (d)*cos((R+r)/r*(t_p)))/(R+r+d)*32767; 
    4441        points[i].y = ((R+r)*sin(t_p) - (d)*sin((R+r)/r*(t_p)))/(R+r+d)*32767; 
    4542         
    46       points[i].r = 0xFF*i/pointCount; 
    47       points[i].g = 0xFF*i/pointCount; 
    48       points[i].b = 0xFF*i/pointCount; 
     43//    points[i].r = 0xFF*i/pointCount; 
     44//    points[i].g = 0xFF*i/pointCount; 
     45//    points[i].b = 0xFF*i/pointCount; 
    4946         
    50 //      points[i].r = 0xFF; 
    51 //      points[i].g = 0xFF; 
    52 //      points[i].b = 0xFF; 
     47        points[i].r = points[i].g = points[i].b = 0xFF; 
    5348        } 
     49   
     50  points[pointCount-1].r = points[pointCount-1].g = points[pointCount-1].b = 0; 
    5451   
    5552  return frame; 
  • trunk/LaserLine_2.0/Src/Sequencing/LZLayer.h

    r360 r362  
    3737- (void)insertElement:(LZSequenceableElement *)element atTime:(NSTimeInterval)start withDuration:(NSTimeInterval)duration; 
    3838- (void)insertElement:(LZSequenceableElement *)element inTimeRange:(LZTimeRange)timeRange; 
     39- (void)appendElement:(LZSequenceableElement *)element withLength:(NSTimeInterval)time; 
    3940 
    4041- (void)removeElement:(LZSequenceableElement *)element; 
  • trunk/LaserLine_2.0/Src/Sequencing/LZLayer.m

    r320 r362  
    131131  } 
    132132 
     133- (void)appendElement:(LZSequenceableElement *)element withLength:(NSTimeInterval)time 
     134  { 
     135  NSTimeInterval start = [self absoluteTimeRangeForSequenceTimeRange:LZMakeTimeRange([layerSequence maxTime], 0)].start; 
     136   
     137  [self insertElement:element atTime:start withDuration:time]; 
     138  } 
     139 
    133140- (void)removeElement:(LZSequenceableElement *)element 
    134141  { 
  • trunk/LaserLine_2.0/Src/Sequencing/LZSequence.m

    r320 r362  
    156156  unsigned index = 0; 
    157157   
    158   //grab index of first element I will insert in front of 
     158  //grab index of the element I will insert in front of 
    159159  while(index < count && [[sequenceTimings objectAtIndex:index] timeRangeValue].start < LZMaxTimeRange(timeRange)) 
    160160        index++; 
    161161   
    162   if(index == count && count != 0) 
    163         return; 
    164   else if(count == 0 || LZMaxTimeRange([[sequenceTimings objectAtIndex:index-1] timeRangeValue]) < timeRange.start) 
     162  if((index == 0     || LZIntersectionTimeRange([[sequenceTimings objectAtIndex:index-1] timeRangeValue], timeRange).duration == 0) &&  
     163         (index == count || LZIntersectionTimeRange([[sequenceTimings objectAtIndex:index  ] timeRangeValue], timeRange).duration == 0)   ) 
    165164        { 
    166165        [sequenceElements insertObject:element atIndex:index];