Tree generator

Hm, no… There is no relative paths in jME3, they always have to be absolute. So you are using the correct ProjectAssetManager of the selected project? You can get the assetManager by going Project.getLookup().lookup(ProjectAssetManager.class); If you load the model from the same path that is later used and it properly loads then but not later idk whats wrong :confused:

This is my current testcase:

Node tree = TreeLoader.LoadTree(“AspenAutumn”, 13, 13, 13, 0, app.getAssetManager());

try{

BinaryExporter be = BinaryExporter.getInstance();

be.save(tree, new File(“assets/Models/test.j3o”));

}catch(Exception exc){

exc.printStackTrace();

}

try{

BinaryImporter bi = new BinaryImporter();

tree = (Node)bi.load(new File(“assets/Models/test.j3o”));

app.getRootNode().attachChild(tree);

}catch(Exception exc){

exc.printStackTrace();

}



(TreeLoader uses the assetManger given as parameter)

You do not load a j3o like that, just do assetManager.loadModel(“Models/test.j3o”); Also, I meant on the plugin level. Since you obviously access the project to find the correct folder, you can get a ProjectAssetManager there, its basically an extended assetManager. And you do not need the “assets” prefix, its roots folder is the assets folder.

Oh btw, I added your nbm to the update center :slight_smile: The nbm file in your download section will be downloaded each night and put in the repository. If you want people to actually get updates, you should up the version number every now and then. If you don’t want this or want to move to the “official” svn repo soon, just say so.

Thanks, I just loaded the model wrong.

I will change the output to j3o



On the plugin level I get the assetmanager by using:

SceneApplication.getApplication().getAssetManager();



Is using the LookUp better?

Yes, the SceneApplication changes the assetManager based on what scene from what project is opened and thus you cannot know what you can load from there and what not. You should get the ProjectAssetManager of the specific project directly as I outlined. Try creating a new Action (New File… wizard) and assign it to “Project” instead of “DataObject”. This way a template action will be created that instantly gives you access to the selected project and from there on you can start the conversion.

Output is now a j3o file.

I think this plugin is beginning to be useful, the biggest problem at this moment is the lack of good bark and leaf textures.

If wanted I can add more tree definitions with a simple brown texture tile for trunk and stems and a green tile for leaves. (Arbaro has more pre defined models)



roadmap:

creating documentation for this plugin

creating crossections (simple LOD)

adding treedefinitions with textures (royalty free leaf textures and tileable bark textures are always welcome)

adding more LOD

1 Like

Awesome! You know you can add and even just link a j3o to another scene? This way one can now conveniently add trees to a terrain, how cool :smiley: A normal wizard UI would be my only wish right now :wink:

Edit: Also, for the manual, maybe simply add javahelp to the plugin (again its a New File… wizard), then the manual will be up to date and searchable with the rest of the SDK manual (F1). The NeoTextureLoader plugin for example has its own javahelp.

Failed to do anything, nothing shows up in my sceen (I’m not using the SDK plugin).

Plugin works fine though, just tested it.

If you are not using the plugin how do you try to use it? The source code posted on code.google is also for the plugin.

In Linux the plugin failed if the scene editor was not correctly loaded. (was not using nightly build)

I have one question, what are the xml files for? And do you have to give them the “xml” extension? As it seems you plan to open them to be edited, what about something like “.tree” or w/e? This way the file suffix can also be registered with the assetManager and you could create a loader that loads the trees and creates them on the fly/procedurally.

This way users could go

[java]Spatial tree = (Spatial) assetManager.loadAsset(“Trees/MyTree.tree”);[/java]

I’d still like to keep the option to create a j3o though :slight_smile:

A tree is based on a tree definition combined with some random seeds.

The tree definition is based on 2 xml files. One is the arbaro xml file (info to create the mesh), the other one contains the parameters to create the textures (number of horizontal, vertical and top tiles).

I always can make a simple textfile with the extension .tree and this would contain the name of the tree definition and the 4 random seeds. This file could be used as described above. I must warn that creating a tree in code can take up to 10 seconds.

A question to you and the community:

What would be better? A static function createTree(name,seed,seed,seed,seed) or files with the extension .tree as described above.

(As you probably noticed my spare time to work on this project has been reduced)

I’d say going with the loader solution (.tree files) is more consistent with the rest of jme3. But I also agree that due to the time involved in creating the tree the focus of the plugin should be on generating models at production time in the SDK (in case you ask about how to divide your time resources :)).

I have just update version 1.1 of the plugin.

Changes:

  • More trees are included (textures are not good)
  • Basic help can be found in the sdk under Help → Browse Help locally
  • new File wizard added: new File → Scene → Tree to create a tree. (only tested by right clicking on a folder in the assets)



    Warning: the plugin may freeze the first time you try to use it. Just give it time, it is unzipping the example trees.
2 Likes

Awesome! :smiley:

One question, where is the data being extracted to?

Edit: Duh, just saw it, into the project assets folder :slight_smile: Thing is, you will pack the whole data into the application this way… Probably you should mention that this data should either be excluded via the assets settings in the project properties or deleted before release. Or you extract the data into the settings folder of jmp, like the OgreXML command line tools and other things…

You can get the path to the settings folder like this:

[java]String settingsDir = System.getProperty(“netbeans.user”);[/java]

Just make a new folder there (e.g. “treedata”) and put the data there.

Will change the folder in the next version of the plugin.



Is there already code available to create billboards, or is it possible to get the color of an Collision point?

1 Like

great job, I didn’t try the plugin yet, it looks awesome.

Billboards exist, its a Control.