Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: A problem in import 3ds file

Threaded View

  1. #1
    Newbie Newbie
    Join Date
    May 2013
    Posts
    1

    Question A problem in import 3ds file

    I am now working on import a 3ds model in my application, but I have a problem. I import the model and show it, but the model have no edge. It just a lump of color. What happened?
    Here is my part code.
    Code :
    BOOL CMyOpenGLView::InitializeOpenGL(CDC *pDC) 
    {
     m_pDC=pDC;
     
    SetupPixelFormat();  
     
    m_hRC=::wglCreateContext(m_pDC->GetSafeHdc()); 
     
    ::wglMakeCurrent(m_pDC->GetSafeHdc(),m_hRC); 
     
    ::glShadeModel(GL_FLAT);
     
     ::glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
     
     ::glClearDepth(1.0F);
     
    ::glEnable(GL_DEPTH_TEST);
     
    ::glEnable(GL_CULL_FACE);
     
    ::glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); 
     
    GLfloat ambientLight[] = { 0.3f, 0.3f, 0.3f, 1.0f};
     GLfloat diffuseLight[] = { 0.7f, 0.7f, 0.7f, 1.0f};
     GLfloat lightPos[]     = {6000.0f,6000.0f,6000.0f, 1.0f};
     
     glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
     glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
     glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
     glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);
     
     glEnable(GL_COLOR_MATERIAL);
     glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
     glEnable(GL_LIGHTING);
     glEnable(GL_LIGHT0);
     
     CMyOpenGLApp * app = (CMyOpenGLApp *)AfxGetApp();
     glNewList(app->m_dizuolist,GL_COMPILE); 
    BOOL result;
     C3dsReader loader;
     result = loader.Reader("DIZUO.3DS",&m_TriList);    //read the file and save in m_TriList
    if (result)
     {
     m_TriList.drawGL();    
    m_TriList.doAfterMath(); 
    }
    glEndList();
     
     
      base_list = app->m_dizuolist; 
    return TRUE;
     }
     
     
    void CMyOpenGLView::RenderScence() 
    {
       static BOOL bBusy = FALSE;   
            if (bBusy) return;
       bBusy=TRUE;
     
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
     
    glTranslatef(m_SceneTransX,m_SceneTransY,m_SceneTransZ);
     
     glRotatef(m_SceneRotX,1.0,0.0,0.0);
     glRotatef(m_SceneRotY,0.0,1.0,0.0);
     glRotatef(m_SceneRotZ,0.0,0.0,1.0);
     glRotatef(-90.0f,1.0f,0.0f,0.0f); 
    glRotatef(-90.0f,0.0f,0.0f,1.0f);
     
    glScalef(m_SceneScale,m_SceneScale,m_SceneScale);
     
     glDisable(GL_LIGHTING);
     glPushMatrix();
     glBegin(GL_LINES);
     glColor3f(1.0,0.0,0.0);
     glVertex3f(-200.0,0.0,0.0);
     glVertex3f( 200.0,0.0,0.0);
     
     glColor3f(0.0,1.0,0.0);
     glVertex3f(0.0,-200.0,0.0);
     glVertex3f(0.0, 200.0,0.0);
     
     glColor3f(0.0,0.0,1.0);
     glVertex3f(0.0,0.0,-200.0);
     glVertex3f(0.0,0.0, 200.0);
     glEnd();
     
     glPushMatrix(); 
    glColor3f(1.0f,0.0f,0.0f);
     glTranslatef(150.0f,0.0f,0.0f);
     glRotatef(90.0f,0.0f,1.0f,0.0f);
     glutSolidCone(10.0,50.0,50,50);
     glPopMatrix();
     
    glPushMatrix();
     glColor3f(0.0f,1.0f,0.0f);
     glTranslatef(0.0f,150.0f,0.0f);
     glRotatef(-90.0f,1.0f,.0.f,0.0f);
     glutSolidCone(10.0,50.0,50,50);
     glPopMatrix();
     
    glPushMatrix();
     glColor3f(0.0f,0.0f,1.0f);
     glTranslatef(0.0f,0.0f,150.0f);
     glutSolidCone(10.0,50.0,50,50);
     glPopMatrix();
     
    glPopMatrix();
     glEnable(GL_LIGHTING);
     
    glDisable(GL_LIGHTING);
     glPushMatrix();
     
     glColor3f(0.0f,0.0f,0.0f);  
     wglUseFontBitmaps(wglGetCurrentDC(),0,255,base);
     glListBase(base);
     
     glRasterPos3f(210.0f,-0.5f,0.0f);
     glCallLists(2,GL_UNSIGNED_BYTE,_T("+x"));
     
     glRasterPos3f(-0.5,210.0f,0.0f);
     glCallLists(2,GL_UNSIGNED_BYTE,_T("+y")); 
     
     glRasterPos3f(-0.5,0.0f,210.0f);
     glCallLists(2,GL_UNSIGNED_BYTE,_T("+z"));
     
     glPopMatrix();
     glEnable(GL_LIGHTING);
     
    glDisable(GL_LIGHTING);
     glDisable(GL_LIGHT0);
     glPushMatrix();
     
    glRotatef(180.0f,1.0f,0.0f,0.0f);
     glRotatef(180.0f,0.0f,1.0f,0.0f);
     glRotatef(180.0f,0.0f,0.0f,1.0f);
     glCallList(base_list);
     glPopMatrix();
     glEnable(GL_LIGHTING);
     glEnable(GL_LIGHT0);
       ::SwapBuffers(m_pDC->GetSafeHdc()); 
       bBusy = FALSE;
     
     return;
     }
    Last edited by Khronos_webmaster; 05-20-2013 at 12:25 PM. Reason: Added code tags to make post readable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •