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

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

    CHPedersen

    Joined:
    Mar 2, 2011
    Posts:
    63
    Aha! :-D That's awesome. I'll be looking forward to the 2.3 update email then. ;)
     
  2. CHPedersen

    CHPedersen

    Joined:
    Mar 2, 2011
    Posts:
    63
    Okay, I've almost got this working perfectly. :) I'm not on Vectrosity 2.3 yet (obviously), so the rendering is with a perspective cam. I realize 2.2 is out, but this is actually from Vectrosity 2.1. When rendering points to the specific pixels in the RenderTexture, I'm noticing something funny that I thought I'd swing by you. For test purposes, I'm basically doing this:

    Code (csharp):
    1.         RenderTexture dataRenderTexture = new RenderTexture(512, 512, 0, RenderTextureFormat.ARGBHalf);
    2.         dataRenderTexture.anisoLevel = 0;
    3.         dataRenderTexture.filterMode = FilterMode.Point;
    4.         dataRenderTexture.useMipMap = false;
    5.         dataRenderTexture.wrapMode = TextureWrapMode.Clamp;
    6.         dataRenderTexture.Create();
    Code (csharp):
    1.     private void RenderTestPoint()
    2.     {
    3.         VectorPoints newPoints = new VectorPoints("VectorPointsTest", new Vector2[] { new Vector2(0, 0) }, Color.red, null, 1.0f);
    4.         Camera vectorCam = VectorPoints.SetCameraRenderTexture(dataRenderTexture);
    5.         newPoints.Draw();
    6.         vectorCam.Render();
    7.         VectorPoints.SetCameraRenderTexture(null);
    8.     }
    9.  
    With that code, I'm expecting a single red pixel in the bottom left corner of the render texture. Interestingly, I get the result in the first picture. (The texture is 512x512, but I enlarged the bottom left corner so you can see it):

    $RedSquareMoved.png

    Initially, I thought that happened because Unity was doing some kind of texture padding internally, but I took a screenshot of the rendertexture's full-size contents from the editor and measured it in a bitmap program, and it's exactly 512x512. It seems to be a vectrosity thing.

    If I create a VectorPoints object with a single point at Vector2(-1,-1) instead, I get the following:

    $RedSquare.png

    That's what I want, but I was expecting that result from passing 0,0. ;-) Err... Am I doing something wrong? Maybe this has to do with the camera being perspective, and it will go away with an orthocam in Vectrosity 2.3? If not, how do I get integer vector coordinates to exactly match the pixel?
     

    Attached Files:

    Last edited: Jun 28, 2013
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Using that code, the pixel is in the lower-left corner using Vector2(0, 0) for me even without using an orthographic camera. Are you using Windows? If so, what happens if you shift the vector camera to the right and down by half a unit (which translates to half a pixel)? I seem to vaguely recall something about Windows/Mac being different by half a pixel in some way when it comes to pixel-perfect representations, but I'm not really sure what it was or if it would apply in this case.

    --Eric
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Speaking of version 2.3, it's out now!

    Additions:
    • VectorLine.MakeCube, for making arbitrary cubes.
    • VectorLine.Version function, which returns a string that contains version information, since it's not always obvious (such as if you're using the DLL).

    Changes:
    • VectorLine.Selected can indicate the index of the line segment (or point, if using VectorPoints) that was selected, by passing in an index variable. Note that the "Selected (point, extraDistance)" override no longer exists; the two-parameter version is now "Selected (point, index)" if using Unityscript and "Selected (point, out index)" in C#. You can still use extraDistance, but now you must also use the index, e.g. "Selected (point, extraDistance, index)". In C# that's "Selected (point, extraDistance, out index)".
    • VectorLine.SetCameraRenderTexture can use an optional boolean to specify the use of an orthographic camera.

    Fixes:
    • VectorLine.SetColor works properly with VectorPoints, and with 1-pixel lines and points if useMeshLines/useMeshPoints are set.
    • Using EndCap.Back with Draw3D works properly, and so does EndCap.Both if the back texture texture has a different aspect ratio than the front texture.
    • VectorLine.Resize works properly with end caps.
    • VectorLine.Destroy works properly with Draw3DAuto.
    • VectorLine.Selected works with drawStart/drawEnd.
    • VectorLine.Selected works properly with VectorPoints.
    • VectorLine.Selected works with lines drawn with a Transform parameter.
    • Using minDrawIndex or maxDrawIndex with Joins.Fill and 3D lines no longer creates an extraneous triangle at the end of the line connecting to Vector3.zero.

    Update notices are being sent out now. (At least to everyone who bought from my site and has update notices turned on. If you don't, then go ahead and turn them on! Everybody loves updates!) Next up, Asset Store submission.

    --Eric
     
  5. memetic-arts

    memetic-arts

    Joined:
    Feb 27, 2011
    Posts:
    82
    HI Eric -

    I'm having a bit of a syntax glitch, hoping you can help.

    I'm generating a single spline, on which an arbitrary number of objects will follow. I thought it would make sense to take your FollowSpline3D script and separate the spline-creation functions from the spline-following one -- that way I could attach the follower script to the objects/prefabs, and just pass in a reference to the spline.

    I can set up a reference to the generated/drawn spline (named "TheSpline") with gameObject.Find("Vector TheSpline"). But this is useless when trying to run the objects because GetPoint3D01 is a function of the VectorLine, not the GameObject, and generates an error ('not a member of Unity.GameObject').

    Is there a simple way to refer to the VectorLine, or do I have to access it through the script where the VectorLine was created?

    Thanks!
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can make the VectorLine be a public variable, and use something like "FindObjectOfType(MyScript).myVectorLine" to refer to the VectorLine. Or use GetComponent to do the same thing.

    --Eric
     
  7. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    Hi.. I recently sent several e-mails but thought I best continue within this thread.

    So I am simply trying out a demo scene. but I get the following errors all relating to

    Assets/Editor/Vectrosity/LineMaker.js(15,32): BCE0004: Ambiguous reference 'Vector3Pair': Vectrosity.Vector3Pair, Vectrosity.Vector3Pair.


    Using Vectrosity 2.3 running Unity4 Pro on a MacBook Pro.

    [ EDIT ] Ok I think I have things a little better under control.... I imported the source package which I think may have been conflicting with other scripts.

    I can now run all Demos :)

    Thx .... sorry about the multiple e-mails..... just throw them out the window...

    Now time to learn to use VECTROSITY !!!!!
     
    Last edited: Jun 29, 2013
  8. memetic-arts

    memetic-arts

    Joined:
    Feb 27, 2011
    Posts:
    82
    Thanks, Eric, public var with FindObjectOfType did the trick.

    Looking forward to grabbing the update . . .also looking forward to grabbing the next update -- you know, the one with SVG-import support.

    Cheers.

     
  9. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    How can I create a small HUD that displays X-Ray vectored objects ? ( I think I need to alter Drawbox.js so it simply renders the "vector cam" onto the HUD plane.

    I've created a plane scaled it so it sits in front of my main camera (an astronauts helmet). I added the XRay line data script to the plane + a Vector Object script to objects I want to highlight as vector lined... but it's not showing up since I need to change the drawbox.js
    so it simply renders rather than mouse input to drag out a rectangle.

    This is where I fall short... altering the Drawbox.js ??

    note: I'm running this through an Oculus Rift so the main camera(s) are two offset (stereo-scopic ) cameras.

    I have changed their tags so they no longer are tagged as being the "main camera" instead I created

    The HUD will allow players (astronauts) to view objects hidden beneath the ground plane.

    here's a sample vid...
     
    Last edited: Jun 29, 2013
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The Xray script works by calling SetCamera with CameraClearFlags.SolidColor and messing with the depth; did you do that?

    --Eric
     
  11. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    Thx for the reply.. I really appreciate the help on such a trivial task... (I'm just getting a feel for Vectrosity again )

    I'll take a look over the X-ray Demo again...

    All I need to do is have a vector x-ray textured onto a plane.

    [ EDIT] OK I did it !! :) I simply commented out the mouse drag functions in the DrawBox script.

    Actually when i say I did it .. I managed to get the demo to simply display a masked black box with vector rendering.... so next up I will try this in the Oculus Rift.
     
    Last edited: Jun 30, 2013
  12. zmeinaz

    zmeinaz

    Joined:
    Jul 3, 2012
    Posts:
    27
    Hey Eric,

    I am noticing a large frame rate drop on the iPad 1. I have a 3D line that is updated via user input (the user draws the line during gameplay). So, in draw mode I call Draw3D() and SetTextureScale(1.0f) every time number of points in the line changes. On the iPad 1 I get about 12 FPS while drawing. I commented the calls to SetTextureScale() and saw an improvement of about 10 FPS, only now my line doesn't look right (it's a dotted line). Is there anyway to improve the performance without sacrificing the way my line looks?
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can use minDrawIndex and maxDrawIndex as an optimization to only update a part of the line if the rest of it's staying the same; see the DrawLinesTouch example.

    --Eric
     
  14. zmeinaz

    zmeinaz

    Joined:
    Jul 3, 2012
    Posts:
    27
    That helps with the performance impact of Draw3D(), but will that have any effect on SetTextureScale()? I modified my implementation like you said and I am still getting ~12FPS during the draw mode. It looks like SetTextureScale iterates over the entire line each time is that correct/necessary?
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It may not be necessary; I'll take a look at it for the next update.

    --Eric
     
  16. CHPedersen

    CHPedersen

    Joined:
    Mar 2, 2011
    Posts:
    63
    You're right! :)

    I am on Windows, and there is something about it being different. I want to say it has something to do with DirectX counting from the center of texels while OpenGL counts from the topleft corner during texel mapping, but I honestly don't know enough to put words to the precise cause. In any case, your suggestion about moving the camera works well and solved the problem. (Except that it had to be moved left and up instead of right and down, but nevermind that).

    On an unrelated note, I'm starting to think you should charge more, not that I'm complaining ;) The company I work for paid 50 bucks for the Pro version when it was still on one-point-something, and in the past, we've paid ridiculously much more money for software ridiculously much less useful than Vectrosity. Coupled with the seemingly limitless support you're offering in this thread, I think you could easily get away with charging twice what you do now. :p
     
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's good to know. Does the same thing apply to the regular camera (i.e., not using rendertextures)?

    Anyone who wants to is free to send me more money. ;) But overall I'd rather see more people be able to afford it; $50/$100 might be reasonable in some countries like the U.S., but not so much in others.

    --Eric
     
  18. supericon

    supericon

    Joined:
    Feb 15, 2013
    Posts:
    63
    Hi Eric

    I am using Vectrosity and loving it - but I have one issue that I don't know how to fix.

    My enemies are a mixture of 3D mesh and vector co-ords - which works great.

    BUT when I spawn more enemies, the enemies spawn OK, everything works fine EXCEPT that the Vector lines are missing. See the screen for example.

    $screenshot4.png
     
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Have a look at the Tank Zone example. Probably the only real difference in that case is the enemies don't use a standard mesh (only VectorLines), but you can use "false" with ObjectSetup so that it uses the existing mesh rather than making a bounds mesh.

    --Eric
     
  20. ShaneStevens

    ShaneStevens

    Joined:
    Nov 16, 2012
    Posts:
    14
    Hi,

    I've just purchased Vectorsity and it's great, however I'm running into an issue with welded world-space lines; i.e. they're not welding.

    I'm using this to create the line:

    line = new VectorLine("DrawnLine", linePoints, lineColor, null, lineWidth, LineType.Continuous, Joins.Weld);

    Any ideas?

    Regards,
    Shane

    $Vectrosity test.jpg
     
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I tested your code with "var linePoints = [Vector3(-5, 5, 5), Vector3(4, 1, 6), Vector3(5, 0, 6), Vector3(5, -4, 4)];" as some sample data for the linePoints array, and it welds as expected. What happens on your end if you use that data?

    --Eric
     
  22. ShaneStevens

    ShaneStevens

    Joined:
    Nov 16, 2012
    Posts:
    14
    I used your world-space vertices and they worked, so I checked further and after a lot of messing around, I think the culprit is line.minDrawIndex. If it's set, I get segments instead of a continuous line. I've included a 'updateAll' bool to show you what I mean.

    I've included code below. Just put it onto the camera in a new project with Vectrosity. The lines are 3D world-space lines generated in the x/z plane with y=0, modified from your mouse example.

    Code (csharp):
    1.  
    2. using System;
    3. using UnityEngine;
    4. using Vectrosity;
    5.  
    6. public class Test : MonoBehaviour
    7. {
    8.     public Color lineColor = Color.white;
    9.     public int maxPoints = 1000;
    10.     public float lineWidth = 4.0f;
    11.     public float minPixelMove = 5;
    12.     public bool updateAll = false;
    13.     public bool updateAuto = true;
    14.     Vector3[] _linePoints;
    15.     VectorLine _line;
    16.     int _lineIndex = 0;
    17.     Vector3 _previousMouse;
    18.     Vector3 _previousPosition;
    19.     float _sqrMinPixelMove;
    20.     bool canDraw = false;
    21.     Plane _groundPlane = new Plane (Vector3.up, Vector3.zero);
    22.     GameObject _current;
    23.     Vector3 _worldMouse = new Vector3 (0, 0, 0);
    24.  
    25.     void Start ()
    26.     {
    27.         _linePoints = new Vector3[maxPoints];
    28.         _line = new VectorLine ("DrawnLine", _linePoints, lineColor, null, lineWidth, LineType.Continuous, Joins.Weld);
    29.  
    30.         _sqrMinPixelMove = minPixelMove * minPixelMove;
    31.     }
    32.  
    33.     void Update ()
    34.     {
    35.         var mousePos = Input.mousePosition;
    36.  
    37.         Ray cursorRay = Camera.main.ScreenPointToRay (Input.mousePosition);
    38.         float distance;
    39.  
    40.         _groundPlane.Raycast (cursorRay, out distance);
    41.         _worldMouse = cursorRay.GetPoint (distance);
    42.         _worldMouse.Set (_worldMouse.x, 0.0f, _worldMouse.z);
    43.  
    44.         if (Input.GetMouseButtonDown (0)) {
    45.             _line.ZeroPoints ();
    46.             _line.minDrawIndex = 0;
    47.             _line.maxDrawIndex = 0;
    48.             _line.Draw ();
    49.  
    50.             _previousMouse = mousePos;
    51.  
    52.             _lineIndex = 0;
    53.             _linePoints [0] = _worldMouse;
    54.             canDraw = true;
    55.         } else if (Input.GetMouseButton (0)  (mousePos - _previousMouse).sqrMagnitude > _sqrMinPixelMove  canDraw) {
    56.             _previousMouse = mousePos;
    57.             _linePoints [++_lineIndex] = _worldMouse;
    58.  
    59.             if (false == updateAll) {
    60.                 _line.minDrawIndex = _lineIndex - 1;
    61.             }
    62.             _line.maxDrawIndex = _lineIndex;
    63.  
    64.             if (_lineIndex >= maxPoints - 1) {
    65.                 canDraw = false;
    66.             }
    67.             if (updateAuto) {
    68.                 _line.Draw3DAuto ();
    69.             } else {
    70.                 _line.Draw3D ();
    71.             }
    72.         } else if (Input.GetMouseButtonUp (0)) {
    73.             string s = "";
    74.             for (int i = 0; i < _lineIndex; ++i) {
    75.                 s += ", new Vector3" + _linePoints [i].ToString ();
    76.             }
    77.             Debug.Log(s);
    78.         }
    79.     }
    80.  
    81.     public bool Raycast (Vector3 inPos, ref RaycastHit hit)
    82.     {
    83.         Camera camera = Camera.main;
    84.  
    85.         // Cast a ray into the screen
    86.         Ray ray = camera.ScreenPointToRay (inPos);
    87.  
    88.         if (Physics.Raycast (ray, out hit)) {
    89.             return true;
    90.         }
    91.         return false;
    92.     }
    93.  
    94. }
    95.  
     
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Oh, I see: weld requires more than one segment to work (it gets the intersection points from two segments), so if you're only allowing one segment to be updated, welding can't work. So you'd have to change minDrawIndex to allow more than one segment to be updated.

    --Eric
     
  24. ShaneStevens

    ShaneStevens

    Joined:
    Nov 16, 2012
    Posts:
    14
    Ok, that makes sense. So by that logic, by simply changing line 59 to:

    Code (csharp):
    1.                 _line.minDrawIndex = _lineIndex - 2;
    should fix the problem, however it doesn't work.

    In fact, all segments BELOW minDrawIndex lose their welds, and everything from minDraw -> maxDraw get welded.

    To see the strange effect, change line 59 to:

    Code (csharp):
    1.                 _line.minDrawIndex = _lineIndex - 20;
    and what you'll see is an effect like a snake. The min->max is welded and everything below isn't, and it grows over time.

    Kind of cute, but not the desired result ;)

    -- Shane
     
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Actually that's true; thinking about it, welding can't really work with min/maxDrawIndex currently, because as far as the drawing routine is concerned, the specified minDrawIndex is the start of the line and there's nothing to weld to.

    --Eric
     
  26. ShaneStevens

    ShaneStevens

    Joined:
    Nov 16, 2012
    Posts:
    14
    Ok, sounds like a pretty easy fix. I can hack away at your code, but do you see it as something you might change in the future?

    -- Shane
     
  27. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's what the "currently" was implying. ;) I don't have a timeframe though (2.3 just came out...).

    --Eric
     
  28. ShaneStevens

    ShaneStevens

    Joined:
    Nov 16, 2012
    Posts:
    14
    Roger that :) I'll hack away.

    --Shane
     
  29. ShaneStevens

    ShaneStevens

    Joined:
    Nov 16, 2012
    Posts:
    14
    Is it possible to create a 3D line in the X/Z plane (y=0), such that the line is "facing" along the plane normal (0,1,0) ?

    In other words, I want to draw a line on the ground in world space and have the welded vertices generated with a Y value 0. This is different from front facing the viewer. I'm effectively drawing ground selection lines, and want them to be a constant width in the X/Z plane, and it needs to sit underneath my objects so I really need it to be at y=0.

    I'm using a fixed orthographic camera, so the lines won't get perspective distortion.

    --Shane
     
  30. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Currently the only way to make a 3D line face a particular direction is kind of a hack involving SetCamera, where you set up a "dummy" camera to orient the line in the way you want and use that camera with SetCamera.

    --Eric
     
  31. ShaneStevens

    ShaneStevens

    Joined:
    Nov 16, 2012
    Posts:
    14
    Looks like I'm finding edge cases for you on day 0 ;)

    Thanks for the tip, I'll try it.

    --Shane
     
  32. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    Sorry if this has been answered before, but I can't find it anywhere. Is there a way to draw a line behind a 2dToolkit sprite? I'm using draw3D and I can see the line is actually behind the sprite, but on the game view it always shows on top.
     
  33. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It might be a problem with the shader used for the line or the sprite; try changing one of them.

    --Eric
     
  34. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    I solved it using the Draw3D(transform) method. I wasn't passing a transform before. :)

    Thanks for your reply! Keep up the great work on this awesome plugin!
     
  35. ShaneStevens

    ShaneStevens

    Joined:
    Nov 16, 2012
    Posts:
    14
    I'm running into another issue which is causing me grief.

    When I pass vertices with a constant Y (y=0) to a VectorLine with a camera with that isn't pointing along the Y axis (e.g. 45' rotation around X) , the resultant vertices have a non-zero Y. This means lines poke through anything along the Y vector in view-space (like the ground).

    Any idea what's happening?

    Here's the code, with a screenshot to explain:

    --Shane

    Code (csharp):
    1.  
    2. using System;
    3. using UnityEngine;
    4. using Vectrosity;
    5.  
    6. public class Test : MonoBehaviour
    7. {
    8.     public Color lineColor = Color.white;
    9.     public int maxPoints = 1000;
    10.     public float lineWidth = 4.0f;
    11.     public float minPixelMove = 5;
    12.     Vector3[] _linePoints;
    13.     VectorLine _line;
    14.     int _lineIndex = 0;
    15.     Vector3 _previousMouse;
    16.     Vector3 _previousPosition;
    17.     float _sqrMinPixelMove;
    18.     bool canDraw = false;
    19.     Plane _groundPlane = new Plane (Vector3.up, Vector3.zero);
    20.     GameObject _current;
    21.     Vector3 _worldMouse = new Vector3 (0, 0, 0);
    22.  
    23.     void Start ()
    24.     {
    25.         Debug.Log ("Vectrosity version: " + VectorLine.Version ());
    26.        
    27.         _linePoints = new Vector3[maxPoints];
    28.         _line = new VectorLine ("DrawnLine", _linePoints, lineColor, null, lineWidth, LineType.Continuous, Joins.Weld);
    29.  
    30.         _sqrMinPixelMove = minPixelMove * minPixelMove;
    31.     }
    32.  
    33.     void Update ()
    34.     {
    35.         var mousePos = Input.mousePosition;
    36.  
    37.         Ray cursorRay = Camera.main.ScreenPointToRay (Input.mousePosition);
    38.         float distance;
    39.  
    40.         _groundPlane.Raycast (cursorRay, out distance);
    41.         _worldMouse = cursorRay.GetPoint (distance);
    42.         _worldMouse.Set (_worldMouse.x, 0.0f, _worldMouse.z);
    43.  
    44.         if (Input.GetMouseButtonDown (0)) {
    45.             _line.ZeroPoints ();
    46.             _line.minDrawIndex = 0;
    47.             _line.maxDrawIndex = 0;
    48.             _line.Draw ();
    49.  
    50.             _previousMouse = mousePos;
    51.  
    52.             _lineIndex = 0;
    53.             _linePoints [0] = _worldMouse;
    54.             canDraw = true;
    55.         } else if (Input.GetMouseButton (0)  (mousePos - _previousMouse).sqrMagnitude > _sqrMinPixelMove  canDraw) {
    56.             _previousMouse = mousePos;
    57.             _linePoints [++_lineIndex] = _worldMouse;
    58.            
    59.             // update all to keep welds
    60.             _line.minDrawIndex = 0;
    61.             _line.maxDrawIndex = _lineIndex;
    62.  
    63.             if (_lineIndex >= maxPoints - 1) {
    64.                 canDraw = false;
    65.             }
    66.            
    67.             _line.Draw3DAuto ();
    68.         }
    69.     }
    70. }
    71.  
    $vectrosity y change.jpg
     
  36. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    What happens if you turn welding off?

    --Eric
     
  37. ShaneStevens

    ShaneStevens

    Joined:
    Nov 16, 2012
    Posts:
    14
    Works fine:

    $vectrosity y ok.jpg

    --Shane
     
  38. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The welding moves the vertices around in order to get the line intersection points to work, so it's not really suited for this sort of thing I'm afraid. I'd suggest using Joins.Fill instead.

    --Eric
     
  39. klEx0n

    klEx0n

    Joined:
    Jul 8, 2013
    Posts:
    3
    Hi Guys,

    i m pretty new here in the Unity Forums but i worked alot with Unity in the last years. First one, i bought last week Vectrosity and i love this Tool its awesome :) good Job Eric
    And now to my Problem, i m working on a Game Project which uses the Kinect Camera. I m drawing an Avatar with an Vectorline in 3D space with Continues lines. I separated Torso, Arms and Hips so that i have three Vectorlines, these are drawing the Avatar himself.
    My Problem is, i want that the Avatar is drawn in a Wireframe. For that I did a new Vectorline with Descrete Linetype so that i can draw a Wireframe. But everytime I try to Draw the Wireframe with the Torso Mesh, it stops to Move / Update the Toros Coordinates.

    Well hope someone understand what I want to do, and maybe someone can help me with my Problem, thx for that

    - klEx0n
     
  40. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'd strongly recommend not using vectorObject.transform; pass a transform into Draw3DAuto instead. (By the way, please use code tags when posting code.)

    --Eric
     
  41. klEx0n

    klEx0n

    Joined:
    Jul 8, 2013
    Posts:
    3
    Hey Eric,

    thank you for your advice but it seems it still doesnt work. The Mesh of the Vectorline just freezes and it wont move after the wireframe is drawn. I dont know where the problem could be. I have several ideas where the problem could be, maybe its how vectorline is drawn. Does Vectorline generate a new Mesh when the line is redrawn again? Maybe here is the Problem that it takes just the first initialized Mesh and then it stops to redrawn.
    Then i recognized that the Vectorline which i generate to draw the Avatar, gets an instance of the Mesh and the wireFramed Vectorline works with the Original. I m a bit clueless at this moment, i m trying to solve this Problem since three Days, maybe you have an advice, or maybe someone else.

    Here is the Part where i Initialize the Points of the Avatar
    Code (csharp):
    1. torsoJoints1[0] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.HipCenter);
    2. torsoJoints1[1] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.Spine);
    3. torsoJoints1[2] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.ShoulderCenter);
    4. torsoJoints1[3] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.Head);
    5.                
    6. armJoints1[0] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.HandLeft);
    7. armJoints1[1] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.WristLeft);
    8. armJoints1[2] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.ElbowLeft);
    9. armJoints1[3] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.ShoulderLeft);
    10. armJoints1[4] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.ShoulderCenter);
    11. armJoints1[5] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.ShoulderRight);
    12. armJoints1[6] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.ElbowRight);
    13. armJoints1[7] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.WristRight);
    14. armJoints1[8] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.HandRight);
    15.  
    16. hipJoints1[0] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.FootLeft);
    17. hipJoints1[1] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.AnkleLeft);
    18. hipJoints1[2] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.KneeLeft);
    19. hipJoints1[3] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.HipLeft);
    20. hipJoints1[4] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.HipCenter);
    21. hipJoints1[5] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.HipRight);
    22. hipJoints1[6] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.KneeRight);
    23. hipJoints1[7] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.AnkleRight);
    24. hipJoints1[8] = KinectManagerUser.GetJointPosition(playerID, (int)KinectWrapper.NuiSkeletonPositionIndex.FootRight);
    25.  
    I m Updating the Points every Frame so that the Avatar is redrawn automatically. But Like i said before, the mesh freezes and it wont be redrawn again.

    - klEx0n
     
  42. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If it's an animated (skinned) mesh, then you'd have to use BakeMesh in order to get the updated mesh.

    --Eric
     
  43. klEx0n

    klEx0n

    Joined:
    Jul 8, 2013
    Posts:
    3
    No it isnt an SkinnedMesh. I use Vectorsity with continues Lines to draw the Avatar in 3D space with the Points which i mentioned before. When a Line is drawn, he puts an normal Mesh Filter to draw the Lines. So I cant use the SkinnedMesh.BakedMesh method to get the updated Vectorline Mesh :)

    -klEx0n
     
  44. Mantra-Games

    Mantra-Games

    Joined:
    Nov 27, 2012
    Posts:
    155
    I'm looking for a tool that will allow me to draw 3D platforms in Unity and then texture them instead of modelling them in another 3D app. Can Vectrosity do this?
     
  45. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, it's a line-drawing utility.

    --Eric
     
  46. druffzy

    druffzy

    Joined:
    Sep 19, 2009
    Posts:
    55
    Hi Eric,

    I am trying to draw dash or dotted line. And all my coding is in CS. Is there any difference between CS and JS?

    This is my following code

    Vector2[] linePoints = { new Vector2(x2, y2), new Vector2(x1, y1) };
    VectorLine myLine = new VectorLine("test", linePoints, lineMaterial, lineWidth);
    myLine.Draw();
    myLine.SetTextureScale (textureScale);

    and when i use dash or dotted material it doesnt work. It works with JS version. for example when i tried one of the uniformtexturedline scene that comes along with the package.

    Thanks
     
  47. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I tried your code and it works in C# as expected. Did you define the types of the variables appropriately? Vectrosity works identically in C# or JS, except where language syntax requires otherwise (e.g., VectorLine.Destroy needs to specify "ref" in c#, whereas ref is implicit in JS and is not specified).

    --Eric
     
  48. druffzy

    druffzy

    Joined:
    Sep 19, 2009
    Posts:
    55
    Its working with continuous line material and doesnt show up with drawviewport as well.
     
  49. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The code you posted works with continuous or discrete lines. But you're correct that it doesn't work with DrawViewport; good catch on that.

    --Eric
     
  50. CHPedersen

    CHPedersen

    Joined:
    Mar 2, 2011
    Posts:
    63
    Hey again,

    Sorry it took so long for me to get back to you. I don't have any more problems, I just wanted to let you know what happens when I tried without drawing to the rendertexture. :)

    I ran this code:

    Code (csharp):
    1. VectorPoints test = new VectorPoints("Test", new Vector2[] { new Vector2(0, 0) }, null, 1);
    2. VectorPoints.SetCamera();
    3. test.Draw();
    With that, we're expecting a single white dot in the bottom left corner. I got this (corner enlarged):

    $DrawnToScreen169.png

    Okay, so when drawn directly to the screen it lands in the correct row, at least. :) It still offsets the pixel one column to the right, however. But the above was in 16:9. So I figured, maybe it has something to do with the wide-screen resolution. So I changed to free-aspect and resized the window in the editor until it was square-ish, then ran the code again:

    $DrawnToScreenOneOne.png

    Tadaa, it landed correctly. So... It does have something to do with the aspect ratio, I guess?
     
Thread Status:
Not open for further replies.