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. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Eric: A little stumped with the pivot issue. I've double checked both models and they are at origin in both blender and unity. If I use line maker and save the data using Vector2, the pivot is correct, but the lines appear in the lower left of the screen (no biggie, I can move them after I draw them in Start...):


    If, on the other hand, I save using Write Complete Line To File the lines appear in the center of the screen, but the pivot is in the lower left of the screen:


    The only obvious difference is using V3's rather then V2's.

    I did a check of the points created by the two different methods.

    Some of the numbers get wonky after P8, but this is the "window strip" and the numbers do "add up" in the end. It must be due to the order that I selected the points manually to create the "window" when I saved the two different data sets in LineMaker.

    So - the points are the same.

    But the center-point of the object is not. I'm unclear where to find this... as the object's transforms all seem to be flat.

    I've used both of these lines and it's the same whether I setup the object or just associate a transform.
    Code (csharp):
    1. Vector.DrawLine (shipVLine, shipV.transform);
    2.   or
    3. VectorManager.ObjectSetup (shipV, shipVLine, Visibility.Dynamic, Brightness.None);
    I'm presuming from the docs and our previous conversation that I need an array of Vector3s for VectorManager.ObjectSetup to work properly.

    And I'm using VectorManager.ObjectSetup so I can use collisions on a Vector Object. If I don't need to use Vector3[] then I'm happy to go with the Vector2[] if it will work...

    Guide me, oh Landru?
     
    Last edited: Aug 17, 2011
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Are you of the body? You will be absorbed. I am of the body, and I do not experience this issue. I have tried your code with the script on an object at (0, 0, 150) and the camera at the origin, it appears to work correctly. Peace be with you. Peace and tranquility.

    --Eric
     
  3. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Got it!

    It was this code:
    Code (csharp):
    1.     void Update () {
    2.         float translationV = Input.GetAxis("Vertical") * speed;
    3.         float rotationV = Input.GetAxis("Horizontal") * rotationSpeed;
    4.         translationV *= Time.deltaTime;
    5.         rotationV *= Time.deltaTime;
    6. //        shipVLine.vectorObject.transform.Translate(0, translationV, 0);
    7. //        shipVLine.vectorObject.transform.Rotate(0, 0, -rotationV);
    8.        
    9.         shipV.transform.Translate(0, translationV, 0);
    10.         shipV.transform.Rotate(0, 0, -rotationV);
    11.        
    12.         float translationY = Input.GetAxis("Vertical2") * speed;
    13.         float rotationY = Input.GetAxis("Horizontal2") * rotationSpeed;
    14.         translationY *= Time.deltaTime;
    15.         rotationY *= Time.deltaTime;
    16. //        shipYLine.vectorObject.transform.Translate(0, translationY, 0);
    17. //        shipYLine.vectorObject.transform.Rotate(0, 0, -rotationY);
    18.        
    19.         shipY.transform.Translate(0, translationY, 0);
    20.         shipY.transform.Rotate(0, 0, -rotationY);
    21.     }
    -

    I was following the code in this section Advanced movement with vectorObject (Think of the little triangular spaceship in old vector games like Asteroids...) which uses myLine.vectorObject.transform.Rotate (Vector3.forward * 45.0); I hadn't revisited this when using the Vector3 data and didn't realize I could move the transform directly. I guess the vectorObject is at (0,0) - lower left - but when the 3D ships are created, they are centered in the screen but still rotating around the vectorObject in the corner. When I referenced the object (shipY shipV) set up by VectorManager.ObjectSetup, then it works correct.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yeah, VectorLine.vectorObject is sometimes useful (which is why I mention it in the docs), but mostly you shouldn't use it.

    --Eric
     
  5. dakasha

    dakasha

    Joined:
    Nov 20, 2010
    Posts:
    29
    So i purchased this a few days ago and am pretty happy with it (great price btw) but i am either doing something wrong or the scripts are just a bit weird (actually i prob just misunderstand some technical aspect :p)

    Anyways I have this class:

    Code (csharp):
    1. public class VectorObject : MonoBehaviour
    2. {
    3.     public string Name = "UNNAMED";
    4.  
    5.     public TextAsset VectorLineData;
    6.     public float LineWidth;
    7.     public Material Material;
    8.     public Color Color = Color.red;
    9.  
    10.     public virtual void Start()
    11.     {
    12.         // Setup line 'graphics'
    13.         Vector3[] linePoints = Vector.BytesToVector3Array(VectorLineData.bytes);
    14.         VectorLine  lineRepresentation = new VectorLine(Name, linePoints, Color, null, LineWidth);
    15.         VectorManager.ObjectSetup(gameObject, lineRepresentation, Visibility.Dynamic, Brightness.None);
    16.     }
    In order to set up vector objects quickly. It works great except that draw batching is strange..

    If I use the line Maker on the included unity meshes Cube, Sphere and plane and use the byte files as the textAsset i get these results:

    Cubes all get batched (I can have 100+ gameobjects and its 1 draw call)
    Planes are 1 draw call each
    Spheres are 2

    :-/

    Im only changing the text assets to read the different byte files so in my mind they should all be drawn the same way (although with more processing due to more points). How are these things drawn?

    Btw if i create a line and draw it in update instead its the same result. Ive read most of the manual but maybe i overlooked something


    EDIT: Oh my... writing it out once again 'solved' it for me..
    Code (csharp):
    1. Vector.BytesToVector3Array(VectorLineData.bytes);
    xD

    Still it would be interesting to know why the draw calls are different in case i do wish to use Vector3's (Im new to 3d programming so its prob pretty obvious)

    edit again:

    Argh nevermind.. Now i get 1 draw call per object but no batching? Im confused :p
    This means that 8 objects on the screen equals 8 draw calls (and i plan on having quite a few more on screen)
    Why do the cubes batch but not the others?
     
    Last edited: Aug 17, 2011
  6. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Ok, after a few days of fun and games with Vectrosity, I must admit: "It is a very well thought thru and elegant system".

    I would recommend this package to anyone looking for a line drawing solution.

    Thanks, Eric, for such well thought thru code.
     
  7. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    Eric,

    Quickie for ya. I am using the DrawPoints() and I want to use a material like the DotLine (or DotLine2) but I want to change colors on it. I know this should be relative simple, but I'm not exactly sure how to do it. If I set the colors on it now, it stays yellow, because the material is yellow. Which shader should I apply to the material to get it to still act sort of like a particle (like it does now), but use the vertex colors from the lines?

    Thanks,
    Gigiwoo.
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Batching only occurs if the triangle/vertex count is low enough for a given object, so I would assume the others are over the limit.

    Particles/Additive would work; that has a tint color that can be applied on top of the vertex colors.

    --Eric
     
  9. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Interesting... I've noticed that in LineMaker, one can push the points around and manually create new lines between the points, but if one were to push a number of points around and hit "Connect All Points", it still seems to use the underlying geometry rather than the point spheres themselves:


    -

    Also, may I pry and ask what the association between the Main Camera and the Vector Camera is?

    It seems that the Main Camera is required for the Vector Camera to appear. If I disable the Main Camera (as an experiment as I'm not using it, really, when all of my game is rendered in VectorLines...), the Vector Camera doesn't appear.
     
    Last edited: Aug 17, 2011
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's a good point about Line Maker; to be consistent I should change it so "connect all points" uses the location of the spheres in the scene rather than the points in the mesh. As for the main camera, that's the default. You can call Vector.SetCamera manually with any camera, but you should get an error if you use DrawLine and no camera can be found. The Vector Camera is used for drawing 2D lines as an overlay, but if you're using DrawLine3D and drawing lines in the scene, then you don't need the Vector Camera (and one won't be made).

    --Eric
     
  11. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Riiight. I'm not explicitly using either DrawLine or DrawLine3D. I'm using VectorManager.ObjectSetup.

    Very similar to DakaSha, I have a VectorObject class:
    Code (csharp):
    1. [System.Serializable]
    2. public class VectorObject {
    3.     public string name = "NewObject";
    4.     public TextAsset lineData;
    5.     public float lineWidth = 1.0f;
    6.     public Material lineMaterial = null;
    7.     public Color lineColor = Color.white;
    8.     public GameObject vectorGO;
    9. }
    ... which I then list, and populate in the inspector:
    Code (csharp):
    1.  
    2.     public List <VectorObject> vectorObjects;
    And then draw all of my objects at once in a method called in Start():
    Code (csharp):
    1.  
    2.     void DrawObjects () {
    3.         foreach (VectorObject vObj in vectorObjects) {
    4.             Vector3[] objectPoints = Vector.BytesToVector3Array (vObj.lineData.bytes);
    5.             VectorLine objectLine = new VectorLine (vObj.name, objectPoints, vObj.lineColor, vObj.lineMaterial, vObj.lineWidth);
    6.             VectorManager.ObjectSetup (vObj.vectorGO, objectLine, Visibility.Dynamic, Brightness.None);
    7.         }
    8.     }
    It must be VectorManager.ObjectSetup that calls DrawLine?
     
  12. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Say, while I'm filling this thread with fragrant prose...

    Is there an easy way to compare colliders with the vector lines? This could be related to the Vector Camera issue above, but, I'm finding that the vector line (which are displayed by the Vector Camera) are disassociated with the Vector's GameObject, and it's difficult to align the colliders:



    Now, the GameObjects seem to be centered in the Main Camera and the Vectors centered in the Vector Camera:
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If you're using ObjectSetup, then a scene object is made with a script on it that handles drawing. By default it uses Vector.DrawLine, but if you set "VectorManager.useDrawLine3D = true", then it will use DrawLine3D. With a game that consists of only lines, you definitely don't need DrawLine3D (DrawLine is faster). Also, it's true that in this case you don't actually need two cameras. By default, the vector camera is transparent except for the lines, so the main camera is just providing the background. You could technically make the vector camera have a solid background and delete the main camera, but personally I'd be inclined to leave it the way it is for simplicity, since having two cameras doesn't hurt anything. Also that way the main camera is there just in case you want to use it for something else (like emulating the painted screen background that some vector games had, such as Asteroids).

    --Eric
     
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    As for aligning colliders, since I mentioned VectorManager.useDrawLine3D, probably you'd want to set that to true temporarily, so that way the lines won't be disassociated from the game object.

    --Eric
     
  15. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Out of amusement I tried resetting the Vector Camera to origin at runtime, but it only moved the camera, leaving the VectorLines behind, even tho' the lines say they are all at origin as well:


    The solution was to include the original geometry in the otherwise empty GameObject (originally containing only the Transform, Box Collider and Rigidbody components).


    This reveals the original geometry I built the lines with so the sizing of the colliders to vector lines should be close enough this way. I'll eventually need a mesh collider anyway, as a box will probably be too annoying for the player, especially with the V-Ship


    I'll keep "VectorManager.useDrawLine3D set to true temporarily" in my back pocket for the next go 'round.
     
    Last edited: Aug 17, 2011
  16. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Dots, Cameras and ObjectSetup...

    I did some experimenting with drawing points. All of the Vector.DrawPoints code is great. I also experimented with putting a collider on the GameObject that sets the transform with Vector.DrawPoints (myPoints, transform); and it triggers properly.

    But I'm discovering that there doesn't seem to be a Vector.ObjectSetup that will take points and draw points. I did try to feed it points, but received the expected kick in the pants with "VectorManager: GetBounds can only be used with a Vector3 array". This returns to the camera issue from above. If I can't do an ObjectSetup on the points, my points end up with the collider in the center of the screen with my other properly setup object, but the visual image of the dot is in the lower left corner.

    I was planning on using points for weapons. Do you have any suggestions? Is there anyway to VectorManager.SetupObject (myObject, myPoint)? Or should I try a 1 pixel line object? myLine { (0,0), (0,1) }? Try something screwy with the camera?
     
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Indeed, ObjectSetup doesn't support points at this time. It didn't occur to me that people would want to use points for that. :) I think the 1-pixel line object is the best idea at this point (sorry, pun intended).

    --Eric
     
  18. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    Heya,

    I think I found a bug... The DestroyLine() method does not seem to accept a VectorPoints object. And there does not seem to be a DestroyPoints() method. So, once I create a VectorPoints, it has to stay on my scene :(.

    PS - If you add this, would you please post the code here? I can paste it in and keep going.

    Gigiwoo.
     
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's strange; I wonder why using ref causes VectorPoints to not work there (it used to work before it used ref). Anyway, you can copy/paste the DestroyLine function and then change "ref VectorLine" to "ref VectorPoints".

    --Eric
     
  20. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    As we push this excellent system beyond it's intended parameters...

    Making a point shot out of two points.

    As I draw all of my objects at this point in a loop called as Start() using the binary file method, I though it would be good to keep the "shot" in the same format.

    So - Into blender for a mesh as simple as it comes, one edge and two verts:


    Pop that into LineMaker and I get two points as spheres! Yay!

    Connect all points? No, didn't think so: There are no triangles, you must connect these by hand! Ok.

    Select the two spheres. Click "Make Line Segment", oh dear! "Must have two points selected":


    But I do, and they are. LineMaker doesn't seem to like this setup.

    -

    [edit]

    Odd. It's inconsistent. I discovered that if I drag the spheres around, I can sometimes draw the segment, but often not. The default was to have one sphere at (0,0,0) and the other at (0, 0.1, 0) and it won't draw.

    It doesn't seem to be distance, as when I move the two to (0,0,0) and the other at (0, 0.5, 0), I don't get a segment - same error.

    But if I move the second to another location sometimes I get a line segment, sometimes I don't. Can't find the consistency to solve the problem.

    Moreover, sometimes I get this error, even tho' both are selected:


    Related to very small objects too close together?

    [/edit]

    -

    [edit2]

    This seems to be the marquis that's the problem. I get consistent segments being created when I click the first sphere and shift+click the second to add the second sphere to the selection, but the marquis selection tool seems to highlight both spheres, but LineMaker returns those two errors most of the time.

    [/edit2]
     
    Last edited: Aug 18, 2011
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I would try making a triangle in Blender that contains the points you want, plus an extra one just to make a triangle. Then LineMaker will work, and you can use the points you want and ignore the other one.

    --Eric
     
  22. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Yes, making a triangle probably would have helped. What struck me most about that experiment was the fact that Unity's marquis tool (drag select) was in consistent ... at least at that scale.
     
  23. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    BTW, Just want to say that I have really enjoyed using Vectrosity. If you need lines or points or vector type shapes in your project, for any reason at all, even if just for something small like a highlight box, then Vectrosity is probably the single most effective purchase you can make. The Unity store sells it for $25 and honestly, it's just an incredible value. It's been very easy to use, has helped me make some wonderful visuals, and Eric works hard to support his users.

    Kudos. +1.

    Gigiwoo.
     
  24. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I've been using vectrosity to have a go at moving some of the excellent stuff at openprocessing.org onto unity with some pretty satisfying results! Especially given my ineptitude at programming/scripting

    Considering the GL class is pro only (Something that counfounds me maybe), vectrosity is an absolutely invaluable tool
     
  25. iisjreg

    iisjreg

    Joined:
    Mar 25, 2011
    Posts:
    101
    Sounds interesting, do you have any examples of sketches you've converted?
     
  26. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Yep i've a few, i'll post em here

    Disco Fever
    Flocking and steering behaviours(Theres actually much more to the code I just did this simple visual for it
    Isometric stuff
    More Isometric stuff
    Bouncy rubber sponge thingy
    They twang
    All of the effects together, may make your computer sad

    Most of them you can click/drag over to interact with on some level

    They were done using vectrosity's line, ellipse, quads etc, my code is awful, to put it simply so im sure they could be done better, i'm happy to post it should anyone want to have a look, due credit goes to the various guys at openprocessing making al this awesome stuff

    One thing i will say is i'd REALLY like some sort of equivalent of Processing's drawing tools that atm you can only do on Unity easily with the GL class, which is pro only, which is annoying as hell. I'd love to be able to draw quads and other shapes and maybe even rotate lines per object without messing around ading a transformation, im not even sure how to get that working my efforts today were in vain (I'm not going to show what that ended up looking like...)

    But yes an ability to draw quads, shapes and even just pixels would be hugely appreciated, and a very fast analogue (as in a quick command like setline/setray) of the vectorline/makesplineinline would be nice, i'm aware I could build a mesh in script for quads etc but it's not very intuitive

    That said, vectrosity is absolutely excellent and as far as i've seen the only way for a unity 'hobbyist' to do some cool fast 2D work with unity without pro
     
  27. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Vectrosity already does this, or do you mean simplified commands specific to those? Actually SetLine does shapes already, you can just add more points at the end; you're not limited to two.

    --Eric
     
  28. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Well i meant filled shapes, i know a line can have as many points as you like, but it wont fill the shape in like a GL quad or Processing shape, i suppose the best way to see what i mean is to look at the Processing reference http://processing.org/reference/

    A quad I mean is a 4 sided polygon, not restricted to a rect, and a shape is a filled shape made from a series of vertices, some of these can be bezier control points, and yeah i guess the main thing is they can be filled with a colour.

    If Unity had the ability to draw as simply and intuitively as Processing it would be absolutely fantastic just for doodling in script, nevermind some fast and artful visual effects with a lot of existing inspiration out there on the net

    That said i'm not detracting from your work it's excellent and im not even sore how hard it would be to implement what i'm mulling over
     
  29. iisjreg

    iisjreg

    Joined:
    Mar 25, 2011
    Posts:
    101
    @LazyGunn, I would LOVE to see your code. That's brilliant work.

    For filling in, could you not create tris using the vertices that are already there? Something along the lines of RageSpline: http://forum.unity3d.com/threads/94918-RageSpline-2D-Vector-Graphics-for-Unity-v1.1-RELEASED

    or:

    http://www.unifycommunity.com/wiki/index.php?title=Triangulator

    Actually: that would be a brilliant addition to the line maker utility - select three points, click "create tri"... lovely. (obviously, there's a lot to do with materials, children, etc.)
     
    Last edited: Aug 23, 2011
  30. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Hmm yep i guess it would work a bit like the cap function in 3ds max, its no good for collections of vertices not on a 2D plane but otherwise it could be very handy

    I'm hanging around to get the new Deus Ex as a break from the last few weeks constant 'coding' atm but I did take a moment this morning to try vectrosity's DrawLine3D using the transform of the object its called from along with one of the above effects - it worked brilliantly, can now apply any of those effects around a level and i'm going to investigate more of Processing's 3D functionality and seeing where vectrosity can help with it

    I'll post a few bits of code from the above with appropriate credits (As specified in the creative commons license) with my changes to make em work with Unity in a few mins (I'm relaxing away from my desktop atm). I'm not really a coder i'm a graphics person so if you see huge mistakes in the code, don't blame me!
     
  31. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Ok here's some example code from above, maybe it will help

    Here's the disco rain code, it was originally written in HSV colour mode which doesnt seem to have an easy analogue outside the editor classes in unity so i put a function i found via google that converts HSV to RGB

    Code (csharp):
    1.  
    2.  
    3. // CC Credits
    4. // Block Matrix by Gerard Geer, licensed under Creative Commons Attribution-Share Alike 3.0 and GNU GPL license.
    5. // Work: http://openprocessing.org/visuals/?visualID=30059
    6. // License:
    7. // http://creativecommons.org/licenses/by-sa/3.0/
    8. // http://creativecommons.org/licenses/GPL/2.0/
    9.  
    10. using UnityEngine;
    11. using System.Collections;
    12.  
    13. public class SquareRain : MonoBehaviour
    14. {
    15.  
    16.  
    17.     public static Material pointMat;
    18.     public int columns = 10;
    19.     public int rows = 20;
    20.     public CellArray cells;
    21.  
    22.     void Start ()
    23.     {
    24.         cells = new CellArray ((float)Screen.width / 1.5f, 2 * (float)Screen.height, rows, columns);
    25.     }
    26.     void Update ()
    27.     {
    28.         cells.staticActivity ();
    29.         //frame.setTitle("FrameRate:"+frameRate);
    30.         for (int i = 0; i < 2; i++)
    31.             cells.mouseAction ();
    32.         cells.handle ();
    33.        
    34.     }
    35.    
    36.    
    37. }
    38.  
    39. public class Cell
    40. {
    41.     float locX, locY;
    42.     float sizeX, sizeY;
    43.     public float cBrightness;
    44.     public float cHue;
    45.     VectorLine square;
    46.     Vector2[] squareSegs;
    47.     Rect rect;
    48.  
    49.  
    50.  
    51.     public Cell (float locX, float locY, float cHue, float sizeX, float sizeY)
    52.     {
    53.         this.squareSegs = new Vector2[5];
    54.         this.locX = locX;
    55.         this.locY = locY;
    56.         this.sizeX = sizeX;
    57.         this.sizeY = sizeY;
    58.         cBrightness = 0;
    59.         this.cHue = cHue;
    60.         this.square = new VectorLine ("Square", squareSegs, SquareRain.pointMat, 1, LineType.Continuous);
    61.        
    62.        
    63.     }
    64.  
    65.     public void spark ()
    66.     {
    67.         cBrightness = 255;
    68.     }
    69.     public void spark (float bright)
    70.     {
    71.         cBrightness += bright;
    72.     }
    73.  
    74.     public void handle (float degredation)
    75.     {
    76.        
    77.         cBrightness /= degredation;
    78.         rect = new Rect (locX, locY, sizeX * 0.7f, sizeY * 0.7f);
    79.         Vector.MakeRectInLine (square, rect);
    80.         Vector3 coltemp = new Vector3 ((cHue / 255) * 360, 255 / 255, cBrightness / 255);
    81.         Vector3 coltemp2 = HSVtoRGB (coltemp);
    82.         Color setcol = new Color (coltemp2.x, coltemp2.y, coltemp2.z);
    83.         Vector.SetColor (square, setcol);
    84.         Vector.DrawLine (square);
    85.        
    86.     }
    87.     public Vector3 HSVtoRGB (Vector3 hsv)
    88.     {
    89.         int i;
    90.        
    91.         float H = hsv.x;
    92.         if (H < 0)
    93.             // catch malformed H input
    94.             H = 0; else if (H > 360)
    95.             H = 360;
    96.         float S = hsv.y;
    97.         if (S < 0)
    98.             // catch malformed S input
    99.             S = 0; else if (S > 1)
    100.             S = 1;
    101.         float V = hsv.z;
    102.         if (V < 0)
    103.             // catch malformed V input
    104.             V = 0; else if (V > 1)
    105.             V = 1;
    106.        
    107.         float R;
    108.         float G;
    109.         float B;
    110.        
    111.         float f;
    112.         // variables for calculating base color mixing around the "spectrum circle"
    113.         float p;
    114.         float q;
    115.         float t;
    116.        
    117.         Vector3 rgb;
    118.        
    119.         if (S == 0) {
    120.             // achromatic (grey) simply set R,G,  B = Value
    121.             R = V;
    122.             G = V;
    123.             B = V;
    124.            
    125.             rgb.x = R;
    126.             rgb.y = G;
    127.             rgb.z = B;
    128.             return rgb;
    129.         }
    130.        
    131.         H /= 60;
    132.         // Hue factored into range 0 to 5
    133.         i = Mathf.FloorToInt (H);
    134.         // integer floor of Hue
    135.         f = H - i;
    136.         // factorial part of H
    137.         p = V * (1 - S);
    138.         q = V * (1 - S * f);
    139.         t = V * (1 - S * (1 - f));
    140.        
    141.         if (i == 0) {
    142.             R = V;
    143.             G = t;
    144.             B = p;
    145.         } else if (i == 1) {
    146.             R = q;
    147.             G = V;
    148.             B = p;
    149.         } else if (i == 2) {
    150.             R = p;
    151.             G = V;
    152.             B = t;
    153.         } else if (i == 3) {
    154.             R = p;
    155.             G = q;
    156.             B = V;
    157.         } else if (i == 4) {
    158.             R = t;
    159.             G = p;
    160.             B = V;
    161.         } else {
    162.             R = V;
    163.             G = p;
    164.             B = q;
    165.         }
    166.        
    167.         rgb.x = R;
    168.         rgb.y = G;
    169.         rgb.z = B;
    170.        
    171.         return rgb;
    172.     }
    173. }
    174.  
    175. public class CellArray
    176. {
    177.     public float arrayWidth;
    178.     public float arrayHeight;
    179.     public float numVert;
    180.     public float numHoriz;
    181.     public Cell[,] cells;
    182.     public int[] offset;
    183.  
    184.  
    185.  
    186.     public CellArray (float arrayWidth, float arrayHeight, int numVert, int numHoriz)
    187.     {
    188.         this.arrayWidth = arrayWidth;
    189.         this.arrayHeight = arrayHeight;
    190.         this.numVert = numVert;
    191.         this.numHoriz = numHoriz;
    192.        
    193.         float cellHeight = arrayHeight / numVert;
    194.         float cellWidth = arrayWidth / numHoriz;
    195.         cells = new Cell[numHoriz, numVert];
    196.         for (int i = 0; i < cells.GetLength (0); i++) {
    197.             for (int k = 0; k < cells.GetLength (1); k++) {
    198.                 cells[i, k] = new Cell (cellHeight * i, cellWidth * k, 100, cellWidth, cellHeight);
    199.                
    200.             }
    201.         }
    202.         offset = new int[numHoriz];
    203.         for (int i = 0; i < offset.Length; i++) {
    204.             offset[i] = Mathf.CeilToInt (Random.value * (numVert));
    205.         }
    206.     }
    207.  
    208.     public void mouseAction ()
    209.     {
    210.         for (int i = 0; i < cells.GetLength (0); i++) {
    211.             cells[i, ((Time.frameCount / 2) + offset[i]) % cells.GetLength (1)].spark ();
    212.         }
    213.     }
    214.  
    215.     public void staticActivity ()
    216.     {
    217.         for (int i = 0; i < cells.GetLength (0); i++) {
    218.             for (int k = 0; k < cells.GetLength (1); k++) {
    219.                 cells[i, k].spark (Random.value * (5));
    220.             }
    221.         }
    222.     }
    223.  
    224.     public void handle ()
    225.     {
    226.         for (int i = 0; i < cells.GetLength (0); i++) {
    227.             for (int k = 0; k < cells.GetLength (1); k++) {
    228.                 cells[i, k].handle (1.08f);
    229.                 cells[i, k].cHue = 255 * Mathf.Abs (Mathf.Sin (Time.frameCount * .005f));
    230.             }
    231.         }
    232.     }
    233.    
    234.    
    235. }
    236.  
    237.  
    The first isometric example, it's actually not in 3D at all and in Unity you can get some fun visual trippy effects by rotating the whole thing

    Code (csharp):
    1.  
    2.  
    3. // CC Credits
    4. // Wavy by BlueThen, licensed under Creative Commons Attribution-Share Alike 3.0 and GNU GPL license.
    5. // Work: http://openprocessing.org/visuals/?visualID=5671
    6. // License:
    7. // http://creativecommons.org/licenses/by-sa/3.0/
    8. // http://creativecommons.org/licenses/GPL/2.0/
    9.  
    10. using UnityEngine;
    11. using System.Collections;
    12.  
    13. public class Test1 : MonoBehaviour {
    14.    
    15.     private float a;
    16.     private Mesh testmesh;
    17.     private int[] newTriangles;
    18.     private VectorLine[,] quadLines;
    19.     private Vector2[] isoPoints;
    20.     public Material isoMat;
    21.    
    22.  
    23.     void Start () {
    24.    
    25.         isoPoints = new Vector2[15];
    26.         quadLines = new VectorLine[14,14];
    27.                                      
    28.          for (int x = 0; x < 14; x++) {
    29.                for (int z = 0; z < 14; z++) {
    30.  
    31.                     quadLines[x,z] = new VectorLine("QuadLine", isoPoints, isoMat, 2, LineType.Continuous);
    32.             }
    33.         }
    34.     }
    35.    
    36.     void Update () {
    37.        
    38.  
    39.       a -= 0.08f;
    40.       for (int x = -7; x < 7; x++) {
    41.             for (int z = -7; z < 7; z++) {
    42.        
    43.  
    44.  
    45.             float y = 24 * Mathf.Cos(0.55f * distance(x,z,0,0) + a);
    46.              
    47.  
    48.             float xm = x*17 +8.5f;
    49.             float xt = x*17 -8.5f;
    50.             float zm = z*17 +8.5f;
    51.             float zt = z*17 -8.5f;
    52.              
    53.  
    54.             int halfw = Screen.width/2;
    55.             int halfh = Screen.height/2;
    56.              
    57.  
    58.             float isox1 = xm - zm + halfw;
    59.             float isoy1 = (xm + zm) * 0.5f + halfh;
    60.             float isox2 = xm - zt + halfw;
    61.             float isoy2 = (xm + zt) * 0.5f + halfh;
    62.             float isox3 = xt - zt + halfw;
    63.             float isoy3 = (xt + zt) * 0.5f + halfh;
    64.             float isox4 = xt - zm + halfw;
    65.             float isoy4 = (xt + zm) * 0.5f + halfh;
    66.                
    67.  
    68.                
    69.             isoPoints[0] = new Vector2(isox2, isoy2-y);
    70.             isoPoints[1] = new Vector2(isox3, isoy3-y);
    71.             isoPoints[2] = new Vector2(isox3, isoy3-40);
    72.             isoPoints[3] = new Vector2(isox2, isoy2-40);
    73.                
    74.                
    75.                
    76.                
    77.             isoPoints[4] = isoPoints[0];
    78.  
    79.             isoPoints[5] = new Vector2(isox3, isoy3-y);
    80.             isoPoints[6] = new Vector2(isox4, isoy4-y);
    81.             isoPoints[7] = new Vector2(isox4, isoy4-40);
    82.             isoPoints[8] = new Vector2(isox3, isoy3-40);
    83.             isoPoints[9] = isoPoints[5];
    84.  
    85.                
    86.             isoPoints[10] = new Vector2(isox1, isoy1-y);
    87.             isoPoints[11] = new Vector2(isox2, isoy2-y);
    88.             isoPoints[12] = new Vector2(isox3, isoy3-y);
    89.             isoPoints[13] = new Vector2(isox4, isoy4-y);
    90.             isoPoints[14] = isoPoints[10];
    91.  
    92.  
    93.  
    94.             Vector.DrawLine(quadLines[x+7,z+7]);
    95.  
    96.             }
    97.         }
    98.     }
    99.  
    100. /*
    101.  
    102. ///* The distance formula */
    103.    
    104.     public float distance(float x,float y,float cx,float cy) {
    105.  
    106.         float f = Mathf.Sqrt(((cx - x)*(cx - x)) + ((cy - y)*(cy - y)));
    107.         return f;
    108.     }
    109.  
    110. }
    111.  
    112.  
    And here's the bouncy sponge example, obviously gravity is reversed because i forgot that screen Y in Unity is top down

    Code (csharp):
    1.  
    2.  
    3. // CC Credits
    4. // Sponge by Asher Salomon, licensed under Creative Commons Attribution-Share Alike 3.0 and GNU GPL license.
    5. // Work: http://openprocessing.org/visuals/?visualID=15431
    6. // License:
    7. // http://creativecommons.org/licenses/by-sa/3.0/
    8. // http://creativecommons.org/licenses/GPL/2.0/
    9.  
    10. using UnityEngine;
    11. using System.Collections;
    12.  
    13. public class Boingy : MonoBehaviour
    14. {
    15.  
    16.     int nH = 10;
    17.     int nV = 16;
    18.     float ds = 12;
    19.     node[,] nodes;
    20.     float k = 0.10f;
    21.     float c = 0.05f;
    22.     float kw = 7;
    23.     float cw = 2;
    24.     void Start ()
    25.     {
    26. //      size (500, 400);
    27. //      smooth ();
    28. //      stroke (255);
    29. //      strokeWeight (0.5);
    30. //      noFill ();
    31. //      ellipseMode (CENTER);
    32.         nodes = new node[nH, nV];
    33.         reset ();
    34.         k = k / 16 * ds;
    35.         c = c / 16 * ds;
    36.         kw = kw / (Mathf.Pow (16 / 2, 2) / 2) * (Mathf.Pow (ds / 2, 2) / 2);
    37.         cw = cw / (Mathf.Pow (16 / 2, 2) / 2) * (Mathf.Pow (ds / 2, 2) / 2);
    38.     }
    39.     void reset ()
    40.     {
    41.         for (int i = 0; i < nH; i++) {
    42.             for (int j = 0; j < nV; j++) {
    43.                 nodes[i,j] = new node (new Vector2 (Screen.width / 2 - (nH - 1) / 2 * ds + i * ds, Screen.height - ds / 2 - (nV - 1) * ds + j * ds));
    44.             }
    45.         }
    46.     }
    47.     void LateUpdate ()
    48.     {
    49.         if (Input.GetMouseButtonDown(0)){
    50.             mousePressed();
    51.         }
    52.         if (Input.GetMouseButtonUp(0)){
    53.             mouseReleased ();
    54.             }
    55.         if (Input.anyKeyDown){
    56.             keyPressed();
    57.         }
    58.         // background (0);
    59.         for (int m = 0; m < rate; m++) {
    60.             for (int i = 0; i < nH - 1; i++) {
    61.                 for (int j = 0; j < nV; j++) {
    62.                     reactor (nodes[i,j], nodes[i + 1,j], new Vector2 (ds / 2, 0), 0);
    63.                 }
    64.             }
    65.             //  for(int j=0;j<nV;j++){
    66.             //    reactor(nodes[nH-1][j],nodes[0][j],new PVector(ds/2,0),TWO_PI);
    67.             //  }
    68.             for (int i = 0; i < nH; i++) {
    69.                 for (int j = 0; j < nV - 1; j++) {
    70.                     reactor (nodes[i,j], nodes[i,j + 1], new Vector2 (0, ds / 2), 0);
    71.                 }
    72.             }
    73.             for (int i = 0; i < nH; i++) {
    74.                 for (int j = 0; j < nV; j++) {
    75.                     bool slip = false;
    76.                     if (nodes[i,j].x.x < ds / 2) {
    77.                         nodes[i,j].f += (new Vector2 ((ds / 2 - nodes[i, j].x.x) * k, 0));
    78.                         slip = true;
    79.                     }
    80.                     if (nodes[i,j].x.x > Screen.width - ds / 2) {
    81.                         nodes[i,j].f += (new Vector2 ((nodes[i,j].x.x - Screen.width + ds / 2) * -k, 0));
    82.                         slip = true;
    83.                     }
    84.                     if (nodes[i,j].x.y < ds / 2) {
    85.                         nodes[i,j].f += (new Vector2 (0, (ds / 2 - nodes[i,j].x.y) * k));
    86.                         slip = true;
    87.                     }
    88.                     if (nodes[i,j].x.y > Screen.height - ds / 2) {
    89.                         nodes[i,j].f += (new Vector2 (0, (nodes[i,j].x.y - Screen.height + ds / 2) * -k));
    90.                         slip = true;
    91.                     }
    92.                     if (slip) {
    93.                         nodes[i,j].v =  nodes[i,j].v * (1.0f - c);
    94.                     }
    95.                     nodes[i,j].update ();
    96.                     if (hold1 == i  hold2 == j) {
    97.                         nodes[i,j].grip ();
    98.                     }
    99.                 }
    100.             }
    101.         }
    102.         for (int i = 0; i < nH; i++) {
    103.             for (int j = 0; j < nV; j++) {
    104.                 nodes[i,j].draw ();
    105.             }
    106.         }
    107.     }
    108.     void reactor (node A, node B, Vector2 dxo, float offset)
    109.     {
    110.         Vector2 refA = A.toWorld (dxo) + A.x;
    111.         Vector2 refB = B.toWorld (dxo * -1)+ B.x;
    112.         Vector2 dx = refB - refA;
    113.         Vector2 mid = refA + (dx * 0.5f);
    114.         Vector2 F = dx * k;
    115.         Vector2 dvmid = B.vat (mid) - A.vat (mid);
    116.         F += dvmid * c;
    117.         A.force (F, mid);
    118.         B.force ((F  * -1), mid);
    119.         //  float dp = (((B.p-A.p)+PI)%TWO_PI)-PI;
    120.         float dp = Mathf.Clamp(B.p - A.p + offset, -Mathf.PI, Mathf.PI);
    121.         dp *= kw;
    122.         dp += (B.w - A.w) * cw;
    123.         A.t += dp;
    124.         B.t -= dp;
    125.     }
    126.     int hold1 = -1;
    127.     int hold2 = -1;
    128.    
    129.     void mousePressed ()
    130.     {
    131.         Vector2 mo = new Vector2 (Input.mousePosition.x, Input.mousePosition.y);
    132.         for (int i = 0; i < nH; i++) {
    133.             for (int j = 0; j < nV; j++) {
    134.                 Vector2 dx = nodes[i,j].x - mo;
    135.                 if (dx.magnitude < ds / 2) {
    136.                     hold1 = i;
    137.                     hold2 = j;
    138.                 }
    139.             }
    140.         }
    141.     }
    142.     void mouseReleased ()
    143.     {
    144.         hold1 = -1;
    145.         hold2 = -1;
    146.     }
    147.     int rate = 3;
    148.     void keyPressed ()
    149.     {
    150.         switch (Input.inputString) {
    151.         case " ":
    152.             reset ();
    153.             break;
    154.         case "1":
    155.             rate = 1;
    156.             break;
    157.         case "2":
    158.             rate = 2;
    159.             break;
    160.         case "3":
    161.             rate = 3;
    162.             break;
    163.         case "4":
    164.             rate = 4;
    165.             break;
    166.         case "5":
    167.             rate = 5;
    168.             break;
    169.         case "6":
    170.             rate = 6;
    171.             break;
    172.         case "7":
    173.             rate = 7;
    174.             break;
    175.         case "8":
    176.             rate = 8;
    177.             break;
    178.         case "9":
    179.             rate = 9;
    180.             break;
    181.         case "0":
    182.             rate = 10;
    183.             break;
    184.         }
    185.     }
    186. }
    187.  
    188. public class node
    189. {
    190.     public Vector2 x;
    191.     public  Vector2 v;
    192.     public  Vector2 f;
    193.     public  float p;
    194.     public  float w;
    195.     public  float t;
    196.     public  float ds = 12;
    197.    
    198.     public VectorLine circle;
    199.     public Material pointMat;
    200.     public Vector2[] circleSegs;
    201.    
    202.     public node (Vector2 xo)
    203.     {
    204.         x = xo;
    205.         v = new Vector2 ();
    206.         f = new Vector2 ();
    207.         p = 0;
    208.         w = 0.1f;
    209.         t = 0;
    210.        
    211.         circleSegs = new Vector2[12];
    212.         circle = new VectorLine("Circle", circleSegs, pointMat,1);
    213.     }
    214.     public void update ()
    215.     {
    216.         v += f;
    217.         f = new Vector2 (0, 0.005f);
    218. //    f = new PVector();
    219.         x += v;
    220.         w += t / (Mathf.Pow (ds / 2, 2) / 2);
    221.         w = Mathf.Clamp(w, -Mathf.PI / 4, Mathf.PI / 4);
    222.         t = 0;
    223.         p += w;
    224.     }
    225.     public  Vector2 toWorld (Vector2 input)
    226.     {
    227.         Vector2 output = new Vector2 ();
    228.         output.x = -input.y * Mathf.Sin (p) + input.x * Mathf.Cos (p);
    229.         output.y = input.y * Mathf.Cos (p) + input.x * Mathf.Sin (p);
    230.         return output;
    231.     }
    232.     public  Vector2 toOri (Vector2 input)
    233.     {
    234.         Vector2 output = new Vector2 ();
    235.         output.x = -input.y * Mathf.Sin (-p) + input.x * Mathf.Cos (-p);
    236.         output.y = input.y * Mathf.Cos (-p) + input.x * Mathf.Sin (-p);
    237.         return output;
    238.     }
    239.     public  void grip ()
    240.     {
    241.         v = new Vector2 (1, 1 );
    242.         x = new Vector2 (Input.mousePosition.x, Input.mousePosition.y);
    243.     }
    244.     public  Vector2 vat (Vector2 R)
    245.     {
    246.         Vector2 dr = R - x;
    247.         float vdr = w * dr.magnitude;
    248.         dr.Normalize ();
    249.         Vector2 output = v + new Vector2 (vdr * -dr.y, vdr * dr.x);
    250.         return output;
    251.     }
    252.     public void force (Vector2 F, Vector2 R)
    253.     {
    254.         Vector2 arm = R - x;
    255.         float tork = F.y * arm.x - F.x * arm.y;
    256.         t += tork;
    257.         f += (F);
    258.     }
    259.     public  void draw ()
    260.     {
    261.         Vector2 point = new Vector2(x.x, x.y);
    262.         Vector.MakeCircleInLine(circle, point, ds/2);
    263.         Vector.DrawLine(circle);
    264.  
    265. // I left the below in to show how all the graphics would be done by Processing
    266.  
    267. //      ellipse (x.x, x.y, ds, ds);
    268. //      line (x.x, x.y, x.x + ds / 2 * cos (p), x.y + ds / 2 * sin (p));
    269.     }
    270. }
    271.  
    Hope these help
     
    Last edited: Aug 23, 2011
  32. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Well, bad news is the DrawLine3D is proving too slow on mobile, have you any suggestions as to how it might be sped up? I'm trying to implement the disco black rain example above and even with only a handful of rows and columns it really hurts performance, it may just be that my code is terrible however
     
  33. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Are you redrawing the square rain every frame? I've not dug deep into the code. TBH: Once they've been drawn, as an animation technique, they only need to be *moved* by the value of one square per unit time to animate. One doesn't need to redraw the graphic each frame. then once the graphic has hit it's max move value, they need to be faded.

    But my guess is that this doesn't conform to the procedural code you are using.

    My only note about filled polygons and vectrosity is: Vectrocity == Lines != Filled Quads? Is this an extension that is beyond the scope of a vector line drawing package?

    That being said, it's all REALLY coool, what you've done, mobile-able or not.
     
  34. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Your suggestion could definitely work i think! As setcolor doesnt require a new draw, eureka via you as a proxy, i'l look into it
     
  35. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Brilliant! That did the trick perfectly, its still a bit of a performance hit changing the colours but actually pretty usuable now, well within the budget i'd given myself for using such effects in this part of the game, colour me pleased (hah). All i had to do was make it draw only once.

    Cheers!
     
  36. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I wonder how reusing/duplicating objects work with Vectrosity... in the these line objects seem identical in the square rain. It makes me wonder if you could draw only one, then clone and pool them and then move/animate them... But I suppose you'd still need to change all of their colors, regardless. Just imagining some sort of simplification/pooling. Not sure.

    I'm going to have to do something like that with Space Duel for the shots and obstacles. At this point I imagine I'm going to procedurally create, draw and store a pool of objects.
     
  37. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    As a lil update for those following, heres those pretty flashing vectrosity rainsquares in situ

    http://pourfoi.com/test/

    its meant for mobile and is a bit broken but hopefully youll enjoy
     
  38. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    269
    My goodness, I remember this. That's amazing! :D
     
  39. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Well I have pro and I still use Vectrosity because it's cross platform :) there's no point in supporting gl lines or whatever if the target platform is DX :)
     
  40. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Eric, concerning the line.maxDrawIndex - does it work on non continuous lines as well ie discrete, because I'm having varying behaviour.

    Also for discrete, is it per 2 points or per 1 point? ie if I specify line.maxDrawIndex = 1; it should draw one line right? indexes 0 and 1?
     
  41. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    GL.LINES works with Direct3D. It may be called "GL" but it uses the same cross-platform backend that the rest of Unity uses, naturally (and it's called GL because for years Unity was OpenGL-only, and there's not a good enough reason to screw people's code up by changing the name now, especially since "GL" is still technically an accurate name). I have Pro and I still use Vectrosity because it's just better. ;)

    Discrete lines do work with maxDrawIndex. line.maxDrawIndex = 1 will draw one line segment; line.maxDrawIndex = 2 will also draw one line segment (since you have one complete segment and only the starting point for the next segment).

    --Eric
     
  42. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Thanks eric, just as I found the bug - I was doing truely dumbass stuff. Regarding that GL stuff... its got me curious. It works in DX? then I might find use for it somewhere, I wonder what I can do. More toys I guess :D
     
  43. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    Question - not specific only to vectrosity, but it is an effect I'm trying to achieve with vectrosity

    I want to paint in a cumulative way. So, one frame, I have 3 or 4 vectrosity objects in a particular spot. It renders to texture (or something like that) and then the next frame, I start out with my previous frame. I move the objects and render again, on top of the output from last frame. If I keep doing that, I could create some really fun effects that look like a painting program, but using the vectrosity objects. I assume I could even go back later and paint in the background color to make it look like it was disappearing...

    But... I don't know how to do it. (I have unity pro, and I assume I need a render to texture or something)

    Can you point me in the right direction?

    Gigiwoo.
     
  44. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Not quite sure what you're asking...is it about how to use rendertextures?

    --Eric
     
  45. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    My point with the GL stuff is just that its fast and useful in certain circumstances, but yes for most uses vectrosity is better, and will be hopefully get a big lookin in my current idea i was mulling over today, i want a terrain to have vectorlines in splines running lengthways along it, following the contours like a DEM visualisation but waving and pretty (Prime31 did some good videos to get this animating nicely) but! without the manual in front of me can you tell me if line widths can be change per line segment point thing? (And I suppose hence animateds), it could look very very prettyyyy
     
  46. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    If you want a nice idea of what GL kind of commands do, an analogue of lots of their functionality is implemented in a java based language called Processing, I put a few examples on the previous page that i moved to vectrocity

    Look at www.openprocessing.org and the top favourites, its some impressive stuff
     
  47. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yep.

    --Eric
     
  48. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    One note - this is further complicated because Vectrosity makes its own camera at runtime. Which makes it hard to setup render texture targets.

    I don't understand how I would render vectrosity to a texture, then reuse that texture as the background and render on top of it, and again and again... There's something I'm missing... I think. Imagine using a single vectrosity shape. Now, draw that one frame on top of a black screen. A big circle in the middle of the screen. Now, next frame, I move the circle 3 pixels left and I draw it. But this time, I want the previous drawing of the circle to already be there. Then next frame, I move the circle 3 move pixels left and 1 up, and I draw it. But I want it to be drawn on top of the previous 2 circles. Does that make sense? Just looking for some general guidance on how to do it.

    Gigiwoo.
     
    Last edited: Aug 26, 2011
  49. iisjreg

    iisjreg

    Joined:
    Mar 25, 2011
    Posts:
    101
    mmm, render what the main camera sees to a texture on a plane just behind the vectrosity object? Then render it whenever you want a new frame...
     
  50. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Gigiwoo: Can you tell us what your final result should be? Rather then the immediate step? It might be easier to come up with an answer. Are you trying to make some sort of vector paint application?
     
Thread Status:
Not open for further replies.