Romania
Joined: Apr 24, 2014
Post Count: 741
Status:
Offline
Furniture to Solid
For around 8 months I've fight with this. 1. What is a sh3d furniture? It have a model centered at origin and a lot of Transform3D applied to this model: (size x,y,z); (rotation x,y,z); (position x,y,z) All this transforms affect the vertices value and result in a HomePieceOfFurniture3D which we see in the preview. So far so good. 2. What is a Solid? As far I've was able to understand it is another way to define a 3D object (vertices, faces, color(materials)). It was defined by D. H. Laidlaw, W. B. Trumbore, and J. F. Hughes. "Constructive Solid Geometry for Polyhedral Objects", 1986. Commonly known as CSG. 3. What's use for? Well, to make some operations whit this objects like boolean (union, intersection, subtract or XOR). 4. What I looking for? A way (simple, eventually), to get the current vertices values of a selected piece of furniture to make a CSGObject. I know, for a professional look's like a newbie question but I'm a newbie.
---------------------------------------- A computer program does what you tell it to do, not what you want it to do. Murphy's Law When all else fails, read the instructions. Murphy's Law If you don't like "AS IS", DIY. Dorin's law
Netherlands
Joined: Apr 8, 2022
Post Count: 1608
Status:
Offline
Re: Furniture to Solid
2. What is a Solid? As far I've was able to understand it is another way to define a 3D object (vertices, faces, color(materials)). It was defined by D. H. Laidlaw, W. B. Trumbore, and J. F. Hughes. "Constructive Solid Geometry for Polyhedral Objects", 1986. Commonly known as CSG.
Besides the CSG method there is another one: Boundary Representation (B-Rep). That is what is used in Sweet Home 3D, or rather used through the .obj definition. B-Rep defines a model by specifying the limits of its volume: a collection of connected faces and their edges and vertices.
There is a free opensource program called OpenSCAD that you can use to import an .obj file and export is as CSG. I'm not sure what you want to do with the resulting CSG because it's useless in Sweet Home 3D. Check out FreeCAD (opensource). You can import .obj files and it can execute several of the operations you want like intersection etc.
4. What I looking for? A way (simple, eventually), to get the current vertices values of a selected piece of furniture to make a CSGObject.
To simply get the vertice values: each v line in an exported obj file represents a vertice of the 3D model. I haven't checked but I'm pretty sure the PieceOfFurniture object in Sweet Home 3D holds exactly that obj definition in some form, maybe twice: original and transformed.
---------------------------------------- Dodecagon.nl 1300+ 3D models, manuals, and projects
Romania
Joined: Apr 24, 2014
Post Count: 741
Status:
Offline
Re: Furniture to Solid
I work to a plugin able to perform boolean operations with furniture. The result is transformed back to furniture. I've managed to make it work except the correct input data. I've tried with
but, in both cases, I have only the original object without the current transformations. I need to apply this transformations to each ones before extract the geometry and perform the boolean operations.
---------------------------------------- A computer program does what you tell it to do, not what you want it to do. Murphy's Law When all else fails, read the instructions. Murphy's Law If you don't like "AS IS", DIY. Dorin's law
Netherlands
Joined: Apr 8, 2022
Post Count: 1608
Status:
Offline
Re: Furniture to Solid
...I have only the original object without the current transformations. I need to apply this transformations to each ones before extract the geometry and perform the boolean operations.
You should be able to get the applied transformations with the getModelTransformations method. Maybe you can use these to apply to the original object to get the transformed object.
In my previous reply I said "...maybe twice: original and transformed." The second is the original+transformations. As in "not a transformed copy" but the original and applied transformations for display/storage.
When you save a transformed object the transformations are stored in the Home.xml file (pitch (X axis), roll (Y axis), angle (rotation), widthInPlan, heightInPlan, etc) along with the original dimensions (width, depth, height) and elevation. Maybe you can trace back where/how the transformation matrix is calculated to get the property values that are stored in the Home.xml file and use the same method for your usage. (I don't have the code available at the moment so I have to use logic, the API model, and programming experience to guess at this.)
---------------------------------------- Dodecagon.nl 1300+ 3D models, manuals, and projects
Romania
Joined: Apr 24, 2014
Post Count: 741
Status:
Offline
Re: Furniture to Solid
I've tried getModelTransformations but it refer to other kind of Transform used for parts of the object(DoorOrWindow and Mannequin). Probably you've right in the part I have to apply all the Transform3D like in Home.xml. My knowledge in java3d and how it work BranchGroup and Transform3D is very poor but I have a whole life in front to learn.
---------------------------------------- A computer program does what you tell it to do, not what you want it to do. Murphy's Law When all else fails, read the instructions. Murphy's Law If you don't like "AS IS", DIY. Dorin's law
Netherlands
Joined: Apr 8, 2022
Post Count: 1608
Status:
Offline
Re: Furniture to Solid
Try to trace back from where the project is saved. Tracing back from save should eventually encounter the method that calculates the property values as they are saved in Home.xml. Then see if you can use that same method for your purpose. If the values aren't recalculated but retrieved from somewhere then you can trace back from there.
In my C# IDE I can call up a list of all methods that call a selected method or object. I don't know if you can do the same with Java in Eclipse but if you can that should greatly help in tracing back.
---------------------------------------- Dodecagon.nl 1300+ 3D models, manuals, and projects
Romania
Joined: Apr 24, 2014
Post Count: 741
Status:
Offline
Re: Furniture to Solid
In Eclipse exist a debugger which do the trace and show variables values but this mechanism need also to be learned before to be used. Well, an other life. Remain 7 from 9 (if I'm a cat and I don't know). Until this year I have a lot of inspiration from some sites with java code samples but it became unavailable.https://www.java2s.com or https://www.java3d.org/tutorial.html
---------------------------------------- A computer program does what you tell it to do, not what you want it to do. Murphy's Law When all else fails, read the instructions. Murphy's Law If you don't like "AS IS", DIY. Dorin's law
Netherlands
Joined: Apr 8, 2022
Post Count: 1608
Status:
Offline
Re: Furniture to Solid
What I meant was follow the chain of calls back until you reach the method that does the calculation. That's why I mentioned the reference list I can call up, Eclipse should have at least that too. Makes it easier to follow back when you know which methods are calling the one where you are.
---------------------------------------- Dodecagon.nl 1300+ 3D models, manuals, and projects
Romania
Joined: Apr 24, 2014
Post Count: 741
Status:
Offline
Re: Furniture to Solid
Thanks Daniels118! I've tried this many times in the past months. Probably I've not tried hard enough. I will keep trying, fail and learn. The plugin I working for intend to be an three actions plugin. At least two of them have to use the boolean operations. I've found at least 3 different libraries specialized for this. The best results was with commons-geometry 1.0 when was used as jar library in an stand alone application. Using sources in the same context have more poor results. Using this library into a plugin make the plugin relatively huge(1.6Mb) comparing with actual 153kb. On all the cases the problem is the input data (vertices values of objects). The resulted object will need have the values like it's position is at zero center but we will see it let say at x: 1.2m /y: 2.3m /z: 0.6m based on where the selected furniture are. Probably the CopyAsNewFurniture plugin hide the solution. I will see.
---------------------------------------- A computer program does what you tell it to do, not what you want it to do. Murphy's Law When all else fails, read the instructions. Murphy's Law If you don't like "AS IS", DIY. Dorin's law