libnff

A modern C++ library for parsing the Neutral File Format.

Introduction

The Neutral File Format is a minimal scene description language, designed in order to test various rendering algorithms and efficiency schemes. The Neutral File Format was developed by Eric Haines, and the Standard Procedural Database, a collection of scenes in the Neutral File Format, is used often in Computer Graphics research for benchmarking ray tracers.

Libnff is a modern C++ library for parsing the Neutral File Format. Libnff consists of an event-based error-reporting parser for the Neutral File Format. Libnff is available under the GNU General Public License.

Features

Libnff's NFF parser currently supports viewing vectors and angles (v), background color (b), positional light location (l), object material properties (f), cone or cylinder primitive (c), sphere primitive (s), polygon primitive (p), and polygonal patch primitive (pp). The parser supports triangular, quadrilateral and polygonal polygon primitive and polygonal patch primitives, and optionally triangulates (convex and planar) non-triangular polygon primitive and polygonal patch primitives. For more information, refer to the NFF specification.

Libnff's NFF parser is event-based, which makes it easy to integrate and well suited for parsing very large files (such as the ones generated with the Standard Procedural Database). Libnff's NFF parser reports errors, which is especially useful for handling the large variety of NFF files out there. Libnff is a modern C++ library written in standard C++, and uses TR1's function objects as an efficient and flexible callback mechanism.

Libnff comes with the nff2nff and nff2obj command line tools. The nff2nff command line tool supports transformations on NFF files, such as triangulation. The nff2obj command line tool converts from the Neutral File Format to the Wavefront OBJ file format.

Author

Libnff was written by Ares Lagae. Ares Lagae is a researcher in the Computer Graphics Research Group at the Katholieke Universiteit Leuven, and a C++ enthusiast. In his spare time, he writes C++ libraries that he uses in his research. Libnff is one of these libraries. Other libraries include libobj, a modern C++ library for parsing the Wavefront OBJ file format, and libply, a modern C++ library for parsing the PLY file format.

Download

Libnff does not depend on any external libraries, but requires <tr1/functional> and <tr1/tuple>. Libnff was developed with gcc version 4.2.0.

Please send bug reports, feature requests, questions and comments to Ares Lagae.

Documentation

To install libnff, download the source distribution, unpack the archive (tar xzf nff-0.1.tar.gz), move into the directory (cd nff-0.1/), configure the package (./configure --prefix=/home/ares), compile the programs and libraries (make), install the programs and libraries (make install), and clean the package (make clean).

To use libnff, create an NFF file (jacks.nff),

b 0.2 0.05 0.2
v
from 0 0 -8
at 0 0 0
up 0 1 0
angle 25
hither 0.001
resolution 256 256
l -10 3 -20
f 0.737 0.561 0.561 0.7 0.7 11.1434 0 1
c -0.704769 -0.128258 -0.222149 0.075 0.704769 0.128258 0.222149 0.075
c 0 -0.649519 0.375 0.075 0 0.649519 -0.375 0.075
c 0.256515 -0.352385 -0.610348 0.075 -0.256515 0.352385 0.610348 0.075
s 0.704769 0.128258 0.222149 0.15
s 0 0.649519 -0.375 0.15
s -0.256515 0.352385 0.610348 0.15
s -0.704769 -0.128258 -0.222149 0.15
s 0 -0.649519 0.375 0.15
s 0.256515 -0.352385 -0.610348 0.15
create an example program (nff.cpp),
#include <iostream>
#include <nff.hpp>

void sphere_callback(const nff::float_3_tuple_type& center, nff::float_type radius)
{
  std::cout << "s " << std::tr1::get<0>(center) << " " << std::tr1::get<1>(center) << " " << std::tr1::get<2>(center) << " " << radius << "\n";
}

int main(int argc, char* argv[])
{
  nff::nff_parser nff_parser;
  nff_parser.sphere_callback(sphere_callback);
  nff_parser.parse("jacks.nff");
}
compile the program (g++ -Wall -I ~/include nff.cpp -L ~/lib/ -l nff -o nff), and execute the program (./nff). In order to locate the locate the dynamic libraries, update the dynamic library search path of the linker (export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/lib). If libnff was installed system-wide (./configure without --prefix=/home/ares), then reconfigure the dynamic linker run time bindings (ldconfig). Alternatively, the example program can be linked statically (g++ -Wall -I ~/include nff.cpp -L ~/lib/ -l nff -static -o nff).

To uninstall libnff, move into the directory (cd nff-0.1/), uninstall the programs and libraries (make uninstall), move out of the directory (cd ..), remove the directory (rm -r nff-0.1/), and remove the source distribution (rm nff-0.1.tar.gz).

Libnff does not have detailed documentation. Please refer to the Doxygen documentation, to the source code of the nff2nff and nff2obj programs that come with libnff, and to TR1 documentation.

Ares Lagae - Personal site (disclaimer) -