Browse Source

- add Control template

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8648 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
nor..67 13 years ago
parent
commit
7a901526c5

+ 14 - 0
jme3-templates/src/com/jme3/gde/templates/files/Control.html

@@ -0,0 +1,14 @@
+<!--
+To change this template, choose Tools | Templates
+and open the template in the editor.
+-->
+<!DOCTYPE html>
+<html>
+    <head>
+        <title></title>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    </head>
+    <body>
+        <div>A generic Control class that extends AbstractControl and can be used to control a spatial.</div>
+    </body>
+</html>

+ 66 - 0
jme3-templates/src/com/jme3/gde/templates/files/Control.template

@@ -0,0 +1,66 @@
+<#assign licenseFirst = "/*">
+<#assign licensePrefix = " * ">
+<#assign licenseLast = " */">
+<#include "../Licenses/license-${project.license}.txt">
+
+<#if package?? && package != "">
+package ${package};
+
+import com.jme3.export.InputCapsule;
+import com.jme3.export.JmeExporter;
+import com.jme3.export.JmeImporter;
+import com.jme3.export.OutputCapsule;
+import com.jme3.renderer.RenderManager;
+import com.jme3.renderer.ViewPort;
+import com.jme3.scene.Spatial;
+import com.jme3.scene.control.AbstractControl;
+import com.jme3.scene.control.Control;
+import java.io.IOException;
+
+</#if>
+/**
+ *
+ * @author ${user}
+ */
+public class ${name} extends AbstractControl{
+    //Any local variables should be encapsulated by getters/setters so they
+    //appear in the SDK properties window and can be edited.
+    //Right-click a local variable to encapsulate it with getters and setters.
+
+    @Override
+    protected void controlUpdate(float tpf) {
+        //TODO: add code that controls Spatial,
+        //e.g. spatial.rotate(tpf,tpf,tpf);
+    }
+
+    @Override
+    protected void controlRender(RenderManager rm, ViewPort vp) {
+        //Only needed for rendering-related operations,
+        //not called when spatial is culled.
+    }
+
+    public Control cloneForSpatial(Spatial spatial) {
+        Control control = new ${name}();
+        //TODO: copy parameters to new Control
+        control.setSpatial(spatial);
+        return control;
+    }
+
+    @Override
+    public void read(JmeImporter im) throws IOException {
+        super.read(im);
+        InputCapsule in = im.getCapsule(this);
+        //TODO: load properties of this Control, e.g.
+        //this.value = in.readFloat(value, "name", defaultValue);
+    }
+
+    @Override
+    public void write(JmeExporter ex) throws IOException {
+        super.write(ex);
+        OutputCapsule out = ex.getCapsule(this);
+        //TODO: save properties of this Control, e.g.
+        //out.write(this.value, "name", defaultValue);
+    }
+
+
+}

+ 14 - 0
jme3-templates/src/com/jme3/gde/templates/layer.xml

@@ -4,6 +4,7 @@
     <folder name="Templates">
         <folder name="Project">
             <folder name="JME3">
+                <attr name="position" intvalue="10"/>
                 <file name="BasicGameProject.zip" url="BasicGameProject.zip">
                     <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/com/jme3/gde/templates/jme-logo.png"/>
                     <attr name="displayName" bundlevalue="com.jme3.gde.templates.Bundle#Templates/Project/JME3/BasicGameProject.zip"/>
@@ -13,5 +14,18 @@
                 </file>
             </folder>
         </folder>
+        <folder name="JME3Classes">
+            <attr name="position" intvalue="200"/>
+            <file name="Control.java" url="files/Control.template">
+                <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator"/>
+                <attr name="position" intvalue="100"/>
+                <attr name="templateCategory" stringvalue="java-classes, java-classes-basic"/>
+                <attr name="template" boolvalue="true"/>
+                <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
+                <attr name="templateWizardURL" urlvalue="nbresloc:/com/jme3/gde/templates/files/Control.html"/>
+                <!--attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.project.Bundle"/-->
+                <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
+            </file>
+        </folder>
     </folder>
 </filesystem>