public override void setRelativePosition(Vector3 pos, CAMERA_LINKER_SWITCH switchType = CAMERA_LINKER_SWITCH.CLS_NONE,
                                             bool useDefaultSwitchSpeed = true, float switchSpeed = 1.0f)
    {
        base.setRelativePosition(pos, switchType, useDefaultSwitchSpeed, switchSpeed);

        mSpringX.setNormaLength(Mathf.Abs(mRelativePosition.x));
        mSpringY.setNormaLength(Mathf.Abs(mRelativePosition.y));
        mSpringZ.setNormaLength(Mathf.Abs(mRelativePosition.z));

        mSpringX.setCurLength(Mathf.Abs(mRelativePosition.x));
        mSpringY.setCurLength(Mathf.Abs(mRelativePosition.y));
        mSpringZ.setCurLength(Mathf.Abs(mRelativePosition.z));

        mSpringX.setForce(0.0f);
        mSpringY.setForce(0.0f);
        mSpringZ.setForce(0.0f);

        mSpringX.setSpeed(0.0f);
        mSpringY.setSpeed(0.0f);
        mSpringZ.setSpeed(0.0f);
        // 改变摄像机位置
        Vector3 targetPos = mLinkObject.getPosition();
        Vector3 curPos    = targetPos + mRelativePosition;

        (mComponentOwner as GameCamera).setPosition(curPos);
    }
Ejemplo n.º 2
0
 public virtual void setRelativePosition(Vector3 pos, CAMERA_LINKER_SWITCH switchType = CAMERA_LINKER_SWITCH.CLS_NONE,
                                         bool useDefaultSwitchSpeed = true, float switchSpeed = 1.0f)
 {
     // 如果不使用转换器,则直接设置位置
     if (switchType == CAMERA_LINKER_SWITCH.CLS_NONE)
     {
         mRelativePosition = pos;
     }
     // 如果使用转换器,则查找相应的转换器,设置参数
     else
     {
         mCurSwitch = getSwitch(switchType);
         // 找不到则直接设置位置
         if (mCurSwitch == null)
         {
             mRelativePosition = pos;
         }
         else
         {
             // 如果不适用默认速度,其实是转换器当前的速度,则设置新的速度
             if (!useDefaultSwitchSpeed)
             {
                 mCurSwitch.init(mRelativePosition, pos, switchSpeed);
             }
             // 否则就将转换器当前的速度设置进去
             else
             {
                 mCurSwitch.init(mRelativePosition, pos, mCurSwitch.getSwitchSpeed());
             }
         }
     }
 }
    public override void setRelativePosition(Vector3 pos, CAMERA_LINKER_SWITCH switchType = CAMERA_LINKER_SWITCH.CLS_NONE, bool useDefaultSwitchSpeed = true, float switchSpeed = 1.0f)
    {
        base.setRelativePosition(pos, switchType, useDefaultSwitchSpeed, switchSpeed);
        // 获得加速度
        Vector3 acceleration  = mLinkObject.getPhysicsAcceleration();
        Vector3 curRelative   = (mComponentOwner as GameCamera).getPosition() - mLinkObject.getPosition();
        float   relativeAngle = getAngleFromVector(curRelative);

        acceleration = rotateVector3(acceleration, relativeAngle) * -1.0f;
        mSpringX.setCurLength(abs(curRelative.x));
        mSpringX.setForce(acceleration.x);
        mSpringY.setCurLength(abs(curRelative.y));
        mSpringY.setForce(acceleration.y);
        mSpringZ.setCurLength(abs(curRelative.z));
        mSpringZ.setForce(acceleration.z);

        mSpringX.setNormaLength(abs(mRelativePosition.x));
        mSpringY.setNormaLength(abs(mRelativePosition.y));
        mSpringZ.setNormaLength(abs(mRelativePosition.z));
        mSpringX.setCurLength(abs(mRelativePosition.x));
        mSpringY.setCurLength(abs(mRelativePosition.y));
        mSpringZ.setCurLength(abs(mRelativePosition.z));
        mSpringX.setForce(0.0f);
        mSpringY.setForce(0.0f);
        mSpringZ.setForce(0.0f);
        mSpringX.setSpeed(0.0f);
        mSpringY.setSpeed(0.0f);
        mSpringZ.setSpeed(0.0f);
        // 改变摄像机位置
        Vector3 targetPos = mLinkObject.getPosition();
        Vector3 curPos    = targetPos + mRelativePosition;

        (mComponentOwner as GameCamera).setPosition(curPos);
    }
Ejemplo n.º 4
0
 public CameraLinkerSwitch(CAMERA_LINKER_SWITCH type, CameraLinker parentLinker)
 {
     mType           = type;
     mParentLinker   = parentLinker;
     mOriginRelative = Vector3.zero;
     mTargetRelative = Vector3.zero;
 }
Ejemplo n.º 5
0
    protected void addSwitch <T>(CAMERA_LINKER_SWITCH type) where T : CameraLinkerSwitch, new()
    {
        T lineSwitch = new T();

        lineSwitch.initType(type, this);
        mSwitchList.Add(type, lineSwitch);
    }
Ejemplo n.º 6
0
 public CameraLinkerSwitchCircle(CAMERA_LINKER_SWITCH type, CameraLinker parentLinker)
     :
     base(type, parentLinker)
 {
     mRotatedAngle = 0.0f;
     mTotalAngle   = Mathf.PI;
     mSpeed        = Mathf.PI;
 }
Ejemplo n.º 7
0
 public Vector3 mDirection;  // 此次转换的方向,用于避免不必要的向量重复计算
 public CameraLinkerSwitchLinear(CAMERA_LINKER_SWITCH type, CameraLinker parentLinker)
     :
     base(type, parentLinker)
 {
     mMovedDistance = 0.0f;
     mDirection     = Vector3.zero;
     mSpeed         = 7.0f;
 }
Ejemplo n.º 8
0
    }                                                                                                    // 由转换器调用,通知连接器转换已经完成

    public CameraLinkerSwitch getSwitch(CAMERA_LINKER_SWITCH type)
    {
        if (mSwitchList.ContainsKey(type))
        {
            return(mSwitchList[type]);
        }
        return(null);
    }
Ejemplo n.º 9
0
 public CameraLinkerSwitchAroundTarget(CAMERA_LINKER_SWITCH type, CameraLinker parentLinker)
     :
     base(type, parentLinker)
 {
     mTotalAngle      = 0.0f;
     mRotatedAngle    = 0.0f;
     mClockwise       = true;
     mDistanceDelta   = 0.0f;
     mDistanceCurrent = 0.0f;
     mSpeed           = Mathf.PI / 2.0f;
 }
Ejemplo n.º 10
0
 protected float mSwitchSpeed;               // 转换器的速度
 public override void init()
 {
     base.init();
     mTarget             = null;
     mSwitchType         = CAMERA_LINKER_SWITCH.CLS_NONE;
     mLinkerName         = "";
     mLookAtTarget       = true;
     mLookatOffset       = Vector3.zero;
     mUseOriginRelative  = true;
     mRelativePosition   = Vector3.zero;
     mUseLastSwitchSpeed = true;
     mSwitchSpeed        = 10.0f;
     mAutoProcessKey     = false;
     mImmediately        = false;
 }
Ejemplo n.º 11
0
 public void initType(CAMERA_LINKER_SWITCH type, CameraLinker parentLinker)
 {
     mType         = type;
     mParentLinker = parentLinker;
 }