38 |
if (self != nil) |
if (self != nil) |
39 |
{ |
{ |
40 |
_init = NO; |
_init = NO; |
|
MdlModel * base = [MdlModel alloc]; |
|
|
base = [base initWithName: @"lara_lower.md3" |
|
|
withTexName: @"lara_lower.skin" |
|
|
withConfigName: @"lara_lower.cfg"]; |
|
|
_model = [[MDlAnimatedModel alloc] initWithModel: base |
|
|
animation: @"LEGS_WALK"]; |
|
41 |
} |
} |
42 |
|
|
43 |
return self; |
return self; |
46 |
- (BOOL) initGL |
- (BOOL) initGL |
47 |
{ |
{ |
48 |
glShadeModel (GL_SMOOTH); |
glShadeModel (GL_SMOOTH); |
49 |
glClearColor (1.0f, 0.0f, 1.0f, 0.5f); |
glClearColor (0.0f, 0.0f, 0.0f, 0.0f); |
50 |
glEnable (GL_DEPTH_TEST); |
glEnable (GL_DEPTH_TEST); |
51 |
|
glEnable (GL_TEXTURE_2D); |
52 |
|
|
53 |
|
_base = [[MdlModel alloc] initWithName: @"lara_lower.md3" |
54 |
|
withTexName: @"lara_lower.skin" |
55 |
|
withConfigName: @"lara_lower.cfg"]; |
56 |
|
_model = [[MdlAnimatedModel alloc] initWithModel: _base |
57 |
|
animation: @"LEGS_WALK"]; |
58 |
|
|
59 |
|
|
60 |
return YES; |
return YES; |
61 |
} |
} |
63 |
- (void) reshape |
- (void) reshape |
64 |
{ |
{ |
65 |
NSRect sceneBounds; |
NSRect sceneBounds; |
66 |
|
|
|
[[self openGLContext] update]; |
|
67 |
sceneBounds = [self bounds]; |
sceneBounds = [self bounds]; |
|
|
|
68 |
glViewport (0, 0, sceneBounds.size.width, sceneBounds.size.height); |
glViewport (0, 0, sceneBounds.size.width, sceneBounds.size.height); |
69 |
|
|
70 |
glMatrixMode (GL_PROJECTION); |
glMatrixMode (GL_PROJECTION); |
71 |
glLoadIdentity (); |
glLoadIdentity (); |
72 |
// gluOrtho2D (0.0, sceneBounds.size.width, 0.0, sceneBounds.size.height); |
gluPerspective(50, (GLfloat)(4.0f/3.0f), 0.1, 1000); |
73 |
|
|
74 |
glMatrixMode (GL_MODELVIEW); |
glMatrixMode (GL_MODELVIEW); |
|
glLoadIdentity (); |
|
75 |
} |
} |
76 |
|
|
77 |
- (void) drawRect: (NSRect)aRect |
- (void) drawRect: (NSRect)aRect |
86 |
|
|
87 |
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
88 |
|
|
89 |
// glColor3f (1.0f, 1.0f, 1.0f); |
glLoadIdentity(); |
90 |
// glBegin (GL_TRIANGLES); |
glTranslatef(0.0,0.0,-100.0); |
91 |
// glVertex2f (0.0, 0.0); |
glRotatef(-90,1.0,0.0,0.0); |
|
// glVertex2f (400.0, 0.0); |
|
|
// glVertex2f (400.0, 400.0); |
|
|
// glEnd (); |
|
|
|
|
|
Camera * cam = [Camera alloc]; |
|
92 |
|
|
93 |
[_model displayWithCamera: ]; |
Camera *cam = [Camera alloc]; |
94 |
|
|
95 |
|
[_model displayWithCamera: cam]; |
96 |
|
|
97 |
|
[self update]; |
98 |
[[self openGLContext] flushBuffer]; |
[[self openGLContext] flushBuffer]; |
99 |
} |
} |
100 |
|
|
101 |
|
|
102 |
@end |
@end |