コード例 #1
0
ファイル: WallShelfLayer.java プロジェクト: xiaocong/3DHomeHD
 private SEVector3f worldLocationToDesk(SEVector3f worldLocation) {
   float r = worldLocation.getVectorZ().getLength();
   float postitionAngle = (float) (worldLocation.getVectorZ().getAngle_II() * 180 / Math.PI);
   float preAngle = mWallShelf.getUserRotate().getAngle();
   float angle = postitionAngle - preAngle;
   float x = (float) (-r * Math.sin(angle * Math.PI / 180));
   float y = (float) (r * Math.cos(angle * Math.PI / 180));
   SEVector3f deskLocation = new SEVector3f(x, y, worldLocation.getZ());
   return deskLocation;
 }
コード例 #2
0
ファイル: DelayFrame.java プロジェクト: xiaocong/3DHomeHD
 public void show(SEAnimFinishListener l, boolean show) {
   if (show) {
     SEVector3f yAxis = getCamera().getAxisY();
     SEVector2f yAxis2f = new SEVector2f(yAxis.getZ(), yAxis.getY());
     float angle = (float) (180 * yAxis2f.getAngle() / Math.PI);
     setTranslate(getCamera().getScreenLocation(0.1f), false);
     setRotate(new SERotate(-angle, 1, 0, 0), false);
     setUserTransParas();
   }
   setVisible(show, true);
 }
コード例 #3
0
ファイル: WallShelfLayer.java プロジェクト: xiaocong/3DHomeHD
  private void setMovePoint(int touchX, int touchY) {
    House house = (House) mWallShelf.getParent();
    SEVector3f location = house.getFingerLocation(touchX, touchY);
    float radius = house.getWallRadius() * 0.8f;

    // SERay Ray = getScene().getCamera().screenCoordinateToRay(touchX, touchY);
    mRealLocation = location; // getTouchLocation(Ray, mWallShelf.getBorderHeight());
    // SEVector3f touchLocation = getTouchLocation(Ray, mWallShelf.getBorderHeight() + 5);
    mObjectTransParas = new SETransParas();
    mObjectTransParas.mTranslate =
        new SEVector3f(location.getX(), location.getY() - 60, location.getZ());
    mObjectTransParas.mRotate.set(mWallShelf.getUserRotate().getAngle(), 0, 0, 1);
  }
コード例 #4
0
ファイル: DelayFrame.java プロジェクト: xiaocong/3DHomeHD
 @Override
 public void onRender(SECamera camera) {
   super.onRender(camera);
   SERect3D rect = new SERect3D();
   rect.setSize(camera.getWidth(), camera.getHeight(), 0.1f);
   SEObjectFactory.createOpaqueRectangle(
       this, rect, mName + "_image", SESceneManager.BACKGROUND_IMAGE_KEY);
   setImageSize(camera.getWidth(), camera.getHeight());
   setTranslate(camera.getScreenLocation(0.1f), false);
   SEVector3f yAxis = getCamera().getAxisY();
   SEVector2f yAxis2f = new SEVector2f(yAxis.getZ(), yAxis.getY());
   float angle = (float) (180 * yAxis2f.getAngle() / Math.PI);
   setRotate(new SERotate(-angle, 1, 0, 0), false);
   setVisible(false, false);
 }
