- Home /
3D ellipse with Vectrosity
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:
...and this is what I need:
Is there an easy way to orient the 3D ellipse that way?
Thanks.
Answer by Eric5h5 · Jan 15, 2013 at 07:58 PM
You'd want to change the up vector (which currently you have as Vector3.forward).
Nope, I need it to be Vector3.forward, or it will be drawn flat on the ground grid (which is not wat I want).
Oh, I see...I misinterpreted your pictures. The easiest way would be to have an empty game object as a reference, and rotate that object in the desired way, and pass in that transform to the Draw3DAuto command.
I should orient that empty game object, then; how can it be oriented along the distance between two arbitrary objects?
hmm, my .Draw3DAuto(); can not take an transform? the only overload available is "float Time"
I can easily rotate my ellipse on X and Y axis, but not on the Z..
ellipse.$$anonymous$$akeEllipse((Vector3)origin, new Vector3(0,0,1), (float)xRadius, (float)yRadius, segments);
well, I found a semi-solution that helped a little, I used:
ellipse.vectorObject.transform.RotateAround((Vector3)origin, Vector3.forward, 150f);
Your answer
Follow this Question
Related Questions
Trouble again with 3D ellipse {FIXED} 1 Answer
Need the user to be able to draw lines on the screen. 1 Answer
Draw lines with Vectrosity in the direction transform.forward 1 Answer
Vectrosity lines being distorted when rotated 0 Answers
What is the best way to draw a border around a viewport? 1 Answer