Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'm afraid I didn't understand that.

    --Eric
     
  2. Arun_Rajps

    Arun_Rajps

    Joined:
    Aug 25, 2010
    Posts:
    68
    Eric , i have the first person control prefab , Mini map camera , when i attach the graph script to first person control prefab, there i have to (Main camera)assign the Target Texture as RenderTexture, when game starts, its not showing the terrain , it only shows the Graph and Mini map .

    my question what i to code to the Vector.SetCamera(--------) to view my terrain and all things,
    or any thing else..??
    pl suggest me what i have to do...!!!

    thanks in advance,
    Arun
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'm still not really following, but maybe take a look at the camera clear flag values.

    --Eric
     
  4. Rush-Rage-Games

    Rush-Rage-Games

    Joined:
    Sep 9, 2010
    Posts:
    1,997
    Looks great!
     
  5. Arun_Rajps

    Arun_Rajps

    Joined:
    Aug 25, 2010
    Posts:
    68
    hi Eric,

    i have problem in on/off of vector line it shows the error of

    MissingFieldException: Field 'VectorLine.gameObject' not found.
    Boo.Lang.Runtime.PropertyDispatcherFactory.FindExtension (IEnumerable`1 candidates)
    Boo.Lang.Runtime.PropertyDispatcherFactory.Create (SetOrGet gos)
    Boo.Lang.Runtime.PropertyDispatcherFactory.CreateGetter ()
    Boo.Lang.Runtime.RuntimeServices.DoCreatePropGetDispatcher (System.Object target, System.Type type, System.String name)
    Boo.Lang.Runtime.RuntimeServices.CreatePropGetDispatcher (System.Object target, System.String name)
    Boo.Lang.Runtime.RuntimeServices+<>c__DisplayClassa.<GetProperty>b__9 ()
    Boo.Lang.Runtime.DispatcherCache.Get (Boo.Lang.Runtime.DispatcherKey key, Boo.Lang.Runtime.DispatcherFactory factory)
    Boo.Lang.Runtime.RuntimeServices.Dispatch (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, System.Object[] args, Boo.Lang.Runtime.DispatcherFactory factory) [0x00000]
    Boo.Lang.Runtime.RuntimeServices.Dispatch (System.Object target, System.String cacheKeyName, System.Object[] args, Boo.Lang.Runtime.DispatcherFactory factory) [0x00000]
    Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name)
    e_graph.grap1 () (at Assets/e_graph.js:128)
    e_graph.OnTriggerEnter (System.Object Collider) (at Assets/e_graph.js:236)


    function OnGUI()
    {
    //Display render tex
    }


    function grap1()
    {
    line1 = new VectorLine("Line", linePoints, lineMaterial,10.0,0.0, 4, LineType.Continuous, Joins.Open);
    Vector.DrawLine(line1);

    GameObject.Find("VectorCam").camera.targetTexture = renderTex;
    line1.gameObject.renderer.enabled =true;
    line2.gameObject.renderer.enabled =false;

    }

    function grap2()
    {
    line2 = new VectorLine("Line", linePoints, lineMaterial,10.0,0.0, 4, LineType.Continuous, Joins.Open);
    Vector.DrawLine(line2);

    GameObject.Find("VectorCam").camera.targetTexture = renderTex;
    line2.gameObject.renderer.enabled =true;
    line1.gameObject.renderer.enabled =false
    ;
    }

    // when the trigger is executed it calls the graph function and display in gui

    function OnTriggerEnter( Collider )
    {
    if(hit the temperature trigger)
    {
    grap1();
    }

    if(hit the energy trigerr)
    {
    grap2();
    }
    }

    pl help me what i have to make correction and point where i have to place the on/off of vector line function

    thanks in advance
    Arun
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Sorry, I meant "vectorObject" rather than "gameObject". So it would be "line1.vectorObject.renderer.enabled".

    --Eric
     
  7. Arun_Rajps

    Arun_Rajps

    Joined:
    Aug 25, 2010
    Posts:
    68
    hi , i used as like it, but it display only one graph for both readings, can you suggest me where i have to place the "line1.vectorObject.renderer.enabled". in graph function or trigger event or On GUI() function
    Now i am using in graph function()

    thanks
    arun
     
  8. CBif

    CBif

    Joined:
    Oct 3, 2010
    Posts:
    8
    Since I needed some 3D circles in my project I played around with the Vectrosity source to create them.

    $circle3d.PNG

    Actually, I just copied the "MakeEllipseInLine" method to "MakeEllipseInLine3D" and changed it to use points3 instead of points2 (and a Vector3 origin). Works great so far. Maybe that would be an affordable feature for upcoming versions of Vectrosity? Would definitely be nice, in my opinion. Maybe also Curve3D, for example.
     
  9. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That depends on what you want to do. If you don't mind I'd prefer to keep this topic focussed on Vectrosity and not turn it into a general programming help topic.

    That would be easy enough (as you discovered ;) ). I didn't really think about 3D uses of those functions, but it's cool to see where people go with this.

    --Eric
     
  10. 22

    22

    Joined:
    May 22, 2009
    Posts:
    63
    Hi, I made a try to compile and run the vectrosity under Unity3D iPhone Pro 1.7 and it does not work. I get the error message that the class name does not match the file name. This message is strange since it should only appear if I would be using C# code but vectrsity comes with JS.

    Is there a trick or special setting I have to use under Unity3D iPhone Pro 1.7?
    I already switched to .NET 2.1, but nothing changed.

    Am I the only one having such issues?

    Thanks
    Martin
     
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I seem to remember somebody getting that error for no apparent reason (in some other project not related to Vectrosity), and I think doing a reimport all might have fixed it. Vectrosity is actually written in C# (the example scripts are JS), but that error wouldn't occur in those scripts since the class names all match properly.

    --Eric
     
  12. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Hi. I made a small webplayer using Vectrosity 1.1. With some imagination (!) you can see some waves. The waves are actually 6 rows of lines, that rotate along the x and z axis. Here is the link :
    http://ippomed.com/wordpress/vector-sea
    $vectorSea.jpg

    The picture is 37kb and the app 76kb :)
     
    Last edited: Oct 8, 2010
  13. marty

    marty

    Joined:
    Apr 27, 2005
    Posts:
    1,170
    Heya, Eric! Have you officially released 1.1 yet? If so, where can I get a copy?
     
  14. Arun_Rajps

    Arun_Rajps

    Joined:
    Aug 25, 2010
    Posts:
    68
    hi eric , i having problem in hiding line
    my task is to show one graph when trigger is activated , when it moves to another trigger it have to display the the another graph
    i am using
    function Update()
    {
    if(i==1) // when first trigger is activated
    {
    line1.gameObject.renderer.enabled = true
    line2.gameObject.renderer.enabled =false;
    }
    if(i==2) //when second trigger is activated
    {
    line2.gameObject.renderer.enabled = true
    line1.gameObject.renderer.enabled =false;

    }

    the problem is it shows the two graph also when i was in second trigger event ..
    pl suggest me some idea..

    thanks in advance
    arun
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You need to use vectorObject rather than gameObject.

    It's sort of official...I still have to finish a download link system since it's now too big to email reliably. In the meantime, any Vectrosity 1.0 owners who want 1.1 can contact me. (So I'll send it over to you. :) )

    --Eric
     
    Last edited: Oct 9, 2010
  16. Arun_Rajps

    Arun_Rajps

    Joined:
    Aug 25, 2010
    Posts:
    68
    hi eric when i use the

    ine2.vectorObject.renderer.enabled = true;
    line1.vectorObject.renderer.enabled =false;

    it shows the error of Null Reference Exception : Object reference is not set to an instance of an object for the line of
    line1.vectorObject.renderer.enabled =false;

    thanks in advance
    Arun
     
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That means you haven't created the line.

    --Eric
     
  18. Arun_Rajps

    Arun_Rajps

    Joined:
    Aug 25, 2010
    Posts:
    68
    i have declared global as var line1 and using in graph function and making on/of in Update function()

    Thanks in advance
    Arun
     
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If you're getting a null reference exception that means you haven't created the line. Declaring a variable isn't enough.

    --Eric
     
  20. LeFishy

    LeFishy

    Joined:
    Feb 11, 2009
    Posts:
    87
    So. On some computers my walls are blue and my enemies are red. On others they are colour flipped. It's weird. Any ideas?
     
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Try turning off dynamic batching. From earlier posts, it sounds like a bug with vertex colors on Windows machines when dynamic batching is enabled.

    --Eric
     
  22. God-at-play

    God-at-play

    Joined:
    Nov 3, 2006
    Posts:
    330
    Have you done any performance comparisons with GL.LINES? I'm curious how this compares. Is that how GL.LINES is a worse alternative, as you mentioned earlier?

    Also, is the most recent version occludable by objects in the scene?
     
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    GL.LINES uses immediate mode, which among other things means it has to be re-drawn every frame. Whereas in Vectrosity the lines are actually meshes, so they only have to be re-drawn when the line or camera changes. (Although simple translation/rotation actually doesn't need redrawing either.)

    Yep.

    --Eric
     
  24. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    kampagner likes this.
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's pretty cool. Out of interest, would people generally prefer that the circle/curve/etc. functions work with 3D lines as well?

    --Eric
     
  26. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    I would love to see this, as well a function/example on how to to create "patches", ie surfaces (not volumes) from a closed curve / polyline. A simple triangle from a 3 point line would be perfect. Or a square. A function/example that lets an GameObject move along a path (curve/line) would also be very handy. Not so sure that I represent majority though :)
     
    Last edited: Oct 22, 2010
  27. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Actually I had this in mind myself.

    I think I'd prefer to keep the focus on drawing stuff; that would be kind of getting out of scope.

    --Eric
     
  28. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    298
    I've imported Vectrosity 1.1 into my project but now I'm getting lots of compiler errors with DrawCurve when I try to build.

    Assets/Scripts/Curve/DrawCurve.js(74,54): BCE0019: 'objectNumber' is not a member of 'UnityEngine.Component'.
    Assets/Scripts/Curve/DrawCurve.js(76,23): BCE0019: 'GetComponent' is not a member of 'UnityEngine.Object'.
    Assets/Scripts/Curve/DrawCurve.js(79,54): BCE0019: 'controlObject' is not a member of 'UnityEngine.Component'.
    Assets/Scripts/Curve/DrawCurve.js(94,52): BCE0019: 'controlObject' is not a member of 'UnityEngine.Component'.
    Assets/Scripts/Curve/DrawCurve.js(99,60): BCE0019: 'controlObject2' is not a member of 'UnityEngine.Component'.
    Assets/Scripts/Curve/DrawCurve.js(156,23): BCE0019: 'GetComponent' is not a member of 'UnityEngine.Object'.
    Assets/Scripts/Curve/DrawCurve.js(158,54): BCE0019: 'controlObject2' is not a member of 'UnityEngine.Component'.
    Assets/Scripts/Curve/DrawCurve.js(201,116): BCE0019: 'objectNumber' is not a member of 'UnityEngine.Component'.

    Any ideas what's wrong?
     
  29. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The DrawCurve example uses dynamic typing; it won't work as-is in Unity iPhone. Here's a version that has dynamic typing removed.

    View attachment $DrawCurve.js

    --Eric
     
    Last edited: Oct 25, 2010
  30. ej2009

    ej2009

    Joined:
    Mar 2, 2009
    Posts:
    353
    Hi,

    I'm making an iPad/iPhone game which has a big (64x64) )tile map. I need to display grid on top of tiles somehow, so thinking maybe Vectrosity could be best solution for grid lines.

    My main camera is orthographic and I allow to zoom in/out with pinch gesture. Is this possible to zoom in/out Vectrosity grid lines as well? Should I just redraw grid every time camera's orthographic size changes?

    I also allow to scroll tiles, but I move camera, so shouldn't be a problem?
     
  31. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yep, you'd redraw the grid when zooming in/out. When scrolling, you can move the line's transform instead of having to redraw it.

    --Eric
     
  32. ej2009

    ej2009

    Joined:
    Mar 2, 2009
    Posts:
    353
    Thanks Eric, will try this out!
     
  33. ej2009

    ej2009

    Joined:
    Mar 2, 2009
    Posts:
    353
    Quick question, how can I draw lines at desired Z coordinates?

    I have main camera at z = 0 and I draw tiles at z = 100. I also have GUI camera at 0 which shows all GUI elements at z = 10.

    I want to draw grid lines with Vectrosity at say z = 20 as at the moment it draws on top of everything.

    I tried setting VectorLine.transform.position to z = 20, but then grid disappeared, it only works when z = 0.

    Probably missing something very obvious, but can't see what. :)
     
  34. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If you have Vectrosity 1.1, use Vector.DrawLine3D. If you don't have Vectrosity 1.1, let me know and I'll send it to you. :)

    --Eric
     
  35. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    298
    That would be cool.

    I can't find the really nice example scene you did for Bezier Curves in the Demo Unity Package I've got. Any chance of getting this please?
     
    Last edited: Nov 2, 2010
  36. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's in the Curve section; if you open the Curve scene, you can uncheck the Simple Curve script on the main camera and check Draw Curve instead.

    --Eric
     
  37. Jon-Huhn

    Jon-Huhn

    Joined:
    Jan 26, 2009
    Posts:
    85
    Hi, Eric

    I've just purchased Vectrosity for the purpose of making a HUD that uses additive blending, since GUI elements can't do that.

    The issue I'm having is that when fog is turned on in the scene and the particle/additive shader is used as the vector material, the vector meshes disappear. My scene is scaled down to 1/100, so I've had to up the density of the fog in the scene alot to look correct at that small scale. This means that the vector meshes as seen through the vector cam are placed so far away from the camera (about 300 meters?) that they're deep in the fog, and apparently Unity isn't displaying them properly when an additive shader is applied.

    Would it be possible in your next release to add a feature allowing the distance from the vector cam to the vector meshes to be set by the developer? This way I could set it to be a small distance, bringing the vector meshes out of the fog and allowing the additive shaders to display correctly.

    Thanks!
     
  38. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, the z distance needs to be a specific number based on the screen height in order for the line coords to work (this way I can just use Vector2 coordinates directly instead of wasting CPU time with ScreenToWorldPosition calculations). However, you can either modify the shader that the vector lines are using to include {fog mode off}, or else you could use this script to turn fog off per-camera.

    --Eric
     
    Last edited: Nov 12, 2010
  39. Jon-Huhn

    Jon-Huhn

    Joined:
    Jan 26, 2009
    Posts:
    85
    I used the per camera fog-disabling script you mentioned, and now it works great. I did have to modify the line " RenderSettings.fog = enabled;
    " to read " RenderSettings.fog = false;", but now it's good.

    Thanks!
     
  40. Samuel

    Samuel

    Joined:
    Nov 14, 2010
    Posts:
    7
    Eric, I'm sure this has been asked before, But the search function in this forum is....

    Extracting the VectrosityScript zip freaks out vista and it will block access to the script files. If you can tell me how to get trough this or I could PM you the paypal TransactionID so you can email me a link to the file or something.

    Thanks.
     
  41. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Actually no, this is the first time I've heard of anyone having problems with unzipping. They were compressed with a bog-standard zip command, so there's nothing special about the archive. I'd suggest trying a different unzip utility. Also, you can import the VectrosityDemos package into a project, in which case the scripts will be in Standard Assets/Vector Scripts. These are exactly the same as the VectrosityScripts archive; the archive was included as just another way of getting the scripts if you didn't want to import the demos package.

    If you still need help, send me a PM.

    --Eric
     
  42. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    I'm using Vectrocity as part of my level editor -- draw lines to make custom meshes. It works great, but I'm wondering how you'd recommend getting the cameras to line up so that everything matches up. I'm using an orthographic camera for rendering the meshes but the vectorcam uses a perspective cam (and simply switching to orthographic messes with the relation to mouse position) -- what do you think the easiest way to align the two cameras would be? For what it's worth, I don't think I'll need to render 3D lines in this project so it's okay if that functionality breaks.
     
  43. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Interestingly I was just considering an option for using an orthographic camera for the vectorcam. I haven't looked at it in-depth yet, but it should be just a matter of changing the SetCamera function to use an orthographic camera, so you'd remove cam.fieldOfView and replace that with cam.orthographicSize. I think .orthographicSize would be set to Screen.height/2? Not sure offhand; will have to experiment.

    --Eric
     
  44. Samuel

    Samuel

    Joined:
    Nov 14, 2010
    Posts:
    7
    I don't think it is related to the zip itself as it complains about the BoundsMaker.js.

    Anyway, got it working now by importing the demo as you suggested. looks amazing!
    Thank you.
     
  45. God-at-play

    God-at-play

    Joined:
    Nov 3, 2006
    Posts:
    330
    I'm having trouble with SetColor. It doesn't seem to be working for me at all right now. I have this code, which updates curves that go from one object to another:

    Code (csharp):
    1. foreach (Connection con in connections)
    2. {
    3.     con.line.points3 = UpdateCurve(con.fromID, con.toID);
    4.            
    5.     Vector.DrawLine(con.line);
    6.     Vector.SetColor(con.line, Color.black);
    7. }
    The curve position gets updated correctly, but none of my lines ever turn black.
     
  46. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Are you using a material that has a shader which uses vertex colors? Such as the Particle shaders, or a custom shader which has support for vertex colors.

    If you're not using vertex colors and want to change the color of a line's material, you can use line.vectorObject.renderer.material.color = Color.black;

    --Eric
     
  47. God-at-play

    God-at-play

    Joined:
    Nov 3, 2006
    Posts:
    330
    Oh I see, I guess I misunderstood. I was using a material based on the Unlit shader, but I guess that won't work right.
     
  48. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yeah, with Unlit, you'd use the "line.vectorObject.renderer.material.color = Color.black" technique.

    --Eric
     
  49. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Yeah orthographicSize of Screen.height/2 works :)

    I'd much prefer to be able to set orthographicSize to any value though -- how would I get the mouse to play nice at any orthographicSize?
     
    Last edited: Nov 16, 2010
  50. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I can't begin to think of any reason for that, but I'm glad you've got it sorted anyway. :)

    Well, in order to set orthographicSize to an arbitrary value, the drawing routines would have to be rewritten, since they depend on being able to directly use Vector2 values for much of the speed (no converting needs to be done). So the size does need to be Screen.height/2 as far as I know. What issues are there with the mouse?

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