Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Vectrosity - fast and easy line drawing

Discussion in 'Assets and Asset Store' started by Eric5h5, May 26, 2010.

Thread Status:
Not open for further replies.
  1. MarcoMeter

    MarcoMeter

    Joined:
    Jun 14, 2013
    Posts:
    69
    $Screenshot 2014-02-24.png

    Hi guys,

    is there a proper solution for making the 2d shaped lines facing the camera? On certain perspectives the lines are too thin.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    They face the camera automatically when you call Draw3D, or you can use Draw3DAuto.

    --Eric
     
  3. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,164
    It is possible to "convert" a whole 3d game to wireframe with Vectrosity? How difficult it would be (how many changes in code)? and if yes, how would be the performance compared to the textured version of the same game?
    Sorry if my questions have been already answered.

    Thanks
     
    Last edited: Feb 25, 2014
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can do that, as shown by the Tank Zone demo. There are some functions specifically for making vector objects behave as much like standard game objects as possible. How many changes depends on what you're doing exactly, but you can use the standard transform.position, Translate, Rotate, physics, etc. and vector objects will typically "just work". The performance is likely to be technically worse since the lines use some CPU for calculations, but in practice the difference would normally be negligible unless you have lots of complex vector objects.

    --Eric
     
  5. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    In our 2D game, in which we're using Unity's 4.3 2D system, we need to have a straight laser (a line that is similar to Superman's heat vision) that will constantly shoot out of a turret and hit walls and not go through them, but also kill the player on collision with the player.

    With Vectrosity the line implementation shouldn't be difficult if we are using a material to draw it. The issue I'm having is my team needs to have a Unity Particle System (Shuriken System) that makes up the laser and not a material, thus I was unsure if it was possible to somehow get the Particle System to work properly with Vectrosity.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Not quite sure what you mean; Vectrosity doesn't use Shuriken. As you mentioned, a material on a line should work well.

    --Eric
     
  7. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    What I meant was that we need additional particle effects along the length of the VectorLine due to the way we want the laser to look. Because we resize the VectorLine based on the distance from where the raycast hit point returns and the turret position, I was trying to interpolate the particles along the VectorLine so that they go the correct distance.

    So, I guess I was just checking if Vectrosity somehow had particle support. Thanks for the answer though. I think I almost figure out how to do what I was trying.
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You could use one of the GetPoint functions to get points along the length of the line, and use that for particle positions.

    --Eric
     
  9. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    I'll try that. Thanks. Also, I can't seem to find the documentation for Vectrosity, do you have a link or somewhere I can get a copy? Thank you.
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's included with Vectrosity; there are two PDF files.

    --Eric
     
  11. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    I'm not if something's wrong, but when I update from the asset store, and import, no PDF's show up. Is there another way to see them?
     
  12. aureliocalegari

    aureliocalegari

    Joined:
    Dec 26, 2012
    Posts:
    20
    Hello Eric,

    I love this framework, but I'm having an annoying problem that I've been trying to get over with a couple of weeks now.

    Basically, in a huge world space (let's say camera clipping plane from 0.01 to 160000), depending on where the main camera is, the camera close by lines appear broken. The only way to get around this is by increasing the near clipping plane. Here are examples:

    $Screen Shot 2014-03-01 at 11.47.00 am.png

    In the above, main camera is at (xyz): ~ -4K, 1K, 16.5K.
    Near Clipping plane is 0.01.

    However, switching the near clipping to 4, here's the result:
    $Screen Shot 2014-03-01 at 11.50.40 am.png

    Which is fine. For a while I can live with that. However, as I approach tiny bodies bodies such as Amalthea, whose world radius is ~0.02f, the near clipping of 4 is no longer good, as the body will be behind the clipped plane as we do a fly over:
    $Screen Shot 2014-03-01 at 11.56.02 am.png

    Reducing then the the near clipping plane to 0.01f, the result is:
    $amalthea.png

    So, while I can now see the body, the closeby lines appear to be broken again. No matter what I do. The only way to get around this is changing the near clipping plane. Note however that this issue does not affect the lines passing far away.

    Is there a way around that?

    Thanks
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can see what's included on the asset store page: https://www.assetstore.unity3d.com/#/content/82. I just verified that there's no problem and everything that you see there imports fine, including the docs.

    @aureliocalegari: I expect you're running into floating point limitations; a view distance of 160K will cause problems aside from Vectrosity. Typically you don't want to exceed 10K if you want to maintain a decent amount of precision. There are a fair number of topics covering this issue, so you can get some ideas for different techniques; typically some kind of subdivided space. There's a bit here (the "Kraken" sidebar in the "Abort" section) about what Kerbal Space Program did (which uses Vectrosity by the way).

    --Eric
     
  14. aureliocalegari

    aureliocalegari

    Joined:
    Dec 26, 2012
    Posts:
    20
    Thanks Eric.

    I was suspecting it might had be related to floating point / float type precision. I have that already subdivided into spaces, but I have to refine that further. Was just wondering there would be a quick way before going to the next fine tuning round.

    That's cool, thanks again for the quick response.
     
  15. AlfieBooth

    AlfieBooth

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

    Ok so I'm having a problem with linemaker that appears to have come up before...

    "Sequential Line with Linemaker?
    Still trying to get the Joins.Weld option to work...

    Is there a way to create discrete, sequential lines with Linemaker? Even if I create the lines in the correct order, they seem to be written in a seemingly random order in the output file...

    Thanks,
    georg.-
    01-24-2013Eric5h5
    It just goes through the linePoints array sequentially and writes that to disk, so it should be in the order that the lines were created as far as I know. I imagine that deleting/adding line segments would change the order.

    --Eric"

    BASICALLY I'm getting exactly the same problem. I'm using linemaker to create a line around the edge of a polygon and no matter which order the points are selected and lines created, the order of the points in the resulting paste-able vector list are seemingly at random and with frequent duplicates causing the line to double back on itself etc... Sometimes I can get the result by going back through the vector3 points in the script and deleting duplicates, but doing this, and switching the jumbled up ones back around make the process enormously time consuming.... and i have A LOT of lines to do :)

    Any thoughts? my meshes are being imported from cinema 4d, I'm using UNITY 4.3 and I'm up to date with Vectrosity.

    Thanks in advance

    Alfie
     
  16. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It looks like the selected points are getting returned by the Unity editor in reverse order. So instead of doing "point1, point2, make line segment, point3, point4, make line segment, etc.", do "point2, point1, make line segment, point4, point3, make line segment, etc." I definitely haven't seen any duplicates being generated.

    --Eric
     
  17. AlfieBooth

    AlfieBooth

    Joined:
    Dec 2, 2013
    Posts:
    31
    Thanks for the prompt reply!!

    I have tried doing exactly as you suggest (take sequential second point first, considering the order is being reversed) yet it still doesn't seem to be working for me? would you mind just checking my script. I'm new to it and I may have made a complete brain fart in the fine print.

    *****************
    import Vectrosity;

    var lineMaterial : Material;

    var lineWidth = 10;

    var segments = 250;

    var loop = false;


    function Start () {


    var splinePoints = [ array from linemaker ];

    //Make the line
    var line = new VectorLine("spline", new Vector3[segments+1], Color.red, lineMaterial, lineWidth, LineType.Continuous);
    line.MakeSpline (splinePoints,segments,loop);

    //Allow the line to be controlled by GameObject Transform (visibility, active, etc...)
    VectorManager.useDraw3D = true;
    VectorManager.ObjectSetup (gameObject, line, Visibility.Dynamic, Brightness.None, false);
    }

    ********

    does that shed any light? If not I can provide screenshots of the problem. It seems to be much better if i'm just creating a line instead of feeding the array to makeSpline. Would that have something to do with it?

    Kindest,
    Alfie
     
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The array from LineMaker isn't really intended to be used in a spline, so I expect that's the issue.

    --Eric
     
  19. AlfieBooth

    AlfieBooth

    Joined:
    Dec 2, 2013
    Posts:
    31
    Ok Thanks for that. I will alter things accordingly :)

    Question 2:

    How would I declare more than one line in a vectorManager.Object Setup? i.e:

    VectorManager.useDraw3D = true;
    VectorManager.ObjectSetup (gameObject, *i want to put three seperate lines here*, Visibility.Dynamic, Brightness.None, false);

    thank you kindly

    Alfie
     
  20. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can only use one line in ObjectSetup. If you use discrete lines, though, you can have the appearance of multiple lines in a single line.

    --Eric
     
  21. Ninjuit

    Ninjuit

    Joined:
    Jul 7, 2012
    Posts:
    9
    Hey Eric,

    I just purchased your software hoping to draw a vector circle centered at the mouse position and that scaled over time from the center. Currently, I'm creating an object that creates and draws the circle itself so that I can scale the object for scaling purposes, but I'm running into two issues.

    One: The circle is not centered on mouse (or in my game, the object's position, converted to a screen point) when the mouse or object moves away from the center of the screen

    Two: When I scale the object, the circle scales and moves away from the mouse point. I assume that the circle is being scaled from one of the corners and not the center?

    Overall, I'm pretty new to Unity and this has been frustrating me for a few hours. Any help would be appreciated.

    Potentially relevant information: I have two cameras set-up and they are both 2D Toolkit cameras. One is culling everything except for a GUI layer and the other is just for GUI. I am also using PoolManager 5 for spawn pools.

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using PathologicalGames;
    4. using Vectrosity;
    5.  
    6. public class CircleScript : MonoBehaviour
    7. {
    8.     /* public */
    9.     public float radius,
    10.                  lineWidth;
    11.     public int vectorPoints;
    12.     /* private */
    13.     private VectorLine myCircle;
    14.  
    15.     void Awake()
    16.     {
    17.         VectorLine.SetCamera(Camera.main, CameraClearFlags.Depth, true);
    18.     }
    19.  
    20.     // use this for spawn
    21.     void OnSpawned()
    22.     {
    23.         Vector2[] linePoints = new Vector2[vectorPoints * 2];
    24.         myCircle = new VectorLine("MyCircle", linePoints, null, 2.0f, LineType.Discrete);
    25.         myCircle.drawTransform = transform;
    26.         myCircle.MakeCircle(Camera.main.WorldToScreenPoint(transform.position), radius, vectorPoints);
    27.         myCircle.Draw();
    28.         InvokeRepeating("ChangeScale", 0.01f, 0.02f);
    29.     }
    30.  
    31.     void OnDespawned()
    32.     {
    33.         VectorLine.Destroy(ref myCircle);
    34.     }
    35.  
    36.     void ChangeScale()
    37.     {
    38.         //Vector3 s = transform.localScale * .01f;
    39.         transform.localScale *= 1.01f;
    40.         transform.position.Scale(transform.localScale);
    41.         myCircle.Draw();
    42.     }
    43.  
    44.    
    45. }
     
  22. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Hi, I'd suggest making the circle at the origin, then using WorldToScreenPoint to move the transform to the desired location instead. That way it will scale from the center, and moving the transform will also move the circle to the correct place. Depending on how you have things set up, you may want to use a second transform as the .drawTransform.

    --Eric
     
  23. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Sorry for the confusion. I didn't actually purchase from the Unity Asset Store, but from your Starscene Asset store here:
    http://starscenesoftware.com/store.html

    After I purchased it, you e-mailed me a link, to which I'm suppose to be able to receive future updates, but the link is dead when I click on it in my e-mail.
     
  24. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If you bought from my site, then you get a zip file, which contains all the packages and documentation. If you bought recently, the link should not be dead; try clicking it again (maybe the web site was briefly down?)...let me know if you're still having problems. If you bought a long time ago, the old links are no longer valid after I updated my site last year, so you can use the contact form on my site to request a new link.

    --Eric
     
  25. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    298
    Hi Eric,

    Not sure if it's by design or not, but when I create two vector lines using the same position array, the one modifies the other when I access each individual line's points2. e.g.:

    Code (csharp):
    1.  
    2. Vector2[] points = new Vector2[2];
    3. points[0] = GetPoint.Screen(transform.position);
    4. points[1] = points[0];
    5.  
    6. vectorLine = VectorLine.SetLine(lineColor, points);
    7. lineHeadCW = VectorLine.SetLine(lineColor, points);
    8.  
    9. ------
    10.  
    11. vectorLine.points2[0] = point0Pos;
    12. vectorLine.points2[1] = point1Pos;
    13.  
    14. lineHeadCW.points2[0] = point0Pos;
    15. lineHeadCW.points2[1] = (Vector3)point0Pos + Quaternion.AngleAxis(45f, Vector3.forward) * direction * 10;
    16.  
    The lineHeadCW.points2[1] line affects the vectorLine. If I duplicate the points array at the beginning and apply it to lineHeadCW, then it works as expected. Is this another of my misinterpretations?
     
  26. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Arrays are by reference, so yep, that's expected behavior.

    --Eric
     
  27. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    298
    Ah, excellent. I just added points for each instead of defining arrays. Any luck with the GetPointAtPosition()?
     
  28. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    We bought it about 2 years ago, so that's probably the issue. We'll fill out the contact form. Thanks.
     
  29. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Arrays are fine, they just need to be unique arrays for each line. The GetPoint thing will be in the next version.

    --Eric
     
  30. mplaczek

    mplaczek

    Joined:
    Feb 13, 2012
    Posts:
    19
    This is a great looking asset!! I've been playing around with it and following through the Documentation (which is extremely thorough!) and it is definitely going to become a staple in the applications I create.

    However I'm currently building an application that requires heavy use of NGUI and I'm having trouble integrating your vector lines with it.
    I can draw lines, however, the scale and or position do not correlate with my NGUI objects.

    I have found a few old posts talking about using NGUI and Vectrosity together however I have not been able to generate any working code from them. The example below seems to be trying to accomplish what I would like, however Draw3DAuto is not liking the argument assigned.
    For example:
    Code (csharp):
    1. var uiElement1 = // Some Element, lets say texture
    2. var uiElement2 = // Some Other Element lets say texture
    3. var uiElementContainer = // Some panel which contains all ui elements
    4. var guiCamera = GetComponentInChildren<Camera>();
    5. var transformedPosition1 = guiCamera.WorldToScreenPoint(uiElement1.transform.position);
    6. var transformedPosition2 = guiCamera.WorldToScreenPoint(uiElement2.transform.position);
    7. var line = VectorLine.SetLine(Color.red, transformedPosition1, transformedPosition2);
    8. line.vectorObject.transform.parent = uiElement1.transform; // Add under uiElement 1 to clip when it moves off the panel
    9. line.Draw3DAuto(uiElementContainer.transform);
    10. line.lineWidth = 2;
    Is there a simple way to ensure any lines I generate are using the same scale and world or screen space that NGUI is using?
    Does anyone have any tip or suggestions on using these two assets together. Anything would be greatly appreciated.
     
    Last edited: Mar 10, 2014
  31. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Draw3DAuto doesn't work like that anymore; see the included upgrade guide for how to use transforms with lines in Vectrosity 3.

    --Eric
     
  32. Christop

    Christop

    Joined:
    Aug 21, 2012
    Posts:
    60
    Hi,
    complete newbie to vectrocity
    I understand that SetRay renders over everything in the scene in contrast to SetRay3D.
    But the 3D version also updates its perspective when I move the camera whereas SetRay (with Vector3 parameters in world space) does not.
    Its like SetRay uses the worldspace projection of the camera it found in the first frame or so.
    The same happens when I use Vector3 with SetLine in World space.

    What is the fundamental difference between these two functions, why is the SetRay using world space coordinates not getting the current camera matrix?

    Thanks
    Dimi
     
  33. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    SetRay (and the Draw function) renders 2D lines in an overlay. You can use both screen space coordinates or world coordinates, but in both cases the lines are rendered once as a 2D overlay and then not updated unless you specifically tell them to update. This is good for lines that don't need to be updated often (or at all) because then they take no extra CPU time.

    --Eric
     
  34. Christop

    Christop

    Joined:
    Aug 21, 2012
    Posts:
    60
    Thanks

     
  35. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
    How do you delete a line created with Draw3D?
     
  36. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Use VectorLine.Destroy().

    --Eric
     
  37. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
    Thx for reply. I am not sure how that works for my code. See below for example code.

    I just want to ensure I am following best practice for the VectorLine class.

    Is this the best way to Destroy the gameobject that Draw3D creates?

    Code (csharp):
    1.  
    2.  
    3.                  // Create VectorLine
    4.                 _vLine1 = new VectorLine(parm, new Vector3[] { GameObject.Find("Player").transform.position, targetPos }, dashedLineMaterial, 4.0f);
    5.  
    6.                 // Draw the line
    7.                 _vLine1.Draw3D();
    8.  
    9.                  // Deactivate line
    10.                 _vLine1.active = false;
    11.  
    12.                // I could do, to destroy
    13.                _vLine1.vectorObject.Destroy();
    14.  
     
  38. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    See "Removing Vectorlines" in the docs, page 17. Do not use vectorObject.

    --Eric
     
  39. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
    Thank you. That's exactly what I was looking for. (My apologies for not reading documentation)
     
  40. Christop

    Christop

    Joined:
    Aug 21, 2012
    Posts:
    60
    Hi
    some additional newbie questions. I waded through almost all of the Documentation (missing still 8 pg until the end :), very nicely written by the way congrats). Unfortunately I havent found a solution to something I noticed almost from the beginning.

    1) When I create a Vector3 /Draw3D line and set a pixel width say 4 or even 2, I notice that the line get thinner/bigger as i move the camera near/far. This is really obvious and I dont understand why the scaling happens.

    2) Is there a way to select lines using rays and world space positions instead of just mouse position? Say I have this character and I want him to select a line (I have his world space position/direction). Or in case I have a 3D tracking device. I imagine a interface like the on we user for Physics.Raycast.

    Thanks
    Dimi
     
  41. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You need to update Draw3D lines yourself if you move the camera. You can use Draw3DAuto instead, where the line is updated automatically every frame. You can use VectorLine.Selected with 3D lines.

    --Eric
     
  42. Christop

    Christop

    Joined:
    Aug 21, 2012
    Posts:
    60
    Hi Eric,
    1) I draw the line with Draw3DAuto already. This facilitates that the line always faces me. But as the camera moves away the line get bigger and bigger. This is especially evident if you use a large with like 15. It looks not right. Here is the code I use, pretty basic. Put that on an empty scene and move the camera in play mode away and near again. You will definitely see what I am talking about. Can you verify this?

    Vector3[] linePoints = new Vector3[2];
    linePoints [0] = new Vector3 (0, 0.2f, 0);
    linePoints [1] = new Vector3 (0, 2, 0);
    myLine = new VectorLine ("line", linePoints, Color.green, mat, 15, LineType.Continuous, Joins.Weld);
    myLine.Draw3DAuto ();


    Added: Here is a video with the problem in action, just to proove what I am saying. I have Unity Pro 4.3. You can clearly the empty scene, the simple line and the scaling issue, I will remove the video as soon as I get your next answer. https://www.youtube.com/watch?v=UD2unUNsOxY

    2) VectorLine.Selected takes screenspace coordinates. I do not have screenspace coordinates but only real world space coordinates. Since you proably do some form of raycast to find the selection would not it be nice if in future version you could feature also a world space 3D vector VectorLine.Selected overload?

    Thanks
    Dimi
     
    Last edited: Mar 13, 2014
  43. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    1) I'm not seeing that; the line maintains a constant width of 15 pixels as expected. Maybe you need to use SetCamera with a different camera?

    2) There isn't raycasting involved in VectorLine.Selected. Since any user input with selecting lines is going to start with Input.mousePosition anyway, even if you convert to a raycast using ScreenToWorldPoint, I'm not sure what advantage there would be in trying to emulate raycasting.

    --Eric
     
  44. Christop

    Christop

    Joined:
    Aug 21, 2012
    Posts:
    60
    Hi Eric,
    1) Did you look look at the video? Please follow the link. Is this behavior OK? There is only one camera in the scene nothing else. You clearly see that the line gets bigger relative to the plane. Is this by design?

    2) No raycasting? How does VectorLine.Selected select a 3D line in world space drawn with Draw3D? Being able to select a line using a ray would be useful if your input device is not a mouse but a 3D stylus or 3D mouse. Or say you have a character (position + forward vector) inside the game and want to determine when he has selected a line.

    Thanks
    Dimi
     
  45. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You didn't have the video when I read your message the first time. ;) Yes, that's correct behavior. The line isn't getting bigger or smaller, it's staying a constant 15 pixels. With vector graphics, lines don't get bigger as you approach them, they stay the same width.

    You can look at the source code to see how VectorLine.Selected works. I'm afraid I don't really understand how a character in a game is meant to select a line. To be able to do so usefully, it seems to me that some kind of input with a pointing device is required, where there is a cursor that you move around the screen. If you don't have Input.mousePosition for whatever reason, you could use WorldToScreenPoint to convert it to screen space.

    --Eric
     
  46. Christop

    Christop

    Joined:
    Aug 21, 2012
    Posts:
    60
    Hi Eric,
    1) I understand now. I essence because everything else in 3D space gets smaller due to perspective but the line stays the exact same amount of pixels you get that impression of the line getting bigger. Is there a way to let the line get smaller due to perspective like a real 3D object? I can imagine computing the width per frame according to how far away the camera is.

    2) yes I have a pointing device other than the mouse :) which always gives world space coordinates.

    Thanks for your time
    Dimi
     
  47. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Not currently.

    --Eric
     
  48. Christop

    Christop

    Joined:
    Aug 21, 2012
    Posts:
    60
    Hi,
    I create a 3D line and draw it with Draw3DAuto(). Then when pressing space I want it to stop auto updating and I call StopDrawing3DAuto()
    Unfortunately immediately after calling the stop function the VectorLine disappears and gets removed from the hierarchy (I see it in the editor). Any further calls to Draw3D have no effect and the VectorLine never appears again.

    Is this a bug? The Doc says that after calling StopDrawing3DAuto() I can call Draw3D() to continue update.

    Thanks
    Dimi

    I have the 2.3 version.
     
  49. Christop

    Christop

    Joined:
    Aug 21, 2012
    Posts:
    60
    Forgto to mention that after calling StopDrawing3DAuto() I get this message in Unity.

    VectorLine "line" seems to have been destroyed. If you have used ObjectSetup, the way to remove the VectorLine is to destroy the GameObject passed into ObjectSetup.
    UnityEngine.Debug:LogError(Object)
    Vectrosity.VectorLine:LogError(String)
    Vectrosity.VectorLine:CheckLine()
    Vectrosity.VectorLine: Draw3D(Transform)
    Vectrosity.VectorLine: Draw3D()
    LineDrawTest:Update() (at Assets/Vectrosity/LineDrawTest.cs:63)
     
  50. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes, that's a bug, sorry. I had done some changes and forgot to remove VectorLine.Destroy on line 96 of LineManager.cs, so you can get rid of that and then it will work properly.

    --Eric
     
Thread Status:
Not open for further replies.