xbuf / jme3_xbuf

xbuf libs, tools, samples for jMonkeyEngine (jme3)
Creative Commons Zero v1.0 Universal
5 stars 4 forks source link

Texture path issue from blender to xbuf #5

Closed Ali-RS closed 8 years ago

Ali-RS commented 8 years ago

It seems that xbuf blender add on replace the paths to be relative to Textures/ inside your asset root. So after exporting to xbuf in Models/ directory i should move the model textures to Texture/ directory to be able to load them on model. see this topic : https://hub.jmonkeyengine.org/t/xbuf-updates-migrating-to-java-physics/35893/20

davidB commented 8 years ago

Textures are exported into the directory define in the render panel, when you select xbuf renderer.

I keep the ticket open, to keep in mind, that the directory should also be configurable into the export side panel.

riccardobl commented 8 years ago

IMO the addon should be changed to copy the textures in the output folder by default and the loader should try to load them from the same folder of the model first, and only if not available from the root. IE. if i load maps/mymap/root.xbuf it will try to load the textures from maps/mymap/Texture/, if not found it will try with Textures/

Ali-RS commented 8 years ago

Agree with Riccardo.

davidB commented 8 years ago

Disagree.

  1. xbuf is not for file only, in fact file is a consequence/bonus. eg in blender you can display a xbuf scene rendered via jme without before/exporting it into an xbuf file
  2. xbuf is based on convention (vs configuration) and every exporter should behave the same
  3. xbuf is to help manage lib of assets, not single one, so every "path" are always relative to an asset root
  4. an xbuf file can be splitted into mutliple file, exploded into the assets tree (materials, animations, models, scenes,...)
  5. Texture should be loadeable independantly from the model that need it
davidB commented 8 years ago

using the asset root is part of the IDL "spec":

https://github.com/xbuf/xbuf/blob/master/src/main/proto/xbuf/primitives.proto#L32

riccardobl commented 8 years ago

So in your design i would have to mix all my models data together and be really really really careful to not use the same name twice... And if i want to let users doing their mods i have to tell them: "Here, this is the list of file names i've already used, pick something else, and btw you should also make arrangements with other modders because if you all call the same texture diffuse_map.png it won't load. "

If you want to keep consistency in loaders we can say that xbuf paths have a special keyword <currdir> and when the loader find it, it knows that it's relative to the model path, while when it find <rootdir> it knows it is relative to asset root. And then add a checkbox in export panel.

Or even better, just say that the path is relative to root only if it starts with / ie /Textures/ vs local Textures/

davidB commented 8 years ago

Yes, like when you manage your assets folder/library in any game. The asset root is configurable, I use a default one, and one per project.

In a studio, artistes work in a single rooted working directory (with lot of sub-folders). It's similar to the assets folder in a jme project.

About mods, you already have the problem today in jme, you define a list of assets root path, and jme pick the first asset that match (like java classes & classpath).

riccardobl commented 8 years ago

Yes and the solution is allow relative paths, so people can put everything in they my_model/ path and it won't interfere with anything .

Ali-RS commented 8 years ago

Just one more question: So based on the convention it is not a good idea (or is not possible) to pack textures inside the model, Yes?

davidB commented 8 years ago

@Ali-RS , include texture inside a xbuf "file", is possible and already defined by the format. But it is not implemented by any tools (the blender exporter/preview, assimp converter, the jme importer).

it's possible because the location of info (like texture) inside a data xbuf "file" is done by id, not by name/path choosen by human.

Ali-RS commented 8 years ago

Oops! something is wrong here ! for my model named "Doha" I changed "asset root folder path" in blender render tab to "//........\Textures\Doha\" this is relative address in my jme asset root directory. After exporting to xbuf all the textures copied to that path successfully. So now I have texture for model "Doha" in "assets\Textures\Doha\Textures\" but when i load .xbuf in jme it does not show textures. if I move textures to "assets\Textures" it shows them. What is wrong?

riccardobl commented 8 years ago

It doesn't work this way, the root path is an information useful only for the exporter, it just tell it where to export the data. The paths will be always relative to the root of the asset folders. So the result you get is not wrong, it fit perfectly the design, that's why it's a BIBGIBIG design flaw :whale2:

Ali-RS commented 8 years ago

It seems i am confused ! So what should I do to have my texture for model "Doha" in this directory "assets\Textures\Doha\" ?

riccardobl commented 8 years ago

To my understanding, it's not possible

Ali-RS commented 8 years ago

No kidding !!!

davidB commented 8 years ago

The asset root path should also be defined as an asset root path on jme3, by default jme3 define "assets" as an asset root path.

Today, there is a bug in the export texture function of the blender addons: it should keep the path of the textures if the texture in under the asset root path (packed or not). when this bug will be fixed, you could share the texture between blender, gimp/photoshop, awesome texture, substance,... your jme app, until your textures are under the asset root path. If texture are not under asset root, texture is copied to asset_root_path/Textures/texture_filename

davidB commented 8 years ago

I push a fixe, in the blender addon, to keep path of texture already under asset root. So, if you take care of the texture's path in blender( I mean path that are under asset root), you could have this kind of layout:

assets/
+-- Models/
|   +-- foo.blend
|   +-- foo.xbuf
+-- Textures/
    +-- foo/
        +-- mytex.png

like this one

assets/
+-- Models/
    +-- foo/
        +-- foo.blend
        +-- foo.xbuf
        +-- textures/
             +-- mytex.png

the second example should solve the @riccardobl's issue about handling user's map and name collision.

Ali-RS commented 8 years ago

Thanks a lot David.

Ali-RS commented 8 years ago

Tested it and works correctly. So let's close this issue.