Merge branch 'feature-ball' into dev
# Conflicts: # Assets/ModelBehaviour.cs # Assets/Models/PoseTransform.cs
This commit is contained in:
commit
abf97571e7
179
Assets/MainBehaviour.cs
Normal file
179
Assets/MainBehaviour.cs
Normal file
|
@ -0,0 +1,179 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Models;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class MainBehaviour : MonoBehaviour
|
||||||
|
{
|
||||||
|
private readonly GameObject[] _nodes = new GameObject[(int)PoseLandmarkType.MaxValue];
|
||||||
|
private readonly List<Bond> _bonds = new List<Bond>();
|
||||||
|
private readonly PoseTransform[] _poseTransforms = new PoseTransform[(int)PoseLandmarkType.MaxValue];
|
||||||
|
private readonly UdpListener _listener = new UdpListener();
|
||||||
|
private const float Scale = 0.2f;
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
PoseTransform.AverageLength = 3;
|
||||||
|
|
||||||
|
CreateNodes();
|
||||||
|
CreateBonds();
|
||||||
|
|
||||||
|
_listener.AddHandler(OnReceive);
|
||||||
|
_listener.Connect(5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
for (var i = 0; i < (int)PoseLandmarkType.MaxValue; i++)
|
||||||
|
{
|
||||||
|
_nodes[i].transform.position = _poseTransforms[i].AveragePos * -5;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var bond in _bonds)
|
||||||
|
{
|
||||||
|
bond.UpdateBond();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
_listener.DisConnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnReceive(List<PoseLandmark> landmarks)
|
||||||
|
{
|
||||||
|
foreach (var landmark in landmarks)
|
||||||
|
{
|
||||||
|
PoseTransform.UpdatePosition(ref _poseTransforms[(int)landmark.Type], landmark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateNodes()
|
||||||
|
{
|
||||||
|
for (var i = 0; i < (int)PoseLandmarkType.MaxValue; i++)
|
||||||
|
{
|
||||||
|
var ball = GameObject.CreatePrimitive(PrimitiveType.Sphere);
|
||||||
|
|
||||||
|
ball.transform.localScale = new Vector3(Scale, Scale, Scale);
|
||||||
|
|
||||||
|
if (i <= 10)
|
||||||
|
{
|
||||||
|
ball.GetComponent<Renderer>().material.color = Color.red;//给头部添加颜色
|
||||||
|
}
|
||||||
|
else if (i <= 22)
|
||||||
|
{
|
||||||
|
ball.GetComponent<Renderer>().material.color = Color.blue;//给手部添加颜色
|
||||||
|
}
|
||||||
|
else if (i <= 32)
|
||||||
|
{
|
||||||
|
ball.GetComponent<Renderer>().material.color = Color.green;//给脚部添加颜色
|
||||||
|
}
|
||||||
|
|
||||||
|
_nodes[i] = ball;
|
||||||
|
_poseTransforms[i] = new PoseTransform((PoseLandmarkType)i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateBonds()
|
||||||
|
{
|
||||||
|
var headBonds = new[]
|
||||||
|
{
|
||||||
|
PoseLandmarkType.RightEar,
|
||||||
|
PoseLandmarkType.RightEyeOuter,
|
||||||
|
PoseLandmarkType.RightEye,
|
||||||
|
PoseLandmarkType.RightEyeInner,
|
||||||
|
PoseLandmarkType.Nose,
|
||||||
|
PoseLandmarkType.LeftEyeInner,
|
||||||
|
PoseLandmarkType.LeftEye,
|
||||||
|
PoseLandmarkType.LeftEyeOuter,
|
||||||
|
PoseLandmarkType.LeftEar
|
||||||
|
};
|
||||||
|
_bonds.AddRange(GenerateBondsList(headBonds));
|
||||||
|
|
||||||
|
var monthBonds = new[]
|
||||||
|
{
|
||||||
|
PoseLandmarkType.MouthLeft,
|
||||||
|
PoseLandmarkType.MouthRight,
|
||||||
|
};
|
||||||
|
_bonds.AddRange(GenerateBondsList(monthBonds));
|
||||||
|
|
||||||
|
var leftArmBonds = new[]
|
||||||
|
{
|
||||||
|
PoseLandmarkType.LeftShoulder,
|
||||||
|
PoseLandmarkType.LeftElbow,
|
||||||
|
PoseLandmarkType.LeftWrist,
|
||||||
|
PoseLandmarkType.LeftPinky,
|
||||||
|
PoseLandmarkType.LeftIndex,
|
||||||
|
PoseLandmarkType.LeftWrist,
|
||||||
|
PoseLandmarkType.LeftThumb
|
||||||
|
};
|
||||||
|
_bonds.AddRange(GenerateBondsList(leftArmBonds));
|
||||||
|
|
||||||
|
var rightArmBonds = new[]
|
||||||
|
{
|
||||||
|
PoseLandmarkType.RightShoulder,
|
||||||
|
PoseLandmarkType.RightElbow,
|
||||||
|
PoseLandmarkType.RightWrist,
|
||||||
|
PoseLandmarkType.RightPinky,
|
||||||
|
PoseLandmarkType.RightIndex,
|
||||||
|
PoseLandmarkType.RightWrist,
|
||||||
|
PoseLandmarkType.RightThumb
|
||||||
|
};
|
||||||
|
_bonds.AddRange(GenerateBondsList(rightArmBonds));
|
||||||
|
|
||||||
|
var leftLegBonds = new[]
|
||||||
|
{
|
||||||
|
PoseLandmarkType.LeftShoulder,
|
||||||
|
PoseLandmarkType.LeftHip,
|
||||||
|
PoseLandmarkType.LeftKnee,
|
||||||
|
PoseLandmarkType.LeftAnkle,
|
||||||
|
PoseLandmarkType.LeftHeel,
|
||||||
|
PoseLandmarkType.LeftFootIndex,
|
||||||
|
PoseLandmarkType.LeftAnkle
|
||||||
|
};
|
||||||
|
_bonds.AddRange(GenerateBondsList(leftLegBonds));
|
||||||
|
|
||||||
|
var rightLegBonds = new[]
|
||||||
|
{
|
||||||
|
PoseLandmarkType.RightShoulder,
|
||||||
|
PoseLandmarkType.RightHip,
|
||||||
|
PoseLandmarkType.RightKnee,
|
||||||
|
PoseLandmarkType.RightAnkle,
|
||||||
|
PoseLandmarkType.RightHeel,
|
||||||
|
PoseLandmarkType.RightFootIndex,
|
||||||
|
PoseLandmarkType.RightAnkle
|
||||||
|
};
|
||||||
|
_bonds.AddRange(GenerateBondsList(rightLegBonds));
|
||||||
|
|
||||||
|
// 最后手动添加身体上的两条横线
|
||||||
|
_bonds.Add(new Bond(
|
||||||
|
_nodes[(int)PoseLandmarkType.LeftShoulder],
|
||||||
|
_nodes[(int)PoseLandmarkType.RightShoulder],
|
||||||
|
Scale));
|
||||||
|
_bonds.Add(new Bond(
|
||||||
|
_nodes[(int)PoseLandmarkType.LeftHip],
|
||||||
|
_nodes[(int)PoseLandmarkType.RightHip],
|
||||||
|
Scale));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建棍子列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="nodes">需要连接起来的关键点 需要按顺序设置</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private List<Bond> GenerateBondsList(PoseLandmarkType[] nodes)
|
||||||
|
{
|
||||||
|
var bonds = new List<Bond>();
|
||||||
|
|
||||||
|
for (var i = 0; i < nodes.Length - 1; i++)
|
||||||
|
{
|
||||||
|
bonds.Add(new Bond(
|
||||||
|
_nodes[(int)nodes[i]],
|
||||||
|
_nodes[(int)nodes[i + 1]],
|
||||||
|
Scale));
|
||||||
|
}
|
||||||
|
|
||||||
|
return bonds;
|
||||||
|
}
|
||||||
|
}
|
11
Assets/MainBehaviour.cs.meta
Normal file
11
Assets/MainBehaviour.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 574a3724e040787f7afd9341fba89cf2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/Materials.meta
Normal file
8
Assets/Materials.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c2963c03969c7f6d480483b45e36590b
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
80
Assets/Materials/PlaneMaterial.mat
Normal file
80
Assets/Materials/PlaneMaterial.mat
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!21 &2100000
|
||||||
|
Material:
|
||||||
|
serializedVersion: 8
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: PlaneMaterial
|
||||||
|
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_ValidKeywords: []
|
||||||
|
m_InvalidKeywords: []
|
||||||
|
m_LightmapFlags: 4
|
||||||
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: -1
|
||||||
|
stringTagMap: {}
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs:
|
||||||
|
- _BumpMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailAlbedoMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailMask:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailNormalMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _EmissionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MainTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MetallicGlossMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _OcclusionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ParallaxMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Ints: []
|
||||||
|
m_Floats:
|
||||||
|
- _BumpScale: 1
|
||||||
|
- _Cutoff: 0.5
|
||||||
|
- _DetailNormalMapScale: 1
|
||||||
|
- _DstBlend: 0
|
||||||
|
- _GlossMapScale: 1
|
||||||
|
- _Glossiness: 0.5
|
||||||
|
- _GlossyReflections: 1
|
||||||
|
- _Metallic: 0
|
||||||
|
- _Mode: 0
|
||||||
|
- _OcclusionStrength: 1
|
||||||
|
- _Parallax: 0.02
|
||||||
|
- _SmoothnessTextureChannel: 0
|
||||||
|
- _SpecularHighlights: 1
|
||||||
|
- _SrcBlend: 1
|
||||||
|
- _UVSec: 0
|
||||||
|
- _ZWrite: 1
|
||||||
|
m_Colors:
|
||||||
|
- _Color: {r: 1, g: 0.29922488, b: 0, a: 1}
|
||||||
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
|
m_BuildTextureStacks: []
|
8
Assets/Materials/PlaneMaterial.mat.meta
Normal file
8
Assets/Materials/PlaneMaterial.mat.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6083fe04391087ca294999838984a59c
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 2100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -8,7 +8,7 @@ public class ModelBehaviour : MonoBehaviour
|
||||||
|
|
||||||
private readonly UdpListener _listener = new UdpListener();
|
private readonly UdpListener _listener = new UdpListener();
|
||||||
|
|
||||||
//private static readonly List<PosTransformator> _posLandmarks = new List<PosTransformator>();
|
private static readonly List<PosTransformator> _posLandmarks = new List<PosTransformator>();
|
||||||
|
|
||||||
private static readonly List<PoseTransform> PoseTransforms = new List<PoseTransform>();
|
private static readonly List<PoseTransform> PoseTransforms = new List<PoseTransform>();
|
||||||
|
|
||||||
|
@ -16,10 +16,10 @@ private void Start()
|
||||||
{
|
{
|
||||||
_animator = GetComponent<Animator>(); // 获取动画控件
|
_animator = GetComponent<Animator>(); // 获取动画控件
|
||||||
|
|
||||||
|
TransformatorInit(); //匹配初始化
|
||||||
InitPoseTransformList();
|
InitPoseTransformList();
|
||||||
|
|
||||||
//_listener.AddHandler(LogLandmarks);
|
_listener.AddHandler(LogLandmarks);
|
||||||
_listener.AddHandler(RigPoint);
|
_listener.AddHandler(RigPoint);
|
||||||
_listener.Connect(5000);
|
_listener.Connect(5000);
|
||||||
}
|
}
|
||||||
|
|
44
Assets/Models/Bond.cs
Normal file
44
Assets/Models/Bond.cs
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 捕捉点之间的连接线
|
||||||
|
/// </summary>
|
||||||
|
public class Bond
|
||||||
|
{
|
||||||
|
protected readonly GameObject Start;
|
||||||
|
protected readonly GameObject End;
|
||||||
|
private readonly GameObject _bond;
|
||||||
|
|
||||||
|
public Bond(GameObject start,GameObject end,float scale)
|
||||||
|
{
|
||||||
|
Start = start;
|
||||||
|
End = end;
|
||||||
|
|
||||||
|
_bond = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
|
||||||
|
|
||||||
|
_bond.transform.localScale = new Vector3(scale/2, scale/2, scale/2);
|
||||||
|
|
||||||
|
//这里可以设置材质,具体自己设置
|
||||||
|
_bond.GetComponent<Renderer>().material.color = Color.cyan;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void UpdateBond()
|
||||||
|
{
|
||||||
|
var startPos = Start.transform.position;
|
||||||
|
var endPos = End.transform.position;
|
||||||
|
var rightPosition = (startPos + endPos) / 2;
|
||||||
|
var rightRotation = endPos - startPos;
|
||||||
|
var halfLength = Vector3.Distance(startPos, endPos) / 2;
|
||||||
|
var thickness = 0.1f;//线的粗细
|
||||||
|
|
||||||
|
//创建圆柱体
|
||||||
|
//bond.gameObject.transform.parent = transform;
|
||||||
|
_bond.transform.position = rightPosition;
|
||||||
|
_bond.transform.rotation = Quaternion.FromToRotation(Vector3.up, rightRotation);
|
||||||
|
_bond.transform.localScale = new Vector3(thickness, halfLength, thickness);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Models/Bond.cs.meta
Normal file
3
Assets/Models/Bond.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 94a8f8c83e58421d9447173d38482d74
|
||||||
|
timeCreated: 1677230676
|
|
@ -35,6 +35,7 @@ public enum PoseLandmarkType
|
||||||
LeftHeel,
|
LeftHeel,
|
||||||
RightHeel,
|
RightHeel,
|
||||||
LeftFootIndex,
|
LeftFootIndex,
|
||||||
RightFootIndex
|
RightFootIndex,
|
||||||
|
MaxValue
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,9 +20,14 @@ public struct PoseTransform
|
||||||
public readonly HumanBodyBones UnityName;
|
public readonly HumanBodyBones UnityName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// MediaPipe捕捉空间坐标
|
/// 取平均的长度
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector3 MediaPipePos;
|
public static int AverageLength;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 取平均之后的结果
|
||||||
|
/// </summary>
|
||||||
|
public Vector3 AveragePos;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 节点的父节点列表
|
/// 节点的父节点列表
|
||||||
|
@ -39,23 +44,50 @@ public struct PoseTransform
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Quaternion CurrentQuaternion;
|
public Quaternion CurrentQuaternion;
|
||||||
|
|
||||||
|
private int _count;
|
||||||
|
private readonly Queue<PoseLandmark> _landmarkQueue;
|
||||||
|
|
||||||
public PoseTransform(
|
public PoseTransform(
|
||||||
PoseLandmarkType type
|
PoseLandmarkType type,
|
||||||
|
int averageLength = 5
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MediaPipeName = type;
|
MediaPipeName = type;
|
||||||
UnityName = GetRelatedBone(type);
|
UnityName = GetRelatedBone(type);
|
||||||
MediaPipePos = new Vector3();
|
AveragePos = new Vector3();
|
||||||
Parent = new List<PoseTransform>();
|
Parent = new List<PoseTransform>();
|
||||||
PreviousQuaternion = new Quaternion();
|
PreviousQuaternion = new Quaternion();
|
||||||
CurrentQuaternion = new Quaternion();
|
CurrentQuaternion = new Quaternion();
|
||||||
|
AverageLength = averageLength;
|
||||||
|
|
||||||
|
_count = 0;
|
||||||
|
_landmarkQueue = new Queue<PoseLandmark>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public static void UpdatePosition(ref PoseTransform pose, PoseLandmark landmark)
|
||||||
/// 计算当前的旋转四元数
|
{
|
||||||
/// </summary>
|
if (pose._count < AverageLength)
|
||||||
/// <param name="landmark"></param>
|
{
|
||||||
public void CalculateCurrentQuaternion(PoseLandmark landmark)
|
pose._landmarkQueue.Enqueue(landmark);
|
||||||
|
pose._count++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pose._landmarkQueue.Dequeue();
|
||||||
|
pose._landmarkQueue.Enqueue(landmark);
|
||||||
|
|
||||||
|
var sum = new Vector3();
|
||||||
|
|
||||||
|
foreach (var poseLandmark in pose._landmarkQueue)
|
||||||
|
{
|
||||||
|
sum += new Vector3(poseLandmark.X, poseLandmark.Y, poseLandmark.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
pose.AveragePos = sum / AverageLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CalculateRotation(PoseTransform poseTransform)
|
||||||
{
|
{
|
||||||
|
|
||||||
//var temp = _posLandmarks.Find(t=>t.mediaPipeName == landmark.Type.ToString());
|
//var temp = _posLandmarks.Find(t=>t.mediaPipeName == landmark.Type.ToString());
|
||||||
|
@ -134,51 +166,5 @@ private static HumanBodyBones GetRelatedBone(PoseLandmarkType type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//绕X轴旋转
|
|
||||||
private Matrix4x4 RotateAxisX(float rot)
|
|
||||||
{
|
|
||||||
var matrix = new Matrix4x4();
|
|
||||||
float cosrot = MathF.Cos(rot);
|
|
||||||
float sinrot = MathF.Sin(rot);
|
|
||||||
|
|
||||||
matrix.SetRow(0, new Vector4(1,0,0,0));
|
|
||||||
matrix.SetRow(1, new Vector4(0,cosrot,-sinrot,0));
|
|
||||||
matrix.SetRow(2, new Vector4(0,sinrot,cosrot,0));
|
|
||||||
matrix.SetRow(3, new Vector4(0,0,0,1));
|
|
||||||
|
|
||||||
return matrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
//绕Y轴旋转
|
|
||||||
private Matrix4x4 RotateAxisY(float rot)
|
|
||||||
{
|
|
||||||
var matrix = new Matrix4x4();
|
|
||||||
float cosrot = MathF.Cos(rot);
|
|
||||||
float sinrot = MathF.Sin(rot);
|
|
||||||
|
|
||||||
matrix.SetRow(0, new Vector4(cosrot,0,sinrot,0));
|
|
||||||
matrix.SetRow(1, new Vector4(0,1,0,0));
|
|
||||||
matrix.SetRow(2, new Vector4(-sinrot,0,cosrot,0));
|
|
||||||
matrix.SetRow(3, new Vector4(0,0,0,1));
|
|
||||||
|
|
||||||
return matrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
//绕Z轴旋转
|
|
||||||
private Matrix4x4 RotateAxisZ(float rot)
|
|
||||||
{
|
|
||||||
var matrix = new Matrix4x4();
|
|
||||||
float cosrot = MathF.Cos(rot);
|
|
||||||
float sinrot = MathF.Sin(rot);
|
|
||||||
|
|
||||||
matrix.SetRow(0, new Vector4(cosrot,-sinrot,0,0));
|
|
||||||
matrix.SetRow(1, new Vector4(sinrot,cosrot,0,0));
|
|
||||||
matrix.SetRow(2, new Vector4(0,0,1,0));
|
|
||||||
matrix.SetRow(3, new Vector4(0,0,0,1));
|
|
||||||
|
|
||||||
return matrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
35
Assets/Models/VirtualSkeleton.cs
Normal file
35
Assets/Models/VirtualSkeleton.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Models
|
||||||
|
{
|
||||||
|
public class VirtualSkeleton : Bond
|
||||||
|
{
|
||||||
|
private readonly GameObject _virtualSkeleton;
|
||||||
|
|
||||||
|
public VirtualSkeleton(GameObject start,GameObject end,float scale) : base(start,end,scale)
|
||||||
|
{
|
||||||
|
_virtualSkeleton = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
|
||||||
|
|
||||||
|
_virtualSkeleton.transform.localScale = new Vector3(scale/2, scale/2, scale/2);
|
||||||
|
|
||||||
|
_virtualSkeleton.GetComponent<Renderer>().material.color = Color.white;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 覆盖基类的更新方法
|
||||||
|
/// </summary>
|
||||||
|
public new void UpdateBond()
|
||||||
|
{
|
||||||
|
var startPos = Start.transform.position;
|
||||||
|
var endPos = End.transform.position;
|
||||||
|
|
||||||
|
var rightPosition = (startPos + endPos) / 2;
|
||||||
|
var rightRotation = endPos - startPos;
|
||||||
|
var lThickness = 0.2f;
|
||||||
|
|
||||||
|
_virtualSkeleton.transform.position = rightPosition;
|
||||||
|
_virtualSkeleton.transform.rotation = Quaternion.FromToRotation(Vector3.up, rightRotation);
|
||||||
|
_virtualSkeleton.transform.localScale = new Vector3(lThickness, lThickness, lThickness);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Models/VirtualSkeleton.cs.meta
Normal file
3
Assets/Models/VirtualSkeleton.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5f725336fc6a4481a4c7d74ec0e3b17b
|
||||||
|
timeCreated: 1677413910
|
459
Assets/Scenes/BallScene.unity
Normal file
459
Assets/Scenes/BallScene.unity
Normal file
|
@ -0,0 +1,459 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!29 &1
|
||||||
|
OcclusionCullingSettings:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_OcclusionBakeSettings:
|
||||||
|
smallestOccluder: 5
|
||||||
|
smallestHole: 0.25
|
||||||
|
backfaceThreshold: 100
|
||||||
|
m_SceneGUID: 00000000000000000000000000000000
|
||||||
|
m_OcclusionCullingData: {fileID: 0}
|
||||||
|
--- !u!104 &2
|
||||||
|
RenderSettings:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 9
|
||||||
|
m_Fog: 0
|
||||||
|
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
m_FogMode: 3
|
||||||
|
m_FogDensity: 0.01
|
||||||
|
m_LinearFogStart: 0
|
||||||
|
m_LinearFogEnd: 300
|
||||||
|
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||||
|
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||||
|
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||||
|
m_AmbientIntensity: 1
|
||||||
|
m_AmbientMode: 0
|
||||||
|
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||||
|
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_HaloStrength: 0.5
|
||||||
|
m_FlareStrength: 1
|
||||||
|
m_FlareFadeSpeed: 3
|
||||||
|
m_HaloTexture: {fileID: 0}
|
||||||
|
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
m_DefaultReflectionMode: 0
|
||||||
|
m_DefaultReflectionResolution: 128
|
||||||
|
m_ReflectionBounces: 1
|
||||||
|
m_ReflectionIntensity: 1
|
||||||
|
m_CustomReflection: {fileID: 0}
|
||||||
|
m_Sun: {fileID: 0}
|
||||||
|
m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1}
|
||||||
|
m_UseRadianceAmbientProbe: 0
|
||||||
|
--- !u!157 &3
|
||||||
|
LightmapSettings:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 12
|
||||||
|
m_GIWorkflowMode: 1
|
||||||
|
m_GISettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_BounceScale: 1
|
||||||
|
m_IndirectOutputScale: 1
|
||||||
|
m_AlbedoBoost: 1
|
||||||
|
m_EnvironmentLightingMode: 0
|
||||||
|
m_EnableBakedLightmaps: 1
|
||||||
|
m_EnableRealtimeLightmaps: 0
|
||||||
|
m_LightmapEditorSettings:
|
||||||
|
serializedVersion: 12
|
||||||
|
m_Resolution: 2
|
||||||
|
m_BakeResolution: 40
|
||||||
|
m_AtlasSize: 1024
|
||||||
|
m_AO: 0
|
||||||
|
m_AOMaxDistance: 1
|
||||||
|
m_CompAOExponent: 1
|
||||||
|
m_CompAOExponentDirect: 0
|
||||||
|
m_ExtractAmbientOcclusion: 0
|
||||||
|
m_Padding: 2
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_LightmapsBakeMode: 1
|
||||||
|
m_TextureCompression: 1
|
||||||
|
m_FinalGather: 0
|
||||||
|
m_FinalGatherFiltering: 1
|
||||||
|
m_FinalGatherRayCount: 256
|
||||||
|
m_ReflectionCompression: 2
|
||||||
|
m_MixedBakeMode: 2
|
||||||
|
m_BakeBackend: 1
|
||||||
|
m_PVRSampling: 1
|
||||||
|
m_PVRDirectSampleCount: 32
|
||||||
|
m_PVRSampleCount: 512
|
||||||
|
m_PVRBounces: 2
|
||||||
|
m_PVREnvironmentSampleCount: 256
|
||||||
|
m_PVREnvironmentReferencePointCount: 2048
|
||||||
|
m_PVRFilteringMode: 1
|
||||||
|
m_PVRDenoiserTypeDirect: 1
|
||||||
|
m_PVRDenoiserTypeIndirect: 1
|
||||||
|
m_PVRDenoiserTypeAO: 1
|
||||||
|
m_PVRFilterTypeDirect: 0
|
||||||
|
m_PVRFilterTypeIndirect: 0
|
||||||
|
m_PVRFilterTypeAO: 0
|
||||||
|
m_PVREnvironmentMIS: 1
|
||||||
|
m_PVRCulling: 1
|
||||||
|
m_PVRFilteringGaussRadiusDirect: 1
|
||||||
|
m_PVRFilteringGaussRadiusIndirect: 5
|
||||||
|
m_PVRFilteringGaussRadiusAO: 2
|
||||||
|
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||||
|
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||||
|
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||||
|
m_ExportTrainingData: 0
|
||||||
|
m_TrainingDataDestination: TrainingData
|
||||||
|
m_LightProbeSampleCountMultiplier: 4
|
||||||
|
m_LightingDataAsset: {fileID: 0}
|
||||||
|
m_LightingSettings: {fileID: 0}
|
||||||
|
--- !u!196 &4
|
||||||
|
NavMeshSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_BuildSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
agentTypeID: 0
|
||||||
|
agentRadius: 0.5
|
||||||
|
agentHeight: 2
|
||||||
|
agentSlope: 45
|
||||||
|
agentClimb: 0.4
|
||||||
|
ledgeDropHeight: 0
|
||||||
|
maxJumpAcrossDistance: 0
|
||||||
|
minRegionArea: 2
|
||||||
|
manualCellSize: 0
|
||||||
|
cellSize: 0.16666667
|
||||||
|
manualTileSize: 0
|
||||||
|
tileSize: 256
|
||||||
|
accuratePlacement: 0
|
||||||
|
maxJobWorkers: 0
|
||||||
|
preserveTilesOutsideBounds: 0
|
||||||
|
debug:
|
||||||
|
m_Flags: 0
|
||||||
|
m_NavMeshData: {fileID: 0}
|
||||||
|
--- !u!1 &99618223
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 99618227}
|
||||||
|
- component: {fileID: 99618226}
|
||||||
|
- component: {fileID: 99618225}
|
||||||
|
- component: {fileID: 99618224}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Plane
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!64 &99618224
|
||||||
|
MeshCollider:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 99618223}
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 4
|
||||||
|
m_Convex: 0
|
||||||
|
m_CookingOptions: 30
|
||||||
|
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!23 &99618225
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 99618223}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 1
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: 6083fe04391087ca294999838984a59c, type: 2}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 3
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_AdditionalVertexStreams: {fileID: 0}
|
||||||
|
--- !u!33 &99618226
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 99618223}
|
||||||
|
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!4 &99618227
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 99618223}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 1
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 3
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &182244630
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 182244631}
|
||||||
|
- component: {fileID: 182244632}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: GameObject
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &182244631
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 182244630}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 2
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &182244632
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 182244630}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 574a3724e040787f7afd9341fba89cf2, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!1 &443683957
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 443683959}
|
||||||
|
- component: {fileID: 443683958}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Directional Light
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!108 &443683958
|
||||||
|
Light:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 443683957}
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 10
|
||||||
|
m_Type: 1
|
||||||
|
m_Shape: 0
|
||||||
|
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
|
||||||
|
m_Intensity: 1
|
||||||
|
m_Range: 10
|
||||||
|
m_SpotAngle: 30
|
||||||
|
m_InnerSpotAngle: 21.80208
|
||||||
|
m_CookieSize: 10
|
||||||
|
m_Shadows:
|
||||||
|
m_Type: 2
|
||||||
|
m_Resolution: -1
|
||||||
|
m_CustomResolution: -1
|
||||||
|
m_Strength: 1
|
||||||
|
m_Bias: 0.05
|
||||||
|
m_NormalBias: 0.4
|
||||||
|
m_NearPlane: 0.2
|
||||||
|
m_CullingMatrixOverride:
|
||||||
|
e00: 1
|
||||||
|
e01: 0
|
||||||
|
e02: 0
|
||||||
|
e03: 0
|
||||||
|
e10: 0
|
||||||
|
e11: 1
|
||||||
|
e12: 0
|
||||||
|
e13: 0
|
||||||
|
e20: 0
|
||||||
|
e21: 0
|
||||||
|
e22: 1
|
||||||
|
e23: 0
|
||||||
|
e30: 0
|
||||||
|
e31: 0
|
||||||
|
e32: 0
|
||||||
|
e33: 1
|
||||||
|
m_UseCullingMatrixOverride: 0
|
||||||
|
m_Cookie: {fileID: 0}
|
||||||
|
m_DrawHalo: 0
|
||||||
|
m_Flare: {fileID: 0}
|
||||||
|
m_RenderMode: 0
|
||||||
|
m_CullingMask:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_Lightmapping: 4
|
||||||
|
m_LightShadowCasterMode: 0
|
||||||
|
m_AreaSize: {x: 1, y: 1}
|
||||||
|
m_BounceIntensity: 1
|
||||||
|
m_ColorTemperature: 6570
|
||||||
|
m_UseColorTemperature: 0
|
||||||
|
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_UseBoundingSphereOverride: 0
|
||||||
|
m_UseViewFrustumForShadowCasterCull: 1
|
||||||
|
m_ShadowRadius: 0
|
||||||
|
m_ShadowAngle: 0
|
||||||
|
--- !u!4 &443683959
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 443683957}
|
||||||
|
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
|
||||||
|
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 1
|
||||||
|
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||||
|
--- !u!1 &2045151417
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 2045151420}
|
||||||
|
- component: {fileID: 2045151419}
|
||||||
|
- component: {fileID: 2045151418}
|
||||||
|
- component: {fileID: 2045151421}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Main Camera
|
||||||
|
m_TagString: MainCamera
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!81 &2045151418
|
||||||
|
AudioListener:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2045151417}
|
||||||
|
m_Enabled: 1
|
||||||
|
--- !u!20 &2045151419
|
||||||
|
Camera:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2045151417}
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 2
|
||||||
|
m_ClearFlags: 1
|
||||||
|
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||||
|
m_projectionMatrixMode: 1
|
||||||
|
m_GateFitMode: 2
|
||||||
|
m_FOVAxisMode: 0
|
||||||
|
m_SensorSize: {x: 36, y: 24}
|
||||||
|
m_LensShift: {x: 0, y: 0}
|
||||||
|
m_FocalLength: 50
|
||||||
|
m_NormalizedViewPortRect:
|
||||||
|
serializedVersion: 2
|
||||||
|
x: 0
|
||||||
|
y: 0
|
||||||
|
width: 1
|
||||||
|
height: 1
|
||||||
|
near clip plane: 0.3
|
||||||
|
far clip plane: 1000
|
||||||
|
field of view: 60
|
||||||
|
orthographic: 0
|
||||||
|
orthographic size: 5
|
||||||
|
m_Depth: -1
|
||||||
|
m_CullingMask:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_RenderingPath: -1
|
||||||
|
m_TargetTexture: {fileID: 0}
|
||||||
|
m_TargetDisplay: 0
|
||||||
|
m_TargetEye: 3
|
||||||
|
m_HDR: 1
|
||||||
|
m_AllowMSAA: 1
|
||||||
|
m_AllowDynamicResolution: 0
|
||||||
|
m_ForceIntoRT: 0
|
||||||
|
m_OcclusionCulling: 1
|
||||||
|
m_StereoConvergence: 10
|
||||||
|
m_StereoSeparation: 0.022
|
||||||
|
--- !u!4 &2045151420
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2045151417}
|
||||||
|
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 7}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
||||||
|
--- !u!114 &2045151421
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2045151417}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 9189b565e8ba9bfc3bdaa38149e3e13f, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
target: {fileID: 182244631}
|
7
Assets/Scenes/BallScene.unity.meta
Normal file
7
Assets/Scenes/BallScene.unity.meta
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 53edd235eaf7da249a8204f606eb1489
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
67
Assets/Utils/RotateUtils.cs
Normal file
67
Assets/Utils/RotateUtils.cs
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Utils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 旋转工具类
|
||||||
|
/// </summary>
|
||||||
|
public static class RotateUtils
|
||||||
|
{
|
||||||
|
private static Matrix4x4 _matrix;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得绕X轴旋转矩阵
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="degree">旋转的角度</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Matrix4x4 RotateAxisX(float degree)
|
||||||
|
{
|
||||||
|
var sin = MathF.Sin(degree);
|
||||||
|
var cos = MathF.Cos(degree);
|
||||||
|
|
||||||
|
_matrix.SetRow(0 ,new Vector4(1,0,0,0));
|
||||||
|
_matrix.SetRow(1, new Vector4(0, cos, -sin, 0));
|
||||||
|
_matrix.SetRow(2, new Vector4(0, sin, cos, 0));
|
||||||
|
_matrix.SetRow(3, new Vector4(0, 0, 0, 1));
|
||||||
|
|
||||||
|
return _matrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得绕Y轴旋转矩阵
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="degree">旋转的角度</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Matrix4x4 RotateAxisY(float degree)
|
||||||
|
{
|
||||||
|
var sin = MathF.Sin(degree);
|
||||||
|
var cos = MathF.Cos(degree);
|
||||||
|
|
||||||
|
_matrix.SetRow(0, new Vector4(cos, 0, sin, 0));
|
||||||
|
_matrix.SetRow(1, new Vector4(0, 1, 0, 1));
|
||||||
|
_matrix.SetRow(2, new Vector4(-sin, 0, cos, 0));
|
||||||
|
_matrix.SetRow(3, new Vector4(0, 0, 0, 1));
|
||||||
|
|
||||||
|
return _matrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得绕Z轴旋转矩阵
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="degree">旋转的角度</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Matrix4x4 RotateAxisZ(float degree)
|
||||||
|
{
|
||||||
|
var sin = MathF.Sin(degree);
|
||||||
|
var cos = MathF.Cos(degree);
|
||||||
|
|
||||||
|
_matrix.SetRow(0, new Vector4(cos, -sin, 0, 0));
|
||||||
|
_matrix.SetRow(1, new Vector4(sin, cos, 0, 0));
|
||||||
|
_matrix.SetRow(2, new Vector4(0, 0, 1, 0));
|
||||||
|
_matrix.SetRow(3, new Vector4(0, 0, 0, 1));
|
||||||
|
|
||||||
|
return _matrix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Utils/RotateUtils.cs.meta
Normal file
3
Assets/Utils/RotateUtils.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d748c6669d714e65a5ca9164c5798583
|
||||||
|
timeCreated: 1677319275
|
Loading…
Reference in New Issue
Block a user