Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    edit, the point about distance, is that the points are generally far apart enough at the moment that removing one let alone 3 will make a difference to my eye.

    Is the code I am using, for drawStart correct?
     
    Last edited: Apr 14, 2013
  2. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    bumped my edited answer.
    Is the code I am using for drawStart correct? As it is not altering the draw of the spline.

    Thanks.
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Are you sure? This is about the number of points in the VectorLine, not the number of spline points. Look at the example code on page 16 for how drawStart works.

    --Eric
     
  4. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    Ok,
    My apologies. I was looking in the wrong pdf. My bad.

    I am using my spline as the line and spline (which after consideration is probably irrelevant)... but, I draw the spline, with the assigned material . I define my spline like this...
    Code (csharp):
    1. splineLine = VectorLine("Spline", new Vector2[segments], splineMaterial, 8.0, LineType.Continuous);
    However, I just noticed I am adding spline points by using splinePoints, a Vector2 list.
    Code (csharp):
    1.  
    2. splineNodePos = somePos;
    3. splinePoints.Add(Camera.main.WorldToScreenPoint(splineNodePos));
    4. splineLine.MakeSpline(splinePoints.ToArray());
    5. splineLine.Draw();
    6.  
    The reason I bring this up, is that it differs from the example on page 16. There you define the Vectorline with linePoints, not "new Vector2[segments]". When I altered my VectorLine definition to match this, it gave an error that I was not matching the correct arguments for VectorLine. Is this even relevant?


    Scratching my head.
     
    Last edited: Apr 15, 2013
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The spline points and the points used to make up the VectorLine are two completely different things. In order to make smooth-looking curves you need many points in a VectorLine. You only need a few points in a spline points array (at least two).

    --Eric
     
  6. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    Oh, ok, so I see what you are saying. So, this raises another question, knowing what you know of my situation. How would I know, what the drawStart value is? It must basically represent the distance between any two given nodes (points). 0-1, 1-2, 2-3....
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The points per node would be "numberOfPoints / (numberOfNodes-1)" I think.

    --Eric
     
  8. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    So wait,
    Number of points, would be what? Is it related to the "segments" value?
     
  9. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    Hi Eric,
    I am still unclear as to find definitive way, without resizing the spline points array (from points list - MakeSpline()) and just using drawStart() to come up with a number which will represent the number of line points in between two nodes.

    Your suggestion " numberOfPoints / (numberOfNodes-1)" makes sense, but how can I get the number of points? Is there a call for this?

    I have two other issues with the material, and line drawing. I need the line drawn to be made up of identically sized sprites, a dashed line. At the moment, and I am unsure how to change this, my line is plotted on what looks like a sphere material (I need flat) and also, any "dot's" size, is determined by the distance between nodes. So, it creates uneven line segment sizing as you can see in the picture.


     
    Last edited: Apr 15, 2013
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You specified it when you made the points array for the VectorLine.

    Look up uniform texture scale in the docs.

    --Eric
     
  11. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    I am not sure if this is the number of points used in the line drawing or points in the spline?
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    As I said, the points array for the VectorLine. Not the spline.

    --Eric
     
  13. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    I am confused.
    I only define one VectorLine. That is mySpline. When I MakeSpline() I use mySpline.MakeSpline(). When I draw it I again use mySpline.Draw().
     
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'm afraid I'm not really sure what else to say; I answered your question above as clearly as I can. I'd suggest (re)reading the docs carefully, and looking at the examples (both in the docs and in the demo scenes).

    --Eric
     
  15. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    These two are the same thing.
     
  16. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    I am going to be using a zoom on my camera, and have noticed if zoom changes, the line drawn becomes a non matching scale of the spline (in real world). Can I negate this somehow? mySpline.SetCamera(Camera.main) did not do the trick.
     
  17. davebuchhofer

    davebuchhofer

    Joined:
    Nov 9, 2007
    Posts:
    126
    Hey Eric, is there a way to change the width of segments of a line?

    IE: I'm drawing lines here by using a trigger button, I'd like to be able to vary the width of the line by how much the trigger button is pressed in?
     
  18. davebuchhofer

    davebuchhofer

    Joined:
    Nov 9, 2007
    Posts:
    126
    Nevermind.. just needed to look a little further into the docs ! might be tricky though.
     
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Redraw the line, or use Draw3DAuto.

    You can use .lineWidth, should be pretty simple and not tricky. ;) If you want to change individual segments, then SetWidths will do it.

    --Eric
     
  20. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    When the transform moves along the spline, he slows down and speeds up. My guess is that this is due to difference in distance between nodes. Is there a way I can insure a constant speed?


    Also, can you explain why my line's texture is not pretty? Below are images of, the texture I am using (test texture). The line I am getting.

    Variables and settings I have been playing with for 48 hours are.... SetTexture, LineType, continuousTexture, segments, speed at which draw() is called.

    I just want a simple, evenly dispersed line of sprites.




     
    Last edited: Apr 16, 2013
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If you move the control variable evenly then the speed is even. See the demo spline follow example. For the texture see the demos that use SetTextureScale, and again, please read and follow the documentation, which thoroughly explains how it works. (Although I'm not really sure what you expect from that particular texture.)

    --Eric
     
  22. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Now i know why your "post counter" growing so fast. ;)
     
  23. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    Hi Eric. I've been playing with Vectrosity and love it.

    Currently I am trying to convert the following Unity Documentation example for spectrum data display which uses Debug.DrawLine at:
    http://docs.unity3d.com/Documentation/ScriptReference/AudioSource.GetSpectrumData.html

    I'm thinking Vectrosity might might be ideal for replacing the Debug.DrawLine but I can't seem to get it to behave. I've been trying with the myLine.Draw() function with myline.points. Should I maybe try MakeSpline.

    Am I going about this the wrong way? Any hints?

    Thanks!

    Paul
     
    Last edited: Apr 16, 2013
  24. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    I have read the diocumentation and will continue to do so. I just need a bit of help in fully getting it. Can you provide a better example? It seems an easy task. I think there is just a timy thing here or there that I dont get, I am hoping you can help me with that.


    By control variable in terms of evening speed. What do you mean "control variable"?

    And as far as the texture goes, yes, it is not much, it was just a test, with a sprite, on a sheet, texture, with a substantial empty area surrounding it. I am hoping to achive your average dotted line. That I am not getting. I set my setTexture() to values ranging from 1 - 1000, both size and offset both at start and just prior to any draw() yet they all pretty much have the same effect, no matter the settings.

    Code (csharp):
    1.  
    2. ////should this have a drastic effect?
    3. myLine.SetTexture(10,10);
    4. myLine.Draw();
    5.  
    Code (csharp):
    1.  
    2. ////ass it had about the same effect as this.
    3. myLine.SetTexture(100,100);
    4. myLine.Draw();
    5.  
     
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Draw() is correct. It's fairly simple to convert that code in the docs to use an array of points, and an array of colors, for use in a VectorLine, so a direct translation would be (with a fix for GetSpectrumData since it doesn't work like that anymore; seems the example code need to be updated):

    Code (csharp):
    1. import Vectrosity;
    2.  
    3. var spectrum : float[];
    4. var spectrumLine : VectorLine;
    5. var spectrumPoints : Vector3[];
    6. var spectrumColors : Color[];
    7.  
    8. function Start () {
    9.     spectrum = new float[1024];
    10.     spectrumPoints = new Vector3[spectrum.Length * 4 * 2];
    11.     spectrumColors = new Color[spectrum.Length * 4];
    12.     spectrumLine = new VectorLine("Spectrum", spectrumPoints, null, 1.0);
    13. }
    14.  
    15. function Update () {
    16.     audio.GetSpectrumData (spectrum, 0, FFTWindow.BlackmanHarris);
    17.     var pointIdx = 0;
    18.     var colorIdx = 0;
    19.     for (var i = 1; i < spectrum.Length-1; i++) {
    20.         spectrumPoints[pointIdx++] = Vector3(i - 1, spectrum[i] + 10, 0);
    21.         spectrumPoints[pointIdx++] = Vector3(i, spectrum[i + 1] + 10, 0);
    22.         spectrumColors[colorIdx++] = Color.red;
    23.         spectrumPoints[pointIdx++] = Vector3(i - 1, Mathf.Log(spectrum[i - 1]) + 10, 2);
    24.         spectrumPoints[pointIdx++] = Vector3(i, Mathf.Log(spectrum[i]) + 10, 2);
    25.         spectrumColors[colorIdx++] = Color.cyan;
    26.         spectrumPoints[pointIdx++] = Vector3(Mathf.Log(i - 1), spectrum[i - 1] - 10, 1);
    27.         spectrumPoints[pointIdx++] = Vector3(Mathf.Log(i), spectrum[i] - 10, 1);
    28.         spectrumColors[colorIdx++] = Color.green;
    29.         spectrumPoints[pointIdx++] = Vector3(Mathf.Log(i - 1), Mathf.Log(spectrum[i - 1]), 3);
    30.         spectrumPoints[pointIdx++] = Vector3(Mathf.Log(i), Mathf.Log(spectrum[i]), 3);                     
    31.         spectrumColors[colorIdx++] = Color.yellow;
    32.     }
    33.     spectrumLine.Draw();
    34.     spectrumLine.SetColors (spectrumColors);
    35. }
    That's not ideal since the colors don't actually change, so it would be better to make another loop in Start to set the colors using SetColors only once; that way it wouldn't need to be done every frame. Another possibility is to make 4 separate VectorLines with a different color for each.

    --Eric
     
  26. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The distance variable that you pass in to GetPoint.

    Can you please look at the provided dotted line examples and see how they work. Experiment with them to begin with before writing your own code, so you know that you're starting from a working base. By "SetTexture" I assume you mean "SetTextureScale", since there is no SetTexture function in Vectrosity. Make sure you understand the parameters, which I'm not sure you do judging from the fact that you used "10, 10" and "100, 100" as example input. The second parameter is the offset, so 1, 10, and 100 are effectively the same, not to mention all other whole numbers. See pages 21 and 22 in the docs, which have pictorial examples of the difference between using .5, 1, and 2 as the scale parameter (I doubt you would ever realistically use 10 or 100, though if you had a texture that was 10X as long as it was tall, then using 10 would be appropriate). It uses the simplest possible code in the example; I don't honestly know what else I could do to explain it.

    --Eric
     
  27. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    Fantastic! Thanks Eric.
     
  28. Pollerty

    Pollerty

    Joined:
    Feb 5, 2013
    Posts:
    4
    Hi Eric

    First of all I would like to say that I've enjoyed working with Vectrocity. It has done all I wanted from it so far, such as frustum representation on a minimap "speed lines", spline movement and other useful stuff.

    However I found something strange with Joins.Fill in Draw3D. If I give the vectorline an array and use a drawindex to update the line, it seems to want to do a fill between the current point and Vector3.zero. This is until the final point is reached. I have tried different approaches: rewriting the array entirely everytime, having unused points in Vector3.zero, having all unused points following currentpoint (which kinda negates the awesomeness of indexcontrolled updates), having the first and last point being both the same and different, and a mixture of these mentioned approaches.

    I looked through the source files, but Fill and Weld is handled so differently, that I couldn't really identify why Weld works and Fill don't. Here's an image of how it lookes in a quickly made script:

    https://www.dropbox.com/s/jv5tz66qz2x7t8g/Example_fill.png

    I have read both documentation and the code several times to figure out if I missed anything, and if so then I apologise. I also tried looking through this thread to see if anybody else mentioned it, but after the first 30 pages I gave up due to the slow loading times.

    FYI: I use Unity3 version of Vectrocity and v. 3.5.7f6 of Unity Pro
     
  29. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Are you using version 2.2 of Vectrosity? The issue you mention should be fixed in 2.2.

    --Eric
     
  30. Pollerty

    Pollerty

    Joined:
    Feb 5, 2013
    Posts:
    4
    Yes, we are using 2.2. Tried with both Unity3 DLLs and with source scripts.
     
  31. neoRiley

    neoRiley

    Joined:
    Dec 12, 2008
    Posts:
    148
    Worked for me too. I'd realized it had installed the Unity3 dll, I switched to the 4 dll, and still got the errors when building for iOS. Then saw this post to remove the DLL and use the source and bingo, it works. Thanks very much
     
  32. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Do you have a code snippet that shows the effect?

    Actually it works if you rename the DLL to just "Vectrosity" rather than "Vectrosity_Unity4"; that way you don't need to use the source.

    --Eric
     
  33. Pollerty

    Pollerty

    Joined:
    Feb 5, 2013
    Posts:
    4
    I still get the bug while using the source scripts. This is a sample of the code where the Vectorline stuff is going on. Am I missing anything?

    It should be said that I'm using an orthographic camera placed at 0,0,-10 looking towards z+. I am using Draw3D because I need to move the line object in space at some point (not in the code yet, so that's not the problem). Furthermore, this bug does not occur if I use a Vector2 array, but for obvious reasons I can't use them in my case.

    Code (csharp):
    1. void Start () {
    2.         maxDrawIndex = 1;
    3.         VectorLine.SetCamera3D();
    4.  
    5.  
    6.         linePoints = new Vector3[detectionPoints.Length];
    7.         linePoints[0] = detectionPoints[0];
    8.         linePoints[1] = detectionPoints[0];
    9.        
    10.         line = new VectorLine(objectName, linePoints, null, lineWidth, LineType.Continuous, Joins.Fill);
    11.        
    12.                 line.maxDrawIndex = maxDrawIndex;
    13.         line.Draw3D();
    14.     }
    15.  
    16. bool DrawLine() {
    17.                 //Make sure the point is always following a certain line
    18.         if(Vector3.Dot((mouseToWorld - linePoints[maxDrawIndex]).normalized, currentRay.direction) > 0)
    19.                 linePoints[maxDrawIndex] = MasterFunctions.PointOnLine(currentRay, mouseToWorld);
    20.            
    21.         if(MasterFunctions.DistancePointToLine(currentRay, mouseToWorld) > detectionLimit * 1.5f || Input.GetMouseButtonUp(0))
    22.         {
    23.             drawing = false;   
    24.             return false;
    25.         }
    26.        
    27.         float rayMag = (detectionPoints[maxDrawIndex] - detectionPoints[maxDrawIndex - 1]).magnitude;
    28.         float lineMag = (linePoints[maxDrawIndex] - linePoints[maxDrawIndex - 1]).magnitude;
    29.        
    30.                 //Moves to next indexnumber if linepiece is done
    31.         if(lineMag > rayMag)
    32.         {
    33.             linePoints[maxDrawIndex] = detectionPoints[maxDrawIndex];
    34.            
    35.             if(maxDrawIndex < linePoints.Length - 1)
    36.             {
    37.                 maxDrawIndex++;
    38.                 line.maxDrawIndex = maxDrawIndex;
    39.                 currentRay = new Ray(detectionPoints[maxDrawIndex - 1], (detectionPoints[maxDrawIndex] - detectionPoints[maxDrawIndex - 1]).normalized);
    40.                 linePoints[maxDrawIndex] = detectionPoints[maxDrawIndex - 1];
    41.                
    42.                
    43.             } else
    44.             {
    45.                 return true;
    46.             }
    47.         }
    48.        
    49.         return false;
    50.     }
     
    Last edited: Apr 22, 2013
  34. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The comments about source/DLL were in regards to the questions about iOS publishing. In any case, there is an issue with .maxDrawIndex and connecting to Vector3.zero with Joins.Fill; it seems I didn't entirely eradicate that bug. I did fix it with .drawEnd though, so you might be able to use .drawEnd instead of .maxDrawIndex.

    --Eric
     
  35. Pollerty

    Pollerty

    Joined:
    Feb 5, 2013
    Posts:
    4
    That did the trick! Thank you. I don't know why I didn't think about trying that in the first place.
     
  36. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    Hi Eric,
    using Unity 3.5.7f6 and Vectrosity 2.2, Vectrosity_Unity3, I can not build to XCode. Instead no build is completed in Unity and I get the error message that, "UnityException: Cross compilation failed."



    I noticed some issues mentioned previously in this thread with @CrazyRobot, however, I believe his fix, was related to using Unity4.0. Any ideas?

    Thanks.
     
  37. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Rename the DLL to "Vectrosity" rather than "Vectrosity_Unity3".

    --Eric
     
  38. steveyates

    steveyates

    Joined:
    Apr 24, 2013
    Posts:
    1
    Hi Eric,
    When building a fairly simple program to draw lines with the latest version of Vectrosity and Unity 4.1.2f1 for IOS I get this compiler error:
    Cross compilation job Assembly-UnityScript-firstpass.dll failed.
    UnityEngine.UnityException: Failed AOT cross compiler: /Applications/Unity/Unity.app/Contents/BuildTargetTools/iPhonePlayer/mono-xcompiler --aot=full,asmonly,nodebug,static,outfile="Assembly-UnityScript-firstpass.dll.s" "Assembly-UnityScript-firstpass.dll"

    The simple code is written in javascript - and I think that calling C# from javascript should be ok. Thanks in advance if you have any ideas,
    Steve
     
  39. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Rename the DLL the "Vectrosity" rather than "Vectrosity_Unity4" or anything else.

    --Eric
     
  40. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    Thank you,
    that seems to have done it.
     
  41. stefann

    stefann

    Joined:
    Jan 4, 2011
    Posts:
    17
    hi eric,
    i just updated my project from 2.1 to 2.2 and i have experienced a huge performance drop.
    my scene has about 550.000 points drawn in 3d. no further interaction or other scripts. no automatic updating enabled.
    in the unity explorer the performance is the same but on an iPad3 the framerate drops from about 23 to 3!!! (please see the attachments below EDIT: the first 2 images are 2.1, the second two are 2.2 /EDIT)

    the only modification i made was in version 2.1 in VectorLine.cs, line4:
    Code (csharp):
    1. #if UNITY_3_4 || UNITY_3_5 || UNITY_IPHONE
    everything else is as published by you. my code is completely the same in both versions. i tried with the .dll and with the source files. the behaviour is the same.

    please have a look at that problem.

    best,
    stefan
     

    Attached Files:

    Last edited: Apr 30, 2013
  42. ryleigh

    ryleigh

    Joined:
    Nov 9, 2010
    Posts:
    6
    I just bought Vectrosity and I'm running into a problem where a 3D circle I'm drawing is scaling with my screen resolution. I've tried to look through the documentation and see if this is intended, or if there is a way around it, but can't find anything. Basically, the width of the circle seems to be getting thicker as my screen size decreases.

    Is it trying to display at a constant size, regardless of my resolution, which is why it looks thicker at smaller screen sizes? If so, is there some way to turn get around that?
    Images: one, two, three, four

    Here's some code: http://pastebin.com/sWmDWpW4

    Thanks!
     
  43. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Not sure what would cause that, since nothing really changed with regard to how Vectrosity works for drawing lines. The only difference is that triangles are always used by default with Unity 4 now, so the modification that you made is no longer necessary in Vectrosity 2.2. If using Unity 4, you can turn hardware lines and points back on for 1-pixel lines (if you're sure your target platform supports them properly) by using VectorLine.useMeshLines = true and VectorLine.useMeshPoints = true. I finished a project a couple weeks ago that uses Vectrosity 2.2 pretty heavily and the performance is as expected on my iPod touch 5.

    Vectrosity uses pixels as the measurement for line width, so that's intended. If you want a line width that scales with screen resolution, you could come up with some formula for the width and use Screen.height in that calculation.

    --Eric
     
  44. stefann

    stefann

    Joined:
    Jan 4, 2011
    Posts:
    17
    Eric,
    I'm aware of what you explained. I'm using Unity 4 but on both versions I made sure that tringles are used as my iPad 3 had problems with pixel-perfect points as mentioned in an earlier post. So I didn't set useMeshPoints to true in 2.2 and I just added the code mentioned above in 2.1 to get the same behaviour.
    Is there any way you could check on an iPad3? Maybe this is a platform specific problem as I tried on two different devices. Unfortunately I don't have any other iOS device available.
    Thanks
     
  45. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I don't have an iPad 3, sorry. There isn't any speed difference on my iPod touch, though, and indeed the drawing method did not change at all, aside from what I mentioned above. Just to be sure I made a benchmark for drawing 16K points, and performance is essentially identical between Vectrosity 2.1 and 2.2.

    --Eric
     
  46. probbins

    probbins

    Joined:
    Oct 19, 2010
    Posts:
    216
    Hey Eric,

    Question 1

    I've been running into issues with the end caps. I am displaying the path of a moving object, when I use mirror or front it works fine and both caps show up.

    Code (csharp):
    1. VectorLine.SetEndCap("path", EndCap.Mirror, defaultPathDrawerProperties.material, defaultPathDrawerProperties.endcap);
    Code (csharp):
    1. VectorLine.SetEndCap("path", EndCap.Front, defaultPathDrawerProperties.material, defaultPathDrawerProperties.endcap);
    If I change it to back it wont appear.

    Code (csharp):
    1. VectorLine.SetEndCap("path", EndCap.Back, defaultPathDrawerProperties.material, defaultPathDrawerProperties.endcap);
    Any ideas? I am drawing these in 3d not 2d.

    Question 2

    When I create a spline I add the end cap

    Code (csharp):
    1. path.endCap = "path";
    2. path.Draw3DAuto();
    When I update the spline I have to do the same call again, otherwise I get a index out of range error. Is this intended?

    Question 3

    This is a bit of a tough question, so don't worry about it if its too big.

    I am currently using dashed line texture and the following code to animate it.

    Code (csharp):
    1. path.SetTextureScale(1, -Time.time * speed % 1);
    The way paths work is that its points on a hex tile board, but its constantly being updated each time it reaches the next tile, I am using the following code to hide points which is has currently progressed.

    Code (csharp):
    1. path.drawStart = (int)(segments * progress);
    2.  
    Unfortunately though it seems dashing / animation tends to jolt and reset a lot.

    Would you have a example of how this could be done more smoothly?

    I originally was just making the first point on the path the objects position, then the second point the first tile it was moving towards etc, but unfortunately the size of the line segments get smaller as it moves which again was messing up the animations;

    Suggestion
    When adding end caps it would be fantastic if there was a parameter which allowed you to centre the end cap on the stand and end points rather then being offset. For example I want to draw a large circle at the ends of my paths, I was hoping endcaps would solve this but unfortunately they get offset.
     
    Last edited: May 7, 2013
  47. vincgoh

    vincgoh

    Joined:
    Jan 8, 2013
    Posts:
    5
    Hi Eric,

    Question:
    I used a for loop calling a function to recreate a few lines joining some Nodes togethers like using Visio in one C# script and add a meshcollider to it. I used the 3D lines in the function:
    ...
    line.MakeSpline(mySplinePoints);

    line.Draw3D();

    When I click on one of the line, I used another script and can detect onClick to display the gameObject name. But since it is dealing with gameObject and not a Vectorline, how can I change the color of the clicked line to green.
     
  48. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    My idea is that I made a stupid mistake, and line 1790 of VectorLine.cs (it's in the CheckLine function) should use "ratio2" instead of "ratio1".

    Nope. Do you have an example that results in this error? I tried what you described and wasn't able to get an error.

    I'm not 100% clear on what you mean; if you had a video that would help. One thing I'd suggest, though, is to animate the texture using Material.MainTextureOffset rather than the SetTextureScale function. Use SetTextureScale only when the line is actually updated; that way it's more efficient.

    I'd actually had some thoughts about that same thing myself.

    How about using VectorLine.Selected() instead of making mesh colliders?

    --Eric
     
  49. LargerEagle

    LargerEagle

    Joined:
    Aug 15, 2012
    Posts:
    59
    Pretty Cool!
     
  50. davebuchhofer

    davebuchhofer

    Joined:
    Nov 9, 2007
    Posts:
    126
    Is there any plan to have a 3d version of VectorLine.Selected? (Before i start hacking my way into your code hehe.)

    I've been playing with this thing: http://buchhofer.com/2013/04/magic-carpet-ride-and-then-some/ which is a Razer Hydra (And optionally Rift) scene where you can draw lines in 3d space, just about everyone who's tried it has asked if I could set it up so that players could grab and move the lines, I guess I could do that with something like a loop thru the points and transform.TransformPoint() each one, but I just wanted to check and see if you had an easier idea before I start digging in
     
Thread Status:
Not open for further replies.