1 /* 2 * To change this template, choose Tools | Templates 3 * and open the template in the editor. 4 */ 5 package jme3test.model.shape; 6 7 import com.jme3.app.SimpleApplication; 8 import com.jme3.material.Material; 9 import com.jme3.scene.Geometry; 10 import com.jme3.scene.shape.Torus; 11 12 public class TestExpandingTorus extends SimpleApplication { 13 14 private float outerRadius = 1.5f; 15 private float rate = 1; 16 private Torus torus; 17 private Geometry geom; 18 19 public static void main(String[] args) { 20 TestExpandingTorus app = new TestExpandingTorus(); 21 app.start(); 22 } 23 24 @Override 25 public void simpleInitApp() { 26 torus = new Torus(30, 10, .5f, 1f); 27 geom = new Geometry("Torus", torus); 28 Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); 29 geom.setMaterial(mat); 30 rootNode.attachChild(geom); 31 } 32 33 @Override 34 public void simpleUpdate(float tpf){ 35 if (outerRadius > 2.5f){ 36 outerRadius = 2.5f; 37 rate = -rate; 38 }else if (outerRadius < 1f){ 39 outerRadius = 1f; 40 rate = -rate; 41 } 42 outerRadius += rate * tpf; 43 torus.updateGeometry(30, 10, .5f, outerRadius); 44 } 45 }