2020-12-29 15:19:56 +01:00
![Pic or it didn't happen ](blender-psx.jpg )
2020-12-27 17:44:19 +01:00
2020-12-27 17:36:47 +01:00
# blender_io_export_psx_tmesh
2020-12-26 19:11:11 +01:00
2020-12-27 17:36:47 +01:00
Blender < = 2.79c plugin to export a gouraud shaded PSX mesh to a C file.
2020-12-27 14:15:58 +01:00
Specifically, it generates a C file containing :
* an array of SVECTOR containing the vertices coordinates
* an array of SVECTOR containing the normals
2020-12-27 17:36:47 +01:00
* an array of CVECTOR containing the color of each vertex
2020-12-27 14:15:58 +01:00
* an array of int that describe the relation between the tri meshes
* a TMESH struct to ease access to those arrays
From `libgte.h` :
```c
typedef struct {
SVECTOR *v; /*shared vertices*/
SVECTOR *n; /*shared normals*/
SVECTOR *u; /*shared texture addresses*/
CVECTOR *c; /*shared colors*/
u_long len; /*mesh length(=#vertex)*/
} TMESH;
```
2020-12-26 19:11:11 +01:00
2020-12-27 17:36:47 +01:00
# Install the plugin
2020-12-26 19:11:11 +01:00
2020-12-27 17:36:47 +01:00
Put the `io_export_psx_tmesh.py` file in the addons folder of blender 2.79 :
2020-12-26 19:11:11 +01:00
2020-12-26 19:43:07 +01:00
On Linux, that's :
2020-12-26 19:11:11 +01:00
2020-12-26 19:43:07 +01:00
`~/.config/blender/2.79/scripts/addons`
# Steps to load your mesh
2020-12-27 12:30:11 +01:00
1. You must first triangulate your mesh (manually or via the modifier).
2020-12-27 13:23:06 +01:00
2020-12-27 12:30:11 +01:00
2. When your model is ready, you can then vertex paint it. If you don't, the vertices colors will default to white.
2020-12-27 12:34:00 +01:00
2020-12-27 12:30:11 +01:00
* If you modify your geometry *after* vertex painting, the plugin will faile to export the mesh. This is because the vertex color data is set to 0 each time you modify your geometry.
2020-12-26 19:43:07 +01:00
2020-12-27 18:11:41 +01:00
3. If needed, edit the `primdraw.c` file , lines 29 and 30, to reflect the number of tris you want to be able to draw ( Max seems to be ~750 in NTSC, ~910 in PAL )
2020-12-27 13:23:06 +01:00
```c
#define OT_LENGTH 2048 // Maximum number of OT entries
2020-12-27 18:11:41 +01:00
#define MAX_PRIMS 1024 // Maximum number of POLY_GT3 primitives
2020-12-27 13:23:06 +01:00
```
seem to be safe values.
2020-12-26 19:43:07 +01:00
2020-12-27 17:36:47 +01:00
# Compiling
2020-12-26 19:43:07 +01:00
2020-12-27 17:36:47 +01:00
The provided `Makefile` uses the [Nugget+PsyQ setup ](https://github.com/ABelliqueux/nolibgs_hello_worlds#setting-up-the-sdk--modern-gcc--psyq-aka-nuggetpsyq ).
2020-12-26 19:43:07 +01:00
2020-12-27 17:36:47 +01:00
Create a folder in `(...)/pcsx-redux/src/mips/` , put the `Makefile` , `cube.c` and `primdrawG.c` in it, then in a terminal, just type `make` to build the ps-exe.
2020-12-26 19:43:07 +01:00
# Credits
2020-12-27 17:36:47 +01:00
Based on the [code ](https://pastebin.com/suU9DigB ) provided by TheDukeOfZill, 04-2014, on http://www.psxdev.net/forum/viewtopic.php?f=64& t=537#p4088
2020-12-26 19:43:07 +01:00
2020-12-27 17:36:47 +01:00
PSX code based on [example ](http://psx.arthus.net/code/primdraw.7z ) by [Lameguy64 ](https://github.com/Lameguy64 )