| 123456789101112131415161718192021222324252627 |
- <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]--><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="Asciidoctor 1.5.4"><title>Projects and Assets</title><link rel="stylesheet" href="./asciidoctor.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
- <link rel="stylesheet" href="./coderay-asciidoctor.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"></head><body class="article toc2 toc-left"><div id="header"><div id="toolbar"><a href="https://github.com/jMonkeyEngine/wiki/edit/master/src/docs/asciidoc/sdk/development/projects_assets.adoc"><i class="fa fa-pencil-square" aria-hidden="true"></i></a><a href="https://github.com/jMonkeyEngine/wiki/new/master/src/docs/asciidoc/sdk/development/"><i class="fa fa-plus-square" aria-hidden="true"></i></a><input dir="auto" style="position: relative; vertical-align: top;" spellcheck="false" autocomplete="off" class="searchbox__input aa-input" id="doc-search" name="search" placeholder="Search in the doc" required="required" type="search"><i class="fa fa-sort-down" aria-hidden="true"></i></div><h1>Projects and Assets</h1><div class="details"><span class="author" id="author"></span><br><span id="revnumber">version ,</span> <span id="revdate">2016/03/17 20:48</span></div><div id="toc" class="toc2"><div id="toctitle">Table of Contents</div><ul class="sectlevel1"><li><a href="#projectassetmanager">ProjectAssetManager</a></li><li><a href="#assetdataobject">AssetDataObject</a></li><li><a href="#new-asset-file-types">New Asset File Types</a></li></ul></div></div><div id="content"><div id="preamble"><div class="sectionbody"><div class="paragraph"><p>The SDK heavily uses the systems provided by the base platform for the handling of assets and projects and extends the system with jME3 specific features.</p></div></div></div>
- <div class="sect1"><h2 id="projectassetmanager">ProjectAssetManager</h2><div class="sectionbody"><div class="paragraph"><p>All AssetDataObjects and SceneExplorerNodes allow access to the ProjectAssetManager of the project they were loaded from.</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">ProjectAssetManager pm = node.getLookup().lookup(ProjectAssetManager.class)</code></pre></div></div>
- <div class="paragraph"><p>The ProjectAssetManager is basically a normal DesktopAssetManager for each project with some added functionality:</p></div>
- <div class="ulist"><ul><li><p>Access to the FileObject of the assets folder of the project to load and save data</p></li><li><p>Convert absolute file paths to relative asset paths and vice versa</p></li><li><p>Get lists of all textures, materials etc. in the project</p></li><li><p>more convenient stuff.. :)</p></li></ul></div></div></div>
- <div class="sect1"><h2 id="assetdataobject">AssetDataObject</h2><div class="sectionbody"><div class="paragraph"><p>Most “files that you encounter in the SDK come in the form of AssetDataObjects. All Nodes that you encounter contain the AssetDataObject they were loaded from. It provides not just access to the FileObject of the specific file but also an AssetData object that allows access to jME specific properties and data. The AssetData object also allows loading the object via the jME3 assetManager. It is accessible via the lookup of the Node or AssetDataObject:</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">assetDataObject.getLookup().lookup(AssetData.class)</code></pre></div></div></div></div>
- <div class="sect1"><h2 id="new-asset-file-types">New Asset File Types</h2><div class="sectionbody"><div class="paragraph"><p>When you add a new file type for a model format or other asset file that can be loaded in jME3 you can start by using new file type template (New File→Module Development→File Type). Change the DataObject to extend AssetDataObject (general), SpatialAssetDataObject (some type of model) or BinaryModelDataObject (basically a j3o savable file). And possibly override the loadAsset and saveAsset methods which are used by the AssetData object to return the correct AssetKey type (needed for import properties to work).</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">class</span> <span class="class">BlenderDataObject</span> <span class="directive">extends</span> SpatialAssetDataObject {
- <span class="directive">public</span> BlenderDataObject(FileObject pf, MultiFileLoader loader) <span class="directive">throws</span> DataObjectExistsException, <span class="exception">IOException</span> {
- <span class="local-variable">super</span>(pf, loader);
- }
- }</code></pre></div></div>
- <div class="paragraph"><p>An AssetManagerConfigurator class can be created to configure the assetManager of the projects and model importer to use the new asset type:</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@org</span>.openide.util.lookup.ServiceProvider(service = AssetManagerConfigurator.class)
- <span class="directive">public</span> <span class="type">class</span> <span class="class">BlenderAssetManagerConfigurator</span> <span class="directive">implements</span> AssetManagerConfigurator {
- <span class="directive">public</span> <span class="type">void</span> prepareManager(AssetManager manager) {
- manager.registerLoader(com.jme3.scene.plugins.blender.BlenderModelLoader.class, <span class="string"><span class="delimiter">"</span><span class="content">blend</span><span class="delimiter">"</span></span>);
- }
- }</code></pre></div></div></div></div></div><div id="footer"><div id="footer-text">Version <br>Last updated 2017-10-25 21:59:24 +00:00</div></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script><script>docsearch({
- apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
- indexName: 'jmonkeyengine',
- inputSelector: '#doc-search',
- debug: false // Set debug to true if you want to inspect the dropdown
- });</script></body></html>
|