Hi, I’m trying to connect two 3D objects with a 3D ellipse using Vectrosity. I managed to get the correct size and position, but cannot find a way to orient the ellipse in the right way. This is the code I’m using:
using UnityEngine;
using System.Collections;
using Vectrosity;
public class TestCircle : MonoBehaviour
{
public Transform obj1, obj2;
private Vector3 origin;
public float xRadius = 0;
public float yRadius = 0;
public int segments = 60;
public float width = 5.0f;
public float pointRotation = 0.0f;
// Use this for initialization
void Start ()
{
origin = (obj1.position + obj2.position) / 2;
xRadius = Vector3.Distance(obj1.position, obj2.position) / 2;
//yRadius = xRadius;
Vector3[] linePoints = new Vector3[segments+1];
VectorLine circle = new VectorLine("Circle", linePoints, null, width, LineType.Continuous, Joins.Weld);
circle.MakeEllipse(origin, Vector3.forward, xRadius, yRadius, segments, pointRotation);
circle.Draw3DAuto();
}
}
This is what I get now:
[6736-schermata+2013-01-15+alle+20.38.22.png|6736]
…and this is what I need:
[6737-schermata+2013-01-15+alle+20.43.14.png|6737]
Is there an easy way to orient the 3D ellipse that way?
Thanks.