Add another 3D model to an existing 3D model?
This topic has been viewed 30462 times and has 14 replies
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.
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.
EnkoNyito
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 creator
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 [font=courier new]WriteNode[/font] method of the [font=courier new]OBJWriter[/font] class?
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 [font=courier new]WriteNode[/font] method of the [font=courier new]OBJWriter[/font] class?
Code: Select all
...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");
...EnkoNyito
Re: Add another 3D model to an existing 3D model?
Since it is possible to import an object into SH3D from a resource ([font=courier new]com/eteks/sweethome3d/io/resources/lightSource.obj[/font]), how to use the URLContent class ?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.
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.
EnkoNyito
Re: Add another 3D model to an existing 3D model?
Look in DefaultFurnitureCatalog how the subclass [font=courier new]ResourceURLContent[/font] is used.
But as [font=courier new]lightSource.obj[/font] may be in different places (in a file during development, then in [font=courier new]Furniture.jar[/font] or [font=courier new]SweetHome3D-x.y.jar[/font] during deployment and finally in a SH3D file when saved), I would suggest to use a copy of that file in your plug-in.
But as [font=courier new]lightSource.obj[/font] may be in different places (in a file during development, then in [font=courier new]Furniture.jar[/font] or [font=courier new]SweetHome3D-x.y.jar[/font] 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 creator
Re: Add another 3D model to an existing 3D model?
For the first version of the plugin, I used this location for the [font=courier new]lightSource.obj[/font] file.
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.
Code: Select all
final Content sourceContent = new ResourceURLContent (DefaultFurnitureCatalog.class, "resources/lightSource.obj");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.
EnkoNyito
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 [font=courier new]lightSource.obj[/font] in your plug-in.
You could even use your own shape naming it in the OBJ file with a prefix equal to [font=courier new]ModelManager.LIGHT_SHAPE_PREFIX[/font] to ensure it has the same behavior as [font=courier new]lightSource.obj[/font].
You could even use your own shape naming it in the OBJ file with a prefix equal to [font=courier new]ModelManager.LIGHT_SHAPE_PREFIX[/font] to ensure it has the same behavior as [font=courier new]lightSource.obj[/font].
Emmanuel Puybaret, Sweet Home 3D creator
Re: Add another 3D model to an existing 3D model?
The ViewLightSources plug-in is available.
EnkoNyito
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
It would be perfect if the coordinates of the light source of the object can be adjusted in real time
Re: Add another 3D model to an existing 3D model?
ViewLightSources-1.1.sh3p
- transparency of the previewed light
- transparency of the previewed light
EnkoNyito
Who is online
Users browsing this forum: No registered users and 2 guests