首页 > 其他 > 详细

Unity3d TweenRotation 使用

时间:2014-02-13 17:48:08      阅读:571      评论:0      收藏:0      [点我收藏+]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
     * parentQuate:需要变换的对像
     * angleX,angleY,angleZ:    旋转哪个方向
     * angle:需要旋转的角度   0~360
     */
    static public Quaternion ChangeRotation(GameObject parnetQuate, float angleX, float angleY, float angleZ, float angle,bool IsAnimation,float duration)
    {
        Quaternion ans  =   Quaternion.identity;
        if( parnetQuate == null )return ans;
        float norm;
        float ccc, sss;
           
        angle  *= 3.14f / 180.0f;
        ans.w = ans.x = ans.y = ans.z = 0.0f;
   
        norm = angleX * angleX + angleY * angleY + angleZ * angleZ;
        if(norm <= 0.0f)
        {
            if( IsAnimation)
                TweenRotation.Begin(parnetQuate,duration,ans);
            return ans;
        }
        norm = 1.0f / Mathf.Sqrt(norm);
        angleX *= norm;
        angleY *= norm;
        angleZ *= norm;
   
        ccc = Mathf.Cos(0.5f * angle);
        sss = Mathf.Sin(0.5f * angle);
         
        ans.w = ccc;
        ans.x = sss * angleX;
        ans.y = sss * angleY;
        ans.z = sss * angleZ;
        if( IsAnimation)
            TweenRotation.Begin(parnetQuate,duration,ans);
        return ans;
    }

Unity3d TweenRotation 使用

原文:http://www.cnblogs.com/chenan/p/3547668.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!