| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width,initial-scale=1">
- <title>The SceneExplorer :: jMonkeyEngine Docs</title>
- <link rel="canonical" href="https://wiki.jmonkeyengine.org/docs/sdk/development/sceneexplorer.html">
- <meta name="generator" content="Antora 2.3.3">
- <link rel="stylesheet" href="../../../_/css/site.css">
- </head>
- <body class="article">
- <header class="header">
- <nav class="navbar">
- <div class="navbar-brand">
- <a class="navbar-item" href="https://wiki.jmonkeyengine.org">jMonkeyEngine Docs</a>
- <button class="navbar-burger" data-target="topbar-nav">
- <span></span>
- <span></span>
- <span></span>
- </button>
- </div>
- <div id="topbar-nav" class="navbar-menu">
- <div class="navbar-end">
- <a class="navbar-item" href="#">Home</a>
- <div class="navbar-item has-dropdown is-hoverable">
- <a class="navbar-link" href="#">Products</a>
- <div class="navbar-dropdown">
- <a class="navbar-item" href="#">Product A</a>
- <a class="navbar-item" href="#">Product B</a>
- <a class="navbar-item" href="#">Product C</a>
- </div>
- </div>
- <div class="navbar-item has-dropdown is-hoverable">
- <a class="navbar-link" href="#">Services</a>
- <div class="navbar-dropdown">
- <a class="navbar-item" href="#">Service A</a>
- <a class="navbar-item" href="#">Service B</a>
- <a class="navbar-item" href="#">Service C</a>
- </div>
- </div>
- <div class="navbar-item has-dropdown is-hoverable">
- <a class="navbar-link" href="#">Resources</a>
- <div class="navbar-dropdown">
- <a class="navbar-item" href="#">Resource A</a>
- <a class="navbar-item" href="#">Resource B</a>
- <a class="navbar-item" href="#">Resource C</a>
- </div>
- </div>
- <div class="navbar-item">
- <span class="control">
- <a class="button is-primary" href="#">Download</a>
- </span>
- </div>
- </div>
- </div>
- </nav>
- </header>
- <div class="body">
- <div class="nav-container" data-component="docs" data-version="master">
- <aside class="nav">
- <div class="panels">
- <div class="nav-panel-menu is-active" data-panel="menu">
- <nav class="nav-menu">
- <h3 class="title"><a href="../../jme3.html">Docs</a></h3>
- <ul class="nav-list">
- <li class="nav-item" data-depth="0">
- <ul class="nav-list">
- <li class="nav-item" data-depth="1">
- <a class="nav-link" href="../../documentation.html">Getting Started</a>
- </li>
- <li class="nav-item" data-depth="1">
- <a class="nav-link" href="https://javadoc.jmonkeyengine.org/v3.3.2-stable">JavaDoc</a>
- </li>
- <li class="nav-item" data-depth="1">
- <button class="nav-item-toggle"></button>
- <a class="nav-link" href="../../jme3.html">jMonkeyEngine 3</a>
- <ul class="nav-list">
- <li class="nav-item" data-depth="2">
- <button class="nav-item-toggle"></button>
- <span class="nav-text">Beginner Tutorials</span>
- <ul class="nav-list">
- <li class="nav-item" data-depth="3">
- <a class="nav-link" href="../../jme3/beginner/hello_simpleapplication.html">Hello SimpleApplication</a>
- </li>
- <li class="nav-item" data-depth="3">
- <a class="nav-link" href="../../jme3/beginner/hello_node.html">Hello Node</a>
- </li>
- <li class="nav-item" data-depth="3">
- <a class="nav-link" href="../../jme3/beginner/hello_asset.html">Hello Asset</a>
- </li>
- <li class="nav-item" data-depth="3">
- <a class="nav-link" href="../../jme3/beginner/hello_main_event_loop.html">Hello Main Event Loop</a>
- </li>
- <li class="nav-item" data-depth="3">
- <a class="nav-link" href="../../jme3/beginner/hello_input_system.html">Hello Input System</a>
- </li>
- <li class="nav-item" data-depth="3">
- <a class="nav-link" href="../../jme3/beginner/hello_material.html">Hello Material</a>
- </li>
- <li class="nav-item" data-depth="3">
- <a class="nav-link" href="../../jme3/beginner/hello_animation.html">Hello Animation</a>
- </li>
- <li class="nav-item" data-depth="3">
- <a class="nav-link" href="../../jme3/beginner/hello_picking.html">Hello Picking</a>
- </li>
- <li class="nav-item" data-depth="3">
- <a class="nav-link" href="../../jme3/beginner/hello_collision.html">Hello Collision</a>
- </li>
- <li class="nav-item" data-depth="3">
- <a class="nav-link" href="../../jme3/beginner/hello_terrain.html">Hello Terrain</a>
- </li>
- <li class="nav-item" data-depth="3">
- <a class="nav-link" href="../../jme3/beginner/hello_audio.html">Hello Audio</a>
- </li>
- <li class="nav-item" data-depth="3">
- <a class="nav-link" href="../../jme3/beginner/hello_effects.html">Hello Effects</a>
- </li>
- <li class="nav-item" data-depth="3">
- <a class="nav-link" href="../../jme3/beginner/hello_physics.html">Hello Physics</a>
- </li>
- </ul>
- </li>
- <li class="nav-item" data-depth="2">
- <button class="nav-item-toggle"></button>
- <span class="nav-text">Intermediate Tutorials</span>
- <ul class="nav-list">
- <li class="nav-item" data-depth="3">
- <button class="nav-item-toggle"></button>
- <span class="nav-text">Concepts</span>
- <ul class="nav-list">
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/intermediate/best_practices.html">Best Practices</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/intermediate/simpleapplication.html">Simple Application</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/features.html">Features</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/intermediate/optimization.html">Optimization</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/faq.html">FAQ</a>
- </li>
- </ul>
- </li>
- <li class="nav-item" data-depth="3">
- <button class="nav-item-toggle"></button>
- <span class="nav-text">Math Concepts</span>
- <ul class="nav-list">
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/math_for_dummies.html">Math For Dummies</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/intermediate/math.html">Math</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/math.html">More Math</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/rotate.html">Rotate</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/math_video_tutorials.html">Math Video Tutorials</a>
- </li>
- </ul>
- </li>
- <li class="nav-item" data-depth="3">
- <button class="nav-item-toggle"></button>
- <span class="nav-text">3D Graphics Concepts</span>
- <ul class="nav-list">
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/intermediate/multi-media_asset_pipeline.html">Multi-Media Asset Pipeline</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/scenegraph_for_dummies.html">Scenegraph for Dummies</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/beginner/hellovector.html">Hello Vector</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/terminology.html">Terminology</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/intermediate/how_to_use_materials.html">How to Use Materials</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/intermediate/transparency_sorting.html">Transparency and Sorting</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/external/blender.html">Importing from Blender</a>
- </li>
- <li class="nav-item" data-depth="4">
- <a class="nav-link" href="../../jme3/external/3dsmax.html">Importing from 3DS Max</a>
- </li>
- </ul>
- </li>
- </ul>
- </li>
- </ul>
- </li>
- <li class="nav-item" data-depth="1">
- <a class="nav-link" href="../../logo.html">Logo Usage</a>
- </li>
- <li class="nav-item" data-depth="1">
- <a class="nav-link" href="../../bsd_license.html">License</a>
- </li>
- <li class="nav-item" data-depth="1">
- <a class="nav-link" href="../../github_tips.html">Github Tips</a>
- </li>
- </ul>
- </li>
- <li class="nav-item" data-depth="0">
- <button class="nav-item-toggle"></button>
- <span class="nav-text">SDK</span>
- <ul class="nav-list">
- <li class="nav-item" data-depth="1">
- <a class="nav-link" href="../../sdk.html">jMonkeyEngine SDK</a>
- </li>
- </ul>
- </li>
- </ul>
- </nav>
- </div>
- <div class="nav-panel-explore" data-panel="explore">
- <div class="context">
- <span class="title">Docs</span>
- <span class="version">master</span>
- </div>
- <ul class="components">
- <li class="component is-current">
- <span class="title">Docs</span>
- <ul class="versions">
- <li class="version is-current is-latest">
- <a href="../../jme3.html">master</a>
- </li>
- </ul>
- </li>
- <li class="component">
- <span class="title">Wiki UI</span>
- <ul class="versions">
- <li class="version is-latest">
- <a href="../../../wiki-ui/index.html">master</a>
- </li>
- </ul>
- </li>
- </ul>
- </div>
- </div>
- </aside>
- </div>
- <main class="article">
- <div class="toolbar" role="navigation">
- <button class="nav-toggle"></button>
- <a href="../../documentation.html" class="home-link"></a>
- <nav class="breadcrumbs" aria-label="breadcrumbs">
- <ul>
- <li><a href="../../jme3.html">Docs</a></li>
- <li><a href="sceneexplorer.html">The SceneExplorer</a></li>
- </ul>
- </nav>
- <div class="edit-this-page"><a href="https://github.com/jMonkeyEngine/wiki/edit/master/docs/modules/ROOT/pages/sdk/development/sceneexplorer.adoc">Edit this Page</a></div>
- </div>
- <div class="content">
- <article class="doc">
- <h1 class="page">The SceneExplorer</h1>
- <div class="sect1">
- <h2 id="adding-node-types-to-sceneexplorer"><a class="anchor" href="#adding-node-types-to-sceneexplorer"></a>Adding Node types to SceneExplorer</h2>
- <div class="sectionbody">
- <div class="paragraph">
- <p>If your plugin brings in its own SceneGraph objects you can still have them work like any other SceneExplorer item, including its special properties.</p>
- </div>
- <div class="paragraph">
- <p>If you want to support special properties of your objects that are not exposed by the SDK automatically, you will have to create your own class that extends org.openide.nodes.Node and implement the interface com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode. Then you register that class by adding</p>
- </div>
- <div class="listingblock">
- <div class="content">
- <pre class="highlightjs highlight"><code>@org.openide.util.lookup.ServiceProvider(service=SceneExplorerNode.class)</code></pre>
- </div>
- </div>
- <div class="literalblock">
- <div class="content">
- <pre>above the body of your class. Thats all, your Spatial type will automatically be used and displayed in the SceneExplorer. Make sure you register a jar with the used classes in the plugin preferences under “wrapped libraries, otherwise the IDE cannot access those classes.</pre>
- </div>
- </div>
- <div class="paragraph">
- <p>AbstractSceneExplorerNode brings some other useful features you might want to include like automatic creation of properly threaded properties etc. JmeSpatial for example bases on it. A simple SceneExplorerNode example for an object extending Spatial would be JmeGeometry (see below). Editors for special variable types can be added using the SceneExplorerPropertyEditor interface, which can be registered as a ServiceProvider as well.</p>
- </div>
- <div class="paragraph">
- <p>The SceneExplorerNode can be used for Spatial and Control type objects.</p>
- </div>
- <div class="ulist">
- <ul>
- <li>
- <p><em>Add the “Nodes <abbr title="Application Programming Interface">API</abbr> and “Lookup <abbr title="Application Programming Interface">API</abbr> libraries to your project when you want to use this</em></p>
- </li>
- </ul>
- </div>
- <div class="sect2">
- <h3 id="spatial-example"><a class="anchor" href="#spatial-example"></a>Spatial Example</h3>
- <div class="listingblock">
- <div class="content">
- <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@org.openide.util.lookup.ServiceProvider(service=SceneExplorerNode.class)
- public class JmeGeometry extends JmeSpatial {
- private static Image smallImage =
- ImageUtilities.loadImage("com/jme3/gde/core/sceneexplorer/nodes/icons/geometry.gif");
- private Geometry geom;
- public JmeGeometry() {
- }
- public JmeGeometry(Geometry spatial, SceneExplorerChildren children) {
- super(spatial, children);
- getLookupContents().add(spatial);
- this.geom = spatial;
- setName(spatial.getName());
- }
- @Override
- public Image getIcon(int type) {
- return smallImage;
- }
- @Override
- public Image getOpenedIcon(int type) {
- return smallImage;
- }
- @Override
- protected Sheet createSheet() {
- Sheet sheet = super.createSheet();
- Sheet.Set set = Sheet.createPropertiesSet();
- set.setDisplayName("Geometry");
- set.setName(Geometry.class.getName());
- Geometry obj = geom;//getLookup().lookup(Geometry.class);
- if (obj == null) {
- return sheet;
- }
- set.put(makeProperty(obj, int.class, "getLodLevel", "setLodLevel", "Lod Level"));
- set.put(makeProperty(obj, Material.class, "getMaterial", "setMaterial", "Material"));
- set.put(makeProperty(obj, Mesh.class, "getMesh", "Mesh"));
- sheet.put(set);
- return sheet;
- }
- public Class getExplorerObjectClass() {
- return Geometry.class;
- }
- public Class getExplorerNodeClass() {
- return JmeGeometry.class;
- }
- public org.openide.nodes.Node[] createNodes(Object key, Object key2, boolean readOnly) {
- SceneExplorerChildren children=new SceneExplorerChildren((com.jme3.scene.Spatial)key);
- children.setReadOnly(readOnly);
- return new org.openide.nodes.Node[]{new JmeGeometry((Geometry) key, children).setReadOnly(readOnly)};
- }
- }</code></pre>
- </div>
- </div>
- </div>
- <div class="sect2">
- <h3 id="control-example"><a class="anchor" href="#control-example"></a>Control Example</h3>
- <div class="listingblock">
- <div class="content">
- <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@org.openide.util.lookup.ServiceProvider(service=SceneExplorerNode.class)
- public class JmeGhostControl extends AbstractSceneExplorerNode {
- private static Image smallImage =
- ImageUtilities.loadImage("com/jme3/gde/core/sceneexplorer/nodes/icons/ghostcontrol.gif");
- private GhostControl control;
- public JmeGhostControl() {
- }
- public JmeGhostControl(GhostControl control, DataObject dataObject) {
- super(dataObject);
- getLookupContents().add(this);
- getLookupContents().add(control);
- this.control = control;
- setName("GhostControl");
- }
- @Override
- public Image getIcon(int type) {
- return smallImage;
- }
- @Override
- public Image getOpenedIcon(int type) {
- return smallImage;
- }
- protected SystemAction[] createActions() {
- return new SystemAction[]{
- // SystemAction.get(CopyAction.class),
- // SystemAction.get(CutAction.class),
- // SystemAction.get(PasteAction.class),
- SystemAction.get(DeleteAction.class)
- };
- }
- @Override
- public boolean canDestroy() {
- return !readOnly;
- }
- @Override
- public void destroy() throws IOException {
- super.destroy();
- final Spatial spat=getParentNode().getLookup().lookup(Spatial.class);
- try {
- SceneApplication.getApplication().enqueue(new Callable<Void>() {
- public Void call() throws Exception {
- spat.removeControl(control);
- return null;
- }
- }).get();
- ((AbstractSceneExplorerNode)getParentNode()).refresh(true);
- } catch (InterruptedException ex) {
- Exceptions.printStackTrace(ex);
- } catch (ExecutionException ex) {
- Exceptions.printStackTrace(ex);
- }
- }
- @Override
- protected Sheet createSheet() {
- Sheet sheet = super.createSheet();
- Sheet.Set set = Sheet.createPropertiesSet();
- set.setDisplayName("GhostControl");
- set.setName(GhostControl.class.getName());
- GhostControl obj = control;//getLookup().lookup(Spatial.class);
- if (obj == null) {
- return sheet;
- }
- set.put(makeProperty(obj, Vector3f.class, "getPhysicsLocation", "setPhysicsLocation", "Physics Location"));
- set.put(makeProperty(obj, Quaternion.class, "getPhysicsRotation", "setPhysicsRotation", "Physics Rotation"));
- set.put(makeProperty(obj, CollisionShape.class, "getCollisionShape", "setCollisionShape", "Collision Shape"));
- set.put(makeProperty(obj, int.class, "getCollisionGroup", "setCollisionGroup", "Collision Group"));
- set.put(makeProperty(obj, int.class, "getCollideWithGroups", "setCollideWithGroups", "Collide With Groups"));
- sheet.put(set);
- return sheet;
- }
- public Class getExplorerObjectClass() {
- return GhostControl.class;
- }
- public Class getExplorerNodeClass() {
- return JmeGhostControl.class;
- }
- public org.openide.nodes.Node[] createNodes(Object key, DataObject key2, boolean cookie) {
- return new org.openide.nodes.Node[]{new JmeGhostControl((GhostControl) key, key2).setReadOnly(cookie)};
- }
- }</code></pre>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="sect1">
- <h2 id="adding-items-to-the-add-and-tools-menus"><a class="anchor" href="#adding-items-to-the-add-and-tools-menus"></a>Adding items to the add and tools menus</h2>
- <div class="sectionbody">
- <div class="paragraph">
- <p>For adding Spatials, Contols and for general tools theres premade abstract classes that you can use to extend the options. Undo/Redo is handled by the abstract class. AbstractNewSpatial*Wizard*Action allows you to show an AWT wizard before creating the Spatial. You can also just implement the base ServiceProvider class and return any kind of action (such as a wizard), in this case you have to handle the threading yourself!</p>
- </div>
- <div class="admonitionblock important">
- <table>
- <tr>
- <td class="icon">
- <i class="fa icon-important" title="Important"></i>
- </td>
- <td class="content">
- <div class="paragraph">
- <p>Note that the classes you create are singletons which are used across multiple nodes and you should not store any data in local variables!</p>
- </div>
- </td>
- </tr>
- </table>
- </div>
- <div class="paragraph">
- <p>To add a new Tool, create a new AbstractToolAction:</p>
- </div>
- <div class="listingblock">
- <div class="content">
- <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@org.openide.util.lookup.ServiceProvider(service = ToolAction.class)
- public class GenerateTangentsTool extends AbstractToolAction {
- public GenerateTangentsTool() {
- name = "Generate Tangents";
- }
- @Override
- protected Object doApplyTool(AbstractSceneExplorerNode rootNode) {
- Geometry geom = rootNode.getLookup().lookup(Geometry.class);
- Mesh mesh = geom.getMesh();
- if (mesh != null) {
- TangentBinormalGenerator.generate(mesh);
- }
- return geom;
- }
- @Override
- protected void doUndoTool(AbstractSceneExplorerNode rootNode, Object undoObject) {
- Geometry geom = rootNode.getLookup().lookup(Geometry.class);
- Mesh mesh = geom.getMesh();
- if (mesh != null) {
- mesh.clearBuffer(Type.Tangent);
- }
- }
- public Class<?> getNodeClass() {
- return JmeGeometry.class;
- }
- }</code></pre>
- </div>
- </div>
- <div class="paragraph">
- <p>For a new Spatial or Control, use AbstractNewSpatialAction</p>
- </div>
- <div class="listingblock">
- <div class="content">
- <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@org.openide.util.lookup.ServiceProvider(service = NewSpatialAction.class)
- public class NewSpecialSpatialAction extends AbstractNewSpatialAction {
- public NewSpecialSpatialAction() {
- name = "Spatial";
- }
- @Override
- protected Spatial doCreateSpatial(Node parent) {
- Spatial spatial=new Node();
- return spatial;
- }
- }</code></pre>
- </div>
- </div>
- <div class="paragraph">
- <p>or AbstractNewControlAction:</p>
- </div>
- <div class="listingblock">
- <div class="content">
- <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@org.openide.util.lookup.ServiceProvider(service = NewControlAction.class)
- public class NewRigidBodyAction extends AbstractNewControlAction {
- public NewRigidBodyAction() {
- name = "Static RigidBody";
- }
- @Override
- protected Control doCreateControl(Spatial spatial) {
- RigidBodyControl control = spatial.getControl(RigidBodyControl.class);
- if (control != null) {
- spatial.removeControl(control);
- }
- Node parent = spatial.getParent();
- spatial.removeFromParent();
- control = new RigidBodyControl(0);
- if (parent != null) {
- parent.attachChild(spatial);
- }
- return control;
- }
- }</code></pre>
- </div>
- </div>
- <div class="sect2">
- <h3 id="adding-using-a-wizard"><a class="anchor" href="#adding-using-a-wizard"></a>Adding using a Wizard</h3>
- <div class="paragraph">
- <p>You can create a new wizard using the wizard template in the SDK (New File→Module Development→Wizard). The Action that the template creates can easily be changed to one for adding a Control or Spatial or for applying a Tool. Note that we extend AbstractNewSpatial*Wizard*Action here.</p>
- </div>
- <div class="paragraph">
- <p>A good example is the “Add SkyBox Wizard:</p>
- </div>
- <div class="listingblock">
- <div class="content">
- <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@org.openide.util.lookup.ServiceProvider(service = NewSpatialAction.class)
- public class AddSkyboxAction extends AbstractNewSpatialWizardAction {
- private WizardDescriptor.Panel[] panels;
- public AddSkyboxAction() {
- name = "Skybox..";
- }
- @Override
- protected Object showWizard(org.openide.nodes.Node node) {
- WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels());
- wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
- wizardDescriptor.setTitle("Skybox Wizard");
- Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
- dialog.setVisible(true);
- dialog.toFront();
- boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
- if (!cancelled) {
- return wizardDescriptor;
- }
- return null;
- }
- @Override
- protected Spatial doCreateSpatial(Node parent, Object properties) {
- if (properties != null) {
- return generateSkybox((WizardDescriptor) properties);
- }
- return null;
- }
- private Spatial generateSkybox(WizardDescriptor wiz) {
- if ((Boolean) wiz.getProperty("multipleTextures")) {
- Texture south = (Texture) wiz.getProperty("textureSouth");
- Texture north = (Texture) wiz.getProperty("textureNorth");
- Texture east = (Texture) wiz.getProperty("textureEast");
- Texture west = (Texture) wiz.getProperty("textureWest");
- Texture top = (Texture) wiz.getProperty("textureTop");
- Texture bottom = (Texture) wiz.getProperty("textureBottom");
- Vector3f normalScale = (Vector3f) wiz.getProperty("normalScale");
- return SkyFactory.createSky(pm, west, east, north, south, top, bottom, normalScale);
- } else {
- Texture textureSingle = (Texture) wiz.getProperty("textureSingle");
- Vector3f normalScale = (Vector3f) wiz.getProperty("normalScale");
- boolean useSpheremap = (Boolean) wiz.getProperty("useSpheremap");
- return SkyFactory.createSky(pm, textureSingle, normalScale, useSpheremap);
- }
- }
- /**
- * Initialize panels representing individual wizard's steps and sets
- * various properties for them influencing wizard appearance.
- */
- private WizardDescriptor.Panel[] getPanels() {
- if (panels == null) {
- panels = new WizardDescriptor.Panel[]{
- new SkyboxWizardPanel1(),
- new SkyboxWizardPanel2()
- };
- String[] steps = new String[panels.length];
- for (int i = 0; i < panels.length; i++) {
- Component c = panels[i].getComponent();
- // Default step name to component name of panel. Mainly useful
- // for getting the name of the target chooser to appear in the
- // list of steps.
- steps[i] = c.getName();
- if (c instanceof JComponent) { // assume Swing components
- JComponent jc = (JComponent) c;
- // Sets step number of a component
- // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
- jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
- // Sets steps names for a panel
- jc.putClientProperty("WizardPanel_contentData", steps);
- // Turn on subtitle creation on each step
- jc.putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE);
- // Show steps on the left side with the image on the background
- jc.putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE);
- // Turn on numbering of all steps
- jc.putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE);
- }
- }
- }
- return panels;
- }
- }</code></pre>
- </div>
- </div>
- <div class="admonitionblock tip">
- <table>
- <tr>
- <td class="icon">
- <i class="fa icon-tip" title="Tip"></i>
- </td>
- <td class="content">
- <div class="paragraph">
- <p>The abstract spatial and control actions implement undo/redo automatically, for the ToolActions you have to implement it yourself.</p>
- </div>
- </td>
- </tr>
- </table>
- </div>
- </div>
- </div>
- </div>
- </article>
- <aside class="toc sidebar" data-title="Contents" data-levels="2">
- <div class="toc-menu"></div>
- </aside>
- </div>
- </main>
- </div>
- <footer class="footer">
- <p>This page was built using the Antora default UI.</p>
- <p>The source code for this UI is licensed under the terms of the MPL-2.0 license.</p>
- </footer>
- <script src="../../../_/js/site.js"></script>
- <script async src="../../../_/js/vendor/highlight.js"></script>
- </body>
- </html>
|