Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Vectrosity - Fast and Easy Line Drawing

Discussion in 'Assets and Asset Store' started by Eric5h5, Sep 26, 2014.

  1. HarvesteR

    HarvesteR

    Joined:
    May 22, 2009
    Posts:
    499
    Hi,

    This might be (I'm hoping it is) a bug in Vectrosity 4.2 and Unity 5.2.0... KSP's map view draws orbit lines using Vectrosity, and because of the scale of the thing (literally astronomical), we need to switch the lines from 3D drawing (so they're culled by objects like planets and such) to 2D drawing, to avoid floating-point inaccuracy issues. This happens when the camera zooms out past a certain distance.

    This has always worked fine, and worked fine in V4.2-U5.1.3. After moving to U5.2.0 however, zooming out like this makes the game go into a semi-crashed state where it maxes out all CPU cores and starts leaking memory like mad.

    I would have updated to V5 already, but it's not up in the asset store just yet. I'm sending you a PM with a question about that.

    But anyhow, is this something that sounds likely to happen with running V4.x (and doing the 3D/2D shifts like this) in unity 5.2.0?

    Thanks in advance!

    Cheers
    .
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    It's an issue with Unity 5.2 not working well with the old method of UIVertex. Actually that sounds like a problem I had with the new method of using meshes with UI drawing, until I figured out that setting the mesh bounds to the size of the screen prevented the issue. I assume they're mapping UIVertex to mesh drawing behind the scenes, but without a way to set the bounds, it won't work. So the solution is Vectrosity 5.

    --Eric
     
  3. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,046
    Vectrosity 5 can't come soon enough :) Maybe you can ping someone from the asset store and make them hurry up? :)
     
  4. russiac

    russiac

    Joined:
    May 31, 2013
    Posts:
    2
    Hi Eric.

    How to make billboard line with VectorLine as like LineRenderer?

    --russiac
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    It already does that; actually that's the point of Vectrosity.

    --Eric
     
  6. Morpheus

    Morpheus

    Joined:
    Feb 2, 2014
    Posts:
    13
    Hello,
    I have recently updated to Vectrosity 5, and I had code that would create 3D lines within the editor, (i.e. without ever pressing the big play button).
    However, now when I try to do this I get the following error:


    Instantiating material due to calling renderer.material during edit mode. This will leak materials into the scene. You most likely want to use renderer.sharedMaterial instead.
    UnityEngine.Renderer:get_material()

    Is there any way to still make 3D lines in the editor and not get error?
     
  7. tatelax

    tatelax

    Joined:
    Feb 4, 2010
    Posts:
    1,147
    Eric, thanks for the update. Being able to offset endcaps and scale them really made my project look a lot better!
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    That was never supported before, so I guess it would depend on what you were doing with the code. Anyway I have plans for supporting 3D points in the editor in a similar way that 2D points are supported.

    --Eric
     
  9. Morpheus

    Morpheus

    Joined:
    Feb 2, 2014
    Posts:
    13
    So does that mean, at this time you do not know of any way to make a 3D line in the editor using Vectrosity?
    Also, do you have a timeline, even a vague one, of when support for 3D points will be available?

    Also, I don't know if it was supposed to be supported, but in vectrosity 2.3 I was able to make these lines by running a script while in the editor. (via making custom editor windows).
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    You can make them in a similar way to which the 2D lines are made; see the source code.

    --Eric
     
  11. earndawg

    earndawg

    Joined:
    Nov 2, 2009
    Posts:
    69
    Hi, i'm looking for a solution to this problem:

    I need to render some wireframe shots of a series of levels. These levels contain hundreds of objects so i'm looking for a solution which can render an entire scene in wireframe rather than adding materials/scripts to individual objects. I also need the ability to revert back from wire mode easily to screengrab with full textures. In my head it would be amazing if it was as easy as toggling on/off an wireframe image effect.

    Is this possible with this plugin?
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    You could write a script that finds all GameObjects and makes a line for each one using the MakeWireframe function, then deactivate the lines.

    --Eric
     
  13. Morpheus

    Morpheus

    Joined:
    Feb 2, 2014
    Posts:
    13
    As vectorline.vectorObject is no longer a thing, and instead there is a rectTransform, and a drawTransform, how would I do the following:

    I am creating a whole bunch of lines, and for the sake of organization I want all of the gameObjects to be the children an empty gameObject that I have created called, say, lines.

    Previously, I would simply set vectorline.vectorObject.transform.parent = lines.transform;

    How do I do the equivalent in vectrosity 5?
     
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    You can use rectTransform.SetParent.

    --Eric
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Vectrosity 5 is on the asset store now.

    --Eric
     
    Devil_Inside likes this.
  16. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,485
    Hi Eric,

    The lines on my app have a specific colour, i.e Orange.

    But on some Android devices the lines show up as black, instead of Orange.

    Do you have any idea what could cause this?
     
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Use Vectrosity 5 with Unity 5.2.

    --Eric
     
    Meltdown likes this.
  18. robertsze

    robertsze

    Joined:
    Jul 8, 2013
    Posts:
    69
    Fixed and working in Vectrosity 5 with Unity 5.2 now. Thanks!
     
  19. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    557
    Sounds like you're better off using a post effect shader. There's definitely one on the asset store that provides an 'xray' example where you can see behind a section of wall. This works as a toggleable on-off effect or even maskable (as per the see through walls example).
     
  20. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,046
    Eric, I've updated Vectrosity to version 5, but I'm running into a number of issues.
    1. I can't set color for a 3d line material. Seems like the 3d material doesn't use vertex colors
    2. If the starting point of a line is close to the camera, the line is not fully drawn, or there are artifacts, like only one triangle of the segment quad is drawn.

    3. If the starting point is close to the camera, the line is drawn either from the camera, or it first goes towards the camera. This really makes it unusable for VR, as the 2 VR cameras can see the line going towards the main camera in the middle.
     
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Yes, I accidentally had the Vectrosity/Resources/DefaultLine3D material set to Unlit/Transparent instead of UI/Unlit/Transparent. As long as you set it to use some shader that uses vertex colors, it will work.

    As for points 2 and 3, I didn't make any changes in the way 3D lines are drawn compared to Vectrosity 4.4 (other than not using a canvas), so Vectrosity 5 works the same way. That said, I can't reproduce the issue. It looks to me that your camera might not be set up correctly.

    --Eric
     
  22. Assault

    Assault

    Joined:
    Aug 21, 2012
    Posts:
    59
    I just updated to Vectrosity 5. I got it working after a while, I had problems with updating because I didnt know I first have to delete the old Vectrosity. At least it seems so, because I had new Vectrosit 1.dll file created in my Plugins folder. This lead to a problem where Unity was using the old version and my code editor (VS) was using the new version. Anyway, I got it working by deleting all and then re-importing the Vectrosity5 package from Vectrosity 5 folder (I didnt even import the 3 and 4 folders), but could you please include some kind of "how to update Vectrosity" guide to the package?

    Another problem is that it seems the SetColor() doesnt work. I set in Start() like this:

    this.myLine = new VectorLine("MyLine", new List<Vector3>(this.segments * 2), this.ropeWidth, LineType.Discrete, Joins.Weld);

    this.myLine.SetColor(this.myColor); //myColor is Color32 object;

    And then in the FixedUpdate I do this:

    this.myLine.MakeCurve(pos1, pos2, pos3, pos4);

    But no matter what I do, the rope stays always white (maybe because of the default material?)

    Setting a texture to my line in the VectorLine constructor works, so I could go around this by making a singlecolor texture, but thats not very nice way around this...so am I doing something wrong or is there an issue with the SetColor()?
     
  23. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,046
    The reason to the color issue is right above your post. Probably will be fixed in the next update.
    The workaround until then is to either modify the material in Vectrosity/Resources/DefaultLine3D to use UI/Unlit/Transparent shader, or create a new material, set its shader to UI/Unlit/Transparent, and apply that material to your line using this.myLine.material
     
  24. Assault

    Assault

    Joined:
    Aug 21, 2012
    Posts:
    59
    Oh, cant believe how I missed that post...

    Both of proposed solutions seem to work. However, I noticed that calling SetColor() on my line makes it invisible. Whats up with that? A bug?
     
  25. wxxhrt

    wxxhrt

    Joined:
    Mar 18, 2014
    Posts:
    151
    I have a problem drawing lines on an Icosphere imported from Blender. Running Linemaker the spheres and lines are in the correct place but after saving to VectorBytes and loading onto the Icosphere at runtime the lines appear in the wrong place see below:



    I'm only using one camera and this is from a fresh project so there's no outside interference.
    Can anyone replicate this, suggest a fix?
     
  26. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    No bug, it's using the color you supplied, which is presumably transparent.

    LineMaker uses local coordinates, so you can either move the points when drawing by using .drawTransform, or else remove all transforms from the object before using LineMaker.

    --Eric
     
  27. Kinkku2

    Kinkku2

    Joined:
    Sep 29, 2014
    Posts:
    106
    Hey. I'm wondering how would I go about creating a wobbly line with Vectrosity. What I mean is a line that has points that sort of randomly wobble to different up and down. Sort of wavering like water.

    Let's say if I had a 50 point line and the space between each point would be about 2 units. So I would have a VectorLine array that has 50 slots in it, then I would iterate through the array and transform.translate the points or? I'm not quite sure. Would hugely appreciate help!
     
    Last edited: Sep 18, 2015
  28. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    You'd just change the points in the line; they're Vector3s (or Vector2s for 2D lines). They're not transforms so you wouldn't use Translate.

    --Eric
     
  29. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,316
    I thought that was happening as well, but I fixed it by moving all my 3D lines closer to the camera to ensure they rendered on top of the UI. Originally my 3D lines were at -0.1f on z, and they rendered on top in Vectrosity 4, but when upgrading to 5, they started rendering behind the UI layer for some reason. I moved them all forward more to -0.5f on z, and they rendered on top again. Weird.

    Edit - Actually, they rendered fine except always white, like yours, but when I changed the material to UI/Transparent, they started rendering behind instead of on top until I moved them forward more on Z.
     
    Last edited: Sep 18, 2015
  30. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Vectrosity 5 Draw3D lines are standard meshes, not drawn with a canvas. Also I doubt UI/Unlit/Transparent uses the zbuffer. You can use whatever shader you want, of course.

    --Eric
     
  31. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,316
    Well, I'm not making it up, if that's what you're implying. ;) The lines that previously drew in front of the canvas when place 0.1f in front of it in Vectrosity 4 no longer appeared in front of it in Vectrosity 5 when I switched to UI/Unlit/Transparent, until I moved them forward more.
     
  32. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,316
    Actually looking at it more, I think I see what's happening; the 3D lines are not actually using the z buffer correctly, but changing the z value seems to change the order they are drawn in, which makes it look mostly correct until the camera angle starts to change and then z-fighting happens. So the problem is that to have 3D lines like we had in Vectrosity 4, we need a shader that is Unlit, uses Vertex Color, and correctly writes to the Z-buffer, but as far as I can tell Unity does not contain one of those out of the box.
     
  33. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,046
    Is there a reason why 3d lines have a RectTransform instead of a Transform?
     
  34. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Of course not, just explaining how Vectrosity 5 works.

    You can use an existing shader and change ZWrite Off to ZWrite On.

    Holdover from the previous version.

    --Eric
     
  35. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,316
    Might I suggest including one in the next version and making that the default 3D material? Writing a new shader is not an obvious step for anyone upgrading from 4 to 5.
     
    hopeful likes this.
  36. fahd

    fahd

    Joined:
    Aug 7, 2014
    Posts:
    33
    in the curve example how to delete the previous point somthing like undo button
     
  37. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    You'd have to program that in, probably using a stack.

    --Eric
     
  38. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    494
    I'm trying to draw lines on a camera that is only being rendered to a texture. I am also drawing 3D lines on another camera. What's the best way to structure this?

    I had a Camera Space canvas set to the render camera and used SetCanvas to set my render texture lines to that canvas but they don't display anything and in the console report "Line Must be attached..." despite setting the canvas. Can I Draw3D to 2 different cameras at once?
     
  39. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Probably would be easiest to use layers with appropriate camera culling masks.

    --Eric
     
  40. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    494
    The cameras don't face the same direction so won't the lines end up skewed? One is a perspective camera facing in a variety of directions and the other is an overhead orthographic.
     
  41. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    In that case you'd draw two sets of lines, one for each camera. Call SetCamera3D with the appropriate camera, then draw the line, and repeat for the other camera.

    --Eric
     
  42. maciekfreak

    maciekfreak

    Joined:
    Sep 21, 2015
    Posts:
    22
    I have a question about Vectrosity before buying. Can anyone tell me is it possible to draw 3d straight line that passes through two points. Not from one to other point but straight line (inifinite or very long) that passes through two points.

    Thanks,
     
  43. TurtleMine

    TurtleMine

    Joined:
    Mar 20, 2013
    Posts:
    5
    Hi Eric,
    Making some progress with my drawing game. I was wondering is it possible to lock lines drawn, like in the draw lines example, to increments of 15 degrees (0, 15, 30, 45, 60). So that lines are straight, like when you hold shift down in paint.net or Photoshop when using the line tool and it snaps?

    Like this:


    The vectorcity drawnlines would be the redone :)

    I think this forum post is very close to what I am trying to get to:
    http://answers.unity3d.com/questions/395375/2d-mouse-angle-in-360-degrees.html

    My idea was to save the last pressed point and then make it so that the next point pressed is angled correctly (15 degree increments). By checking were current mouse position is and were the closest 15 degree increment is. Then snapping to the correct angle from a mouse down press.

    I'm going to keep at it but I thought I might ask if you have any idea's or if Vectrocity has functionality to support this.
     
  44. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    It will draw whatever points you supply. (But not infinite.) In this case you'd want to compute a bunch of points along that line, without a huge distance between points, since Vectrosity will cull segments where one point is too far behind the camera.

    That's a general math question and not really specific to Vectrosity; it doesn't have a built-in function to do that. It's certainly possible, but up to you to compute the points.

    --Eric
     
  45. maciekfreak

    maciekfreak

    Joined:
    Sep 21, 2015
    Posts:
    22
    I know that infinite is not possible. But I want to just say that I need really loooong lines:).
    Is vectrosity have any function for this or I need to calculate points to create this line on my own?
     
  46. maciekfreak

    maciekfreak

    Joined:
    Sep 21, 2015
    Posts:
    22
    I have also other question. Is it possible to draw grid but in 3D? On your website I saw only demo for 2D grid on GUI.
     
  47. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Yes, it will draw whatever points you pass in. If you make grid lines from 3D points then it will draw that.

    --Eric
     
  48. Morpheus

    Morpheus

    Joined:
    Feb 2, 2014
    Posts:
    13
    Hello,
    I seemed to have fixed my problem of getting errors when trying to create 3D lines in the editor by changing the following lines in the VectorObject3D source code:

    Old:
    GetComponent<MeshRenderer>().material = mat;
    GetComponent<MeshRenderer>().material.mainTexture = tex;

    New:
    GetComponent<MeshRenderer>().sharedMaterial = mat;
    GetComponent<MeshRenderer>().sharedMaterial.mainTexture = tex;

    However, I am unable to get visible lines. The code I am using to create these lines is the following script, just run in the editor.

    List<Vector3> pointList = new List<Vector3>();
    pointList.Add(new Vector3(-5, 0, 5);
    pointList.Add(new Vector3(5, 0, 5);
    float linewidth = 5.0f;
    VectorLine line = new VectorLine("line", pointList, linewidth);
    line.Draw3D();

    I do get the line objects in my scene, but nothing is visible.

    If there are any suggestions in regards to how to fix this, please let me know.
     
  49. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    The script has errors so it won't compile. If you fix the script, it works fine, assuming the camera is somewhere that can see the line.

    --Eric
     
  50. Morpheus

    Morpheus

    Joined:
    Feb 2, 2014
    Posts:
    13
    If by the compilation errors you mean the missing parentheses at the end of adding points ( -> pointList.Add(new Vector3(-5,0,-5)): ) Then that was always fixed in my actual script, I just made a typo when copying it here. I do not have any compilation errors. However I also have no visible lines.

    As for my camera it is located at
    Position: 0, 25, 0
    Rotation: 90, 0, 0

    with near clipping plane 0.3, far 100, and field of view 60

    so it should be able to see the line
     
unityunity