- for ( j = 0; j < nproperties; ++j ) {
- char prop_type;
- sgReadChar( fp, &prop_type );
-
- sgReadUInt( fp, &nbytes );
- // cout << "property size = " << nbytes << endl;
- if ( nbytes > buf.get_size() ) { buf.resize( nbytes ); }
- char *ptr = buf.get_ptr();
- sgReadBytes( fp, nbytes, ptr );
- if ( prop_type == SG_MATERIAL ) {
- strncpy( material, ptr, nbytes );
- material[nbytes] = '\0';
- // cout << "material type = " << material << endl;
- }
- }
-
- // read triangle strip elements
- for ( j = 0; j < nelements; ++j ) {
- sgReadUInt( fp, &nbytes );
- // cout << "element size = " << nbytes << endl;
- if ( nbytes > buf.get_size() ) { buf.resize( nbytes ); }
- char *ptr = buf.get_ptr();
- sgReadBytes( fp, nbytes, ptr );
- int count = nbytes / (sizeof(short) * 2);
- short *sptr = (short *)ptr;
- int_list vs, tcs;
- vs.clear(); tcs.clear();
- for ( k = 0; k < count; ++k ) {
- if ( sgIsBigEndian() ) {
- sgEndianSwap( (unsigned short *)&(sptr[0]) );
- sgEndianSwap( (unsigned short *)&(sptr[1]) );
- }
- vs.push_back( sptr[0] );
- tcs.push_back( sptr[1] );
- // cout << sptr[0] << "/" << sptr[1] << " ";
- sptr += 2;
- }
- // cout << endl;
- strips_v.push_back( vs );
- strips_tc.push_back( tcs );
- strip_materials.push_back( material );
- }
+ read_object( fp, SG_TRIANGLE_STRIPS, nproperties, nelements,
+ &strips_v, &strips_n, &strips_c, &strips_tc,
+ &strip_materials );