Jump to content

Drawing lines with Vectrosity?


Recommended Posts

Hi, does anyone here have experience with drawing lines in Vectrosity?

I have been trying to draw a simply trajectory using Vectrosity, but all I get is weirdness.

Here's a snipped of the module:

public class TrajectoryLine: MonoBehaviour
{
    public List<Vector3d> Vertices = new List<Vector3d>();

    private List<Vector3> vl_Vertices = new List<Vector3>();

    VectorLine line;

    public void Start()
    {
        line = new VectorLine("TrajectoryLine", vl_Vertices, 10.0f);
        line.SetColor(Color.yellow);
    }

    public void Update()
    {
        vl_Vertices.Clear();

        foreach (var v in Vertices)
            vl_Vertices.Add(v);

        line.Draw3D();
    }
}

 

The module is attached to the camera like this:


            FlightCamera.fetch.mainCamera.gameObject.AddComponent<TrajectoryLine>();

The result looks like this:

tyNUQnI.png

 

Here, the blue line is drawn with another method (fed from the same Vertices) and is the actually correct line. The white line is the Vectrosity line (I don't quite get why yellow is white, but that's another issue). The really weird thing is that the line thickness changes if I rotate the camera, but not the position of the line.

There is obviously some relationship between the correct line and the Vectrosity line, and it's probably coordinate related - but I don't understand how.

Does anybody have a good idea how to use Vectrosity for my purpose?

 

Link to comment
Share on other sites

8 minutes ago, sarbian said:

At work so I don't have code around to check but from memory I think it is related to the camera used by Vectrosity. It is setup to draw in ScaledSpace.

I figured it was something like that, but I still can't get it to work. I tried drawing in the screenspace with 2d-coordinates and I also even tried to set the Camera with VectorLine in every frame in Update(), but it still didn't change anything.

For now, the code from MechJeb for the line drawing works well enough (that's the blue line in the picture), but unfortunately it's only one pixel wide and I'm just not proficient in this GL drawing business to understand how to make it wider.

I was just hoping: if we already have this damn vectrosity in the namespace, why can't I use it?

Link to comment
Share on other sites

I ll try to unearth some code I have to use it, but I think it had some large problems. That s why I don't use it in MJ (I own the asset so I have all the nedeed doc and still did not manage to make it work as I wanted).

My advice would be to wait for the next KSP to redo it. It should use a new Unity and version avec 5.4 have a improved lineRenderer that does as well as vectosity and is much easier tu use.

 

Link to comment
Share on other sites

4 minutes ago, sarbian said:

I ll try to unearth some code I have to use it, but I think it had some large problems. That s why I don't use it in MJ (I own the asset so I have all the nedeed doc and still did not manage to make it work as I wanted).

Yeah, I "found" documentation that "fell of the truck" but I also couldn't get it to work. Would be cool if you could copy-paste some code!

 

4 minutes ago, sarbian said:

My advice would be to wait for the next KSP to redo it. It should use a new Unity and version avec 5.4 have a improved lineRenderer that does as well as vectosity and is much easier tu use.

Sounds good, but I haven't a single word about SQUAD using the next Unity version in KSP. For that matter, I haven't even heard that they will make releases with significant changes after 1.3.1. Do you know more than me?

 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...