public Camera(Game game, Vector3 position, ObjectUnit target, Vector3 Up) : this(game) { this.cameraType = CameraType.Observer; this.position = position; this.ObjUp = Up; this.observedUnit = target; this.observedPoint = target.Position; }
/// <summary> /// 处理单位和射线的碰撞检测 /// </summary> /// <param name="unit"></param> /// <param name="ray"></param> /// <returns></returns> public static bool IsCollided(ObjectUnit unit, Ray ray) { if (unit.Model.TransformedMajorSphere.Intersects(ray) != null) { foreach (BoundingSphere k in unit.Model.TransformedBoundingSpheres) { if (k != null) { if (k.Intersects(ray) != null) { return(true); } } } } return(false); }
public static bool IsCollided(ObjectUnit unit, Vector3 point) { if (Vector3.Distance(unit.Position, point) <= GameConsts.BoundingDistance) { if (unit.Model.TransformedMajorSphere.Contains(point) == ContainmentType.Contains) { foreach (BoundingSphere k in unit.Model.TransformedBoundingSpheres) { if (k != null) { if (k.Contains(point) == ContainmentType.Contains) { return(true); } } } } } return(false); }
public static bool IsCollided(ObjectUnit unit, ObjectUnit unit2) { //if (Vector3.Distance(unit.Position, unit2.Position) <= GameConsts.BoundingDistance) { if (isCollided(unit.Model.TransformedMajorSphere, unit2.Model.TransformedMajorSphere)) { foreach (BoundingSphere b1 in unit.Model.TransformedBoundingSpheres) { foreach (BoundingSphere b2 in unit2.Model.TransformedBoundingSpheres) { if (isCollided(b1, b2)) { return(true); } } } } } return(false); }
void Start() { unit = GetComponentInParent <ObjectUnit>(); }