?????? ???????

Members
  • Content count

    3
  • Joined

  • Last visited

Community Reputation

113 Neutral

About ?????? ???????

  • Rank
    Newbie
  1. Hello all. How load 3ds file with texture in opengl window. Object i loaded successfull, but i dont know how load texture. code model load [CODE] void display() { Gl::glEnable(Gl::GL_DEPTH_TEST); Gl::glDepthFunc(Gl::GL_LEQUAL); Gl::glClear(Gl::GL_COLOR_BUFFER_BIT|Gl::GL_DEPTH_BITS); Gl::glClearColor(235, 242, 250, 1); Gl::glLoadIdentity(); lightup(); Gl::glScalef(0.5,0.5,0.5); Gl::glTranslatef(0.0,-1200.0,-1500.0); Gl::glRotatef(280, 1, 0, 0); Gl::glRotatef(rotat, 0, 0, 1); Gl::glColor3f(50.0,100.0,0.0); long meshcount; for(meshcount=0;meshcount<model->meshes->Count;meshcount++) { for(int fd=0;fd<mesh[meshcount]->faces->Count;fd++) face.Add(mesh[meshcount]->faces[fd]); for(long i=0;i<mesh[meshcount]->nfaces;i++) { Gl::glMaterialfv(Gl::GL_FRONT,Gl::GL_DIFFUSE,material[face[i]->material]->diffuse); Gl::glMaterialfv(Gl::GL_FRONT,Gl::GL_AMBIENT,material[face[i]->material]->ambient); Gl::glMaterialfv(Gl::GL_FRONT,Gl::GL_SPECULAR,material[face[i]->material]->specular); // progressBar1->Maximum=mesh[meshcount]->nfaces; // progressBar1->Value=i; Gl::glBegin(Gl::GL_TRIANGLES); Gl::glColor3f(50.0,100.0,0.0); Gl::glVertex3fv(mesh[meshcount]->vertices[face[i]->index[0]]->ToArray()); Gl::glVertex3fv(mesh[meshcount]->vertices[face[i]->index[1]]->ToArray()); Gl::glVertex3fv(mesh[meshcount]->vertices[face[i]->index[2]]->ToArray()); Gl::glEnd(); Gl::glFlush(); } face.Clear(); } } [/CODE]
  2. Hello all. How loaded 3ds file with texture in opengl window. Object i loaded successfull, but i dont know how loaded texture. code model loaded [CODE] void display() { Gl::glEnable(Gl::GL_DEPTH_TEST); Gl::glDepthFunc(Gl::GL_LEQUAL); Gl::glClear(Gl::GL_COLOR_BUFFER_BIT|Gl::GL_DEPTH_BITS); Gl::glClearColor(235, 242, 250, 1); Gl::glLoadIdentity(); lightup(); Gl::glScalef(0.5,0.5,0.5); Gl::glTranslatef(0.0,-1200.0,-1500.0); Gl::glRotatef(280, 1, 0, 0); Gl::glRotatef(rotat, 0, 0, 1); Gl::glColor3f(50.0,100.0,0.0); long meshcount; for(meshcount=0;meshcount<model->meshes->Count;meshcount++) { for(int fd=0;fd<mesh[meshcount]->faces->Count;fd++) face.Add(mesh[meshcount]->faces[fd]); for(long i=0;i<mesh[meshcount]->nfaces;i++) { Gl::glMaterialfv(Gl::GL_FRONT,Gl::GL_DIFFUSE,material[face[i]->material]->diffuse); Gl::glMaterialfv(Gl::GL_FRONT,Gl::GL_AMBIENT,material[face[i]->material]->ambient); Gl::glMaterialfv(Gl::GL_FRONT,Gl::GL_SPECULAR,material[face[i]->material]->specular); // progressBar1->Maximum=mesh[meshcount]->nfaces; // progressBar1->Value=i; Gl::glBegin(Gl::GL_TRIANGLES); Gl::glColor3f(50.0,100.0,0.0); Gl::glVertex3fv(mesh[meshcount]->vertices[face[i]->index[0]]->ToArray()); Gl::glVertex3fv(mesh[meshcount]->vertices[face[i]->index[1]]->ToArray()); Gl::glVertex3fv(mesh[meshcount]->vertices[face[i]->index[2]]->ToArray()); Gl::glEnd(); Gl::glFlush(); } face.Clear(); } } [/CODE]
  3. OpenGL OpenGl and lib3ds

    Hello all. I need help. I didnt cant load 2 or more models to scene. (I have 3 files .3ds and i must load hes) its my code [CODE] #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h> #include "lib3ds.h" #include <iostream> typedef float Lib3dsVector[3]; typedef float Lib3dsTexel[2]; using namespace std; Lib3dsFile* model; Lib3dsMesh** mesh; Lib3dsCamera** camera; Lib3dsFace* face; Lib3dsLight** light; Lib3dsMaterial** material; float rotat=0; GLuint vertexVBO,normalVBO,textureVBO; unsigned long total_face; void lightup() { glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); float gambient[]={0.2,0.2,0.2,1.0}; float lightpos[]={1.0,1.0,1.0,0.0}; float lambient[]={1.0,1.0,1.0,1.0}; float ldiffuse[]={0.8,0.8,0.8,1.0}; float lspecular[]={0.3,0.3,0.3,1.0}; glLightfv(GL_LIGHT0,GL_DIFFUSE,ldiffuse); glLightfv(GL_LIGHT0,GL_AMBIENT,lambient); glLightfv(GL_LIGHT0,GL_SPECULAR,lspecular); glLightfv(GL_LIGHT0,GL_POSITION,lightpos); glLightModelfv(GL_LIGHT_MODEL_AMBIENT,gambient); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); } void getfaces() { total_face=0; for(long meshcount=0;meshcount<model->nmeshes;meshcount++) total_face+=mesh[meshcount]->nfaces; } void display() { glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BITS); glLoadIdentity(); // gluLookAt(camera[0]->position[0]+1000,camera[0]->position[1],camera[0]->position[2],camera[0]->target[0],camera[0]->target[1],camera[0]->target[2],0.0,0.0,1.0); glPushMatrix(); lightup(); glScalef(0.5,0.5,0.5); glTranslatef(0.0,-1000.0,-2500.0); glRotatef(280, 1, 0, 0); glRotatef(rotat, 0, 0, 1); long meshcount; for(meshcount=0;meshcount<model->nmeshes;meshcount++) { face=mesh[meshcount]->faces; for(long i=0;i<mesh[meshcount]->nfaces;i++) { glMaterialfv(GL_FRONT,GL_DIFFUSE,material[face[i].material]->diffuse); glMaterialfv(GL_FRONT,GL_AMBIENT,material[face[i].material]->ambient); glMaterialfv(GL_FRONT,GL_SPECULAR,material[face[i].material]->specular); glBegin(GL_TRIANGLES); glColor3f(50.0,100.0,0.0); glVertex3fv(mesh[meshcount]->vertices[face[i].index[0]]); glVertex3fv(mesh[meshcount]->vertices[face[i].index[1]]); glVertex3fv(mesh[meshcount]->vertices[face[i].index[2]]); glEnd(); } } glPopMatrix(); /* glPushMatrix(); glTranslatef(0.0,0.0,-2000.0); glColor3f(1.0,1.0,1.0); glBegin(GL_QUADS); glVertex3f(-10000.0f,-10000.0f,0.0f); glVertex3f(10000.0f,-10000.0f,0.0f); glVertex3f(10000.0f,10000.0f,0.0f); glVertex3f(-10000.0f,10000.0f,0.0f); glEnd(); glPopMatrix(); */ glutSwapBuffers(); } static void Timer(int value){ rotat+=1.0f; if(rotat>=360) { rotat=0; } glutPostRedisplay(); glutTimerFunc(30, Timer, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); } void keypress(unsigned char key,int x,int y) { switch(key) { case 27: exit(0); break; } } void reshape(int w,int h) { if(h==0) h=1; glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0,w/h,0.0,1000.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } int main(int argc,char* argv[]) { glutInit(&argc,argv); model=lib3ds_file_open("torce.3DS"); if(model==NULL) cout<<"Error"<<endl; else cout<<model->nmaterials<<endl; mesh=model->meshes; material=model->materials; camera=model->cameras; light=model->lights; cout<<"Light Num:"<<model->nlights<<endl; glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH); glutInitWindowSize(800,800); glutInitWindowPosition(100,100); glutCreateWindow("VC 2008 Glut"); //glutFullScreen(); glClearColor(0.0, 0.0, 0.0, 0.0); glClearDepth(1.0); glShadeModel(GL_FLAT); glutKeyboardFunc(keypress); glutDisplayFunc(display); glutReshapeFunc(reshape); Timer(0); glutMainLoop(); return 0; } [/CODE]