Created
August 25, 2014 15:42
-
-
Save majorpakhom/2e9110b936588ef484a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int l3dh_load_geometry_vtn(l3dh_model_t *model, char *path) { | |
uint32_t vf_count = 0, tf_count = 0, nf_count = 0; | |
char *file = l3dh_read_file(path); | |
if(!file) { | |
return -1; | |
} | |
vf_count = buf4CharToUint32(file); | |
tf_count = buf4CharToUint32(file+4); | |
nf_count = buf4CharToUint32(file+8); | |
printf("%d %d %d\n", vf_count, tf_count, nf_count); | |
fflush(stdout); | |
float *v, *t, *n; | |
v = (float*) malloc(vf_count*sizeof(float)); | |
t = (float*) malloc(tf_count*sizeof(float)); | |
n = (float*) malloc(nf_count*sizeof(float)); | |
memcpy(v, file+12, vf_count*sizeof(float)); | |
memcpy(t, file+12+vf_count*sizeof(float), tf_count*sizeof(float)); | |
memcpy(n, file+12+vf_count*sizeof(float)+tf_count*sizeof(float), nf_count*sizeof(float)); | |
uint32_t facesCount = vf_count/9; | |
model->facesCount = facesCount; | |
model->verticies.floats = v; | |
model->verticies.length = vf_count; | |
model->textureCoordinates.floats = t; | |
model->textureCoordinates.length = tf_count; | |
model->normals.floats = n; | |
model->normals.length = nf_count; | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment