Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package simu;
- import jme.Tube;
- import com.jme.app.SimpleGame;
- import com.jme.image.Texture.MagnificationFilter;
- import com.jme.image.Texture.MinificationFilter;
- import com.jme.image.Texture.WrapMode;
- import com.jme.math.FastMath;
- import com.jme.math.Quaternion;
- import com.jme.scene.state.TextureState;
- import com.jme.util.TextureManager;
- /**
- *
- * Basic code to showcase the features of the modified tube.
- *
- * @author Ahmed Abdelkader
- *
- */
- public class TubeTest extends SimpleGame {
- private Tube tube;
- private float outerRadius = 10;
- private float innerRadius = 6;
- private float height = 30;
- private int axisSamples = 1;
- private int radialSamples = 100;
- private float arcAngle = 270;
- private int angleSign = 1;
- private int radiusSign = 1;
- protected void simpleInitGame() {
- display.setTitle("Tube Test");
- tube = new Tube("", outerRadius, innerRadius, height, axisSamples, radialSamples, arcAngle);
- tube.setLocalTranslation(0, -5, -40);
- tube.setLocalRotation(new Quaternion().fromAngles(0, -FastMath.HALF_PI, -FastMath.QUARTER_PI));
- rootNode.attachChild(tube);
- TextureState ts = display.getRenderer().createTextureState();
- ts.setEnabled(true);
- ts.setTexture(TextureManager.loadTexture("BlueLines.jpg",
- MinificationFilter.Trilinear, MagnificationFilter.Bilinear));
- ts.getTexture().setWrap(WrapMode.Repeat);
- rootNode.setRenderState(ts);
- }
- @Override
- protected void simpleUpdate() {
- if(tpf < 1) {
- arcAngle = arcAngle + angleSign * tpf * 360;
- if(FastMath.abs(arcAngle) > 360) {
- angleSign = -angleSign;
- if(innerRadius == outerRadius || innerRadius == 0)
- radiusSign = -radiusSign;
- innerRadius += radiusSign * 1;
- }
- }
- tube.updateGeometry(outerRadius, innerRadius, height, axisSamples, radialSamples, arcAngle * FastMath.PI/180);
- }
- public static void main(String[] args) {
- new TubeTest().start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement