int main(int argc, char *argv[]) { glutInit(&argc, argv); options(argc, argv); if (mapmode) { /* read map data */ readDigitalMap(MAPDIR "nara.map"); readMeshData(MAPDIR "nara.mem"); calcAllAltitude(); } mapwindow = openMapWindow(argv[0]); /* initialize 3D map window */ /* 970904 イベントハンドラの設定 */ glutDisplayFunc(drawScene); glutKeyboardFunc(mapKeyFunc); glutSpecialFunc(mapSpecialFunc); /* 特殊キー用 */ glutMouseFunc(mapMouseFunc); glutMotionFunc(mapMotionFunc); readdata(); /* read guide data */ initGuide(); /* initialize the guide */ initIndex(); /* initialize the index */ initTOC(); /* initialize the TOC */ /* prepare graphics objects */ setPartNVec(&compass); setPartNVec(&pencursor); /* texture */ /* 970904 あとで参考にするかもしれない if (!wiremode && !mapmode && texturemode) { tevdef(1, 0, tevprops[0]); tevbind(TV_ENV0, 1); if ((tid = readTexture(texturename, texturemode - 1)) == 0) { perror("cannot read texture data\n"); exit(0); } texbind(TX_TEXTURE_0, tid); } */ calcLookAtPoint(lookAt, FALSE); glutSetWindow(mapwindow); glutPostRedisplay(); /* main loop */ glutMainLoop(); }
MeshDataHeader* BinaryFileReader::readMeshDataHeader(std::ifstream& stream) { char* buf = new char[sizeof(MeshDataHeader)]; stream.read(buf, sizeof(MeshDataHeader)); MeshDataHeader* meshHeader = r_c(MeshDataHeader*, buf); stream.seekg((uint)meshHeader->meshes); MeshData* meshData = new MeshData[meshHeader->numberOfMeshes]; MeshData* tmp; for(unsigned int i = 0; i < meshHeader->numberOfMeshes; i++) { memcpy(&meshData[i],tmp = readMeshData(stream), sizeof(MeshData)); delete tmp; } meshHeader->meshes = meshData; return meshHeader; }
//http://www.opengl.org/discussion_boards/showthread.php/176961-Modelview-translation-with-GLM ////////////////////////////////////////////////////////////////////////////////// // // Just hard code the geometry // void InitGeometry() { vector <Vertex> verts; vector <GLuint> indices; GLfloat b[3]= {0.0,0.0,1.0}; GLfloat r[3]= {1.0,0.0,0.0}; InitSquare(verts,indices); cout <<" verts size "<<verts.size()<<" indice "<<indices.size()<<endl; vertxLists.push_back(verts); tindicesLists.push_back(indices); verts.clear(); indices.clear(); createSphere(3,20,20,r,verts,indices); vertxLists.push_back(verts); tindicesLists.push_back(indices); verts.clear(); indices.clear(); createConics(0.5,0.5,2.0,12,12,r,verts,indices); vertxLists.push_back(verts); tindicesLists.push_back(indices); verts.clear(); indices.clear(); createCube(verts,indices); vertxLists.push_back(verts); tindicesLists.push_back(indices); verts.clear(); indices.clear(); readMeshData("/home/arindam/Course/lab3/cse5542Lab3/dragon.off",verts,indices); vertxLists.push_back(verts); tindicesLists.push_back(indices); verts.clear(); indices.clear(); /* // square InitSquare(verts,indices); cout <<" verts size "<<verts.size()<<" indice "<<indices.size()<<endl; vertxLists.push_back(verts); tindicesLists.push_back(indices); verts.clear(); indices.clear(); */ /* readMeshData("/home/arindam/Course/lab3/cse5542Lab3/dragon.off",verts,indices); vertxLists.push_back(verts); tindicesLists.push_back(indices); verts.clear(); indices.clear(); createSphere(2,20,20,r,verts,indices); vertxLists.push_back(verts); tindicesLists.push_back(indices); verts.clear(); indices.clear(); createConics(0.5,0.5,2.0,10,10,r,verts,indices); vertxLists.push_back(verts); tindicesLists.push_back(indices); verts.clear(); indices.clear(); createConics(1.0,1.0,2.0,10,10,r,verts,indices); vertxLists.push_back(verts); tindicesLists.push_back(indices); verts.clear(); indices.clear(); readMeshData("/home/arindam/Course/lab3/cse5542Lab3/bunny.off",verts,indices); vertxLists.push_back(verts); tindicesLists.push_back(indices); verts.clear(); indices.clear(); */ }