コード例 #5
0
ファイル: WallShelfLayer.java プロジェクト: xiaocong/3DHomeHD
  public boolean onObjectMoveEvent(ACTION event, SEVector3f worldLocation) {
    NormalObject conflictObject = null;
    switch (event) {
      case BEGIN:
        {
          // mWallShelf.getExistentSlot(getOnMoveObject());
        }
        break;
      case MOVE:
        {
        }
        break;
      case UP:
        {
        }
        break;
      case FLY:
        {
        }
        break;
      case FINISH:
        cancelConflictAnimationTask();
        if (mInRecycle) {
          handleOutsideRoom();
        } else {
          int currentMountPointIndex =
              mWallShelf.calculateNearestMountPointIndex(getOnMoveObject(), worldLocation, true);
          if (currentMountPointIndex == -1) {
            handleNoMoreRoom();
            return false;
          }

          conflictObject =
              mWallShelf.getConflictedObject(getOnMoveObject(), currentMountPointIndex);
          Log.i(TAG, "## current layer = " + mWallShelf.mIndex + " ###");
          boolean placeObjectOK = true;
          if (conflictObject == null) {
            cancelConflictAnimationTask();
          } else {
            // playConflictAnimationTask(conflictObject, 0);
            placeObjectOK =
                this.placeObjectOnMountPoint(
                    conflictObject,
                    currentMountPointIndex,
                    getOnMoveObject().getObjectInfo().mSlotType,
                    getOnMoveObject().getObjectSlot().mSlotIndex,
                    getOnMoveObject().getObjectSlot().mMountPointIndex);
          }
          if (placeObjectOK == false) return false;
          getOnMoveObject().getObjectInfo().mSlotType = ObjectInfo.SLOT_TYPE_WALL_SHELF;
          SEVector3f desLocation =
              mWallShelf.getSlotPosition(getOnMoveObject().mName, currentMountPointIndex);
          getOnMoveObject().getObjectInfo().mObjectSlot.mMountPointIndex = currentMountPointIndex;
          getOnMoveObject().getObjectInfo().mObjectSlot.mSlotIndex = mWallShelf.mIndex;
          SEVector3f srcLocation = mWallShelf.toObjectPoint(worldLocation);
          // desLocation.mD[1] = srcLocation.mD[1];
          getOnMoveObject().changeParent(mWallShelf);
          getOnMoveObject().getUserTransParas().mTranslate = srcLocation;
          getOnMoveObject().getUserTransParas().mRotate.set(0, 0, 0, 1);
          getOnMoveObject().setUserTransParas();
          if (srcLocation.subtract(desLocation).getLength() > 1) {
            mMoveObjectAnimation =
                AnimationFactory.createMoveObjectAnimation(
                    getOnMoveObject(), srcLocation, desLocation, 3);
            mMoveObjectAnimation.setAnimFinishListener(
                new SEAnimFinishListener() {

                  public void onAnimationfinish() {
                    handleSlotSuccess();
                  }
                });
            mMoveObjectAnimation.execute();
          } else {
            handleSlotSuccess();
          }
        }
        break;
    }
    return true;
  }
