Print at Feb 8, 2026, 7:33:21 AM View all posts in this thread on one page
Posted by db4tech at Oct 10, 2010, 5:23:51 AM
Reading a texture from a plugin
Hi,

Been trying an idea, for something I want to implement, and it works well, it requires loading an image to be used as a texture.

This is where I run in to the problem.

Can read the texture without problems from my desktop, which is okay for me.
The trouble I'm having is, reading the texture from a "resources" folder located with the class files in the plugin.

Tried looking through many the Sweet Home scr files, where images are loaded for texture and icons, to try and learn how to do this, also read many articles on the the Internet. Still failing to read the texture from within the plugin though! sad


At first I was trying:

this.sunflow.parameter("texture", "/resources/my_texture.png");

Plus

this.sunflow.parameter("texture", "/com/eteks/sweethome3d/plugin/advancedrendering/resources/my_texture.png");

Am I on the right lines with?

java.net.URL imageURL = AdvancedPhotoRenderer.class.getResource("resources/my_texture.png");


Thought it might help explaining what I've tried. Used the second method (replaced with the path to my desktop) to successfully read the texture.

Thank you in advance for any help offered!
It's really frustrating having lots of ideas, getting stuck and feeling bad asking for help, when should be able to work it out. sad


db4tech