-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCOBJLoader.cpp
More file actions
66 lines (62 loc) · 1.29 KB
/
COBJLoader.cpp
File metadata and controls
66 lines (62 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdlib.h>
#include <stdio.h>
#include "COBJLoader.h"
#include "CMesh.h"
CMesh* COBJLoader::loadMesh(char* filename)
{
/*printf("Loading OBJ file %s...\n", filename);
CMesh* ret = new CMesh();
char ch;
float v1, v2, v3, n1, n2, n3, t1, t2;
uint f1, f2, f3;
uint nTex = 0, nNor = 0;
FILE* f = fopen(filename, "r");
if(f == NULL)
{
printf("ERROR - file is null!\n");
return NULL;
}
else
{
while( (ch = fgetc(f)) != EOF)
{
if(ch == 'v' || ch == 'V')
{
ch = fgetc(f);
if(ch == ' ')
{
fscanf(f, "%f %f %f", &v1, &v2, &v3);
//printf("POINT: %f, %f, %f\n", v1, v2, v3);
vec3 pos(v1, v2, v3);
CVertex vert(pos);
ret->addVertex(vert);
}
else if(ch == 'n' || ch == 'N')
{
fscanf(f, "%f %f %f", &n1, &n2, &n3);
CVertex& temp = ret->getVertex(nNor);
vec3 Nor(n1, n2, n3);
temp.nor = Nor;
nNor ++;
}
else if(ch == 't' || ch == 'T')
{
fscanf(f, "%f %f", &t1, &t2);
CVertex& temp = ret->getVertex(nTex);
vec3 Tex(t1, t2, 0);
temp.tex = Tex;
nTex++;
}
}
else if(ch == 'f' || ch == 'F')
{
fscanf(f, "%d %d %d", &f1, &f2, &f3);
//printf("TRIANGLE: %u, %u, %u\n", f1, f2, f3);
ret->addTriangle(f1-1, f2-1, f3-1);
}
}
}
fclose(f);
return ret;*/
return 0;
}