Editing Obj2grid

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
Obj2grid was created by Renol/Yoshi2. It is a command line tool that converts Wavefront OBJ files to Pikmin 2 grid.bin (collision) and mapcode.bin (footstep sounds) files, and converts Pikmin 2 grid.bin files back into Wavefront OBJ.
+
Obj2grid was created by Renol/Yoshi2 and can be found on his [https://github.com/RenolY2/obj2grid Github Repository].
  
== Download ==
+
__TOC__
* [https://github.com/RenolY2/obj2grid GitHub repository]
 
  
[[Category:Tools]]
+
==obj2grid==
[[Category:Pikmin 2]]
+
obj2grid is a command line tool that converts Wavefront OBJ files to Pikmin 2 grid.bin (collision) and mapcode.bin (footstep sounds) files, and converts Pikmin 2 grid.bin files back into Wavefront OBJ.
 +
 
 +
==Requirements==
 +
This tool requires Python 3. Newer = better (at the moment the newest version is 3.6 or so) When installing Python on Windows, make sure you check the box that says "Add Python to PATH" if you want to make use of the included .bat files.
 +
 
 +
==How To==
 +
The .obj model file you want to convert needs to be triangulated (i.e. all faces are triangles and have exactly 3 vertices). If it isn't triangulated, obj2grid will throw an error.
 +
 
 +
For a quick set-up on Windows, drag your .obj file onto the included make_collision.bat which will create a grid.bin and a mapcode.bin out of your .obj file in the folder of the .obj file. In a similar way, drag a grid.bin file onto make_obj.bat to turn Pikmin 2 collision back into .obj.
 +
 
 +
===Command line usage:===
 +
<pre>
 +
python obj2grid.py [-h] [--cell_size CELL_SIZE] [--grid2obj] [--flipyz]
 +
                  [--target_rarc TARGET_RARC]
 +
                  input [output_grid] [output_mapcode]
 +
 
 +
positional arguments:
 +
  input                Filepath of the wavefront .obj file that will be
 +
                        converted into collision. If --grid2obj is set,
 +
                        filepath of the grid.bin to be converted into .obj. If
 +
                        input is a RARC archive (texts.szs/texts.arc) then the
 +
                        grid.bin will be extracted from it.
 +
  output_grid          Output path of the created collision file. If
 +
                        --grid2obj is set, output path of the created obj file
 +
  output_mapcode        Output path of the created mapcode file
 +
 
 +
optional arguments:
 +
  -h, --help            show this help message and exit
 +
  --cell_size CELL_SIZE
 +
                        Size of cells in grid structure. Bigger can result in
 +
                        smaller file but lower ingame performance
 +
  --grid2obj            Use this option to create an OBJ file out of a
 +
                        grid.bin file
 +
  --flipyz              If option is set, the Y and Z axis are swapped.
 +
  --target_rarc TARGET_RARC
 +
                        Target RARC archive (texts.szs, texts.arc) into which
 +
                        grid.bin and mapcode.bin will be written. The archive
 +
                        needs to exist already.
 +
</pre>
 +
 
 +
===Examples===
 +
<code>python obj2grid.py --cell_size 100 MyCustomCollision.obj MyPikminGrid.bin MyPikminMapcode.bin</code>
 +
 
 +
<code>python obj2grid.py MyCustomCollision.obj --target_rarc "C:\Modding\Pikmin 2\user\Kando\map\tutorial\texts.szs"</code>
 +
 
 +
<code>python obj2grid.py --grid2obj MyPikminGrid.bin MyCollision.obj</code>
 +
 
 +
Note: you can use absolute file paths (i.e. ones starting with C:\ or C:/) so that your finished collision is put directly into the folder you want them in, see second example above.

Please note that all contributions to Pikmin Technical Knowledge Base are considered to be released under the Creative Commons Attribution-ShareAlike (see Pikmin Technical Knowledge Base:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)