コード例 #1
0
ファイル: WallShelfLayer.java プロジェクト: xiaocong/3DHomeHD
  public SETransParas getSlotTransParas(ObjectInfo objectInfo) {
    SETransParas transParas = new SETransParas();
    if (objectInfo.mObjectSlot.mSlotIndex == -1) {
      transParas.mTranslate.set(0, 0, mWallShelf.getBorderHeight());

    } else {
      transParas.mTranslate =
          mWallShelf.getSlotPosition(
              objectInfo.mModelInfo.mName, objectInfo.mObjectSlot.mSlotIndex);
    }
    return transParas;
  }
コード例 #2
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);
  }
コード例 #3
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;
  }