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
    You mean the VectorLines script? I just tried that with a default screen camera switched to orthographic, and seems to work the same as before.

    --Eric
     
  2. mythicwave

    mythicwave

    Joined:
    Jul 13, 2008
    Posts:
    144
    Yes, that's what I mean. I just created a new project, added the script to the camera and it worked. When I switched to orthographic, it didn't work...
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Hmm, works here; not sure what could be wrong.

    --Eric
     
  4. mythicwave

    mythicwave

    Joined:
    Jul 13, 2008
    Posts:
    144
    Dunno. I'll try again. I'm using Unity Pro 2.6 in Windows. Maybe you can post a project? I usually use C#.

    -- Brian
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    All I did was copy the code from the VectorLines page into a script and put it on the camera in an empty scene. If it works with a non-orthographic camera I can't imagine why it wouldn't work on an orthographic camera.

    --Eric
     
  6. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    And now it's time for something completely different. Ellipses. This script should be attached to main camera.
    Once selected in the Hierarchy panel, its properties are exposed i the Inspector. Hit play. Tweak the properties and hit the Go button. The xcenter and ycenter refers to screen coordinates. SemiMajorAxis and semiMinorAxis are points that refer to the center of the ellipse and denote the biggest and the smallest diameter.
    Refer to the attached image for a visual explanation of the parameters.

    Code (csharp):
    1. // Elipse function by Bournellis Ippokratis, for Vectrosity.
    2. // Just for fun, no optimisations.
    3. // Play with the properties that are exposed in the editor
    4. // And hit go
    5.  
    6. var lineMaterial : Material;
    7. var semiMinorAxis : Vector2;
    8. var semiMajorAxis : Vector2;
    9. var xcenter : int;
    10. var ycenter : int;
    11. var myEllipse : VectorLine;
    12.  
    13. function Ellipse (xcenter : int, ycenter : int, semiMinorAxis: Vector2, semiMajorAxis : Vector2) {
    14.     // Create a javascript array to hold the points of the ellipse
    15.     var pointsArray = new Array();
    16.     // Calculate each point of the ellipse. Inefficient but fun.
    17.     for (var theta : float = 0; theta < (3 * Mathf.PI); theta += 0.01)
    18.     {    x = xcenter + semiMinorAxis.x * Mathf.Sin(theta) + semiMajorAxis.x*Mathf.Cos(theta);
    19.          y = ycenter + semiMinorAxis.y * Mathf.Sin(theta) + semiMajorAxis.y*Mathf.Cos(theta);
    20.          pointsArray.Push (Vector2 ( x, y ));
    21.     }  
    22.     // Copy the data from the javascript array to a Vector2 array
    23.     var ellipsePoints : Vector2[] = pointsArray.ToBuiltin ( Vector2 );
    24.     return ellipsePoints;
    25. }  
    26.  
    27. function Start () {
    28.     // Set up the vector object camera (using the camera tagged "Main Camera" by default)
    29.     Vector.SetCamera();
    30. }
    31.  
    32. function OnGUI() {
    33.     // If the go button is pushed
    34.     if (GUI.Button(Rect(20, Screen.height-40, 30, 20), "Go")) {
    35.         // Destroy pre-existing ellipses (if any)
    36.         Vector.DestroyLine(myEllipse);
    37.         // Get the points of the ellipse
    38.         var linePoints = Ellipse ( xcenter, ycenter, semiMinorAxis, semiMajorAxis );
    39.         // Connect them
    40.         myEllipse = new VectorLine ( "myEllipse", linePoints, Color.white, lineMaterial, 3, 0,
    41.                   1, LineType.Continuous, Joins.Fill); 
    42.     }      
    43. }
    44.    
    45. function LateUpdate(){
    46.     // If there is an ellipse object
    47.     if(myEllipse){
    48.     // Draw it 
    49.     Vector.DrawLine(myEllipse);
    50.     }              
    51. }
     

    Attached Files:

  7. Grune

    Grune

    Joined:
    Nov 8, 2009
    Posts:
    136
    could be could effect when entering a "cyberspace mode"
    from within a normal looking game ;)
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Excellent; I was just thinking about ellipses. :)

    --Eric
     
  9. LeFishy

    LeFishy

    Joined:
    Feb 11, 2009
    Posts:
    87
    Ok I'm pretty sure that vectorlines will not be occluded by objects in the worldspace but I thought I'd just make sure that is correct. It'd be really nice for me if they are.
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Not currently, but I do have a method for achieving that, so it should be in the next version.

    --Eric
     
  11. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    It took me some days ( my math are worse than my programming skills) but I managed to create an interactive cubic bezier curve with Vectrosity.
    Follow the link for the web player:
    http://ippomed.com/bezier.html
    I will post the code in Tuesday, have to tide it up a little first.
     

    Attached Files:

  12. Tinus

    Tinus

    Joined:
    Apr 6, 2009
    Posts:
    437
    This is looking excellent guys. Looking forward to building some diegetic user interface elements with it, such as trajectory visualisation, visualising airflow, etc. :)

    Edit: Oh hey, it's cheap! I don't think I'll be able to resist that paypal button now.
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Do not resist the paypal button...it is calling for you...do not resist...you must click...resistance is futile.... ;)

    Good job with the bezier curve!

    --Eric
     
  14. dannyflint

    dannyflint

    Joined:
    Mar 12, 2010
    Posts:
    28
    Hi guys, I just bought and tried to bring into Unity iPhone but just get this error:

    Assets/Standard Assets/VectorScripts/VectorManager.cs(95,20): error CS8025: Parsing error

    Any thoughts?

    Thanks in advance

    Danny

    ps And I get about 20 of these:

    Couldn't load the script "RotateAroundY" because its file name doesn't match the class name.
    Please make sure the file name of the script is the same as the class defined inside it.
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Make sure you read the page in the docs about Unity iPhone (second-to-last page).

    That's a spurious error that should go away when you take care of the iPhone requirements. (Frequently cascading errors are meaningless; take care of the first ones first.)

    --Eric
     
  16. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Nice that you got a bezier working but it seems really slow?
     
  17. bumba

    bumba

    Joined:
    Oct 10, 2008
    Posts:
    358
    wow really cool. If you would add an example how to make a iPhone Line drawing games like Flight Control with it i would immediately buy it
     
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I don't see any lag or anything here, and I have a 6-year-old G5 so I doubt it's a case of my CPU being particularly cutting edge. ;)

    The DrawLines example is pretty close to that already. Just replace mouse clicking with touch input, and have it be polled a number of times per second, and that should pretty much do it I think.

    --Eric
     
  19. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Here is the code of the bezier curve as promised. I think that it is more flexible to use matrices, it will take a while until I figure out how this works though.
    Any suggestions are welcome
    Code (csharp):
    1. // Bezier function by Bournellis Ippokratis, for Vectrosity.
    2. // Just for fun, no optimisations.
    3. // Make 4 GUI Textures and paste on them the Draggable GUI Element from the wiki
    4. // While the program runs, drag them with the mouse to modify the curve
    5. // Based on the code found here [url]http://www.paultondeur.com/2008/03/09/drawing-a-cubic-bezier-curve-using-actionscript-3/[/url]
    6.  
    7. var lineMaterial : Material;
    8.  
    9. // Assign a GUI Texture object to each of the following vars
    10.  
    11. var anchor1T : Transform;
    12. var anchor2T : Transform;
    13. var control1T : Transform;
    14. var control2T : Transform;
    15.  
    16. //
    17. var anchor1 : Vector3;
    18. var anchor2 : Vector3;
    19. var control1 : Vector3;
    20. var control2 : Vector3;
    21.  
    22. var myCurve : VectorLine;
    23.  
    24. function Curve (anchor1 : Vector2, anchor2 : Vector2, control1 : Vector2, control2 : Vector2)  {
    25.     // Create a javascript array to hold the points of the curve
    26.     var pointsArray = new Array();
    27.    
    28.     // Calculate each point of the curve.
    29.     for (var theta : float = 0; theta < 1; theta += 0.01)
    30.     {
    31.         var theta3 : float = theta*theta*theta;
    32.         var theta2 : float = theta*theta;    
    33.        
    34.         var x : float  =  theta3 * ( anchor2.x + 3 * ( control1.x - control2.x) - anchor1.x )
    35.         + 3 * theta2 * ( anchor1.x - 2 * control1.x + control2.x )
    36.         + 3 * theta * ( control1.x - anchor1.x )
    37.         + anchor1.x;   
    38.        
    39.         var y : float  =  theta3 * ( anchor2.y + 3 * ( control1.y - control2.y) - anchor1.y )
    40.         + 3 * theta2 * ( anchor1.y - 2 * control1.y + control2.y )
    41.         + 3 * theta * ( control1.y - anchor1.y )
    42.         + anchor1.y;
    43.  
    44.         pointsArray.Push (Vector2 ( x, y ));
    45.     }  
    46.     // Copy the data from the javascript array to a builtin Vector2 array
    47.     var curvePoints : Vector2[] = pointsArray.ToBuiltin ( Vector2 );
    48.     return curvePoints;
    49. }  
    50.  
    51. function Start () {
    52.     // Set up the vector object camera (using the camera tagged "Main Camera" by default)
    53.     Vector.SetCamera();
    54. }
    55.    
    56. function LateUpdate(){
    57.    
    58.     // Translate the positions of the GUI Textures from Viewport coordinates
    59.     // to Screen Coordinates
    60.     anchor1 = Camera.mainCamera.ViewportToScreenPoint(anchor1T.position);
    61.     anchor2 = Camera.mainCamera.ViewportToScreenPoint(anchor2T.position);
    62.     control1 = Camera.mainCamera.ViewportToScreenPoint(control1T.position);
    63.     control2 = Camera.mainCamera.ViewportToScreenPoint(control2T.position);
    64.    
    65.     // Destroy the curve that was created in the last Late Update frame
    66.     Vector.DestroyLine(myCurve);
    67.    
    68.     // Get the points of the curve
    69.     var linePoints = Curve (anchor1, anchor2, control1, control2);
    70.    
    71.     // Connect them
    72.     myCurve = new VectorLine ( "myCurve",  linePoints, Color.red, lineMaterial, 2, 0,
    73.             0, LineType.Continuous, Joins.Fill);   
    74.     // Draw the curve  
    75.     Vector.DrawLine(myCurve);
    76.                  
    77. }
    78.  
    Could you please be a little more specific ?
    Your post made me curious since I tried the 'Dinosaur' option in the Graphics Emulation section and haven't noticed any lag.
     
  20. LeFishy

    LeFishy

    Joined:
    Feb 11, 2009
    Posts:
    87
    Just started my first project using this and I have to say I really like it. Very little work is added to the scripting side of things thanks to VectorManager and it means I don't have to beat my friend into creating art assets for me, haha.

    The one hiccough I had was that I did not realise the coordinate system was local for 3D vector objects.

    Then again we've seen how observant and quick to work things out I am.
     
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Cool, glad it's working well for you.

    --Eric
     
  22. Mathieu

    Mathieu

    Joined:
    Jun 13, 2005
    Posts:
    103
    Very nice work Eric!
    Drawing lines on Unity iPhone can be useful :)
     
  23. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    Eric, would you know how to make it so that a line segment would be drawn around the silhouette of a 3D model? Outlining the model.
     
  24. Vert

    Vert

    Joined:
    Mar 23, 2010
    Posts:
    1,099
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yeah, I'd suggest the toon shader too...maybe it can be done programmatically but I don't know how.

    --Eric
     
  26. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    My hope for getting it to draw a line segmet around the sillhouette was so that I could then put a texture on that line segment for a pseudo glow effect. Not just a straight toon outline.
     
  27. bergerbytes

    bergerbytes

    Guest

    Purchased :D

    I'm going to use this in a game I'm developing for iPad. =]

    Now to figure it out....

    -Mike
     
  28. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Nifty...if it's not figure-outable what with the docs and examples and stuff, then I dunno what to do. ;) (Other than answer questions here if you have any, of course!)

    --Eric
     
  29. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521

    Attached Files:

  30. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    ...or maybe someone like Ippokratis would pop up with some tutorials. ;)

    --Eric
     
  31. Lord_Pall

    Lord_Pall

    Joined:
    Sep 25, 2009
    Posts:
    52
    Any pointers on how to track down mangled 3d lines? I tried the external text assets, but switched because of the warning about corrupt files.

    I grabbed the coordinates using linemaker, and they look right, but no matter what I do, the objects come out munged. In fact, the points seem to have no bearing on what I actually see...

    I assume I'm doing something silly, but I just don't see it right now.

    Example code that I run in Start

    Code (csharp):
    1.        Vector3[] points = { new Vector3(-1078.821f, 0f, -271.874f), new Vector3(-1078.765f, 0f, -272.052f), new Vector3(-1078.765f, 0f, -272.052f), new Vector3(-1060.977f, 0f, -266.216f), new Vector3(-1060.977f, 0f, -266.216f), new Vector3(-1078.821f, 0f, -271.874f), new Vector3(-1078.765f, 0f, -272.052f), new Vector3(-1060.92f, 0f, -266.395f), new Vector3(-1060.92f, 0f, -266.395f), new Vector3(-1060.977f, 0f, -266.216f), new Vector3(-1133.25f, 0f, -206.004f), new Vector3(-1133.907f, 0f, -206.552f), new Vector3(-1133.907f, 0f, -206.552f), new Vector3(-1078.464f, 0f, -271.689f), new Vector3(-1078.464f, 0f, -271.689f), new Vector3(-1133.25f, 0f, -206.004f), new Vector3(-1133.907f, 0f, -206.552f), new Vector3(-1079.121f, 0f, -272.237f), new Vector3(-1079.121f, 0f, -272.237f), new Vector3(-1078.464f, 0f, -271.689f), new Vector3(-1153.662f, 0f, -228.203f), new Vector3(-1153.441f, 0f, -228.403f), new Vector3(-1153.441f, 0f, -228.403f), new Vector3(-1133.689f, 0f, -206.178f), new Vector3(-1133.689f, 0f, -206.178f), new Vector3(-1153.662f, 0f, -228.203f), new Vector3(-1153.441f, 0f, -228.403f), new Vector3(-1133.468f, 0f, -206.378f), new Vector3(-1133.468f, 0f, -206.378f), new Vector3(-1133.689f, 0f, -206.178f), new Vector3(-1181.744f, 0f, -242.426f), new Vector3(-1181.601f, 0f, -242.707f), new Vector3(-1181.601f, 0f, -242.707f), new Vector3(-1153.623f, 0f, -228.163f), new Vector3(-1153.623f, 0f, -228.163f), new Vector3(-1181.744f, 0f, -242.426f), new Vector3(-1181.601f, 0f, -242.707f), new Vector3(-1153.48f, 0f, -228.444f), new Vector3(-1153.48f, 0f, -228.444f), new Vector3(-1153.623f, 0f, -228.163f), new Vector3(-1181.452f, 0f, -242.567f), new Vector3(-1181.893f, 0f, -242.567f), new Vector3(-1181.893f, 0f, -242.567f), new Vector3(-1181.452f, 0f, -286.707f), new Vector3(-1181.452f, 0f, -286.707f), new Vector3(-1181.452f, 0f, -242.567f), new Vector3(-1181.893f, 0f, -242.567f), new Vector3(-1181.893f, 0f, -286.707f), new Vector3(-1181.893f, 0f, -286.707f), new Vector3(-1181.452f, 0f, -286.707f), new Vector3(-1181.526f, 0f, -286.206f), new Vector3(-1181.818f, 0f, -287.208f), new Vector3(-1181.818f, 0f, -287.208f), new Vector3(-1081.258f, 0f, -315.419f), new Vector3(-1081.258f, 0f, -315.419f), new Vector3(-1181.526f, 0f, -286.206f), new Vector3(-1181.818f, 0f, -287.208f), new Vector3(-1081.55f, 0f, -316.422f), new Vector3(-1081.55f, 0f, -316.422f), new Vector3(-1081.258f, 0f, -315.419f), new Vector3(-1051.189f, 0f, -279.077f), new Vector3(-1051.559f, 0f, -278.777f), new Vector3(-1051.559f, 0f, -278.777f), new Vector3(-1081.219f, 0f, -316.071f), new Vector3(-1081.219f, 0f, -316.071f), new Vector3(-1051.189f, 0f, -279.077f), new Vector3(-1051.559f, 0f, -278.777f), new Vector3(-1081.589f, 0f, -315.771f), new Vector3(-1081.589f, 0f, -315.771f), new Vector3(-1081.219f, 0f, -316.071f), new Vector3(-1060.885f, 0f, -266.257f), new Vector3(-1061.012f, 0f, -266.353f), new Vector3(-1061.012f, 0f, -266.353f), new Vector3(-1051.311f, 0f, -278.879f), new Vector3(-1051.311f, 0f, -278.879f), new Vector3(-1060.885f, 0f, -266.257f), new Vector3(-1061.012f, 0f, -266.353f), new Vector3(-1051.437f, 0f, -278.975f), new Vector3(-1051.437f, 0f, -278.975f), new Vector3(-1051.311f, 0f, -278.879f) };
    2.        l = new VectorLine("f", points, lineColor, lineMaterial, 1);
    3.        VectorManager.ObjectSetup(gameObject, l, Visibility.Always, Brightness.Normal);
     
  32. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    This is what I get, with the camera at <-1100, 150, -260> looking down. What is it supposed to look like? (It's probably better in general if it was modeled around the origin, unless of course there's a specific reason not to.)

    --Eric
     

    Attached Files:

  33. ipad

    ipad

    Joined:
    Apr 4, 2010
    Posts:
    27
    Mark it... tank!shoot!
     
  34. GeneralGrant

    GeneralGrant

    Joined:
    Jun 10, 2010
    Posts:
    977

    awesome name.
     
  35. Lord_Pall

    Lord_Pall

    Joined:
    Sep 25, 2009
    Posts:
    52
    Hmm. That's correct actually.

    I was having difficulty viewing it. It seems like it was so far away from the core camera that it ended up all smeared and stretched, even though the representation was not actually horked.

    In case anyone was wondering, it's greenland.

    Thanks for checking it out. I was tearing out my hair, and never thought that it was something as simple as a camera problem..
     
  36. Lord_Pall

    Lord_Pall

    Joined:
    Sep 25, 2009
    Posts:
    52
    The docs suggest that you can make a large array of points for a line, but only use the first few for a dynamically changing line.

    I tried this using vector3's, and I'm getting a line that draws to 0,0,0 even though I haven't initialized those points.

    So points 1 and 2 are set, points 3 through N are not. once I pass a time threshold, I initialize point 3, and so on.

    It's there to draw a continual trajectory as something travels through the world.

    Is this incorrect? Should I be doing this a different way? Creating/Destroying lines every frame?
     
  37. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Vector3s are set to 0,0,0 when not initialized (they're structs). You may want to look in the DrawLines example script for what I did in a case similar to that...basically I have all the colors set to invisible initially, so even though the line is connecting to 0,0,0, you don't see it.

    Another possibility would be to set all points from the current point to the end as the current point, i.e. point 1 is say <.1, .2, .3>, point 2 is <.5, .5, .5>, and make points 3 through N the same as point 2. When you add point 3, then make points 4 through N the same as point 3. The invisible thing is faster and easier though.

    A third possibility would be to use a discrete line instead of a continuous line, since you don't have the "connecting to 0,0,0" problem in the first place. However it would take more points to accomplish the same line.

    --Eric
     
  38. Lord_Pall

    Lord_Pall

    Joined:
    Sep 25, 2009
    Posts:
    52
    Got it. Used the color trick. Had a bit of a confusing time because I forgot to use the Vector.SetColors call, but after that, it works like a champ.


    I swapped over to OSX to try this all under the simulator and am hitting a weird error.

    I have my editor scripts for Vectrosity in:

    /Lines/Assets/Editor

    BoundsMaker.js and LineMaker.js

    I am getting a bunch of compile errors when I open the project under Unity Iphone:

    Assets/Editor/BoundsMaker.js(14,34): BCE0019: 'SaveFilePanelInProject' is not a member of 'UnityEditor.EditorUtility'. Did you mean 'SaveFilePanel' ?
    Assets/Editor/LineMaker.js(68,76): BCE0019: 'sharedMaterial' is not a member of 'UnityEngine.Component'.
    Assets/Editor/LineMaker.js(71,57): BCE0019: 'material' is not a member of 'UnityEngine.Component'.
    Assets/Editor/LineMaker.js(189,58): BCE0019: 'instanceIDs' is not a member of 'UnityEditor.Selection'.
    Assets/Editor/LineMaker.js(204,58): BCE0019: 'instanceIDs' is not a member of 'UnityEditor.Selection'.
    Assets/Editor/LineMaker.js(367,34): BCE0019: 'systemCopyBuffer' is not a member of 'UnityEditor.EditorGUIUtility'.
    Assets/Editor/LineMaker.js(383,42): BCE0019: 'SaveFilePanelInProject' is not a member of 'UnityEditor.EditorUtility'. Did you mean 'SaveFilePanel' ?
    Assets/Editor/LineMaker.js(436,66): BCE0019: 'material' is not a member of 'UnityEngine.Component'.

    I'm fairly confident these aren't Vectrosity errors and are in fact issues with where the JS files are located in the OSX projects, but I haven't a clue how to fix it.. Any ideas?
     
  39. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yeah, as the docs note, the editor scripts don't work with Unity iPhone. You can just remove them for now; Unity 3 will fix that problem.

    --Eric
     
  40. Lord_Pall

    Lord_Pall

    Joined:
    Sep 25, 2009
    Posts:
    52
    Keen. I just found the mention in the docs. Sorry for the confusion.

    Still waiting for my 3.0 beta invite (HINT HINT UNITY FOLKS)
     
  41. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    198
    hey, i bought Vetrosity because i think i might find a use for it in several projects...

    I do have some problems making it look how i desire tho'.

    Maybe someone can help me out ,i'm sure i'm overlooking something very basic.

    First off, i want the look of hanging computercables.
    I have the code done, the cables can be dragged with the mouse and connected to sockets - just like how its done in 'Reason'
    http://stuff.tv/csfiles/blogs/music/reason.jpg

    Check that that picture link to see what i'm aiming at.

    I tried the included shaders and all standard unity shaders, but it seems i'm having big problems getting the 'cable' look...

    Anyone can help me ?

    EDIT: i found a bug using the lineMaker script. I changed the variable in the script to useCsharp = true because i'm obviously using c#...
    then when i make the line ,it copies the data to the clipboard, i paste it to Ms Visual c# and i get something like this:
    new Vector3(-0,5f, -0,5f, 0,5f), new Vector3(0,5f, -0,5f, 0,5f), new Vector3(0,5f, -0,5f, 0,5f), new Vector3(-0,5f, 0,5f, 0,5f), new Vector3(-0,5f, 0,5f, 0,5f), etc...

    So isntead of putting 3 values in a Vector3 ,it puts 6.
    example : first value is -0,5f -which should be 0.5f.

    This is easy fixable with small arrays but with large arrays this becomes very anoying and eat a lot of time. Do you think you can fix this ?
     
  42. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'm not actually sure Vectrosity is really the best choice for making 3D shapes like cables. It's intended more for 2D sorts of overlay lines.

    I would guess your localization settings are doing this. If I use it on my U.S. system, I get "new Vector3(-0.5f, -0.5f, 0.5f)".

    --Eric
     
  43. tatelax

    tatelax

    Joined:
    Feb 4, 2010
    Posts:
    1,168
    Wow this is very good. Must have taken a long time to make.
     
  44. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    198
    I'm using default European/Belgium settings and keyboard. I never had this problem in unity before,for the rest i dont know.

    I got the look i desired by adding a second cable. Having a slightly larger black cable in the background of the actual colored cable gives the desired effect.

    Now i got one more problem i'm afraid i have to work around.
    I'm using this on my hud, cables connecting hud components.

    My hud is made in OnGUI,which renders on top of everything. Is there a way that i don't know of to render the cables on top of the gui ? If not i would have to make gui parts in a guitexture but i was hoping i didn't have to do that.
     
  45. ej2009

    ej2009

    Joined:
    Mar 2, 2009
    Posts:
    353
    How is Vectrosity's performance on iPhone? Can you draw few hundred lines without big performance hit?
     
  46. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Thanks. :) Yep, it wasn't thrown together in an evening....

    You can try putting

    Code (csharp):
    1. System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
    in a function like CreateWizard or Initialize; see if that changes things.

    Yeah, I'm afraid nothing in the universe can render on top of OnGUI. The only way around that is to become a UT employee with access to the source code and change the OnGUI system somehow.

    You can draw some hundreds of line segments (500+) on a 2G touch very smoothly. That's if they're updating every frame...if you have static line segments that don't need to update all the time, then the limit is much higher.

    --Eric
     
  47. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    198
    That worked ! Maybe you wana change that in your script ? i put it in Initialize and it works flawless now - Thanks again !
     
  48. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Cool, but I wonder if just changing it is the right thing to do in all cases. Maybe a "usePeriodForDecimal" variable?

    --Eric
     
  49. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    198
    yeh or just add it in the docs pdf with the notes or something. If you got the floating point/decimal problem - do this... that should be enough
     
  50. ej2009

    ej2009

    Joined:
    Mar 2, 2009
    Posts:
    353
    Just purchased Vectrocity, have a first stupid question :)

    How do I draw grid when using orthographic camera? I've "borrowed" grid drawing code from your website and converted it to C#.

    It draws grid alright, but it's not visible in game view, but visible in scene view.

    I've never used orthographic camera before so maybe I'm just missing something obvious.

    My goal is to have a simple 2D plane with grid on top of it.
     
Thread Status:
Not open for further replies.