Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Textures Library

Developers
helge-h
2010-12-18
2013-06-05
1 2 > >> (Page 1 of 2)
  • helge-h
    helge-h
    2010-12-18

    I have an idea about how to implement a textures library of sorts. The textures dialog (Scene > Textures) could be extended with these items:

    - a list of AoI files; this list can be edited - files can be added and deleted (buttons for this)
    this list is saved on disk, maybe in the preferences file

    - a 'list' of preview images of all the textures in the highlighted file in the files list
    each texture can be selected, maybe several at a time
    also, each texture could be editable
    buttons for edit, delete, copy etc.

    Todays computers should be powerful enough to make the preview images, but these images could also be saved somewhere as a speed optimalisation. There could be issues with large files, I don't know how that works in AoI. I'm thinking it is possible to load just the textures into memory.

    The Import button would import the selected texture(s) into the current scene.

    It should be possible to export any texture in the current scene to a file in the files list.

    This way most of the existing texture handling can be as it is.

    Some texture library files should be distributed with AoI, thus giving newcomers instant access to lots of textures. These files should be included in the list from the start. Maybe they should be protected also. Perhaps these files should be located in a textures folder, but I think any file could be included in the files list. Proper naming is important here, as always.

    (Maybe textures could be dragged and dropped onto objects; just a thought.)

    I don't have the knowledge or the time to work on this for the moment, but I hope this can inspire someone.

    In my view the texture system in AoI is a weak point, especially for newcomers. The program would be more attractive if you have lots of ready-to-use textures to play with from the start.

    (This idea could perhaps be extended to objects as well? An object library? I don't know how it should work, though.)

    H

     
  • Harald G
    Harald G
    2010-12-19

    The idea seems obvious.
    Maybe Nik gets back to AoI someday and might finish the "Librarian" (successor of Plugin- and Scriptmanager).
    This one should do what you suggest and maybe even more.
    Meanwhile Siri has done some cool things about Libraries:
    http://www.aoi-board.de/index.php?action=posts&fid=10&tid=852&site=2

    I guess it´s posted also here somewhere.

    But you´re right.
    My old trueSpace 4.3 could show textures and objects and scenes. It came out 1988!
    It´s about time to suggest something like that for AoI 2.9 or 3.0 before new cool features comes to our mind ;).
    (Did I wrote that down here?)

    Like you said: This feature attracts (new and old) users, - or in case it isn´t available - the opposite might happen.

    Harald

     
  • This idea could perhaps be extended to objects as well? An object library? I don't know how it should work, though.

    PME has a templates feature. Maybe that could be "extended" somehow. Actually, there's a couple of powerful features in PME that would became more attractive with some planning and coding season. I'm referring to UV textures most than all.

    I'd like Librarian to come to light. At least as a beta. I don't feel entirely comfortable with the textures system neither, and sometimes i wish i color palette to easily create simple (uniform) textures, btw. I mean, i wish a color panel in the right panel to click paint objects in a quick and handy way (some more controls would be available in the same panel, light bright…).

    Mayid.

     
  • Peter Eastman
    Peter Eastman
    2010-12-20

    Agreed, improved texture management would be a nice feature.  Nik has been discussing the Librarian as a replacement for SPManager, so maybe he can comment on whether it would serve this purpose  If not, I could definitely implement something along the lines of what you describe.

    Peter

     
  • helge-h
    helge-h
    2010-12-21

    Thanks, Peter. It would be wonderful if you could do this.

    I have started to write a tool script to test out my ideas, if I get something working I'll let you have the code (unless you beat me to it).

    This is how the script will work (I hope):

    A folder inside AoI main folder, called Textures and Materials, contains sub-folders for grouping the files. Inside these group folders are the regular .aoi files. (This structure is not very flexible, so it should be expanded, but it's just for testing purposes for now.) Also, I have thought of having a 'notes.txt' file in every group folder for text to be displayed for each group (maybe notes on the author, or the way to use a texture; e.g. combining both texture and material to make glass).

    The script will present a dialog equivalent to the Textures and the Materials dialogs combined, but expanded with a list of the file/folder structure in the main Textures and Materials folder, and a preview of every texture/material of the selected group. (I have thought of having a radio button group to choose how many previews to show: all in the library, all in a group, a finite number or just none; just in case it takes too long.)

    Each preview will have the name and the type of texture/material; simple, image, procedural 2D/3D etc., and a select checkbox. Perhaps also a choice of preview object: sphere, cube, cylinder.

    In addition to the library groups, there will be a special group with the textures in the current scene.

    The buttons will be the ones already in the Textures and Materials dialogs plus these:
    Import selected texture/material into the current scene (replacing the current Import button)
    Create new group
    Create new file
    Copy existing texture/material from the current scene into a library file
    (maybe delete buttons also, but perhaps not in the first version)

    (These are the ones I can think of now, there are probably some obvious ones I have forgotten.)

    The groups can of course contain anything; metals, ceramics, plastics, stones etc. Also, a template group, especially with starting points for procedural textures; I find myself doing the same building each time with these, some general textures to copy from would save a lot of time and work.

    (Naming the textures correctly is important; some of the FStextures have some fancy names, but they are perhaps not so descriptive? The previews will (most likely) be presented alphabetically, so to make further grouping possible the names could begin with special characters; space, bullets, stars etc. This is of no concern to the script, though; I'm just writing down my ideas here.)

    When the script starts it will check to see if the folders are there, if not they will be created. For each new group it will create a general notes file.

    A keyboard shortcut will make it easy to run.

    There will not be a lot of safety handling, but that should be implemented in the next version. Maybe it's enough to lock the files in the operating system.

    This is a simple way of making a library, no need for databases or extra files.

    The same scheme could be used for an objects library, but I don't think I'll do that.

    I'm still testing, so I'm not sure if I can get it to work, but these are my intentions. I'll try to have a test version ready soon, but I give no promises.

    I'm open for more ideas, so please bring them forward.

    @Harald: is this the thread you had in mind?
    http://www.friendlyskies.net/aoiforum/viewtopic.php?id=2269

    H

     
  • helge-h
    helge-h
    2010-12-21

    Some additional ideas:

    I mentioned the number of previews to show; the options should maybe be these:

    all in the library
    all in a group
    all in a file (forgot this one)
    a finite number (perhaps not)
    none

    But previews could be generated on the first reading of the file, and then saved as a regular image in the file; possibly with some identification, such as "Library" or just a special character in front of its name (the same name as the texture, obviously). This would save some time when browsing. (Also, a button for updating this preview image could be included.) If this is implemented in the regular AoI program, these images could be treated separately from the other images.

    As for an object library, if implemented the same way as this, could have the option of just linking to the current scene, importing the object into the scene or copy the library file into the same folder as the scene file, and then linking that into the scene. (Did that make any sense?)

    H

     
  • Peter Eastman
    Peter Eastman
    2010-12-21

    That sounds great.  I look forward to seeing it!

    Peter

     
  • Harald G
    Harald G
    2010-12-21

    Yes Helge,

    this is the (same) thread as in the german forum.
    If you take a look at Siris comments on her texture library you´ll find some nice technical aspects on textures!

    http://www.screencast.com/users/Siri-65/folders/Jing/media/c040b67d-d336-46a4-8f5c-78af252def87

    These information are invaluable!

    So I prefer a "quick preview on a ball" as well as the texture library "man" with many more information about textures and materials under certain conditions.

    I would really like to see such an script! Any enhancement in this area is welcome.

    Harald

     
  • Harald G
    Harald G
    2010-12-21

    Another idea:
    Why not having a image of the camera rendered and saved with the *.aoi file?
    That way we could see scenes and of course single objects in a kind of preview.

    I´m sure that an automated setup won´t help to much (because of different light situations),
    but a user saved image within the aoi file might do it perfectly.

     
  • helge-h
    helge-h
    2010-12-21

    Thanks, Harald, for the input. A saved preview for regular scene files sounds nice. It could probably be implemented in a script.

    Thanks, Peter, for the enthusiasm. But sorry to disappoint a bit, I have run into some trouble. I have tried to use MaterialPreviewer, but when I have more than one preview element in a dialog, it will at most render one preview (often the last one). As far as I can see, this is because AoI can render only one scene at a time, and I cannot tell when a render is finished (renderInProgress). I have tried to make an update button and then wait a while after each preview re-rendering, and that works, confirming my theory. But this is not a good solution. Looks like I have to make my own MaterialPreviewer (a simpler version, I think). It is probably necessary to save preview images in the texture files, to enhance browsing speed. I'm slow at this, so don't expect too much.

    Another idea I have is to store the descriptions in a scripted object (as a comment) in each file, thus avoiding the text files I was thinking of. This is nice for general use also, to have notes and other text inside the aoi file this way. (I'm sure someone else has thought of this.)

    H

     
  • Peter Eastman
    Peter Eastman
    2010-12-21

    You're right, the renderer is designed to only render one image at a time, so you'll have to wait until it finishes rendering one image before starting the next one.  As for determining when that happens, how about subclassing MaterialPreviewer and implementing a isRenderInProgress() method?  You could also override imageComplete() to take some action as soon as it finishes.

    Peter

     
  • helge-h
    helge-h
    2010-12-21

    Thanks, Peter. I'll certainly try that. I'm fairly new to Java, so I didn't think of it.

    H

     
  • helge-h
    helge-h
    2010-12-22

    I'm stuck; it's probably something obvious, but I'm new to this. What's wrong with this code?

    class myMaterialPreviewer extends MaterialPreviewer {
        public void myMaterialPreviewer (Texture tex, Material mat, int width, int height) {
            super (tex, mat, width, height);
        }
    }
    scene = window.getScene();
    obj = new Sphere (1,1,1);
    tex = scene.getTexture("tx");
    obj.setTexture( tex, tex.getDefaultMapping(obj) );
    objInfo = new ObjectInfo (obj, new CoordinateSystem(), "test");
    [b]// preview = new myMaterialPreviewer (tex, null, 160, 160); // this does not work
    preview = new MaterialPreviewer (tex, null, 160, 160); // this does[/b]
    dlg = new ComponentsDialog(window, "Test", new Widget [] {preview}, new String [] {null});
    if (!dlg.clickedOk()) return;
    

    H

     
  • Peter Eastman
    Peter Eastman
    2010-12-22

    You haven't imported whatever package myMaterialPreviewer is in.  By the way, Java class names should always begin with a capital letter: MyMaterialPreviewer.

    Peter

     
  • Hi Folks,

    Yes, I haven't given up on the Librarian code.
    However, I don't want the delay in completing the Librarian to hold up everyone else.

    The existing Librarian alreadyhas the concept of local repositories, so I can certainly make any future Librarian code work with any structure you design in the meantime.

    May I suggest that the repos should be kept in the .artofillusion folder rather than the AOI installation folder.

    I keep multiple installations of AOI around - usually of different versions, and it would be inconvenient to have to install textures for each new version.
    … Unless the textures in the texture library are usually dependent on the version of AOI - which is not usually the case as far as I know?

    We could arrange to keep multiple versions of the texture files in the .artofillusion folder, eg for version 1 and version 2 of the texture format.

    Just my thoughts.

    Cheers!
    Nik
    PS: from Hyderabad India - teaching a course
    (… on dependency injection, among other things :o)

     
  • helge-h
    helge-h
    2010-12-22

    Sorry to trouble you with this, it's probably something obvious.

    Just to make it clear: this is a Beanshell script, and the MaterialPreviewer class is in the artofillusion package, right? So it shouldn't be necessary to import it. Anyway, there's no difference if I try that. In the example above I omitted the "implements RenderListener" part, but including it does not make any difference. AoI does not do anything when I run the script. (No error messages either.) I found this somewhere, and it works as a tool script in AoI:

    class MyFrame extends JFrame {
        static final String title = "BeanShell JFrame Class";
        public MyFrame() {
            super(title);
            addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
                }
            });
        setBounds(100, 100, 300, 300);
        setVisible(true);
        }
    }
    new MyFrame();
    

    I can't see that the principle is different, so why does not my script work?

    Re-reading your post, I see you say "You haven't imported whatever package myMaterialPreviewer is in.". But myMaterialPreviewer (or MyMaterialPreviewer) is the extension I'm making, and that is inside the script, so I don't understand that. What am I missing?

    Nice to hear from you, Nik. I don't understand much of what you say here, but I'll leave that to you and Peter; I'm just doing some tests.

    H

     
  • helge-h
    helge-h
    2010-12-22

    Sorry, I give up. I don't know enough about Java and Beanshell, and it takes too long to learn; I don't have the time now. But if anyone wants do try out the ideas, you're welcome.

    Merry Christmas to you all.

    H

     
  • Peter Eastman
    Peter Eastman
    2010-12-23

    Sorry, I should have tried your script before replying.  The actual problem was the "void" in this line:

    public void myMaterialPreviewer (Texture tex, Material mat, int width, int height) {

    Constructors don't have a return type, so it thought that was an ordinary method, not a constructor.  Fixing that, however, still doesn't make it work.  It fails, writing the following error to the console:

    java.lang.Error: HERE!
    at bsh.BshMethod.invoke(Unknown Source)
    at bsh.ClassGeneratorUtil.initInstance(Unknown Source)
    at MyMaterialPreviewer.<init>(BeanShell Generated via ASM (www.objectweb.org))

    which looks to me like a bug in the Beanshell interpreter. :(

    If you do decide to continue with this, I can suggest a workaround, but if you decide this is too much work, I understand.

    Peter

     
  • Peter Eastman
    Peter Eastman
    2010-12-23

    May I suggest that the repos should be kept in the .artofillusion folder rather than the AOI installation folder.

    It's an interesting question, how to handle this.  We currently have two similar folders (Plugins and Scripts) that are in the installation folder.  Arguably those should also be kept elsewhere.  The difficulty is how to handle installation.  Suppose we kept texture libraries somewhere outside the installation folder.  Then how could we include a default set of textures with the installation?  There are options, of course.  We could have a more complicated installer that knew how to install texture libraries.  Someone would have to write that installer, though, as well as create a functional deinstaller (which we currently don't have, but it isn't a big deal because the whole installation is just a single folder).  Or the default libraries could be bundled inside the app, and it would install them the first time it was run.  That creates similar issues, though.

    Peter

     
  • helge-h
    helge-h
    2010-12-23

    Here is a more complete design:

    The library itself is located somewhere logical; I would have it inside the AoI folder, along with the application, the Scripts and Plugins folders etc. The main folder is called "Library", and contains a "Textures" folder, a "Materials" folder and maybe an "Objects" folder. (I don't think it's necessary to change the other folders, even if it would seem logical then, to have Scripts and Plugins in there too.) Inside each of these folders are sub-folders for several groups, such as "Wood", "Ceramic" etc. There can also be sub-groups.

    The textures, materials (and obects) are stored in regular AoI files. Any text notes are stored as object scripts (some management is needed; the script can have a specific name, say "Textures Notes"). This way it is easy to understand for the interested user. Files and folders can be handled in the OS if the user wants, and AoI will just read what is there; no need for extra databases. As each preview takes some time to generate, the preview images are stored as regular images in each file. Since these files are only in the library, this does not affect any other AoI file. The preview images are only generated if they are not already present.

    There should be a lot of textures and materials from the start. This is most important for beginners, but everyone will benefit. (Someone should administer it, but we could have a brain-storming in the forums to get lots to choose from. Just a thought.) The library is distributed together with Aoi, but can be expanded with packs via the SPManager (or manually in the OS). For example, there can be a limited "Woods" in the regular installation, and "Woods2" can be added later.

    The dialog is invoked from two or three menu items: Textures Library, Materials Library, and possibly Objects Library. This one dialog replaces the current Textures and Materials dialogs.

    The dialog window has the title "Library", and can be resized. AoI stores the location and size from one session to another.

    There are two or three flips at the top: Textures, Materials (and Objects), to choose the appropriate section.

    There is a text field (somewhere, maybe at the bottom) with status messages and short help texts. For example, stating that textures are on the surface and materials in the volume of objects. This should be helpful for the newcomer, but not get in the way for experienced users. (There are already similar status fields in AoI.)

    There is a (large) area for preview images that is scrollable. There is some way of selecting one or more items; a check-box perhaps. Some information on each item; the name, texture/material type (uniform, image based, 2D/3D procedural). Each preview does not have to be semi-editable (as in the object texture dialog), but if it's easy to implement, then fine. But browsing must be fast.

    There is a text list for the folder structure, preferably on the left-hand side of the dialog. Folders are indicated by a small arrow, like in the objects list in AoI. The groups should be in expanded view at the start, but can be compacted, just like in the objects list. Selecting a file will load all the previews for this file into the preview area. If the selected item is a group, the preview area will show folder symbols with their names. The text field can be expanded/contracted left to right, and fills (mostly) the height of the dialog; scrollable when necessary.

    The textures/materials in the current file show up in a special group at the very top of the list, and this is the group initially selected and displayed in the preview area. The groups reflect any changes instantly.

    There is an area for buttons, maybe at the bottom. The buttons are:

    - Help (if necessary, maybe explains the structure and use)
    - Import the selection into the current scene
    - Save the selection to the library (only items in the current scene can be saved)
    - Delete from library
    - New library group (folder) (the user is asked where it should be located)
    - New
    - Duplicate (a better name for Copy)
    - Delete
    - Edit
    - Close

    The last five are the same as in the present Textures/Materials dialogs, and only work on items in the current scene (except "Close", of course).

    The buttons are enabled/disabled according to the selection.

    There should be some safety so that items cannot be deleted/altered too easily. Save to Library must check to see if the texture name exists, for example. To delete a group, the user must delete the folder in the OS.

    I believe this is best programmed inside AoI, rather than a script or a plugin. Or maybe if AoI provides the necessary methods, it could be a plugin. My design should be relatively easy and quick to implement as far as I can see, since it would use mostly existing code. And there is no need for new file formats or extra files and databases.

    There could also be a Scripts Library (with Startup, Tools and Objects sub-groups), if it's easy to implement. Plugins are a different breed, and I don't think it's logical to include them here, but maybe I'm wrong.

    Above all, it should be user-friendly, both for the newcomer and the experienced user. A visual representation of textures etc. is a lot more convenient than just text.

    (I would very much like the Images dialog to be improved too; slightly bigger thumbnails and the image name below each image. Maybe images could be handled in the library too, but that's not important, to me anyway.)

    H

     
  • helge-h
    helge-h
    2010-12-26

    I've been looking at the AoI code a bit more, and I see that storing the preview images inside the AoI files is probably not an option. The images are stored without any other data, so it's not possible to reference them reliably since the file may contain other images for the textures. The solution could be to store the preview images outside the files, in a Preview Images folder (next to the file), and naming them in an unambiguos way (file name + texture name most likely). It's possible to have more textures with the same name, so this must be taken into account.

    I've been trying to code a bit more after all, but run into a lot of trouble; some of it because I don't have access to all the methods and data inside AoI, and partly because Beanshell is different from Java in some respects. (And because I lack the necessary skills.) I may do some more tests, but I won't be able to finish anything. However, I think the design is possible to implement inside AoI.

    H

     
  • Peter Eastman
    Peter Eastman
    2010-12-27

    Have you considered not saving preview images, and just rendering them as needed?  For a moderate sized preview, most textures can be rendered very quickly (much less than a second), so saving them might not really be necessary.

    Here's a feature of Beanshell you should be aware of, if you need access to things that aren't currently accessible: if you just call

    setAccessibility(true);

    then it will allow you to access the private fields and methods of any object.  That obviously isn't a good long term solution, but it's very convenient for prototyping.

    Peter

     
  • Harald G
    Harald G
    2010-12-28

    So I prefer a "quick preview on a ball" as well as the texture library "man" with many more information about textures and materials under certain conditions.

    I can just repeat myself: I prefer a quick preview over "nothing", but you won´t get the same information out of a 40² pixel preview,
    than you might get from the "library man" in Siris database.
    Take a look at other libraries - vray for example:
    http://www.vray-materials.de/all_materials.php

    You'll see a picture of 480 x 600 pixels on a special geometry to get more info about the material and texture.
    These could be made during the "free" cpu time on that pc / mac - no need to dl all the pics.

    Harald

     
  • helge-h
    helge-h
    2011-01-24

    Here is a prototype of a Textures and Materials Library function. I must stress that it is a prototype; use with care! It is not tested enough that I can say it is safe to use, it may destroy files on your computer.

    Also, it is not intended to be used on a regular basis, it is just a starting point for a discussion about how to implement a library function in AoI. There are some issues I know of, and probably many I have not discovered, but that is not important here.

    It will not be available for long, so if you want to download it you should do it now.

    Download

    It is a tool script, place it in the Scripts > Tools folder in the AoI folder. Run the script from the Tools > Scripts menu.

    The script replaces the Textures and the Materials dialogs, along with some subdialogs. It adds a library function with a list of the content in the library, a preview of the selected item and buttons for performing a number of tasks.

    Requirements:
    - A folder; named Textures and Materials, located in the AoI main folder.
    - Subfolders may be used, for example named Woods, Ceramics etc. as appropriate.
    - The main folder may contain several subfolders in several levels.
    - AoI files containing the textures and materials inside the main folder or the subfolders.

    Issues at the moment are a slow startup and some selection trouble. If there are more than a few files in the library folder it will take some time to start. This is the main drawback at the moment, but if the script is turned into a plugin it will just add a little to the startup time of AoI. I have about 50 aoi files in the library and it takes about eight seconds to load. This is too much I think, it should be virually instantaneous. A regular Java program may be faster than a script.

    Since this is a tool script under Beanshell, not all variables have type; in fact some cannot have type.

    Buttons:

    Current scene:
    - New; select type of texture/material
    - Duplicate
    - Delete
    - Edit
    - Apply to Selected Object(s) (opens object texture/material dialog)

    Library:
    - Load from Library: Load the selection from the library into the current scene
    - Save to Library: Save the selection to the library (only items in the current scene can be saved); you are asked which aoi file to save to
    - Delete: Delete item from a library file
    - New file: Make new library file, may make new folders at the same time
    - Include File: any AoI file may be temporarily connected to the library list, and items may be imported into the current scene

    General:
    - Close

    Library list to the left. Lists the folder structure and the AoI files.
    Textures are marked with a white bullet character, materials have a black bullet.
    The external file is marked with #.

    Status field at the bottom (not working very well here, maybe it should use a new thread).

    Preview:
    - preview image
    - item name and type

    Features to be implemented (maybe) or changed:

    - Preview images for all items in a file. I had some problems with this, because only one image may be rendered at a time. Therefore I only use one preview in this prototype. Since the rendering of several images in a row may take some time, one solution would be to have pre-rendered images.

    - If the Textures and Materials folder does not exist it should be created. Now you just get an error message.

    - Not sure about the apply button; does it belong here? It just brings up the Object Texture/Material dialog, and you have to select the item again in the new dialog. Not a good solution.

    - Browse the list with arrow keys.

    - Toggle expand list folder by clicking. That is, if you click a folder in the list, it should expand; click it again and it should contract.

    - Search function. Not sure about this. You would have a really large library if this has any meaning. And items should be arranged in a logical order anyway.

    - Turn the script into a plugin (or could the code be included in AoI?).

    - Could it be a dockable window along with the objects list and properties window? Just the list in the dockable window, the rest can be shown with a button.

    - Add proper text handling (some text items are translated, most are not).

    I'm not sure if I'm going any further with it; if Peter or anyone else is interested in developing it you are welcome to. But it should not be distributed as it is; again, this is a prototype.

    H

     
1 2 > >> (Page 1 of 2)