Пример #1
0
 void SplinePath::read(DataSourceRef source)
 {
     auto stream = source->createStream();
     
     int newPointsSize;
     stream->readLittle(&newPointsSize);
     
     points.reserve(size() + newPointsSize);
     
     // ---
     
     Vec2f point;
     
     for (int i = 0; i < newPointsSize; i++)
     {
         stream->readLittle(&point.x);
         stream->readLittle(&point.y);
         add(point);
     }
 }
Пример #2
0
void TriMesh::read( DataSourceRef dataSource )
{
	IStreamRef in = dataSource->createStream();
	clear();

	uint8_t versionNumber;
	in->read( &versionNumber );
	
	uint32_t numVertices, numNormals, numTexCoords, numIndices;
	in->readLittle( &numVertices );
	in->readLittle( &numNormals );
	in->readLittle( &numTexCoords );
	in->readLittle( &numIndices );
	
	for( size_t idx = 0; idx < numVertices; ++idx ) {
		Vec3f v;
		in->readLittle( &v.x ); in->readLittle( &v.y ); in->readLittle( &v.z );
		mVertices.push_back( v );
	}

	for( size_t idx = 0; idx < numNormals; ++idx ) {
		Vec3f v;
		in->readLittle( &v.x ); in->readLittle( &v.y ); in->readLittle( &v.z );
		mNormals.push_back( v );
	}

	for( size_t idx = 0; idx < numTexCoords; ++idx ) {
		Vec2f v;
		in->readLittle( &v.x ); in->readLittle( &v.y );
		mTexCoords.push_back( v );
	}

	for( size_t idx = 0; idx < numIndices; ++idx ) {
		uint32_t v;
		in->readLittle( &v );
		mIndices.push_back( v );
	}
}
Пример #3
0
ImageSourcePng::ImageSourcePng( DataSourceRef dataSourceRef, ImageSource::Options /*options*/ )
	: ImageSource(), mInfoPtr( 0 ), mPngPtr( 0 )
{
	mPngPtr = png_create_read_struct( PNG_LIBPNG_VER_STRING, (png_voidp)NULL, NULL, NULL );
	if( ! mPngPtr ) {
		throw ImageSourcePngException( "Could not create png struct." );
	}

	mCiInfoPtr = shared_ptr<ci_png_info>( new ci_png_info );
	mCiInfoPtr->srcStreamRef = dataSourceRef->createStream();

	png_set_read_fn( mPngPtr, reinterpret_cast<void*>( mCiInfoPtr.get() ), ci_PNG_stream_reader );
	mInfoPtr = png_create_info_struct( mPngPtr );

	if( ! mInfoPtr ) {
		png_destroy_read_struct( &mPngPtr, (png_infopp)NULL, (png_infopp)NULL );
		mPngPtr = 0;
		throw ImageSourcePngException( "Could not destroy png read struct." );
	}
	
	if( ! loadHeader() )
		throw ImageSourcePngException( "Could not load png header." );
}
ImageSourceFileRadiance::ImageSourceFileRadiance( DataSourceRef dataSourceRef, ImageSource::Options options )
{
	IStreamRef stream = dataSourceRef->createStream();
	
	loadStream( stream );
}