Argentina
Joined: Sep 8, 2009
Post Count: 40
Status:
Offline
Re: Is it possible to give Texture to Furniture?
1- It is possible to have the texture already on the model, which would be a static texture, but I guess that is not what you mean. 2- A plug-in could be done so you can change a texture on a furniture. It is not that difficult: -Scan the model J3D tree and put all material defined on a list. -Change the desired texture. -Make a UI to do the above and select the texture.
France
Joined: Nov 7, 2005
Post Count: 9141
Status:
Offline
Re: Is it possible to give Texture to Furniture?
Hum... you would have to generate UV texture coordinates too. Java 3D has something to help you generate some default UV coordinates but I don't how well it works.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
Argentina
Joined: Sep 8, 2009
Post Count: 40
Status:
Offline
Re: Is it possible to give Texture to Furniture?
Well, that was a rough outline. I've changed textures on-the fly, but I've allways tried to have a dummy texture before (to know where to do the change) with a named material.
private void deepUpdateMaterial(Node node) { if (node instanceof Group) { Group bg = (Group) node; for (int i = 0; i < bg.numChildren(); i++) { Node shape = bg.getChild(i); deepUpdateMaterial(shape); } } else if (node instanceof Shape3D) { Shape3D shape = (Shape3D) node; Appearance material = shape.getAppearance(); if (material != null) { shape.setAppearanceOverrideEnable(true); String texture = null; /* Here, set the texture to whatever is to set */ if (texture != null) { BufferedImage textureImage = null; try { textureImage = ImageIO.read(new URL(texture)); } catch (IOException ex) { // Ignore images at other format } if (textureImage != null) { TextureLoader textureLoader = new TextureLoader(textureImage, TextureLoader.GENERATE_MIPMAP | TextureLoader.BY_REFERENCE); material.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE); material.setCapability(Appearance.ALLOW_TEXTURE_WRITE); material.setTexture(textureLoader.getTexture()); } } } } }
That is how I do it, and it works. Emmanuel, some of this code would seem familiar to you :-). Anyway, in this case there is already a defined material. If there weren't any, you should have to list all shapes and assign a texture for each, and create materials as needed.
Why not to post this to the developpers forum, in case someone wants to try?
----------------------------------------
[Edit 1 times,
last edit by alied at Feb 7, 2010, 6:18:34 PM]
I am a simple user buddies :) I mean it in this way; you can easily change the texture of walls or floor, because there is a option on the menu ( you can change color or texture of walls) but on furnitures, there is only the option to change the color. is it not possible to add the texture option also to the furnitures? most importantly, to the boxes, because I create new furnitures with boxes :)
France
Joined: Nov 7, 2005
Post Count: 9141
Status:
Offline
Re: Is it possible to give Texture to Furniture?
Texture on boxes is an other simpler story and a wizard that will let you create parallelepipeds with images on each face should be available soon.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
Argentina
Joined: Sep 8, 2009
Post Count: 40
Status:
Offline
Re: Is it possible to give Texture to Furniture?
Do you mean to apply a texture to the WHOLE model? It's simpler on the User interface part only. Inside there is no much difference. So far, there is a tip: sh3d files are actually zip files (technically they are jar files, wich in turn are zip files with specific parameters). You can replace a texture by opening it with any zip utility and replacing the desired texture with the new one, provided you keep the name and format.
France
Joined: Nov 7, 2005
Post Count: 9141
Status:
Offline
Re: Is it possible to give Texture to Furniture?
For your information, applying texture to furniture models will be available in next version 2.3. If you're interested, you can text this feature in current Beta version.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer