Updating Blender-to-Saturn script

Hi all,

I recently joined, and it's my first time posting, but have been a long time reader!

I'm looking for some scripting help for 3D model exporting in Blender for the Sega Saturn.

I've been working on updating the Blender to Saturn Model Exporter script. So far, it's been going well, but I can't seem to get the orientation and rotation correct when I pop the models into Jo-Engine. I have 2 versions of the script:

One where I can add an image to a polygon via a material and UV Map, individually, and then run the script (this one seems work work, but is pretty tedious).
Second where I can use one image and a UV Map (or maps) and it'll bake the images from the face of the polygon.

The second script is where I'm stuck. I run it, and it creates two .h files (one places the polygons, the other grabs the images to use on the polygons).

Unfortunately, as I mentioned earlier, the orientation and rotation are off, most of the time (see below).

What I have in Blender (made the faces red, and used different eye colors to see placement):

Screen Shot 2023-04-06 at 11.21.45 PM.png


What I get when running the model in Yabause:

sc2.png


I was wondering if there's anyone here who can help with this, or if you know who I can connect with in order to get this working. The file is attached. You can just use it in Blender's Text Editor. NOTE: Your material names should have an "_" in them. If you need help running it, you can DM me.

Apologies for the long post, just wanted to provide as many details as possible.

Thank you, in advance!
 

Attachments

  • Saturn_Export_UV.py.zip
    3.8 KB · Views: 115
Last edited:
Are you certain that your texture generation is correct?
I'm sure it is. It works for simple 1:1 polygon-to-texture uses (UV map covering the entire image). The images that come out after baking are the right ones, it just seems like orientation and rotation are off. Give it a try, I could be wrong.
 
You need to keep in mind that order of vertices within the quad will affect how your texture is rotated or even whether it is flipped.
I don't rember correctly but I think v0-v1 are X axis of texture and v0-v3 are Y axis.

The problem you are describing points me to the conclusion that the order of vertex indexes for quads is incorrect.
 
You need to keep in mind that order of vertices within the quad will affect how your texture is rotated or even whether it is flipped.
I don't rember correctly but I think v0-v1 are X axis of texture and v0-v3 are Y axis.

The problem you are describing points me to the conclusion that the order of vertex indexes for quads is incorrect.
I appreciate it. I do use a method here where I create a temporary UVMap and use the polygon's loop indices to re-draw the UV Map onto the image. That gets me the correct baked images...but that doesn't mean I'm mapping them correctly to the polygon's vertices...I'll try and mess around with it to see if something comes out right.

Thanks
 
Well, aside from this, how is your Saturn work going otherwise? Do you think you could press on without this? What kind of game do you want to make?
 
Thanks for the interest! I can go on with simple, textured models using my first script, but also have to learn getting the animation exported. We'll see how that goes. I've been reading a lot on the hardware and its potential uses, but need to see how that translate to the Jo-Engine. The documentation is good, but there's a lot of digging around that still has to be done.

I actually have 2D experience in Unity, SpriteKit, and Cocoas2D (Python), and this is my first foray into 3D. What better way of doing so than with my first 3D experience (Saturn). I imagine 3D work in Unity would be much easier in most cases, but I like this as a challenge. Plus, lessons from this might make me better at games in Unity.

Anyway, I want to build a semi-open world demo, along the lines of Shenmue and Shadow of the Colossus marries Legend of Oasis. I remember daydreaming about it as a kid playing my Saturn, and now I hope to make it happen.

I appreciate the interest! Sorry for sucha long answer lol
 
No, I like to learn about new devs interests. The original script was made for 2.79 so I suppose if you really needed the UV mapping you could go back to that. I myself also started 3D maths with Saturn.

Animation is an issue that I have followed XL2's solutions to in his model converter tool; having that figured out for me so early was a big help.
 
No, I like to learn about new devs interests. The original script was made for 2.79 so I suppose if you really needed the UV mapping you could go back to that. I myself also started 3D maths with Saturn.

Animation is an issue that I have followed XL2's solutions to in his model converter tool; having that figured out for me so early was a big help.
Yeah, I was thinking about using that too, but I work on a Mac, and my PC is currently back in the US (I go back and forth from US to El Salvador as a snowbird lol). I'm also going to see if I can get animation work going. Do you know of any examples of animations from a C file that are used in Jo Engine? Could be helpful in order to create export files using the Blender API.

Blender itself isn't up to date with the Blender API, which could be a bug or due to them moving from 3.4 to 3.5 APIs. The API changes usually mess addons up, so I'm not surprised.

Also, I'm looking at the Jo Engine docs, but I can't find anything on Attributes for polygons. Do you know where I can find types or options for the parameters in the attributes? ex:

ATTRIBUTE(Dual_Plane, SORT_CEN, 0, C_RGB(204, 204, 204), CL32KRGB | No_Gouraud, CL32KRGB|No_Gouraud, sprNoflip, UseLight)

Thanks, again. I hope I'm not taking up too much of your time!
 
ATTRIBUTE(Dual_Plane, SORT_CEN, 0, C_RGB(204, 204, 204), CL32KRGB | No_Gouraud, CL32KRGB|No_Gouraud, sprNoflip, UseLight)

This is an SGL declarative. If you did not know, Jo Engine is just a wrapper for SGL.
This ATTRIBUTE parameter assigns data to a single member of an `` attbl ``, which is itself a member of a struct called PDATA. Again, that's all pure SGL from 1996.
You can find information about SGL (and the ATTRIBUTE macro) inside <sl_def.h> found in the compiler/COMMON/SGL_302j/INC directory. Additionally, you can use the SGL reference document found on Antime's documentation site here: Saturn documentation, libs & stuff

