46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.PlayerLoop;
|
|
|
|
namespace Models
|
|
{
|
|
public class VirtualSkeleton : Bonds
|
|
{
|
|
//private GameObject start;
|
|
//private GameObject end;
|
|
private GameObject virtualskeleton;
|
|
|
|
|
|
|
|
public VirtualSkeleton(GameObject start,GameObject end,float scale) : base(start,end,scale)
|
|
{
|
|
this.start = start;
|
|
this.end = end;
|
|
|
|
virtualskeleton = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
|
|
|
|
virtualskeleton.transform.localScale = new Vector3(scale/2, scale/2, scale/2);
|
|
|
|
virtualskeleton.GetComponent<Renderer>().material.color = Color.white;
|
|
}
|
|
|
|
public void UpdateVS()
|
|
{
|
|
|
|
var startpos = start.transform.position;
|
|
var endpos = end.transform.position;
|
|
Vector3 rightPosition = (startpos + endpos) / 2;
|
|
Vector3 rightRotation = endpos - startpos;
|
|
|
|
float LThickness = 0.2f;//线的粗细
|
|
|
|
//创建圆柱体
|
|
|
|
//bond.gameObject.transform.parent = transform;
|
|
virtualskeleton.transform.position = rightPosition;
|
|
virtualskeleton.transform.rotation = Quaternion.FromToRotation(Vector3.up, rightRotation);
|
|
//virtualskeleton.transform.rotation = Quaternion.LookRotation(rightRotation, Vector3.forward);
|
|
virtualskeleton.transform.localScale = new Vector3(LThickness, LThickness, LThickness);
|
|
}
|
|
|
|
}
|
|
} |