コード例 #1
0
  private void doneLoading() {
    for (int i = 0; i < model.nodes.size; i++) {
      String id = model.nodes.get(i).id;
      ModelInstance instance = new ModelInstance(model, id);
      Node node = instance.getNode(id);

      instance.transform.set(node.globalTransform);
      node.translation.set(0, 0, 0);
      node.scale.set(1, 1, 1);
      node.rotation.idt();
      instance.calculateTransforms();

      if (id.equals("space")) {
        space = instance;
        continue;
      }

      instances.add(instance);

      if (id.equals("ship")) ship = instance;
      else if (id.startsWith("block")) blocks.add(instance);
      else if (id.startsWith("invader")) invaders.add(instance);
    }
    for (ModelInstance block : blocks) {
      float r = 0.5f + 0.5f * (float) Math.random();
      float g = 0.5f + 0.5f * (float) Math.random();
      float b = 0.5f + 0.5f * (float) Math.random();
      block.materials.get(0).set(ColorAttribute.createDiffuse(r, g, b, 1));
    }
  }
コード例 #2
0
ファイル: MyGame.java プロジェクト: cyber2024/threedexample
  private void doneLoading() {
    Model model = assets.get("data/invaderscene5.g3dj", Model.class);
    for (int i = 0; i < model.nodes.size; i++) {
      String id = model.nodes.get(i).id;
      ModelInstance instance = new ModelInstance(model, id);
      Node node = instance.getNode(id);

      instance.transform.set(node.globalTransform);
      node.translation.set(0, 0, 0);
      node.scale.set(1, 1, 1);
      node.rotation.idt();
      instance.calculateTransforms();

      if (id.equals("space")) {
        space = instance;
        continue;
      }

      instances.add(instance);
      Gdx.app.log("tag: ", "test");
      if (id.equals("ship")) {
        ship = instance;
        Gdx.app.log("tag: ", "Cube added");
      } else if (id.startsWith("block")) {
        blocks.add(instance);
        Gdx.app.log("tag: ", "Cube added");
      } else if (id.startsWith("invader")) invaders.add(instance);
    }

    loading = false;
  }
コード例 #3
0
 /** End applying multiple animations to the instance and update it to reflect the changes. */
 protected void end() {
   if (!applying) throw new GdxRuntimeException("You must call begin() first");
   for (Entry<Node, Transform> entry : transforms.entries()) {
     entry.value.toMatrix4(entry.key.localTransform);
     transformPool.free(entry.value);
   }
   transforms.clear();
   target.calculateTransforms();
   applying = false;
 }
コード例 #4
0
 /**
  * Apply a single animation to the {@link ModelInstance} and update the it to reflect the changes.
  */
 protected void applyAnimation(final Animation animation, final float time) {
   if (applying) throw new GdxRuntimeException("Call end() first");
   applyAnimation(null, null, 1.f, animation, time);
   target.calculateTransforms();
 }