검색결과 리스트
게임 프레임워크에 해당되는 글 1건
- 2011.02.14 OpenGL ES 게임 프레임웍
글
OpenGL ES 게임 프레임웍
아이폰
2011. 2. 14. 16:04
이 포스트는 작성중... -_-;; 음 마무리 지어야 하는데 이런 저런 일들로 정리를 못하고 있네;;;
메시 사각영역을 스크린 사각영역으로 변환
-(CGRect)screenRectFromMeshRect:(CGRect)rect atPoint:(CGPoint)meshCenter
{
// find the point on the screen that is the center of the rectangle
// and use that to build a screen-space rectangle
CGPoint screenCenter = CGPointZero;
CGPoint rectOrigin = CGPointZero;
// since our view is rotated, then our x and y are flipped
screenCenter.x = meshCenter.y + 160.0; // need to shift it over
screenCenter.y = meshCenter.x + 240.0; // need to shift it up
rectOrigin.x = screenCenter.x - (CGRectGetHeight(rect)/2.0); // height and width
rectOrigin.y = screenCenter.y - (CGRectGetWidth(rect)/2.0); // are flipped
return CGRectMake(rectOrigin.x, rectOrigin.y, CGRectGetHeight(rect), CGRectGetWidth(rect));
}
SceneObject 업데이트 메소드
-(void)update
{
glPushMatrix();
glLoadIdentity();
// move to my position
glTranslatef(translation.x, translation.y, translation.z);
// rotate
glRotatef(rotation.x, 1.0f, 0.0f, 0.0f);
glRotatef(rotation.y, 0.0f, 1.0f, 0.0f);
glRotatef(rotation.z, 0.0f, 0.0f, 1.0f);
//scale
glScalef(scale.x, scale.y, scale.z);
// save the matrix transform
glGetFloatv(GL_MODELVIEW_MATRIX, matrix);
//restore the matrix
glPopMatrix();
if (collider != nil) [collider updateCollider:self];
}
SceneObject 렌더메소드
-(void)render
{
if (!mesh || !active) return; // if we do not have a mesh, no need to render
// clear the matrix
glPushMatrix();
glLoadIdentity();
glMultMatrixf(matrix);
[mesh render];
glPopMatrix();
}
'아이폰' 카테고리의 다른 글
| Sprite Sheet 제작툴 Zwoptex (0) | 2011.03.16 |
|---|---|
| 애플리케이션 응답성 향상을 위해 동시성 사용하기 (0) | 2011.03.15 |
| OpenGL ES 게임 프레임웍 (0) | 2011.02.14 |
| OpenGL ES 사용 (0) | 2011.02.14 |
| OpenGL ES 사용설정 (0) | 2011.02.13 |
| [iPhone] 로깅 프레임웍 cocoalumberjack (0) | 2010.12.21 |