-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathKinemeGLOrthoPatch.m
86 lines (69 loc) · 2.23 KB
/
KinemeGLOrthoPatch.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#import <OpenGL/CGLMacro.h>
#import "KinemeGLOrthoPatch.h"
@implementation KinemeGLOrthoPatch : QCPatch
+ (QCPatchExecutionMode)executionModeWithIdentifier:(id)fp8
{
return 1;
}
+ (BOOL)allowsSubpatchesWithIdentifier:(id)fp8
{
return YES;
}
+ (BOOL)isSafe
{
return YES;
}
- (id)initWithIdentifier:(id)fp8
{
self=[super initWithIdentifier:fp8];
if(self)
{
[inputLeft setDoubleValue:-1.];
[inputRight setDoubleValue:+1.];
[inputBottom setDoubleValue:-3./4];
[inputTop setDoubleValue:+3./4];
[inputNear setDoubleValue:-10];
[inputFar setDoubleValue:200.];
[[self userInfo] setObject:@"Kineme GL Ortho" forKey:@"name"];
}
return self;
}
- (BOOL)execute:(QCOpenGLContext *)context time:(double)time arguments:(NSDictionary *)arguments
{
// double modifiedMatrix[16],t1,t2,t3;
if([inputBypass booleanValue])
{
[self executeSubpatches:time arguments:arguments];
return YES;
}
CGLContextObj cgl_ctx = [context CGLContextObj];
/*for(i=1;i<15;++i)
modifiedMatrix[i] = 0.0;//oldMatrix[i];
// @@@ The math is right ... the output is wrong though. need to investigate more.
t1 = ([inputRight doubleValue] + [inputLeft doubleValue]) / ([inputRight doubleValue] - [inputLeft doubleValue]);
t2 = ([inputTop doubleValue] + [inputBottom doubleValue]) / ([inputTop doubleValue] - [inputBottom doubleValue]);
t3 = ([inputFar doubleValue] + [inputNear doubleValue]) / ([inputFar doubleValue] - [inputNear doubleValue]);
modifiedMatrix[ 0] = 2. / ([inputRight doubleValue] - [inputLeft doubleValue]);
modifiedMatrix[ 3] = t1;
modifiedMatrix[ 5] = 2. / ([inputTop doubleValue] - [inputBottom doubleValue]);
modifiedMatrix[ 7] = t2;
modifiedMatrix[10] = 2. / ([inputFar doubleValue] - [inputNear doubleValue]);
modifiedMatrix[11] = t3;
modifiedMatrix[15] = 1.0;*/
glMatrixMode(GL_PROJECTION);
glPushMatrix();
{
glLoadIdentity();
glOrtho([inputLeft doubleValue],[inputRight doubleValue],
[inputBottom doubleValue], [inputTop doubleValue],
[inputNear doubleValue], [inputFar doubleValue]);
//glLoadMatrixd(modifiedMatrix);
glMatrixMode(GL_MODELVIEW);
[self executeSubpatches:time arguments:arguments];
}
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
return YES;
}
@end