Example #1
0
  protected void applyTransforms() {
    Matrix.setIdentityM(mWorldMatrix, 0);
    Matrix.translateM(mWorldMatrix, 0, mTransDir.getX(), mTransDir.getY(), mTransDir.getZ());
    if (mRotAxes != null) {
      Matrix.rotateM(mWorldMatrix, 0, mRotAngle, mRotAxes.getX(), mRotAxes.getY(), mRotAxes.getZ());
    }
    Matrix.scaleM(mWorldMatrix, 0, mScaleFac.getX(), mScaleFac.getY(), mScaleFac.getZ());

    mDirty = false;
  }
Example #2
0
  public GridMapState() {

    Vec3 eye = new Vec3(0.0f, 4.0f, 6.0f);
    Vec3 look = new Vec3(0.0f, 2.0f, -1.0f);
    Vec3 up = new Vec3(0.0f, 1.0f, 0.0f);
    float near = 1.0f;
    float far = 1000.0f;
    float fov = 50.0f;

    try {

      Vec3 pushback = new Vec3(0.0f, 0.0f, -5.0f);
      List<InputUiElement> uiElements = GeometryIO.loadInputUiElements(R.raw.gray_ui);
      for (InputUiElement iu : uiElements) {
        iu.translate(pushback.getX(), pushback.getY(), pushback.getZ());
      }
      mInputHandlers.addAll(uiElements);
      mUi.addAll(GeometryIO.loadUiElements(R.raw.gray_ui));
      pushback = new Vec3(0.0f, 0.0f, -6.0f);
      for (Geometry g : mUi) {
        g.translate(pushback);
      }

      Map<String, Geometry> island = GeometryIO.loadGeometryMap(R.raw.island);
      Geometry arrow = island.get("Arrow");

      mActor = new Actor(arrow);
      mActor.changeState(new MatchHeadingWithDirectionState());
      mActor.rotate(180.0f, new Vec3(0, 1.0f, 0));

      mCamera = new CameraNode(eye, look, up, near, far, fov, mActor);
      mCamera.resizeViewport(GameWorld.inst().getViewport());
      GridMapRenderer gmr = (GridMapRenderer) RendererManager.getRenderer();
      gmr.setCurrentCamera(mCamera);
      mCamera.setParent(mActor);

      //			mCamera.rotate(-30.0f, new Vec3(1.0f,0.0f,0.0f));

      mActor.addChild(mCamera);
      mScene.addChild(mActor);

      Skybox skybox = new Skybox("skybox_shader", "tenerife_etc1");
      mScene.addChild(skybox);

      Geometry terrain = island.get("Landscape");
      mScene.addChild(new GeometryNode(terrain));

      Geometry ocean = island.get("Water");
      WaterNode wn = new WaterNode(ocean);
      wn.setSkybox(skybox);
      mScene.addChild(wn);

    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }