# Vectrosity - fast and easy line drawing

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

Not open for further replies.
1. ### wbl1

Joined:
Apr 22, 2009
Posts:
151
Eric,

I need a function to return the distance along a spline, given a 3d point. So kind of the opposite of GetPoint3D. Without a better idea (i.e. the reason for this post), I plan to do something like this:

1) check to see if the input 3d point is in the splines points3. I'll do this with a for loop, using Vector3.Distance to see if they are close within some tolerance.
2) if this returns a point, I'll infer a distance by dividing the returned point's position in the points3 array by the total number of points in points3.

Just wonder what you think. Is there something for this already. If not, is my logic reasonable or is there a better way?

Thanks!

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
What's your ISP? It might just be taking an excessively long time, or maybe they are blocking emails from starscenesoftware.com. (Like Comcast does, or at least did.)

--Eric

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
Not built-in, no. Hmm, tricky...I'm sure there's some clever math way, maybe try searching on various combinations of "spline", "point", and "distance" and see if you can find anything. Otherwise, if that method works, good enough.

--Eric

4. ### crashposition

Joined:
May 24, 2012
Posts:
5
It's been more than 24 hours. I would have expected something by now. The mail for the domain goes through Media Temple. I can try white-listing the email address if you know what it will be?

I can give you a gmail address if that's easier?

Last edited: May 24, 2012

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
It's sales "at" starscenesoftware.com. (Written the correct way, of course.)

--Eric

6. ### crashposition

Joined:
May 24, 2012
Posts:
5
Spoke to MT and they claim they're not blocking the domain but have added it to the whitelist to be sure. I reckon it might be a typo in the original order? Can I send an email to that address to confirm?

Joined:
Mar 11, 2012
Posts:
58
Hi Eric.
One day I posted VectorLine's x position problem.

And you said VectorLine.SetCamera(true) will work and it really works well in windows standalone.
But in android, it goes to left 1px than in other platform and I also tested it with GL.
So I explain it again the following problem.

I made two lines and set the same position.

GLLine (100, 100) - (100, 300)
VectorLine (100, 100) - (100, 300)

I test it in Unity Editor, Windows Standalone and Android.

On Sreen the two lines appears as following position.

- Unity Editor
GLLine (100, 100) - (100, 300)
VectorLine (102, 100) - (102, 300) (2 px goes to right than GL)

- Windows Standalone
GLLine (100, 100) - (100, 300)
VectorLine (102, 100) - (102, 300) (Same as Unity Editor)

- Android
GLLine (100, 100) - (100, 300)
VectorLine (101, 100) - (101, 300) (1 px goes to right than GL, 1 px goes to left than Unity Editor and Win Standalone)

1. Why are two(Vector GL) lines position different?
2. Why is Vector Line's x position different in multiplatform?

Help me.
Best Regards,
Thank you,

Last edited: May 25, 2012

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
It's possible floating point works differently on your Android device, so the calculations are slightly different compared to your computer.

--Eric

Joined:
Mar 11, 2012
Posts:
58
What do you mean?
So I should implement it differently on multiplatform?

I tested it in Android Galaxy tab 10.1(1280 * 800)
And no way to make same with GL's position?

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
It might be that using doubles would help, but Unity's math functions all use floats, so I'm not sure there's much that could be done. Also, I have to say I haven't seen what you're talking about on my computer or iOS devices, so it would be hard for me to debug, if in fact there's anything I can debug. What are you using to draw the lines? If you're using Vector2 coordinates to draw 2D lines using VectorLine.Draw, then it's actually using integers for the coords, so there's really nothing I can think of that could be off as long as you're using an orthographic camera. (Which is what SetCamera(true) does.)

--Eric

Joined:
Mar 11, 2012
Posts:
58
Yes, I am using Vector 2D Line.
Is there really no way to resolve it?
If that never happens on your computer or iOS, I really want you to try on Android.
If you are possible, I want you to hint me what should I see when I debug it?
I will try to fix it.

Joined:
Jul 19, 2006
Posts:
31,393

--Eric

13. ### benfattino

Joined:
Nov 26, 2010
Posts:
43
Big problem. I'm working with vectrosity to draw wireframe model.
I need to vary the transparency of the lines dynamically so as to create a smooth transition from one scene to another.
The best thing would be to modify all the parameters with the panel animations, but the variable material used in the script is not available.
I'm using this script to draw line:

Help!

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
You should be able to change line.vectorObject.renderer.material.color.a as needed.

--Eric

15. ### benfattino

Joined:
Nov 26, 2010
Posts:
43
Thanks for answer. I try editing color.a in animation panel. The opacity changes in the editor, but the model remains the same.
Must I modify the script? For example moving line.Draw in Update Function or another change? Help...

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
No, all you have to do is change the renderer.material.color.a as I described; the same rules apply to that as any other object. (i.e., the shader you're using in the material must support transparency, etc.)

--Eric

17. ### Creslin321

Joined:
Apr 26, 2012
Posts:
53
Hi Eric,

After having all kinds of issues with LineRenderer on my iPad, I've been mulling over picking up Vectrosity for the last 30 minutes or so, but there's one question I had that I haven't been able to find an answer to. Specifically, is it possible to draw a line with a "thickness gradient" so that it starts out at say 20 thickness, but slims down to be 0 thickness at the end? I was doing this with LineRenderer, and I love the effect for a "trail," but as I said, it's giving me a lot of grief when I build for my iPad.

So would Vectrosity be able to do this? If not, I will probably wind up picking it up later anyway just because it seems like there's a lot of cool effects I could do...but for now I'm fixated on getting this trail effect to work.

Thanks!

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
Yes, you can set the thickness for each line segment, and have it interpolate between segments (or not, as you desire).

--Eric

Joined:
Apr 26, 2012
Posts:
53

20. ### creat327

Joined:
Mar 19, 2009
Posts:
759
Hi there,

I'm browsing through the long list of pages but I can't find a reply. Can we use this tool as a simple paint brush tool?
I want to create a basic 'paint with your finger' app that runs at good performance on old android devices. I see vectrosity does vector painting of lines but I don't know whether it can be used to draw similar to a brush (continuously) with typical pen sizes that have a rounded look on the edges.

Can it? is there an example on the package on how to do this?

Regards,
Joaquin

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
If you mean rounded ends, it doesn't currently have that ability.

--Eric

22. ### cpasjuste

Joined:
Apr 2, 2012
Posts:
138
Hi Eric5h5,

i do encounter a little problem with Vectrosity: i'm making a game wich only use some cubes mesh, but from any size (not scaled but made in blender).

I want to reproduce the "_Simple3DObject" scene to outline my cubes, but it only work with 1x1 cubes sizes: i can create a basic 1x1 cube, apply the "Simple3D 3" script then scale it to any size and it work. But when i try the script on a bigger cube then the outline is always 1x1, not matter if i then scale the object or not.

Any hint would be appreciated !

Thanks,
David.

23. ### benfattino

Joined:
Nov 26, 2010
Posts:
43
I'm using Vectrosity (2.01) with iPad (5.1.1) and Unity (3.5.0). I have script to draw wireframe. It's work fine with player, but when i compile for iPad Xcode give me error and wireframe doesn't appear on scene.

This is Script:
and this is screenshot of Xcode:

I can solve problem using similar script where the list of point are directly insert inside script, but because i have 15.000 points compilation time is very long...
Somebody help me?
Thanks.

Last edited: Jun 4, 2012
24. ### cpasjuste

Joined:
Apr 2, 2012
Posts:
138
Well, i didn't find a way to get an outline style on my cubes ( 24 verts ) so i did write a script to get an outline effect using Vectrosity, this can surely be improved (or even better already possible with Vectrosity '( ) but it does a very nice outline toon effect in one draw call.

Code (csharp):
1.
2. using UnityEngine;
3. using System.Collections;
4.
5. public class VectrosityOutline : MonoBehaviour
6. {
7.     public Material _outlineMaterial;
8.     public float _outlineWidth = 0.1f;
9.     public Color _outlineColor = Color.black;
10.
11.     void Start()
12.     {
13.         GameObject[] objs = (GameObject[])GameObject.FindSceneObjectsOfType( typeof( GameObject ) );
14.         foreach( GameObject obj in objs )
15.         {
16.             MeshFilter _meshFilter = obj.GetComponent<MeshFilter>();
17.             if( _meshFilter == null )
18.                 continue;
19.
20.             Mesh _mesh = _meshFilter.mesh;
21.             if( _mesh == null )
22.                 continue;
23.
24.             if( _mesh.vertices.Length != 24 )
25.                 continue;
26.
27.             Vector3[] points = new Vector3[5];
28.             points[0] = obj.transform.TransformPoint( _mesh.vertices[0] );
29.             points[1] = obj.transform.TransformPoint( _mesh.vertices[4] );
30.             points[2] = obj.transform.TransformPoint( _mesh.vertices[6] );
31.             points[3] = obj.transform.TransformPoint( _mesh.vertices[3] );
32.             points[4] = obj.transform.TransformPoint( _mesh.vertices[0] );
33.             SetupLine( points, obj.name + " [0]" );
34.
35.             points = new Vector3[5];
36.             points[0] = obj.transform.TransformPoint( _mesh.vertices[1] );
37.             points[1] = obj.transform.TransformPoint( _mesh.vertices[2] );
38.             points[2] = obj.transform.TransformPoint( _mesh.vertices[7] );
39.             points[3] = obj.transform.TransformPoint( _mesh.vertices[5] );
40.             points[4] = obj.transform.TransformPoint( _mesh.vertices[1] );
41.             SetupLine( points, obj.name + " [1]" );
42.
43.             points = new Vector3[2];
44.             points[0] = obj.transform.TransformPoint( _mesh.vertices[1] );
45.             points[1] = obj.transform.TransformPoint( _mesh.vertices[3] );
46.             SetupLine( points, obj.name + " [2]" );
47.
48.             points = new Vector3[2];
49.             points[0] = obj.transform.TransformPoint( _mesh.vertices[0] );
50.             points[1] = obj.transform.TransformPoint( _mesh.vertices[2] );
51.             SetupLine( points, obj.name + " [3]" );
52.
53.             points = new Vector3[2];
54.             points[0] = obj.transform.TransformPoint( _mesh.vertices[7] );
55.             points[1] = obj.transform.TransformPoint( _mesh.vertices[4] );
56.             SetupLine( points, obj.name + " [4]" );
57.
58.             points = new Vector3[2];
59.             points[0] = obj.transform.TransformPoint( _mesh.vertices[6] );
60.             points[1] = obj.transform.TransformPoint( _mesh.vertices[5] );
61.             SetupLine( points, obj.name + " [5]" );
62.         }
63.     }
64.
65.     void SetupLine( Vector3[] pPoints, string pName )
66.     {
67.         VectorLine line = new VectorLine( pName, pPoints, _outlineColor, _outlineMaterial, _outlineWidth, LineType.Continuous );
68.         line.Draw3D();
69.     }
70. }
71.

Last edited: Jun 4, 2012

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
I don't have any issues running Vectrosity on iOS, so unfortunately I don't know what the issue could be. I'd recommend never using Array, though...change those to built-in arrays or Lists, maybe it will somehow fix the problem, and in any case it will work better.

--Eric

26. ### cpasjuste

Joined:
Apr 2, 2012
Posts:
138
Hi,

i do encounter anothor problem with Vectrosity : it seems the lines width are calculated from the camera distance?
So if i create a bunch of lines in 3D space, when i move around the lines that was close to the camera when created behave normally but lines that was far from the camera when created are very tick. Calling "myLine.Draw3D()" every updates fix the problem but have a big impact on performances.

Is this a normal bevhior or is there something wrong here ?

Thanks,
David.

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
Since Vectrosity is a mesh-based solution, 3D lines must be recalculated every frame or else the width will be incorrect when the camera moves. You can use Draw3DAuto so you don't have to do this manually. (2D lines aren't affected by this since they are drawn with a separate camera that doesn't move.)

--Eric

28. ### cpasjuste

Joined:
Apr 2, 2012
Posts:
138
Thanks, i understand!

29. ### Amon

Joined:
Oct 18, 2009
Posts:
874
Just bought this! Another fine addition to my unity toolset.

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
Thanks! I hope you find it useful.

--Eric

31. ### yahodahan

Joined:
Apr 26, 2009
Posts:
1,337
Just purchased my very own copy!

Question: How could I make 3D Lines work with multiple cameras in a scene? Do I need to call "SetCamera3d()" from each camera, every frame, or somesuch? That seems excessive- guessing there is a better method.

example:

Thanks!

32. ### yahodahan

Joined:
Apr 26, 2009
Posts:
1,337
Might there also a way to make the line's thickness be "world-space"? Guess I should have looked that one up first

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
The line width is always calculated in screen space; unfortunately there's not really a good way to do it using world units. Using 3D lines with multiple cameras is kind of tricky...currently you'd have to call SetCamera3D for each camera as needed every frame. It's possible I could add an overload to use multiple cameras automatically; I've thought about it before, but it is, as I mentioned, tricky.

--Eric

34. ### amw157

Joined:
Jun 11, 2012
Posts:
6
I really hope this hasn't been asked already (60 pages is quite a bit) ... I'm referring to the simple graph on page 17, the post dated 03:14 PM 01-26-2011. Yes, I'm a n00b.

How can I get a graph like that inside a window? I'm doing this:

GUI.Window(123, wdwRect, drawWindowContent, "");

In my drawWindowContent method, I have labels, buttons, etc. But when I put the line drawing code in there, it still draws outside the actual window.

Help?

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
OnGUI code always draws on top of everything and is a separate thing from the rest of the system, so unfortunately there's not much I can do about that.

--Eric

36. ### stoop33

Joined:
Jun 12, 2012
Posts:
1
Any news on when Flash exporting will be supported fully? I currently get two errors when trying to export to Flash:
and
Would be great to have Vectrosity working with Flash for when the exporter is properly released.

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
That's up to UT to support all Unity features when exporting. Keep in mind the Flash export is still a preview.

--Eric

38. ### amasinton

Joined:
Aug 12, 2006
Posts:
117
Hi Eric,

I bought Vectrosity ages ago (back when it first came out) and have only just now had time to play with it. Absolutely brilliant toolset.

I'm using VectorPoints objects to draw all the stars visible to the naked eye (based on the Harvard Bright Star Catalog). This is quite fun. Each point in the VectorPoints object is a point on a 10 unit radius sphere (a projection of the star's coordinates from RA/Dec to XYZ). Now, I have to do some aligning of this star sphere as I change time and viewer's position on the earth, which requires me to rotate the VectorPoints game object. For various reasons I've got seven of these VectorPoints spheres (one for each visible magnitude) and I have parented these to a null and have rotated the null to rotate all seven VectorPoints objects together.

My camera is in the centre of these spheres. It only rotates around its own centre, it does not change its 0,0,0 position in space. However, after I rotate the spheres using the null, the stars in the VectorPoints objects go very dim and many fade way all together as I rotate my camera view.

I'm using Draw3DAuto, and I can see in the scene view that the points in the VectorPoints objects are updating dynamically as the camera rotates, but they don't point straight at the camera.

-- Anthony

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
That's cool; I imagined something like this when I did the Orbit demo. By rotating the actual VectorPoints game object, you're preventing the system from being able to align the points properly...rotating the actual game object will only work in certain cases, namely 2D rotations. Instead, typically you'd pass in the transform of an object when using Draw3DAuto, rather than rotating the VectorPoints game object. An empty game object for this purpose would be fine; see the Text demo for an example.

--Eric

40. ### Hotshot10101

Joined:
Jun 23, 2012
Posts:
87
Is there a way for those of us who have bought it on the asset store to get the "better packaging" that you have on your site?

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
If you send me some indication of purchase from the asset store (like a receipt), I can add you to my system.

--Eric

42. ### Hotshot10101

Joined:
Jun 23, 2012
Posts:
87
I can do that just let me know how to get it directly to you.

Another thing might be if you created a document or readme or simple web page describing the layout of the package I got from the assert store and what modules work together and which do not.

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
Send me a PM. The documentation does actually describe the packages, and everything works together, other than the DLL and source code should not be used at the same time in the same project. (I've added a line to the docs emphasizing that.)

--Eric

44. ### Hotshot10101

Joined:
Jun 23, 2012
Posts:
87
So is that what I am doing wrong? Did I add the dll and the source to my project? If so which package is the dll so I can just remove it?

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
It's not a package, it's just a .dll. The extension doesn't show in the editor, but it has a blank page icon, or you can delete it outside the editor so you can see the .dll extension.

--Eric

Joined:
Nov 2, 2009
Posts:
96
I got Vectrosity and just started using it in my new game, but I have a little problem. There is always created a new VectorCam. Is there a way to stop this? I already have one VectorCam defined in the scene and it's working ok. The other one that is created is a perspective camera with the "lower left corner" of the rect set at 0,0 the pos and size of this camera seem to be almost random. The scene has one camera (orto) for the game. Another cam (also orto) on top of that for an ingame editor menu. The vector cam should/will be used for drawing safe area on the zoomed out game view and display curves that the editor add to the level data.

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
The VectorCam is needed for drawing 2D lines. The size depends on the resolution.

--Eric

Joined:
Nov 2, 2009
Posts:
96
Hes, but why does it show two vectorcams?

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
31,393
Oh, sorry, I thought you were creating one for some reason. Can you explain a little more about how you're using Vectrosity? It will create the VectorCam if none exists, however it shouldn't ever be able to create more than one, since it can only do that if the internal "cam" variable is null. It uses DontDestroyOnLoad so even changing levels shouldn't enable "cam" to become null.

--Eric

Joined:
Nov 2, 2009
Posts:
96
Here are some screenshots of my setup

The VectorCam is on layer 31, and linked into the game script.

In the script I set the VectorCam as camera for VectorLine using SetCamera.

But when I run the game in the editor a second (new) VectorCam is created and filled with strange values....

Last edited: Jul 8, 2012