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