Do you know of any examples of animations from a C file that are used in Jo Engine?

No, XL2's tool (and my bastard fork of it) generates a binary file for the animation data, and is the only animation format that I am familiar with. You could ping Romulo, I know he's done some work on animations.
 
There are multiple ways for you to do animations on saturn, as there is no concrete way and everyone does what they think is best for their use case.

1) Vertex animation - Store different mesh for each frame and interpolate between them
2) Skeleton animation - store a skeleton of sorts and animate transformation of its bones
each of these have certain advantages and disadvantages, but what you will do completely depends on how you will implement it. In moder graphics these two are used together.

You can use the skeleton harness in SGL (never used it, but I know its there and its mentioned in docs somewhere) if you want
 
This is an SGL declarative. If you did not know, Jo Engine is just a wrapper for SGL.
This ATTRIBUTE parameter assigns data to a single member of an `` attbl ``, which is itself a member of a struct called PDATA. Again, that's all pure SGL from 1996.
You can find information about SGL (and the ATTRIBUTE macro) inside <sl_def.h> found in the compiler/COMMON/SGL_302j/INC directory. Additionally, you can use the SGL reference document found on Antime's documentation site here: Saturn documentation, libs & stuff



No, XL2's tool (and my bastard fork of it) generates a binary file for the animation data, and is the only animation format that I am familiar with. You could ping Romulo, I know he's done some work on animations.
Aaaahh, okay :) That information is super helpful! With that info, I found the right stuff in the documentation! The SGL Dev Manual Reference. I feel like Link :p
 
There are multiple ways for you to do animations on saturn, as there is no concrete way and everyone does what they think is best for their use case.

1) Vertex animation - Store different mesh for each frame and interpolate between them
2) Skeleton animation - store a skeleton of sorts and animate transformation of its bones
each of these have certain advantages and disadvantages, but what you will do completely depends on how you will implement it. In moder graphics these two are used together.

You can use the skeleton harness in SGL (never used it, but I know its there and its mentioned in docs somewhere) if you want
Very cool! I do use bones for animation in Blender. I wonder how that would translate. I'm looking over the Dev Manual and Tutorial manual, but I don't see anything about a harness. Do you know if there's a particular name?

Thanks!
 
Very cool! I do use bones for animation in Blender. I wonder how that would translate. I'm looking over the Dev Manual and Tutorial manual, but I don't see anything about a harness. Do you know if there's a particular name?

Thanks!
Look at Akira sample where struct MOTION is used. this struct is inside ss_akira.h.
 
Very cool! I do use bones for animation in Blender. I wonder how that would translate. I'm looking over the Dev Manual and Tutorial manual, but I don't see anything about a harness. Do you know if there's a particular name?

Thanks!

You have to be much more clear with "bones".
My animations are done with bones, but they (the skeleton) are parented to a single continuous mesh. This is exported ultimately to "vertex animation" with interpolation between keyframes. However, it _would_ be possible to program the game to accept data for the bones themselves to animate a mesh so long as it had the bone weights for each vertex. No one does this right now, but the hardware could do it if you programmed it.

If you mean that each bone is parented to a single mesh like Mario in SM64, that too is also possible and there is an SGL demo demonstrating it. The problem comes in exporting the translations/rotations of the bones.
 
You have to be much more clear with "bones".
My animations are done with bones, but they (the skeleton) are parented to a single continuous mesh. This is exported ultimately to "vertex animation" with interpolation between keyframes. However, it _would_ be possible to program the game to accept data for the bones themselves to animate a mesh so long as it had the bone weights for each vertex. No one does this right now, but the hardware could do it if you programmed it.

If you mean that each bone is parented to a single mesh like Mario in SM64, that too is also possible and there is an SGL demo demonstrating it. The problem comes in exporting the translations/rotations of the bones.
Also good to know. I was looking at the Akira "tutorial" using Matrix Animation, but it's not very helpful at the moment (since I'm just starting to read through some of the SGL manual). Do you have the url to the SGL demo you mentioned? Also, I can't seem to find the ss_akria.h file that @SuperReye mentioned as well. If you could point me in that direction, that would be cool.

I'm getting lots of ideas to test out and taking notes as I go. Enjoying this more than I enjoy dev work in Unity. Much more nuanced.
 
""nuanced"" does not even begin to describe it :flash:

On Antime's documentation page, download "SGL Libraries". This will get you a zip/rar file named "SGL302j". In this file there are SAMPLE folders. It's in there. Which one I honestly don't know, I haven't actually looked at them.

In some ways, fishing through that stuff is a lot less helpful than just winging it tbh.
 
""nuanced"" does not even begin to describe it :flash:

On Antime's documentation page, download "SGL Libraries". This will get you a zip/rar file named "SGL302j". In this file there are SAMPLE folders. It's in there. Which one I honestly don't know, I haven't actually looked at them.

In some ways, fishing through that stuff is a lot less helpful than just winging it tbh.
That's hilarious. I had downloaded that file and was going to sniff through it later (having no idea what was in it, mind you). Perfect. Now I can make comparisons to Blender's bones feature, or plain animation, to see if there's something translatable there.

Thank you very much for the knowledge!

Also, LOL @ the comment on my nuanced comment
 
Back
Top