Changeset 362
- Timestamp:
- 04/08/07 02:10:15 (2 years ago)
- Files:
-
- trunk/LaserLine_2.0/Src/MainController.h (modified) (1 diff)
- trunk/LaserLine_2.0/Src/MainController.m (modified) (5 diffs)
- trunk/LaserLine_2.0/Src/Sequencing/Generators/LZ3DTorus.h (modified) (1 diff)
- trunk/LaserLine_2.0/Src/Sequencing/Generators/LZ3DTorus.m (modified) (2 diffs)
- trunk/LaserLine_2.0/Src/Sequencing/Generators/LZSinewave.h (modified) (1 diff)
- trunk/LaserLine_2.0/Src/Sequencing/Generators/LZSinewave.m (modified) (2 diffs)
- trunk/LaserLine_2.0/Src/Sequencing/Generators/LZSpirograph.h (modified) (1 diff)
- trunk/LaserLine_2.0/Src/Sequencing/Generators/LZSpirograph.m (modified) (1 diff)
- trunk/LaserLine_2.0/Src/Sequencing/LZLayer.h (modified) (1 diff)
- trunk/LaserLine_2.0/Src/Sequencing/LZLayer.m (modified) (1 diff)
- trunk/LaserLine_2.0/Src/Sequencing/LZSequence.m (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/LaserLine_2.0/Src/MainController.h
r360 r362 21 21 - (IBAction)addAntiClock:(id)sender; 22 22 - (IBAction)add3DTorus:(id)sender; 23 - (IBAction)addLissajous:(id)sender; 24 - (IBAction)addSpirograph:(id)sender; 23 25 - (IBAction)addBeamEffect:(id)sender; 24 26 trunk/LaserLine_2.0/Src/MainController.m
r360 r362 25 25 if(self) { 26 26 timeline = [[LZTimeline alloc] init]; 27 layer = [[LZLayer alloc] initWithDuration: 60];27 layer = [[LZLayer alloc] initWithDuration:5]; 28 28 29 29 [timeline addTrack:[LZTrack track]]; … … 45 45 [splitViewTop setColor:[NSColor blackColor]]; 46 46 47 //[self addBeamEffect:self]; 47 48 //[self addAntiClock:self]; 48 //[self add3DTorus:self]; 49 //[self addBeamEffect:self]; 49 [self add3DTorus:self]; 50 [self addLissajous:self]; 51 [self addSpirograph:self]; 52 50 53 [[output frameNotificationCenter] addObserver:[[[LZDisplayDevice alloc] initWithView:renderView] autorelease]]; 51 54 } … … 93 96 } 94 97 98 - (IBAction)addLissajous:(id)sender { 99 [self addGenerator:[LZSinewave class]]; 100 } 101 102 - (IBAction)addSpirograph:(id)sender { 103 [self addGenerator:[LZSpirograph class]]; 104 } 105 95 106 - (IBAction)addBeamEffect:(id)sender { 96 107 [self addGenerator:[LZBeamEffect class]]; … … 99 110 - (void)addGenerator:(Class)generatorClass 100 111 { 101 [self addSequence:[[[generatorClass alloc] init] autorelease] withLength: 60];112 [self addSequence:[[[generatorClass alloc] init] autorelease] withLength:5]; 102 113 } 103 114 … … 105 116 - (void)addSequence:(LZSequenceableElement *)sequenceElement withLength:(NSTimeInterval)time 106 117 { 107 [layer insertElement:sequenceElement inTimeRange:LZMakeTimeRange([layer duration], time)];118 [layer appendElement:sequenceElement withLength:time]; 108 119 } 109 120 trunk/LaserLine_2.0/Src/Sequencing/Generators/LZ3DTorus.h
r339 r362 8 8 9 9 #import <Cocoa/Cocoa.h> 10 #import <sys/time.h>11 10 #import <RawTypes.h> 12 11 #import "LZSequenceableElement.h" trunk/LaserLine_2.0/Src/Sequencing/Generators/LZ3DTorus.m
r360 r362 32 32 w = 25; 33 33 34 xs = 10 ;35 ys = 31 ;36 zs = 27 ;34 xs = 10/35.; 35 ys = 31/35.; 36 zs = 27/35.; 37 37 } 38 38 return self; … … 41 41 - (RawFrame)renderAtPosition:(float)position 42 42 { 43 struct timeval time;44 gettimeofday(&time,NULL);45 46 43 unsigned pointCount = 500; 47 44 RawPoint *points = malloc(sizeof(RawPoint)*pointCount); 48 45 RawFrame frame = {points, pointCount}; 49 46 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; 53 51 54 52 for (int p = 0 ; p <= pointCount ; p++) 55 53 { 56 float t = p * 2 * 3.14159 /pointCount;54 float t = p * 2 * 3.141592653589793/pointCount; 57 55 58 56 float x0 = A*cosf(t)*(R+r*cosf(w*t)); trunk/LaserLine_2.0/Src/Sequencing/Generators/LZSinewave.h
r333 r362 8 8 9 9 #import <Cocoa/Cocoa.h> 10 #import <sys/time.h>11 10 #import <RawTypes.h> 12 11 #import "LZSequenceableElement.h" trunk/LaserLine_2.0/Src/Sequencing/Generators/LZSinewave.m
r341 r362 17 17 if(self) 18 18 { 19 freq_x = 1;20 freq_y = 2.9955;19 freq_x = 9; 20 freq_y = 8; 21 21 } 22 22 return self; … … 26 26 - (RawFrame)renderAtPosition:(float)position 27 27 { 28 struct timeval time;29 gettimeofday(&time,NULL);30 31 28 unsigned pointCount = 1000; 32 29 RawPoint *points = malloc(sizeof(RawPoint)*pointCount); 33 30 RawFrame frame = {points, pointCount}; 34 31 35 float t = ( time.tv_sec + time.tv_usec/1000000)/10000*position;32 float t = (((double)clock())/CLOCKS_PER_SEC)*10; 36 33 37 34 unsigned i; 38 35 for(i = 0; i < pointCount; i++) 39 36 { 40 float t_p = (i/( float)pointCount)*2*3.14159*5+t;37 float t_p = (i/((float)pointCount-1)) * 2. * 3.141592653589793; 41 38 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; 44 41 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; 48 45 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; 52 47 } 48 49 points[pointCount-1].r = points[pointCount-1].g = points[pointCount-1].b = 0; 53 50 54 51 return frame; trunk/LaserLine_2.0/Src/Sequencing/Generators/LZSpirograph.h
r319 r362 8 8 9 9 #import <Cocoa/Cocoa.h> 10 #import <sys/time.h>11 10 #import <RawTypes.h> 12 11 #import "LZSequenceableElement.h" trunk/LaserLine_2.0/Src/Sequencing/Generators/LZSpirograph.m
r320 r362 27 27 - (RawFrame)renderAtPosition:(float)position 28 28 { 29 struct timeval time;30 gettimeofday(&time,NULL);31 32 29 unsigned pointCount = 1000; 33 30 RawPoint *points = malloc(sizeof(RawPoint)*pointCount); 34 31 RawFrame frame = {points, pointCount}; 35 32 36 float t = ( time.tv_sec + time.tv_usec/1000000)/10000*position;33 float t = (((double)clock())/CLOCKS_PER_SEC); 37 34 38 35 unsigned i; 39 36 for(i = 0; i < pointCount; i++) 40 37 { 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; 42 39 43 40 points[i].x = ((R+r)*cos(t_p) - (d)*cos((R+r)/r*(t_p)))/(R+r+d)*32767; 44 41 points[i].y = ((R+r)*sin(t_p) - (d)*sin((R+r)/r*(t_p)))/(R+r+d)*32767; 45 42 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; 49 46 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; 53 48 } 49 50 points[pointCount-1].r = points[pointCount-1].g = points[pointCount-1].b = 0; 54 51 55 52 return frame; trunk/LaserLine_2.0/Src/Sequencing/LZLayer.h
r360 r362 37 37 - (void)insertElement:(LZSequenceableElement *)element atTime:(NSTimeInterval)start withDuration:(NSTimeInterval)duration; 38 38 - (void)insertElement:(LZSequenceableElement *)element inTimeRange:(LZTimeRange)timeRange; 39 - (void)appendElement:(LZSequenceableElement *)element withLength:(NSTimeInterval)time; 39 40 40 41 - (void)removeElement:(LZSequenceableElement *)element; trunk/LaserLine_2.0/Src/Sequencing/LZLayer.m
r320 r362 131 131 } 132 132 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 133 140 - (void)removeElement:(LZSequenceableElement *)element 134 141 { trunk/LaserLine_2.0/Src/Sequencing/LZSequence.m
r320 r362 156 156 unsigned index = 0; 157 157 158 //grab index of firstelement I will insert in front of158 //grab index of the element I will insert in front of 159 159 while(index < count && [[sequenceTimings objectAtIndex:index] timeRangeValue].start < LZMaxTimeRange(timeRange)) 160 160 index++; 161 161 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) ) 165 164 { 166 165 [sequenceElements insertObject:element atIndex:index];
