Ejemplo n.º 1
0
  public static void addChildToTargetsChildGroup(
      MeshComponent target, RenderableEntity a, boolean insertAtBeginnung) {
    if (a == null) {
      Log.e(LOG_TAG, "Request to add NULL object as a child to " + target + " was denied!");
      return;
    }

    if (target.myChildren == null) {
      target.myChildren = a;
      return;
    }

    if (!(target.myChildren instanceof RenderList)) {
      RenderList childrenGroup = new RenderList();
      // keep the old animation:
      if (target.myChildren != null) {
        childrenGroup.add(target.myChildren);
      }
      // and change myChildren to the created group:
      target.myChildren = childrenGroup;
    }

    if (insertAtBeginnung) {
      ((RenderList) target.myChildren).insert(0, a);
    } else {
      ((RenderList) target.myChildren).add(a);
    }
  }
 private void setHighlightNodeTransformations(MeshComponent m) {
   if (m != null) {
     m.removeAllAnimations();
     m.addAnimation(new AnimationColorMorph(BLENDING_TIME, newHighlightColor()));
     m.addAnimation(new AnimationRotate(50, new Vec(0, 0, 1)));
   }
 }
 private void setPassedTransformationsOn(MeshComponent m) {
   if (m != null) {
     m.removeAllAnimations();
     m.addAnimation(new AnimationMove(MOVEMENT_TIME, new Vec(0, 0, -2)));
     m.addAnimation(new AnimationColorMorph(BLENDING_TIME, newAlreadyPassedColor()));
   }
 }
Ejemplo n.º 4
0
  @Override
  public boolean update(float timeDelta, Updateable parent) {
    if (physicsActive) {
      Obj obj = (Obj) parent;
      final MeshComponent v = obj.getGraphicsComponent();

      updateAccel(timeDelta);
      velocityVerletIntegration(timeDelta, v.getPosition());
      updateSpeed(timeDelta);
      iterateCollisions(timeDelta, obj);
    }
    return true;
  }
Ejemplo n.º 5
0
  public void getAbsoluteMeshPosition(Vec pos) {
    if (myPosition != null) {
      pos.add(myPosition);
    }

    Updateable p = getMyParent();
    if (p instanceof MeshComponent) {
      ((MeshComponent) p).getAbsoluteMeshPosition(pos);
    }
  }
Ejemplo n.º 6
0
  @Override
  public void addObjectsTo(GL1Renderer renderer, World world, GLFactory objectFactory) {
    GeoObj o = new GeoObj(-29.456251, -51.968653);
    //		o.setComp(GLFactory.getInstance().newSolarSystem(new Vec()));
    MeshComponent mesh1 = GLFactory.getInstance().newCube();
    //		mesh1.setScale(new Vec(3, 3, 3));
    o.setComp(mesh1);
    world.add(o);

    Color color = new Color("#ff00ff");
    MeshComponent mesh = GLFactory.getInstance().newCube(color);
    // mesh.setScale(new Vec(20, 20, 20));

    GeoObj cedro = new GeoObj(-29.477376, -51.983571);
    cedro.setComp(mesh);
    world.add(cedro);

    // Faleiro: -29.466055,-51.961384
    Color colorF = new Color("#ff00ff");
    MeshComponent meshF = GLFactory.getInstance().newCube(colorF);
    meshF.setScale(new Vec(20, 20, 20));

    GeoObj cemetery = new GeoObj(-29.460381, -51.967412);
    cemetery.setComp(meshF);
    world.add(cemetery);

    // São Cri: -29.454733,-51.966877
    Color colorS = new Color("#00ff00");
    MeshComponent meshS = GLFactory.getInstance().newCube(colorS);
    // meshS.setScale(new Vec(20, 20, 20));

    // Objetos sao visiveis ate 1 km
    GeoObj saocri = new GeoObj(-29.454733, -51.966877);
    saocri.setComp(meshS);
    world.add(saocri);
  }
Ejemplo n.º 7
0
  @Override
  public void _b_addWorldsToRenderer(
      GL1Renderer renderer, GLFactory objectFactory, GeoObj currentPosition) {

    camera = new GLCamera(new Vec(0, 0, 1));
    world = new World(camera);

    MeshComponent arrow = GLFactory.getInstance().newArrow();
    arrow.setPosition(new Vec(0, 0, 4));

    MeshComponent circle = GLFactory.getInstance().newCircle(Color.redTransparent());
    circle.setScale(new Vec(4, 4, 4));
    // circle.myAnimation = new AnimationPulse(2, new Vec(0, 0, 0), new
    // Vec(4, 4, 4), 0.2f);

    final MeshComponent itemMesh = new Shape();
    itemMesh.addChild(arrow);
    itemMesh.addChild(circle);
    itemMesh.setPosition(Vec.getNewRandomPosInXYPlane(camera.getPosition(), 5, 10));

    Obj itemToCollect = new Obj();
    itemToCollect.setComp(
        new ProximitySensor(camera, 3f) {
          @Override
          public void onObjectIsCloseToCamera(
              GLCamera myCamera2, Obj obj, MeshComponent m, float currentDistance) {
            catchedNumber++;
            new CommandShowToast(myTargetActivity, "You got me " + catchedNumber + " times")
                .execute();
            itemMesh.setPosition(Vec.getNewRandomPosInXYPlane(camera.getPosition(), 5, 20));
          }
        });

    itemToCollect.setComp(itemMesh);
    world.add(itemToCollect);
    renderer.addRenderElement(world);
  }
 private void setNormalTransformations(MeshComponent m) {
   if (m != null) m.setColor(newNormalColor());
 }