-
Notifications
You must be signed in to change notification settings - Fork 8
/
KinemeGLInverseRotation.m
62 lines (47 loc) · 1.15 KB
/
KinemeGLInverseRotation.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
/*
* KinemeGLInverseRotation.m
* GLTools
*
* Created by Christopher Wright on 5/25/09.
* Copyright (c) 2009 Kosada Incorporated. All rights reserved.
*
*/
#import <OpenGL/CGLMacro.h>
#import "KinemeGLInverseRotation.h"
//#import "KinemeGLInverseRotationUI.h"
@implementation KinemeGLInverseRotation : QCPatch
+ (QCPatchExecutionMode)executionModeWithIdentifier:(id)fp8
{
return 0;
}
+ (BOOL)allowsSubpatchesWithIdentifier:(id)fp8
{
return NO;
}
+ (QCPatchTimeMode)timeModeWithIdentifier:(id)identifier
{
return 1;
}
+ (BOOL)isSafe
{
return YES;
}
- (id)initWithIdentifier:(id)fp8
{
if(self=[super initWithIdentifier:fp8])
{
[[self userInfo] setObject:@"Kineme GL Inverse Rotation" forKey:@"name"];
}
return self;
}
- (BOOL)execute:(QCOpenGLContext *)context time:(double)time arguments:(NSDictionary *)arguments
{
CGLContextObj cgl_ctx = [context CGLContextObj];
float m[16];
glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat*)&m);
[outputZRotation setDoubleValue: -atan2f(m[1],m[0])*180.f/M_PI];
[outputYRotation setDoubleValue: asinf(m[2])*180.f/M_PI];
[outputXRotation setDoubleValue: -atan2f(m[6],m[10])*180.f/M_PI];
return YES;
}
@end