I’m working on a project right now in Panda3D (1.6.2) that views and edits mesh files from an old Playstation game (Final Fantasy Tactics). The program is mostly working, but I’ve encountered two problems caused by the way the mesh files are stored and rendered on the Playstation itself, and I don’t know the best way of dealing with them.
So you can get an idea of what I’m talking about, here’s an example of what the mesh files look like:
The first problem is that there’s a single 4-bit-per-pixel 256x1024 texture image for the whole scene, and each polygon can apply one of sixteen 16-color palettes to the texture image while the polygon is being rendered.
One way to solve this would be to create 16 copies of the texture in Panda3D, each with a different palette applied. Then, I could create 16 empty NodePaths, each with a different texture applied to it, and then parent each polygon to the appropriate NodePath. This is a fairly simple way to do it, but it requires duplicating the texture in memory, which makes editing a little more of a pain.
Another possibility would be to use shaders. If I could pass the palettes to the shaders (I’ve done this before in OpenGL without Panda3D by making a special 1D texture that contained a pixel for each palette color), then I could have the shader decide which palette to apply to the polygon. I haven’t used shaders in Panda yet, though, and I’m not sure I’d be able to use that same 1D texture trick, so I don’t know if this method will work.
The second problem is that each polygon has a set of 12 bits that indicate when each polygon should be drawn, based on the rotation of the camera around the scene. This works sort of like back-face culling, but it’s explicit and provides more flexibility because there are 12 angle ranges (NE, NNE, NNW, etc.) instead of 2 (front and back).
One solution for this is to have 12 empty NodePaths, each of which contains the full set of polygons that should be visible from that angle. Then, as the camera rotates, check the camera’s angle and show/hide the appropriate NodePaths. This is simple, but creates a lot of duplicate information (many polygons would appear in all 12 NodePaths).
I guess I could do away with the empty NodePaths in both cases and individually show or hide polygons or set their textures, but I’m a little worried about the performance impact that might have with 1500 or so polygons. Maybe that’s not such a big deal, though.
Is there an easy solution to either of these problems that I’m missing?