- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Meshing >
- Blender - Blender Object (S3ASC) Import/Export Scripts
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Meshing >
- Blender - Blender Object (S3ASC) Import/Export Scripts
Posts: 231
Thanks: 402 in 1 Posts
Installation Instructions:
For different operating systems this is:
- Linux: ~/.blender/scripts
- Windows XP: C:\Program Files\Blender Foundation\Blender\.blender\scripts
- Windows XP (alt): C:\Documents and Settings\USERNAME\Application Data\Blender Foundation\Blender\.blender\scripts
- Windows Vista: C:\Users\USERNAME\AppData\Roaming\Blender Foundation\Blender\.blender\scripts
- Mac OS X: Under Mac OSX the path is actually hidden in the blender.app so to know the path you would have to know that the script folder is actually hidden in the blender.app itself. Assuming that Blender is in the applications directory the path would be "/Applications/blender/blender.app/Contents/MacOS/.blender/scripts" If you try to open the .app contents from the finder you will notice that .blender section of the path is not visible, while blender will still be able to navigate to this folder. Right-click (or ctrl-click) the file "blender", and select "Show Package Contents" in the popup-menu. It will display all the hidden files under blender's folder, and select "scripts" folder inside it.
To see this folder from the OSX terminal use the ls -a command (lists all folders/files even hidden) in the MacOS folder of the listed path. It is probably a good idea to create an alias to the scripts folder in the "/Applications/blender-2.37a-OSX-10.3-powerpc" folder so that scripts can be easily manipulated through the finder. I know that its confusing that Blender should have its script folder buried inside the app but it is necessary to keep the app portable and not require an install. - Mac OS X: A safer approach than the one above consists in keeping your scripts somewhere in your home folder: with this scheme, there is no risk of deleting your scripts when you upgrade your blender application, as they are not contained within its folder. A method that follows this principle is as follows: create a folder that will contain your scripts (or some of them) inside your own home directory; then, instead of putting your files directly in the .../.blender/scripts/ folder discussed above, simply add a link to your script directory in the .../.blender/scripts/ folder (for instance with the "ln -s" Unix command, or by doing "open /Applications/blender-2.37a-OSX-10.3-powerpc/blender.app/Contents/MacOS/.blender/scripts/" [adapted to your version of blender] and then creating a link through the Finder, with File->Make Alias). Blender will now find all the scripts that you put in your home directory: it will follow the link you created in its .../.blender/scripts/ folder and go to the corresponding folder in your own directory, and find all the python scripts you put there.
How to use:
I'll load simplistic videos on Youtube for this as we go along and I find people having particular issues which might be better explained through that medium:
http://www.youtube.com/user/ThysCeixari
Please Note:
These scripts are for objects only. If you wish to do Body Meshing (GEOM), please see the Blender GEOM Mesh Plugin
Import History:
0.1.0 - First test script
0.1.1 - Rewrite, much smaller, less complex code, learnt more Python
0.1.2 - Added UV code
0.1.3 - Fix for UV Code due to extra UV lines in some .s3ascg files
0.1.4 - UV now the right way round
0.1.5 - Smoothing per face (causing black faces on my laptop)
0.1.6 - Calculation of Normals = Blackness gone
0.1.7 - Quick fix for files without UV
0.2.8 - Added Armature/Bones / Upped the w/o to keep it in sync
0.3.9 - Added the text objects that was necessary for the export to function
0.3.10 - Added a check to ensure one import is not done while another import is active
0.4.11 - Rewrite of the script to accommodate multiple UVs
0.4.12 - Sometimes there's a skin line with zero quantity and no lines
0.4.13 - Fix needed for Vertex Groups where the related bone was a duplicate and therefor removed
0.4.14 - Removed some debug print lines I left in.
0.5.0 - Setting the version same as export script. Both seems stable.
Export History:
0.1.0 - First test script
0.2.1 - Skipped to keep minor versions in sync
0.3.2 - Test version for initial testing
0.3.3 - Fixed an error where the imported assignments were zero and weren't stored by Blender
0.3.4 - Added a check to ensure it can parse the group names. Added a check to ensure a prior .s3asc import was done
0.3.5 - Fixed another error where the imported assignments were zero and weren't stored by Blender
0.4.6 - Changes necessary for multiple UVs
0.4.7 - Error on no default UV Texture now provides a better error message. Making provision for VRTF-6 and non-sequenced VRTF/VBUF sections
0.4.8 - Ensuring no errors are reported for meshes which do not have/should not have UV textures
0.4.9 - A further fix to the VRTF/VBUF sequencing when multiple UVs aren't next to each other
0.5.0 - Fixed an error with assignments. Been using this version for some time while writing the .wso scripts. Seems stable so far.
PLEASE NOTE:
Delete any scripts in your Blender scripts directory starting with S3ASC. Now that we have the proper scripts, we no longer need files specifying with and without bones, so a simple import and export name is sufficient.
IMPORTANT:
These scripts, especially the export script, is still in testing phase until the version is upped to 1.0. If any problems in the process is experienced while using these scripts, even if you see the error in S3ObjTool, please report the error here. We'll be able to tell if the error is with the scripts or with another tool.
.
Tutorial - How to use the Blender Scripts for Replacement Meshes (Single Bone).zip (2.25 MB, 1532 downloads) - View custom content | ||
3938156 04-06-10 18:10 Tutorial - How to use the Blender Scripts for Replacement Meshes (Single Bone).pdf -------- ------- 3938156 1 file |
||
Description: Tutorial - How to use the Blender Scripts for Replacement Meshes (Single Bone) | ||
Blender_TS3_Object_ImportExport_Scripts .zip (10.2 KB, 2494 downloads) - View custom content | ||
13645 06-20-10 08:28 s3asc_export .py 19622 06-20-10 08:32 s3asc_import.py -------- ------- 33267 2 files |
||
Description: Blender Import/Export Scripts (0.4) - 20 June 2010 |
Posts: 44
i'd be glad to guinea pig and cheer on the sidelines. that's about as useful as i can be haha. good luck and you are great for doing this YAY.
just wanted to add moral support XD
<3tash.
Posts: 231
Thanks: 402 in 1 Posts
I'm working on the Import script first and I've been able to import the first .s3asc (or rather directly from the .s3ascg). I need to debug the script today as some of the vertices were totally out of place, so the object looked weird. I used on of the simplest objects (a bowl) to play with initially.
The script is extremely bare and thin at the moment, which is why it's basically importing per group rather than loading all the files at once. For now I'm only importing vertices and faces to create the basic mesh, but hope to move on the the rest of the script by tomorrow.
Posts: 11,006
Thanks: 423038 in 1121 Posts
Do you know that there is a (small, inactive) "Blender users" group on this site? http://www.modthesims.info/forumdis...546&groupid=245 <-- if you need testers or something, you could post there, I imagine most of them will have subscribed to posts in that group (even though it looks a bit dead).
Stuff for TS2 · TS3 · TS4 | Please do not PM me with technical questions – we have Create forums for that.
In the kingdom of the blind, do as the Romans do.
Posts: 231
Thanks: 402 in 1 Posts
Posts: 1,740
Thanks: 107803 in 53 Posts
I will be more than happy to test and help in any way (not much of a script writer though )
| (• ◡•)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
Posts: 11,006
Thanks: 423038 in 1121 Posts
Stuff for TS2 · TS3 · TS4 | Please do not PM me with technical questions – we have Create forums for that.
In the kingdom of the blind, do as the Romans do.
Posts: 2,932
Thanks: 15574 in 28 Posts
Quite honestly, it's one thing to hope your favored tool is added to the list of tools that can be used as a primary corridor between your mesh and the game, it's another to say what has already been provided to you is "ridiculous".
If the major lifting hadn't already been done, I seriously doubt you'd be complaining about this issue...you'd be sitting there hoping someone would create something...*anything*...that would allow you to edit Sims 3 objects.
I would suggest a little gratitude, but then, I'm hoping after considering how your post comes across you might show some without any hints.
Just my two cents.
Posts: 11,006
Thanks: 423038 in 1121 Posts
If one works in Tool A, it is more complicated to go through Tool B and back rather than using Tool A directly. It doesn't matter who made them, how good they are, etc .. it's a detour, and if there were a Tool A script, that detour wouldn't be necessary. That's all. In comparison to TS2 (where one could make stuff with just blender and simPE), going through S3OC > S3PE > converter > milkshape > blender > milkshape > converter > S3PE > S3OC *is* a very long chain – a script that could eliminate one or two of these stations would almost cut it in half. This is why it matters for blender users.
Stuff for TS2 · TS3 · TS4 | Please do not PM me with technical questions – we have Create forums for that.
In the kingdom of the blind, do as the Romans do.
Posts: 1,740
Thanks: 107803 in 53 Posts
...going through S3OC > S3PE > converter > milkshape > blender > milkshape > converter > S3PE > S3OC *is* a very long chain... |
And that's if you get it right the first time through, which never happens.
| (• ◡•)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
Posts: 11,006
Thanks: 423038 in 1121 Posts
And that's if you get it right the first time through, which never happens. |
LOL – tell me about it!
I got it to work in the end (the presets too, yay!), and the shadows look super awesome now. Thanks again for your help.
Stuff for TS2 · TS3 · TS4 | Please do not PM me with technical questions – we have Create forums for that.
In the kingdom of the blind, do as the Romans do.
Posts: 2,932
Thanks: 15574 in 28 Posts
In my opinion calling that means ridiculous in some way is a belittling thing to say. I don't think it is "over-interpreting " to think so. It is far different than saying you would like a more stream-lined avenue which it seems like what you really meant. If that's what you mean then you should stick to what you mean and not add in a pejorative concept like "ridiculous" IMO.
I'm not going to argue the point further. I've said my piece.
Posts: 231
Thanks: 402 in 1 Posts
The script can do the vert positions, the faces and the texture coordinates. The .obj import script does not import normals and for now I'm going to let Blender automaticaly recalculate the normals as well, but of course the export script will have to include those, but that's not a problem.
I do have a question though and that's about the VRTF section. I can see form the WIKI specs that the VBUF and VRTF has some relationship and I can relate it in the file as well.
I extracted the Garden Gnome object and one of it's files has the following:
vrtf 6 28
0 0 0 7 0
1 1 0 5 8
2 2 0 6 12
3 3 0 4 16
4 4 0 5 20
5 5 0 5 24
skin 1
0 1C5C004B 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.112335
vbuf 731
0 0 -0.153813 0.045656 0.022614
0 1 -0.156250 -0.976563 0.164063
0 2 0.109702 0.062361
0 3 0 0 0 0
0 4 1.000000 0.000000 0.000000
0 5 0.953125 -0.265625 0.093750
1 0 -0.199377 0.051820 0.017457
1 1 -0.156250 -0.976563 0.164063
1 2 0.038329 0.067287
1 3 0 0 0 0
1 4 1.000000 0.000000 0.000000
1 5 0.960938 -0.250000 0.000000
Now I know that the first character is the line column represents a counter (line number if you wish). In VBUF it's more like a grouping counter, but you know what I mean.
For column 2 in VBUF 0=position, 1=normal, 2=UV, 3=assignment, 4=skin weight, 5=tangent and I'm taking that it means the same in VRTF. In the VBUF section I'm kind of covered with the rest of the columns, but the VRTF columns still escapes me.
Posts: 11,682
Thanks: 9680 in 11 Posts
"You can do refraction by raymarching through the depth buffer" (c. Reddeyfish 2017)
Posts: 2,932
Thanks: 15574 in 28 Posts
Sorry to go off topic in your thread again Ceixari...I'm very glad you're moving forward with this project
Posts: 2,832
Thanks: 6613 in 20 Posts
Well, back to the scripts then vrtf 6 28 0 0 0 7 0 1 1 0 5 8 2 2 0 6 12 3 3 0 4 16 4 4 0 5 20 5 5 0 5 24 |
The first line has the item count [6] and total bytes-per-vertex [28] .
Then, for each of the [6] specified lines you have:
The "counter" in the first column... it is there to maintain a check on line sync.
The second column is the item type, position, normal, etc. from the list.
The third column is the instance number... usually this is zero, but some files have multiple UV maps, so for those [type 2 in column 2] you may see a "2 0" and then a "2 1", the first is the first UV map (instance 0) and the next would be UV map 2 (instance 1). There is not an example of multiple UV maps in that file, but they will be in others.
The fourth column is a compression type... you don't need to keep this, but the recompiler needs that to make sure it produces the proper format on the binary end. The decompiler has converted the compressed binary to ascii floats or ints.
The last column is the byte offset... again, this is needed for recompilation, but of little use to an import script.
When writing the export, you need to first read in the vrtf section, so you can write it out following the format. While position is usually the first thing, followed by normals and then UVs, this is not a requirement, and things are not always ordered 0, 1, 2, 3, 4, 5. The list of types can be in any order.
How I manage this is I build an array from the vrtf, and then when I read the vbuf I loop in this case 731 times, with each of those loops expecting to read six lines (a nested loop) following the mapping laid out in the vrtf. Each line read should match the first column in the vbuf to the outer loop counter (0 to 730) and the second column should match the type of the item (position, normal, UV...). The remaining columns are the proper number of operands... 3 for position, normal and tangent, 2 for UV, 4 for bone assignments and 3 for skin weights.
If a skin weight is zero, the the matching bone assignment is immaterial, although you will probably always see zeroes for anything unused. Now there are only three skin weights and four assignments, how that works is the fourth skin weight is implied, when used, it is 1.0 minus the sum of the three other weights.
Not that object meshes use anything but a single weight, always 1.0 (or 0.0 for unassigned vertices). But the text format is really a simplified version of the binary, with all the data reordered from separate parts (vrtf, vbuf, ibuf and skin) into one file (per group).
I hope this doesn't make your head explode, because then everybody will be mad at me for bumping off their new hero.
If you like to say what you think, be sure you know which to do first.
Posts: 1,740
Thanks: 107803 in 53 Posts
| (• ◡•)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
Posts: 2,932
Thanks: 15574 in 28 Posts
Posts: 2,832
Thanks: 6613 in 20 Posts
Only nowadays, 6 million simoleans won't get you a yacht, much less a bionic man.
If you like to say what you think, be sure you know which to do first.
Posts: 231
Thanks: 402 in 1 Posts
This will take some reading and re-reading, but the VRTF section and the loop through the VBUF section is straight-forward enough.
Posts: 231
Thanks: 402 in 1 Posts
For Windows mine goes into D:\Blender\.blender\scripts, but that's just how I organised mine. I didn't download the installer just the zip file. It may also be in your user directory depending on how you installed it. I have no idea how other OSes will handle these scripts.
You may also just put it anywhere and open it with the text editor and execute it from there. This is what I normally do while I'm developing it. Once you run it, just select any file in the directory which you wish to load from, it will automatically select the .s3ascg files.
This script will basically open all (*.s3ascg) files in a directory, so please make sure the only files in the directory is to do with one of the .lod or .model files and not mixed. The popup that shows can be used as is for defaults, but you can play around with other selections if you want, just make sure you export (when it is ready) the same amount of groups as went in.
As I said I'm still learning Blender, so the groups are still a bit above what I know. I played around with single objects on a single layer before now.
For instance, to test this particular file I loaded the Business Building's first .lod exports and that has 27 groups. I can confirm it loaded all 27 groups, but because of my lack of knowledge I could only view each group one at a time and not together to see the whole building as one view.
I did consider loading each group into a seperate layer, but I'm not sure (after seeing the building) whether you could have 27 layers. I can only see about 16 layer buttons on my views.
At the moment it will load the vertex positions, faces and UV positions. I'm still playing with the bones and materials. That said it will create a basic material for each group.
If anyone wonders, this is a conversion of the .obj script which is given with the blender installation, of course with new code to read the .s3ascg format. The python debugger is a bit iffy which slows the work down a bit
Posts: 11,006
Thanks: 423038 in 1121 Posts
Groups are a bit of a science in blender, since there's a few different concepts of "group" – it's pretty simple to reorganise stuff though (once it's in blender), so as long as everything gets imported it's probably going to work out somehow.
Stuff for TS2 · TS3 · TS4 | Please do not PM me with technical questions – we have Create forums for that.
In the kingdom of the blind, do as the Romans do.
Posts: 1,740
Thanks: 107803 in 53 Posts
Something is wrong with the UVs, though. In the UV Editor it's just a dot in the general location of where it should be.
As for the groups, one thing I noticed is all the groups imported had different DataBlocks, but the same object name. It seems the object name is taken from the last group imported. For example, the mesh I imported had 4 groups, and all of the object names were group03. For comparison, in an obj. datablock "group00" = object name "group00", and so on.
Hope that helps you figure something out, and thanks a lot for you hard work.
| (• ◡•)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
Posts: 231
Thanks: 402 in 1 Posts
0 F393EB45 -1.000000 0.000000 0.000000 -0.159300 0.000000 0.000000 1.000000 -0.427463 0.000000 1.000000 0.000000 -0.715816
Position 1: Counter
Position 2: Name
Position 3: Parent maybe? With -1 indicating none?
Position 4:
Position 5: Rotation X (?)
Position 6: Position X
Position 7:
Position 8:
Position 9: Rotation Y (?)
Position 10: Position Y
Position 11:
Position 12:
Position 13: Rotation Z (?)
Position 14: Position Z
The rotations are wrong, but for now that's my guesses until shown otherwise
Thanks
Posts: 231
Thanks: 402 in 1 Posts
Something is wrong with the UVs, though. In the UV Editor it's just a dot in the general location of where it should be. |
To be honest, I imported the UV coordinates, but didn't look at where they went as I was more concerned with the mesh, but thank you very much for pointing this out.
As for the groups, one thing I noticed is all the groups imported had different DataBlocks, but the same object name. It seems the object name is taken from the last group imported. For example, the mesh I imported had 4 groups, and all of the object names were group03. For comparison, in an obj. datablock "group00" = object name "group00", and so on. |
This one is a bit strange, because when I imported the building, each group had a different name. I'll test with some other objects as well to make sure.
And, of course, thanks for taking the time to have a look at it
Who Posted
|