Download

Online

Gallery

Blog

  Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 25
Posts: 25   Pages: 3   [ Previous Page | 1 2 3 | Next Page ]
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 10730 times and has 24 replies Next Thread
sjb007
Advanced Member




Joined: May 18, 2021
Post Count: 210
Status: Offline
Reply to this Post  Reply with Quote 
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.
[Jun 19, 2022, 2:31:35 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
sjb007
Advanced Member




Joined: May 18, 2021
Post Count: 210
Status: Offline
Reply to this Post  Reply with Quote 
cool 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.
<kitchen-level>|<island-group>|<tall-chair-group>|<tall-chair-01>
<kitchen-level>|<island-group>|<tall-chair-group>|<tall-chair-02>
<kitchen-level>|<island-group>|<tall-chair-group>|<tall-chair-03>

I'm not decided whether the SH3D groups should become sub-collections or be done with parent objects. Parent Objects would behave more like SH3D.
[Jun 19, 2022, 8:13:00 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Daniels118
Advanced Member
Member's Avatar

Italy
Joined: Nov 17, 2021
Post Count: 398
Status: Offline
Reply to this Post  Reply with Quote 
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.
[Jun 20, 2022, 7:45:26 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
sjb007
Advanced Member




Joined: May 18, 2021
Post Count: 210
Status: Offline
Reply to this Post  Reply with Quote 
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. biggrin )
[Jun 20, 2022, 11:37:52 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
sjb007
Advanced Member




Joined: May 18, 2021
Post Count: 210
Status: Offline
Reply to this Post  Reply with Quote 
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.
[Jun 20, 2022, 12:35:17 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Daniels118
Advanced Member
Member's Avatar

Italy
Joined: Nov 17, 2021
Post Count: 398
Status: Offline
Reply to this Post  Reply with Quote 
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?
[Jun 20, 2022, 4:06:57 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
sjb007
Advanced Member




Joined: May 18, 2021
Post Count: 210
Status: Offline
Reply to this Post  Reply with Quote 
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 confused 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.
[Jun 20, 2022, 11:37:33 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
sjb007
Advanced Member




Joined: May 18, 2021
Post Count: 210
Status: Offline
Reply to this Post  Reply with Quote 
Re: Add "o" to OBJWriter output

So if anyone wants to take a look or have a test, the first version is posted as a diff against the 6.6 source.

To be clear: This is only partially useful until I finish the Blender Python importer.

What this will do: All Walls, Rooms, and Furniture will get "o" entries.

The entries are "|" delimited which will (when I finish) give structure through collections in Python. i.e.
<levelheight-levelname>|<group_name>|...|<subgroup_n_name>|<item_name>

Where an item has multiple meshes "g" (very common) they can be optionally turned into blender vertex groups for easy selection.
[Jun 21, 2022, 12:21:05 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Daniels118
Advanced Member
Member's Avatar

Italy
Joined: Nov 17, 2021
Post Count: 398
Status: Offline
Reply to this Post  Reply with Quote 
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:
Room3D room3D = new Room3D(room, home, false, true);
Node floor = room3D.getChild(0);
writer.writeNode(floor);
if (room.isCeilingVisible()) {
Node ceiling = room3D.getChild(1);
writer.writeNode(ceiling);
}

[Jun 21, 2022, 9:08:53 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
sjb007
Advanced Member




Joined: May 18, 2021
Post Count: 210
Status: Offline
Reply to this Post  Reply with Quote 
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:
Room3D room3D = new Room3D(room, home, false, true);
Node floor = room3D.getChild(0);
writer.writeNode(floor);
if (room.isCeilingVisible()) {
Node ceiling = room3D.getChild(1);
writer.writeNode(ceiling);
}

Once again making a bid for Most Valued Player I see. wink

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.
[Jun 22, 2022, 2:55:16 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Posts: 25   Pages: 3   [ Previous Page | 1 2 3 | Next Page ]
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

    Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads
   
© Copyright 2006-2024 eTeks - All rights reserved