view3d

diff src/scene.c @ 8:5562a637e5aa

load multiple files and concatenate them
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 23 Jan 2012 08:51:59 +0200
parents 75e4377f3cdc
children d0896caa3e5b
line diff
     1.1 --- a/src/scene.c	Sat Jan 21 18:20:14 2012 +0200
     1.2 +++ b/src/scene.c	Mon Jan 23 08:51:59 2012 +0200
     1.3 @@ -20,6 +20,16 @@
     1.4  
     1.5  extern int verbose;
     1.6  
     1.7 +int init_scene(struct scene *scn)
     1.8 +{
     1.9 +	scn->meshes = 0;
    1.10 +	scn->lights = 0;
    1.11 +
    1.12 +	scn->bbox.min[0] = scn->bbox.min[1] = scn->bbox.min[2] = FLT_MAX;
    1.13 +	scn->bbox.max[0] = scn->bbox.max[1] = scn->bbox.max[2] = -FLT_MAX;
    1.14 +	return 0;
    1.15 +}
    1.16 +
    1.17  int load_scene(struct scene *scn, const char *fname)
    1.18  {
    1.19  	int i, j;
    1.20 @@ -37,9 +47,6 @@
    1.21  		printf("scene: %s  (%d meshes, %d lights)\n", fname, aiscn->mNumMeshes, aiscn->mNumLights);
    1.22  	}
    1.23  
    1.24 -	scn->meshes = 0;
    1.25 -	scn->lights = 0;
    1.26 -
    1.27  	for(i=0; i<aiscn->mNumLights; i++) {
    1.28  		struct light *lt;
    1.29  		struct aiLight *ailt = aiscn->mLights[i];
    1.30 @@ -97,9 +104,7 @@
    1.31  		scn->lights = lt;
    1.32  	}
    1.33  
    1.34 -	scn->bbox.min[0] = scn->bbox.min[1] = scn->bbox.min[2] = FLT_MAX;
    1.35 -	scn->bbox.max[0] = scn->bbox.max[1] = scn->bbox.max[2] = -FLT_MAX;
    1.36 -
    1.37 +	/* load meshes and calculate bounding box */
    1.38  	for(i=0; i<aiscn->mNumMeshes; i++) {
    1.39  		struct mesh *m;
    1.40  
    1.41 @@ -120,11 +125,6 @@
    1.42  		scn->meshes = m;
    1.43  	}
    1.44  
    1.45 -	if(verbose) {
    1.46 -		printf("scene bounds: %.2f %.2f %.2f -> %.2f %.2f %.2f\n", scn->bbox.min[0], scn->bbox.min[1],
    1.47 -				scn->bbox.min[2], scn->bbox.max[0], scn->bbox.max[1], scn->bbox.max[2]);
    1.48 -	}
    1.49 -
    1.50  	aiReleaseImport(aiscn);
    1.51  	return 0;
    1.52  }