private void attachRandomGeometry(Node node, Material mat) {
   Box box = new Box(0.25f, 0.25f, 0.25f);
   Torus torus = new Torus(16, 16, 0.2f, 0.8f);
   Geometry[] boxes =
       new Geometry[] {
         new Geometry("box1", box),
         new Geometry("box2", box),
         new Geometry("box3", box),
         new Geometry("torus1", torus),
         new Geometry("torus2", torus),
         new Geometry("torus3", torus)
       };
   for (int i = 0; i < boxes.length; i++) {
     Geometry geometry = boxes[i];
     geometry.setLocalTranslation(
         (float) Math.random() * 10 - 10,
         (float) Math.random() * 10 - 10,
         (float) Math.random() * 10 - 10);
     geometry.setLocalRotation(
         new Quaternion()
             .fromAngles(
                 (float) Math.random() * FastMath.PI,
                 (float) Math.random() * FastMath.PI,
                 (float) Math.random() * FastMath.PI));
     geometry.setLocalScale(
         (float) Math.random() * 10 - 10,
         (float) Math.random() * 10 - 10,
         (float) Math.random() * 10 - 10);
     geometry.setMaterial(mat);
     node.attachChild(geometry);
   }
 }
 /**
  * Returns a player base geometry.
  *
  * @param basevec - Local translation for base.
  * @param basescale - Local scale for base.
  * @return
  */
 public Geometry getBase(Vector3f basevec, Vector3f basescale) {
   Geometry base_geom = new Geometry("Base", new Box(1, 1, 1));
   base_geom.setMaterial(bs.getMaterial("Base"));
   base_geom.setLocalScale(basescale);
   base_geom.setLocalTranslation(basevec);
   return base_geom;
 }
Beispiel #3
0
  private Spatial createFollowBox() {
    // add spatial representing the position the driving car is steering towards
    Box box = new Box(new Vector3f(0, 0, 0), 1f, 1f, 1f);
    Geometry followBox = new Geometry("followBox", box);
    followBox.setLocalTranslation(0, 0, 0);
    Material followBoxMaterial =
        new Material(sim.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
    followBoxMaterial.setColor("Color", ColorRGBA.Green);
    followBox.setMaterial(followBoxMaterial);
    followBox.setLocalScale(0.4f);
    sim.getSceneNode().attachChild(followBox);

    if (!settings.isPathVisible()) followBox.setCullHint(CullHint.Always);

    return followBox;
  }
  public void initMachineScreenText() {

    Box box2 = new Box(6, 0.5f, 0.2f);
    Geometry red = new Geometry("Box", box2);
    Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat2.setColor("Color", ColorRGBA.Black);
    red.setName("MachineScreen");
    red.setMaterial(mat2);
    red.setLocalScale(0.5f);
    red.setLocalTranslation(-0.0f, 2.0f, -4.7f);
    rootNode.attachChild(red);

    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    BitmapText inHand = new BitmapText(guiFont, false);
    inHand.setSize(guiFont.getCharSet().getRenderedSize());
    inHand.setText("Welcome");
    inHand.setName("MachineScreenText");
    inHand.setLocalScale(0.01f);
    inHand.setLocalTranslation(-2.8f, 2.0f, -4.5f);
    rootNode.attachChild(inHand);
  }