//要画其他部位,但我们希望能以头为中心,1为半径
//先做一个物体当圆心
GameObject center = new GameObject();
//设置圆心位置
center.transform.position = new Vector3(0, 0, 0);
//建立旋转点
GameObject point = new GameObject();
//把point放在圆表面,因为圆的半径是1
point.transform.localPosition = new Vector3(0, 0, -1f);
//删掉定位点
DestroyImmediate(center);
DestroyImmediate(point);
五、画左耳朵
以上知识点就讲完了,我们以左耳朵为例,代码如下。
//画一个头
//要白色的画笔
Gizmos.color = Color.white;
Gizmos.DrawSphere(new Vector3(0, 0, 0), 1);
//要画其他部位,但我们希望能以头为中心,1为半径
//先做一个物体当圆心
GameObject center = new GameObject();
center.transform.position = new Vector3(0, 0, 0);
//再做一个物体,来确定旋转中心
GameObject point = new GameObject();
//把point放在圆表面,因为圆的半径是1
point.transform.localPosition = new Vector3(0, 0, -1f);
//旋转到左耳的位置
point.transform.RotateAround(center.transform.position, Vector3.right, leftEarRotation.x);
point.transform.RotateAround(center.transform.position, Vector3.up, leftEarRotation.y);
point.transform.RotateAround(center.transform.position, Vector3.forward, leftEarRotation.z);
//画一个黄色的左耳朵
Gizmos.color = Color.yellow;
//此时point的位置,就是我希望的耳朵的位置 //半径为0.3f
Gizmos.DrawSphere(point.transform.position, 0.3f);
//把物体都销毁,只是定位用的,现在不需要了
DestroyImmediate(center);
DestroyImmediate(point);
这样我们就拥有了一个会动的左耳朵了!~如图5所示。
六、全部代码
using UnityEngine;
public class MyBear : MonoBehaviour
{
//待会用来调
public Vector3 leftEarRotation = new Vector3();
public Vector3 rightEarRotation = new Vector3();
public Vector3 noseRotation = new Vector3();
public void OnDrawGizmos()
{
#if UNITY_EDITOR
//画一个头
//要白色的画笔
Gizmos.color = Color.white;
Gizmos.DrawSphere(new Vector3(0, 0, 0), 1);
//要画其他部位,但我们希望能以头为中心,1为半径
//先做一个物体当圆心
GameObject center = new GameObject();
center.transform.position = new Vector3(0, 0, 0);
//再做一个物体,来确定旋转中心
GameObject point = new GameObject();
//把point放在圆表面,因为圆的半径是1
point.transform.localPosition = new Vector3(0, 0, -1f);
//旋转到左耳的位置
point.transform.RotateAround(center.transform.position, Vector3.right, leftEarRotation.x);
point.transform.RotateAround(center.transform.position, Vector3.up, leftEarRotation.y);
point.transform.RotateAround(center.transform.position, Vector3.forward, leftEarRotation.z);
//画一个黄色的左耳朵
Gizmos.color = Color.yellow;
//此时point的位置,就是我希望的耳朵的位置 //半径为0.3f
Gizmos.DrawSphere(point.transform.position, 0.3f);
//旋转到右耳的位置
point.transform.localPosition = new Vector3(0, 0, -1f);
point.transform.eulerAngles = new Vector3(0, 0, 0);
point.transform.RotateAround(center.transform.position, Vector3.right, rightEarRotation.x);
point.transform.RotateAround(center.transform.position,Vector3.up, rightEarRotation.y);
point.transform.RotateAround(center.transform.position, Vector3.forward, rightEarRotation.z);
//画一个黄色的右耳朵
//此时point的位置,就是我希望的耳朵的位置 //半径为0.3f
Gizmos.DrawSphere(point.transform.position, 0.3f);
//旋转到鼻子的位置
point.transform.localPosition = new Vector3(0, 0, -1f);
point.transform.eulerAngles = new Vector3(0, 0, 0);
point.transform.RotateAround(center.transform.position,Vector3.right,noseRotation.x);
point.transform.RotateAround(center.transform.position, Vector3.up, noseRotation.y);
point.transform.RotateAround(center.transform.position, Vector3.forward, noseRotation.z);
//画一个红色的鼻子
Gizmos.color = Color.red;
//此时point的位置,就是我希望的耳朵的位置 //半径为0.1f
Gizmos.DrawSphere(point.transform.position, 0.1f);
//把物体都销毁,只是定位用的,现在不需要了
DestroyImmediate(center);
DestroyImmediate(point);
#endif
}
}
BiBa模型的*特性规则:主体不能修改更高完整级的客体(主题不能向上写) Diffie-Hellman密钥交换协议的安全性基于求解离散对数的困难性,既对于C^d M mod P,在已知C和P的前提下,由d求M很容易,但是…