Joined: May 18, 2021
Post Count: 255
Status:
Offline
Re: Add "o" to OBJWriter output
Just so no one else wastes time, I've added the vertex groups and scaling to the blender obj import. Limited tests, but looks good.
I've written a provisional, untested patch for SH3D that I think will do the "o" entry. I'm not a Java dev but can sort of understand it, so it looks correct. I don't yet have Eclipse/JDK installed in order to try building it. That's the next job.
After that (if can figure it out) I might try and implement the idea of putting imported objects into a tree of blender containers based on Level and furniture groups (idea 2 in my earlier message). No promises on that one though.
Joined: May 18, 2021
Post Count: 255
Status:
Offline
Re: Add "o" to OBJWriter output
OK, so Java is horrible. Bloomin' strange lingo. My untested attempt did not work at all. Many iterations and tests later...
I have gotten furniture being named, and even prefixed by the level name, with the "|" character as a seperator. It imports into blender perfectly.
Walls and rooms still need attention to prefix with their level name in the same way. Additionally Rooms have names, so I'll add that. Maybe I should separate the walls and rooms into sub-collections of the level... might be nice for organisation.
I haven't yet started to look at the bit to get Blender to create collections based on the level name, and make the objects a child of the level/collection. That is Python (which I'm way better at than Java) so it will just be a bit of a dive trying to understand the Blender API.
And now a question for the people familiar (and, unlike me, competent) with the Java code: Is it possible to check/get the parent groups from a HomePieceOfFurniture? I'm thinking the group hierarchy could be also turned into sub-collections. i.e.
Italy
Joined: Nov 17, 2021
Post Count: 465
Status:
Offline
Re: Add "o" to OBJWriter output
Is it possible to check/get the parent groups from a HomePieceOfFurniture?
I'm quite sure you can't get the parent directly. However you can get the child from the parent, so you can iterate over all groups to build a child->parent map, and use it later to query the parent from the child. Keep in mind that groups can be nested, so if you want to recreate the hierarchy you have to prepend the parent name in a loop until the object has no more ancestors. Another approach could be to retrieve the objects using Home.getSelectableViewableItems(), which returns all the non-grouped objects + the groups, then you can itearate over the items and if you find a group dive into it using a recursive method.
Joined: May 18, 2021
Post Count: 255
Status:
Offline
Re: Add "o" to OBJWriter output
Is it possible to check/get the parent groups from a HomePieceOfFurniture?
I'm quite sure you can't get the parent directly. However you can get the child from the parent, so you can iterate over all groups to build a child->parent map, and use it later to query the parent from the child. Keep in mind that groups can be nested, so if you want to recreate the hierarchy you have to prepend the parent name in a loop until the object has no more ancestors. Another approach could be to retrieve the objects using Home.getSelectableViewableItems(), which returns all the non-grouped objects + the groups, then you can itearate over the items and if you find a group dive into it using a recursive method.
I was afraid of that, but good to have better eyes than mine confirm it. Guess I have to figure out more Java-isms. Ugh. At least the HomePane.OBJExporter class already has code to iterate through the objects using getSelectableViewableItems/getSelectedItems. Reading the code the structure looks flat, so there shouldn't need to be any recursion. Just create a HashMap child:parent, then loop over the hashmap to build the parent groups when creating the full "path". Nothing too complicated.
So when I get the SH3D bit finished, would you mind taking a look over it? It'll be pretty short as patches go, but I'm sure I've done some bits in bad way. (i.e. that there is a Javonic way, just like there is a Pythonic way, and I'm forcing Pythonic style into Java. )
Joined: May 18, 2021
Post Count: 255
Status:
Offline
Re: Add "o" to OBJWriter output
Reading the code the structure looks flat, so there shouldn't need to be any recursion. Just create a HashMap child:parent, then loop over the hashmap to build the parent groups when creating the full "path". Nothing too complicated.
Ha! Spoke too soon. That getAllFurniture does the descent for you, returning a flattened list of furniture, buggering up my first attempt at group nesting.
Joined: May 18, 2021
Post Count: 255
Status:
Offline
Re: Add "o" to OBJWriter output
So when I get the SH3D bit finished, would you mind taking a look over it?
For sure. One question: are you planning to build a plugin or a derived version of the main program?
I refer you to my previous comments regarding my lack of Java skills I now have it working perfectly, but I've done it by hacking on chunks of HomePane.java and OBJWriter.java.
I wouldn't know how to separate it to make a plugin, but I guess I can take a look at the guide. Maybe I can figure it out. I definitely wouldn't do a derived version as in my own version of SH3D, not for such a minor feature. I was thinking of submitting it as a patch to the ticket I raised in SF.
The only thing I can see to change now is to have rooms separate the floor and ceiling, otherwise you can't easily see the aerial view without messing around. That a nice to have, and first I have to get the collection division working in Blender. Back to lovely Python, ahhh... and the Blender API, AHHHHHGGGGHHHH!
Mostly this is scratching an itch I have. I need to get some planning grade diagrams. My path currently is going to be SH3D -> Blender (model finessing) -> FreeCAD (using the Technical Draw workbench for 1:50 scale plans, elevations and sections. I could use Blender further for the prettied up 3D renders.
If FreeCAD proves uncooperative I have the option of exporting from Blender to SketchUp, and holding my nose and Stumping up for the Pro version that includes Layout which also does good elevations, sections etc., but £235 per year is a bit rich just to get access to Layout.
Italy
Joined: Nov 17, 2021
Post Count: 465
Status:
Offline
Re: Add "o" to OBJWriter output
The only thing I can see to change now is to have rooms separate the floor and ceiling, otherwise you can't easily see the aerial view without messing around
For anyone wondering, this can be wordarounded in Blender by simply turning on backface culling for the ceiling material.
An alternative could be to export each room 2 times as 2 separate objects, one with both ceiling and floors, and one with floor only (the Room3D constructor has a ignoreCeilingPart parameter that can be used for this purpose).
The third option is to use the second option, with the addition to select only the ceiling node:
Joined: May 18, 2021
Post Count: 255
Status:
Offline
Re: Add "o" to OBJWriter output
For anyone wondering, this can be wordarounded in Blender by simply turning on backface culling for the ceiling material.
An alternative could be to export each room 2 times as 2 separate objects, one with both ceiling and floors, and one with floor only (the Room3D constructor has a ignoreCeilingPart parameter that can be used for this purpose).
The third option is to use the second option, with the addition to select only the ceiling node:
Once again making a bid for Most Valued Player I see.
That was very helpful, although I've slightly modified the idea. Floors and Walls are entirely separate, and members of separate collections, so I can hide ceilings in one tap.
I've posted the first real proof of concept to the ticket in comment 1 of this thread. It all works perfectly on my 90 MB exported obj file. It would be useful if some others could give it a try and see if it works for them.
I just had the thought that the reverse could be done. Blender export to obj, and a special mode for SH3D to reimport. Roundtripping between the two. But I'm not think about that right now.
I am still thinking about the plugin idea, but I just don't know if I have the Java chops to be able to do that.
I'm noticing quite a few issues in Blender with flipped normals. This makes backface culling look quite bad, and tends to butcher the textures/smoothing. I'm not sure if this is poor quality models, the export, or the import. Whatever it is, it is not my code, because I'm not monkeying around with that stuff.