Print at Jan 25, 2022, 11:41:42 AM
Posts: 14   Pages: 2   [ 1 2 | Next Page ]
View all posts in this thread on one page
Posted by enkonyito at Sep 12, 2021, 12:23:03 AM
Add another 3D model to an existing 3D model?
Since Sweet Home 3D 6.5, there is a method to modify the 3D model of a piece of furniture.

Is it possible to modify this model by adding another one?
This modified 3D model (possibly a clone) would only be visible in a 3D preview.
----------------------------------------
standby before shutdown

Posted by Puybaret at Sep 13, 2021, 2:21:38 PM
Re: Add another 3D model to an existing 3D model?
The setModel method requires a parameter of Content type, like URLContent class. The supported content are the ones cited in the furniture import wizard, i.e. OBJ, 3DS, DAE or a ZIP file containing a file at this format. I don’t see how you could add a second model with these restrictions, unless you generate a model file containing both models.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer

Posted by enkonyito at Sep 16, 2021, 3:45:44 AM
Re: Add another 3D model to an existing 3D model?
When I select a light and added sources manually, only the light is taken into account when exporting the selection in OBJ format.
If I only select the sources added manually, the .obj and .mtl files are empty when exporting the selection in OBJ format.

How to bypass the restriction in the WriteNode method of the OBJWriter class?
...else if (node instanceof Shape3D) {
Shape3D shape = (Shape3D)node;
Appearance appearance = shape.getAppearance();
RenderingAttributes renderingAttributes = appearance != null
? appearance.getRenderingAttributes() : null;
if (shape.numGeometries() >= 1
&& (renderingAttributes == null
|| renderingAttributes.getVisible())) {
...
// Start a new object at OBJ format
this.out.write("g " + objectName + "\n");
...

----------------------------------------
standby before shutdown

Posted by enkonyito at Sep 25, 2021, 4:39:10 AM
Re: Add another 3D model to an existing 3D model?
The setModel method requires a parameter of Content type, like URLContent class. The supported content are the ones cited in the furniture import wizard, i.e. OBJ, 3DS, DAE or a ZIP file containing a file at this format. I don’t see how you could add a second model with these restrictions, unless you generate a model file containing both models.

Since it is possible to import an object into SH3D from a resource (com/eteks/sweethome3d/io/resources/lightSource.obj), how to use the URLContent class ?

The goal would be to preload a scene with the model of a light and those of these sources before displaying them in the 3D preview.
----------------------------------------
standby before shutdown

Posted by Puybaret at Sep 26, 2021, 9:30:15 AM
Re: Add another 3D model to an existing 3D model?
Look in DefaultFurnitureCatalog how the subclass ResourceURLContent is used.
But as lightSource.obj may be in different places (in a file during development, then in Furniture.jar or SweetHome3D-x.y.jar during deployment and finally in a SH3D file when saved), I would suggest to use a copy of that file in your plug-in.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer

Posted by enkonyito at Sep 28, 2021, 5:06:02 AM
Re: Add another 3D model to an existing 3D model?
For the first version of the plugin, I used this location for the lightSource.obj file.
final Content sourceContent = new ResourceURLContent (DefaultFurnitureCatalog.class, "resources/lightSource.obj");


Taking inspiration from your ShapeGenerator plug-in, I get these results.
ViewLightSources_firstOpening.jpg
ViewLightSources_secondOpening.jpg

We see that when using the plug-in for the first time, a white box serves as a 3D model of the sources while for other uses the correct model is displayed in the 3D preview.

I can publish this version so that you can suggest some improvements.
----------------------------------------
standby before shutdown

Posted by Puybaret at Sep 28, 2021, 7:14:10 PM
Re: Add another 3D model to an existing 3D model?
As said before, I would suggest not to rely on such a resource in Sweet Home 3D (they can change like icons recently), and would copy lightSource.obj in your plug-in.
You could even use your own shape naming it in the OBJ file with a prefix equal to ModelManager.LIGHT_SHAPE_PREFIX to ensure it has the same behavior as lightSource.obj.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer

Posted by enkonyito at Sep 30, 2021, 2:04:25 AM
Re: Add another 3D model to an existing 3D model?
The ViewLightSources plug-in is available.
----------------------------------------
standby before shutdown

Posted by YGYL at Oct 1, 2021, 2:09:05 PM
rose   Re: Add another 3D model to an existing 3D model?
Tested and available
It would be perfect if the coordinates of the light source of the object can be adjusted in real time

Posted by enkonyito at Oct 2, 2021, 5:05:31 AM
Re: Add another 3D model to an existing 3D model?
ViewLightSources-1.1.sh3p
- transparency of the previewed light
----------------------------------------
standby before shutdown

Posts: 14   Pages: 2   [ 1 2 | Next Page ]