Subversion Repositories gelsvn

Rev

Rev 335 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 335 Rev 596
Line 132... Line 132...
132
					printf ("type %d\n", file_type);
132
					printf ("type %d\n", file_type);
133
 
133
 
134
					/* go through each kind of element that we learned is in the file */
134
					/* go through each kind of element that we learned is in the file */
135
					/* and read them */
135
					/* and read them */
136
 
136
 
-
 
137
                    cout << "nelems: " << nelems << endl;
137
					for (int i = 0; i < nelems; i++) 
138
					for (int i = 0; i < nelems; i++) 
138
					{
139
					{
139
 
140
 
-
 
141
                        cout << "." << flush;
140
						/* get the description of the first element */
142
						/* get the description of the first element */
141
						elem_name = elist[i];
143
						elem_name = elist[i];
142
						//plist = ply_get_element_description (ply, elem_name, &num_elems, &nprops);
144
						//plist = ply_get_element_description (ply, elem_name, &num_elems, &nprops);
143
						ply_get_element_description (ply, elem_name, &num_elems, &nprops);
145
						ply_get_element_description (ply, elem_name, &num_elems, &nprops);
144
 
146
 
Line 146... Line 148...
146
						printf ("element %s %d\n", elem_name, num_elems);
148
						printf ("element %s %d\n", elem_name, num_elems);
147
 
149
 
148
						/* if we're on vertex elements, read them in */
150
						/* if we're on vertex elements, read them in */
149
						if (equal_strings ("vertex", elem_name)) 
151
						if (equal_strings ("vertex", elem_name)) 
150
						{
152
						{
-
 
153
                            cout << "v" << flush;
151
							typedef struct PlyVertex {
154
							typedef struct PlyVertex {
152
								float x,y,z;             /* the usual 3-space position of a vertex */
155
								float x,y,z;             /* the usual 3-space position of a vertex */
153
							} PlyVertex;
156
							} PlyVertex;
154
 
157
 
155
							PlyProperty vert_props[] = { /* list of property information for a vertex */
158
							PlyProperty vert_props[] = { /* list of property information for a vertex */
Line 170... Line 173...
170
								PlyVertex * pv = (PlyVertex *) malloc (sizeof (PlyVertex));
173
								PlyVertex * pv = (PlyVertex *) malloc (sizeof (PlyVertex));
171
 
174
 
172
								/* grab and element from the file */
175
								/* grab and element from the file */
173
								ply_get_element (ply, (void*)pv);
176
								ply_get_element (ply, (void*)pv);
174
 
177
 
175
								Vec3f v = transform.mul_3D_point(Vec3f(pv->x, pv->y, pv->z));
178
								Vec3f v = 	Ntransform.mul_3D_point(Vec3f(pv->x, pv->y, pv->z));
176
								verts.push_back(v);
179
								verts.push_back(v);
177
 
180
 
178
								Vec3f n = Ntransform.mul_3D_vector(Vec3f(0,0,1));
181
								Vec3f n = Ntransform.mul_3D_vector(Vec3f(0,0,1));
179
								norms.push_back(n);
182
								norms.push_back(n);
180
 
183
 
Line 267... Line 270...
267
		{
270
		{
268
			cout << "file error " << fn << endl;
271
			cout << "file error " << fn << endl;
269
			return;
272
			return;
270
		}
273
		}
271
 
274
 
272
		fprintf( pFile, "# %d vertices with normal\n", verts.size());
275
		fprintf( pFile, "# %lu vertices with normal\n", verts.size());
273
		//fprintf( pFile, "# center : %d vertices with normal", verts.size());
276
		//fprintf( pFile, "# center : %d vertices with normal", verts.size());
274
		
277
		
275
		for(unsigned int i=0; i<verts.size(); ++i )
278
		for(unsigned int i=0; i<verts.size(); ++i )
276
		  fprintf( pFile, "v %f %f %f\n", verts[i][0], verts[i][1], verts[i][2]);
279
		  fprintf( pFile, "v %f %f %f\n", verts[i][0], verts[i][1], verts[i][2]);
277
		for(unsigned int i=0; i<norms.size(); ++i )
280
		for(unsigned int i=0; i<norms.size(); ++i )
Line 403... Line 406...
403
	// LOAD OBJ
406
	// LOAD OBJ
404
	string fn;
407
	string fn;
405
	if(argc>1)
408
	if(argc>1)
406
		fn = argv[1];
409
		fn = argv[1];
407
	else
410
	else
408
		fn = "bun.conf";
411
		fn = "/Users/jab/Studio/3DModels/OriginalBunnyScans/bunny/data/bun.conf";
409
 
412
 
410
	verts_from_conf(fn, 0.002);
413
	verts_from_conf(fn, 0.002);
411
 
414
 
412
	cout << "Loading " << fn << endl;
415
	cout << "Loading " << fn << endl;
413
	if(fn == "") exit(0);
416
	if(fn == "") exit(0);
414
 
417
 
415
	write_obj("bunny.obj");
418
	write_obj("/Users/jab/Studio/3DModels/OriginalBunnyScans/bunny/data/bunny.obj");
416
	//return 0;
419
	//return 0;
417
 
420
 
418
	// Initialize Trackball
421
	// Initialize Trackball
419
 
422
 
420
	ball = new QuatTrackBall(cen,2*rad,800,800);
423
	ball = new QuatTrackBall(cen,2*rad,800,800);