From z64 wiki
Jump to: navigation, search

Original author(s) spinout
Written in C
Operating system Cross platform
Available in English
Type Library
License Open Source
Website libobj on bitbucket.

libobj is a library written by spinout for manipulating wavefront obj data. It can read and write obj files and their material (mtl) files, as well as write output in N64 F3DEX2, and Zelda 64 collision. There is also an experimental viewer bundled with libobj.


Originally intended as an example of how to use libobj for obj -> F3DEX2, objn64tool has since grown to a complex converter capable of converting obj not only to F3DEX2 but also to Zelda 64 collision, using functions provided by libobj. It also can produce display lists which are "ready" to have animated materials, outputting a C header and source file defining many aspects of the output.

Latest Win32 binary

Using objn64tool

Make sure you know how to use a command line. I even took the time to do long options.
Usage: objn64tool.exe [options]

OptionLong optionDescription
-h--helpThis help
-v--verboseBe verbose
-N--normalize-allNormalize all materials (EXPERIMENTAL)
-n MAT--normalize=MATNormalize a specific material (EXPERIMENTAL)
-C FILE--consts=FILEWrite constants to file FILE (- for stdout)
-H FILE--header=FILEWrite declarations of symbols to FILE
-i OBJ--input=OBJConvert obj file OBJ
-o FILE--output=FILEWrite to file FILE
-b ADDR--base=ADDRSet base address to ADDR (ex: 0x06000000)
-s SCALE--scale=SCALEMultiply verts by SCALE (default 1.0)
-a MAT--scroll=MATSet up material MAT to be scrolled (See note)
-c--collisionGenerate collision
-M OPT--organize=OPTSee note below
-E NAME--collision-exclude=NAMESee note below

  objn64tool.exe -v -C conf.c -b 0x06000000 -s 2.0 -i test.obj -o test.bin
Converts object test.obj to F3DEX2 binary test.bin, scaling it by 2.0, using base address 0x06000000, writing a configuration to conf.c.

It should be noted that the -a/--scroll option does not make a scrolling texture, but instead, it sets a texture offset to a bank greater than 8 and gives texture information to the file specified by the -C/--consts option. It is intended to use this option in combination with code which sets up banks which play with texture offests - for example, a texture can be made to scroll left-to-right by increasing it's offset by one pixel at a given interval, since the -a option also copies the first row of pixels to an (unused) row of pixels. Again, check out the information the consts file produces when this option is used.

About -M (--organize) and -E (--collision-exclude) options
The -M option specifies what collision types are sorted by. Valid values are:

The -E option excludes every one of the object's components that can be categorized by the -M option and the -E argument's option. Take the following options in an example set of options:
  -M group -E water_group_00
The -M group tells that collision is to be generated and sorted by groups, and the -E water_group_00 tells the converter not to generate collision for the group named water_group_00. If the -E option is used without the -M option, the sorting is assumed to be done by material.

A similar function for excluding and sorting graphics mesh is planned