前文读取了obj格式文件中顶点相关的数量信息,下面读取显示obj格式文件中顶点相关的坐标信息;使用前面的立方体obj文件;
- void CObjtest2View::OnDraw(CDC* pDC)
- {
- CObjtest2Doc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // TODO: add draw code for native data here
-
- CStdioFile file;
- CString strline;
- CString str1;
- int row=0,col=0;
-
- if(NULL != file.Open("cube1.obj", CFile::modeRead))
- {
- while (file.ReadString(strline))
- {
- if (strline[0] == 'v') {
- if (strline[1] == 'n') {//vn
- pDC->TextOut(75, 230, "法线:");
- for (int i=1; i<5; i++)
- {
- AfxExtractSubString(str1, strline, i, ' ');
- pDC->TextOut(50+(col+1)*100, 90 + row*20, str1);
- col = col + 1;
- }
- row = row + 1;
- col = 0;
- }
- else if (strline[1] == 't') {//vt
- pDC->TextOut(75, 390, "UV坐标:");
- for (int i=