2013-03-29 2 views
0

OpenGL ES 1.1을 사용하여 3D 세계에서 입자 (2D)를 그리려하고 있습니다. 3D world without particles3D 세계에서 2D 객체를 그리는 방법

3 차원 세계에서 2D 입자를 그릴려고 노력, 그것은 (알 그리드 지금 바닥에 어떻게 든 이동과 같습니다

(2 차원 입자없이) 차원 세계는 다음과 같습니다 왼쪽 모서리) : 3D world attempted with particles

그러나 3D 그리드 위에 직접 그려야합니다. 이것을 달성하는 방법에 대한 아이디어 또는 왼쪽 하단 모서리로 이동하는 이유는 무엇입니까?

지금까지 내 작업.

- (void)drawFrame 
{  
    [(EAGLView *)self.view setFramebuffer]; 

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

///////////// 3D Drawing the Grid floor 

    glDisable(GL_BLEND); 
    glDisable(GL_TEXTURE_2D); 
    glEnable(GL_DEPTH_TEST); 
    glDepthFunc(GL_LESS); 
    glDepthMask(GL_TRUE); 

    glMatrixMode(GL_MODELVIEW); 
    glLoadIdentity(); 

    static GLfloat z = 0; 
    gluLookAt(0, 5, -10, 0, 0, 0, 0, 1, 0); 
    z += 0.075f; 

    // Rotate the scene 
    glRotatef(angle, 0, 1, 0); 

    // Draw the Floor 
    glColor4f(1.0f, 1.0f, 1.0f, 1.0f); 
    glDisableClientState(GL_COLOR_ARRAY); 
    glEnableClientState(GL_VERTEX_ARRAY); 
    glVertexPointer(3, GL_FLOAT, 0, zFloorVertices); 
    glDrawArrays(GL_LINES, 0, 42); 
    glVertexPointer(3, GL_FLOAT, 0, xFloorVertices); 
    glDrawArrays(GL_LINES, 0, 42); 

//////////// 2D drawing the particle system 

    glMatrixMode(GL_MODELVIEW); 
    glLoadIdentity(); 
    glMatrixMode(GL_PROJECTION); 
    glLoadIdentity(); 

    glOrthof(0.0f, 320.0f, 0.0f, 480.0f, -100.0f, 100.0f); 

    glDisable(GL_DEPTH_TEST); 
    glDisable(GL_CULL_FACE); 
    glEnable(GL_TEXTURE_2D); 
    glEnable(GL_BLEND); 

    [explosion1 update:UPDATE_INTERVAL]; 

    if (explosion1.active != YES) 
    { 
     explosion1.sourcePosition = Vector2fMake(200, 200); 
     explosion1.active = YES; 
     explosion1.duration = 1; 
     explosion1.sourcePositionVariance = Vector2fMake(0, rand() % 20); 
    } 

    [explosion1 renderParticles]; 

    [(EAGLView *)self.view presentFramebuffer]; 
} 

- (void)initOpenGLES1 
{ 
    // Set the clear color 
    glClearColor(0, 0, 0, 1.0f); 

    // Projection Matrix config 
    glMatrixMode(GL_PROJECTION); 
    glLoadIdentity(); 
    CGSize layerSize = self.view.layer.frame.size; 
    gluPerspective(45.0f, (GLfloat)layerSize.width/(GLfloat)layerSize.height, 0.1f, 750.0f); 

    // Modelview Matrix config 
    glMatrixMode(GL_MODELVIEW); 
    glLoadIdentity(); 

    // This next line is not really needed as it is the default for OpenGL ES 
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
    glDisable(GL_BLEND); 

    // Enable depth testing 
    glEnable(GL_DEPTH_TEST); 
    glDepthFunc(GL_LESS); 
    glDepthMask(GL_TRUE); 
} 

답변

0

3 차원 렌더링의 gluPerspective를 재설정해야합니다.

// 3D 
glMatrixMode(GL_PROJECTION); 
glLoadIdentity(); 

CGSize layerSize = self.view.layer.frame.size; 
gluPerspective(45.0f, (GLfloat)layerSize.width/(GLfloat)layerSize.height, 0.1f, 750.0f); 

glMatrixMode(GL_MODELVIEW); 
glLoadIdentity(); //gets rid of any rotations, movement, or other changes to the virtual world and puts us back at the origin standing upright 

.... 
관련 문제