コード例 #6
0
ファイル: WallShelfLayer.java プロジェクト: xiaocong/3DHomeHD
  public boolean onObjectMoveEvent(ACTION event, float x, float y) {
    stopMoveAnimation();
    updateRecycleStatus(event, x, y);
    // calculate object's move location
    setMovePoint((int) x, (int) y);
    // mRealLocation is in the reference frame of Dock
    SEMountPointChain.ClosestMountPointData closestMountPoint =
        calculateNearestMountPoint(mRealLocation);
    SEObject myConflickedObj =
        mWallShelf.getConflictedObject(getOnMoveObject(), closestMountPoint.mIndex);
    Log.i(TAG, "## wall shelf conflicked object = " + myConflickedObj);
    if (closestMountPoint != null) {
      Log.i(TAG, "## wall shelf nearst slot t = " + closestMountPoint.mMPD.getTranslate());
      Log.i(TAG, "## wall shelf nearest slot index = " + closestMountPoint.mIndex);
    }
    // calculate object's nearest slot on wall
    ObjectSlot objectSlot = calculateSlot();
    ConflictObject conflictSlot = null;
    /*
    if (!cmpSlot(objectSlot, mObjectSlot)) {
        conflictSlot = mWallShelf.getConflictSlot(objectSlot);
    }
    */
    switch (event) {
      case BEGIN:
        SETransParas srcTransParas = getOnMoveObject().getUserTransParas().clone();
        SETransParas desTransParas = mObjectTransParas.clone();
        if (getOnMoveObject().getObjectInfo().mIsNativeObject) {
          SETransParas localTrans = getOnMoveObject().getObjectInfo().mModelInfo.mLocalTrans;
          if (localTrans != null) {
            desTransParas.mTranslate.selfSubtract(localTrans.mTranslate);
          }
        }
        SETransParas ttt = desTransParas.clone();
        ttt.mTranslate.mD[2] += 20;
        mSetToRightPositionAnimation =
            AnimationFactory.createSetPositionAnimation(getOnMoveObject(), srcTransParas, ttt, 20);
        mSetToRightPositionAnimation.execute();
        if (!cmpSlot(objectSlot, mObjectSlot)) {
          mObjectSlot = objectSlot;
          // playConflictAnimationTask(conflictSlot, 1000);
        }
        mWallShelf.getExistentSlot(getOnMoveObject());
        break;
      case MOVE:
        Log.i(TAG, " ## in MOVE state ##");
        getOnMoveObject().getUserTransParas().set(mObjectTransParas);
        getOnMoveObject().setUserTransParas();
        /*
        if (!cmpSlot(objectSlot, mObjectSlot)) {
            mObjectSlot = objectSlot;
            playConflictAnimationTask(conflictSlot, 400);
        }
        */
        break;
      case UP:
        Log.i(TAG, "## in UP state ##");
        cancelConflictAnimationTask();
        getOnMoveObject().getUserTransParas().set(mObjectTransParas);
        getOnMoveObject().setUserTransParas();
        if (!cmpSlot(objectSlot, mObjectSlot)) {
          mObjectSlot = objectSlot;
        }
        break;
      case FLY:
        Log.i(TAG, "## in FLY state ##");
        cancelConflictAnimationTask();
        getOnMoveObject().getUserTransParas().set(mObjectTransParas);
        getOnMoveObject().setUserTransParas();
        if (!cmpSlot(objectSlot, mObjectSlot)) {
          mObjectSlot = objectSlot;
        }
        break;
      case FINISH:
        Log.i(TAG, "## in FINISH state ##");
        cancelConflictAnimationTask();
        if (mInRecycle) {
          handleOutsideRoom();
        } else {
          int mountPointIndex =
              mWallShelf.calculateNearestMountPointIndex(getOnMoveObject(), mRealLocation, true);
          if (mObjectSlot == null) {
            handleNoMoreRoom();
            return true;
          }

          conflictSlot = mWallShelf.getConflictSlot(getOnMoveObject(), mObjectSlot.mSlotIndex);
          if (conflictSlot == null) {
            cancelConflictAnimationTask();
          } else {
            // playConflictAnimationTask(conflictSlot, 0);

          }
          SEVector3f desLocation =
              mWallShelf.getSlotPosition(getOnMoveObject().mName, mObjectSlot.mSlotIndex);
          getOnMoveObject().getObjectInfo().mObjectSlot.mSlotIndex = mObjectSlot.mSlotIndex;
          SEVector3f srcLocation =
              worldLocationToDesk(getOnMoveObject().getUserTransParas().mTranslate);
          getOnMoveObject().changeParent(mWallShelf);
          getOnMoveObject().getUserTransParas().mTranslate = srcLocation;
          getOnMoveObject().getUserTransParas().mRotate.set(0, 0, 0, 1);
          getOnMoveObject().setUserTransParas();
          if (srcLocation.subtract(desLocation).getLength() > 1) {
            mMoveObjectAnimation =
                AnimationFactory.createMoveObjectAnimation(
                    getOnMoveObject(), srcLocation, desLocation, 3);
            mMoveObjectAnimation.setAnimFinishListener(
                new SEAnimFinishListener() {

                  public void onAnimationfinish() {
                    handleSlotSuccess();
                  }
                });
            mMoveObjectAnimation.execute();
          } else {
            handleSlotSuccess();
          }
        }
        break;
    }

    return true;
  }