Exemplo n.º 1
0
        /// <summary>
        /// 计算碰撞点
        /// </summary>
        /// <param name="startPoint"></param>
        /// <param name="endPoint"></param>
        public bool CalcBouncePoint(GolfMapFlyCollision collision, GolfFlyPoint startPoint, int haveReboundCount, ref GolfBouncePoint golfBouncePoint)
        {
            //Debug.Log("lastPos:" + lastPos + "  curPos:" + curPos + " collisionPoint:" + ret.Point + " ret.Tri:" + ret.Tri);
            golfBouncePoint.Position = collision.Point;
            golfBouncePoint.ColType  = collision.ColType;
            if (collision.ColType == CollisionType.Out)
            {
                return(true);
            }
            //计算碰撞点的速度
            Vector3 collisionVelocity = CalcCollisionVelocity(startPoint.Position, collision.Point, startPoint.Velocity);

            golfBouncePoint.Velocity = collisionVelocity;
            golfBouncePoint.Poly     = collision.Poly;
            golfBouncePoint.AType    = collision.Type;

            //计算反弹
            //旋球限制
            //int type = (int)ret.Type;
            //if (type >= 1 && type <= 5)
            //{
            //    GolfBounceParam.SpinVelocityRevise = Mathf.Clamp(GolfBounceParam.SpinVelocityRevise, -MaxSpinList[type - 1], MaxSpinList[type - 1]);
            //}
            Vector3 outVelocity = Vector3.zero;
            bool    rebound     = CalcBounce(collisionVelocity, collision.Normal, collision.Type, haveReboundCount, ref outVelocity);

            golfBouncePoint.IsRebound   = rebound;
            golfBouncePoint.OutVelocity = outVelocity;
            return(rebound);
        }
Exemplo n.º 2
0
        public GolfFlyPoint CalcFlyPoint(Vector3 initialVelocity, Vector3 initPos, float time)
        {
            GolfFlyPoint point = new GolfFlyPoint();
            //x分量,影响:曲度、精准度、左右曲度、风向
            Vector3 pointPos = new Vector3();
            float   vx       = initialVelocity.x + GlobalAcc.x * time + InitHookVelocity + HookAcc * time;

            pointPos.x = initPos.x + (initialVelocity.x * time + 0.5f * GlobalAcc.x * time * time + InitHookVelocity * time + 0.5f * HookAcc * time * time);
            //y分量,影响:重力
            float vy = initialVelocity.y + LogicConstantData.Gravity * time;

            pointPos.y = initPos.y + (initialVelocity.y * time + 0.5f * LogicConstantData.Gravity * time * time);
            //z分量,影响:杆力量、球力量、风向
            float vz = initialVelocity.z + GlobalAcc.z * time;

            pointPos.z     = initPos.z + (initialVelocity.z * time + 0.5f * GlobalAcc.z * time * time);
            point.Position = pointPos;
            point.Velocity = new Vector3(vx, vy, vz);
            //Debug.Log("Pos:" + pointPos.x + "," + pointPos.y + "," + pointPos.z + "  Vel:" + vx + "," + vy + "," + vz);
            return(point);
        }