Unity Community


Page 49 of 122 FirstFirst ... 3947484950515999 ... LastLast
Results 961 to 980 of 2421

  1. Posts
    53
    Quote Originally Posted by Eric5h5 View Post
    I modified the Simple3D 2 example script a bit as a test, works fine:
    Thanks, this works for me too now. My problem was that I did not set the maxDrawIndex to 1 in the start to begin with.

    Though I am a little confused and am not sure if there is a bug here though it's likely again to me doing something wrong. Would you check out this simple script and see if there is a bug in Vectrosity? I just create a scene with 5 Empty GameObjects named NULL_Line1 through 5. This draws a 50 segment line. All works fine until you try to change the minDrawIndex or set the maxDrawIndex to something less than it was when Start() executed.

    Running this and hitting the F5 key shows 2 segments (as if the first segment is not erased properly?) instead of moving where the segment is being drawn along the line. Can you test this on your end and tell me what I am doing wrong or if there is a refresh command or something that gets minDrawIndex to work, or maxDrawIndex to work when set to something less than it already is?

    thanks for your help with this!



    Code:  
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class TestLineDrawingScript: MonoBehaviour
    5. {
    6.     private VectorLine myline;
    7.     private Material myMat;
    8.    
    9.     private GameObject Line1;
    10.     private GameObject Line2;
    11.     private GameObject Line3;
    12.     private GameObject Line4;
    13.     private GameObject Line5;
    14.    
    15.     private const int MAX_SEGMENTS = 50;
    16.    
    17.     private GameObject MyLineNULL;
    18.  
    19.     private Vector3[] linePoints;
    20.    
    21.     // Use this for initialization
    22.     void Start ()
    23.     {
    24.         Line1 = GameObject.Find("NULL_Line1");
    25.         Line2 = GameObject.Find("NULL_Line2");
    26.         Line3 = GameObject.Find("NULL_Line3");
    27.         Line4 = GameObject.Find("NULL_Line4");
    28.         Line5 = GameObject.Find("NULL_Line5");
    29.  
    30.         myMat = (Material)Resources.Load("MyMat");
    31.  
    32.         myline = new VectorLine("MyLine",new Vector3[MAX_SEGMENTS+1], myMat, 5.0f, LineType.Continuous, Joins.Weld);       
    33.    
    34.         // Set the points of the array linePoints at the positions
    35.         linePoints = new Vector3[] {Line1.transform.position, Line2.transform.position,  Line3.transform.position, Line4.transform.position, Line5.transform.position};
    36.        
    37.         Vector.MakeSplineInLine (myline, linePoints, MAX_SEGMENTS)
    38.  
    39.         MyLineNULL = new GameObject("myLineNULL");
    40.  
    41.         VectorManager.useDrawLine3D = true;
    42.        
    43.         myline.minDrawIndex = 10;
    44.         myline.maxDrawIndex = 20;
    45.         VectorManager.ObjectSetup(MyLineNULL, myline, Visibility.Always, Brightness.None, false);
    46.  
    47.     }
    48.  
    49.     // Update is called once per frame
    50.     void Update ()
    51.     {
    52.         if(Input.GetKeyDown(KeyCode.F5))
    53.         {
    54.             myline.minDrawIndex = 30;
    55.             myline.maxDrawIndex = 40;
    56.         }
    57.     }
    58. }

  2. Volunteer Moderator
    Posts
    23,746
    Min and maxDrawIndex won't remove segments that are already drawn; they are just an optimization so that, for example, the entire line doesn't have to be recomputed if you're just adding some points at the end and not changing any of the earlier points. See the DrawLinesMouse example script. If you want to remove segments, you can set the relevant points to Vector3.zero and redraw the line.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes

  3. Administrator



    Location
    London, UK
    Posts
    3,308
    So, speaking of which... I've just started looking into the best way to do this, and have not gone far... If I had a HUD being drawn by Vectrocity, and wanted to toggle the whole shebang on and off... Is there and easy shortcut? Having done little to no research except ask?

  4. Volunteer Moderator
    Posts
    23,746
    Yes, you can use VectorLine.active. If the HUD is made of more than one VectorLine, then you'd toggle .active for each one. Another possibility is to just disable the vector camera, if the HUD is the only thing being drawn by Vectrosity. In this case you can get a reference to the vector camera by doing "var cam = Vector.SetCamera();" at the start and do "cam.enabled = false/true".

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes

  5. Administrator



    Location
    London, UK
    Posts
    3,308
    Thanks for the tips!

    I'll try the camera trick, and I'll wrap where I'm updating the HUD in a bool as well, so it won't be calculating in the BG.


  6. Posts
    586
    Quote Originally Posted by Eric5h5 View Post
    Min and maxDrawIndex won't remove segments that are already drawn; they are just an optimization so that, for example, the entire line doesn't have to be recomputed if you're just adding some points at the end and not changing any of the earlier points. See the DrawLinesMouse example script. If you want to remove segments, you can set the relevant points to Vector3.zero and redraw the line.

    --Eric
    aah!

    I made the same mistake as psdev.


  7. Posts
    586
    so if I wanted to change the drawmouse sample scene so that I could hold down the right mouse button and the lines would be erased from the last point drawn to the first, I would cycle through the linepoints arrays and set each point to vector.zero?

  8. Volunteer Moderator
    Posts
    23,746
    Yep, that should work.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  9. Location
    Bergen, Norway
    Posts
    274
    Quick question. How do I go about parenting a 3D line to a GameObject?
    Petter Sundnes
    MentalFish.com

  10. Volunteer Moderator
    Posts
    23,746
    VectorLine.vectorObject is a reference to the line's GameObject, so you can use that.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  11. Location
    Bergen, Norway
    Posts
    274
    Thanks a bunch, just what I needed.
    Petter Sundnes
    MentalFish.com


  12. Posts
    586
    hey guys, this may relate to my last question, but I'm using code similar to mouse draw sample code except it allows drawing multiple lines as separate vector objects. I've been pondering if there is an easy way to create an erase tool? any thoughts?

  13. Volunteer Moderator
    Posts
    23,746
    Not really an easy way that I can think of. Unless you have a solid-colored background, in which case just make a line the same color as the background and have it draw on top of the other lines. It's not really erasing, of course, but it would look like it. Otherwise I think you'd have to scan through the points in the line arrays and compare them to the current mouse position, and zero out the closest match if it's within a certain distance.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  14. Posts
    586
    Quote Originally Posted by Eric5h5 View Post
    Not really an easy way that I can think of. Unless you have a solid-colored background, in which case just make a line the same color as the background and have it draw on top of the other lines. It's not really erasing, of course, but it would look like it. Otherwise I think you'd have to scan through the points in the line arrays and compare them to the current mouse position, and zero out the closest match if it's within a certain distance.

    --Eric
    both of those seem like pretty good ideas, thanks Eric, except those erased areas won't be drawable again...perhaps drawing every new line at a z distance a small bit closer to the camera than the last?

  15. Volunteer Moderator
    Posts
    23,746
    Quote Originally Posted by redmacmanz View Post
    both of those seem like pretty good ideas, thanks Eric, except those erased areas won't be drawable again...perhaps drawing every new line at a z distance a small bit closer to the camera than the last?
    That sounds like it would work; you can use VectorLine.depth for that.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  16. Location
    Bergen, Norway
    Posts
    274
    I thought I had a Vectrosity issue but it turns out to be something else.

    I came across a C# implementation of a Delauney triangulation solution which works like a treat (Unity editor view on the left), but as you can see in the image to the right it goes all wonky on the lower parts of the triangulation while running on an iPad:


    My gut is telling me it has something to do with decimal precision? Care to take a look?

    http://dl.dropbox.com/u/1258056/Unit...t.unitypackage

    Update: it works on Android but no go on iPod, so it must be an iOS/Xcode issue:


    Solution, use different Delaunay implementation: http://code.google.com/p/jdt/downloads/list

    Works on iOS:


    Isn't talking to oneself the first sign of insanity?
    Last edited by MentalFish; 03-25-2012 at 10:32 AM. Reason: Solved
    Petter Sundnes
    MentalFish.com


  17. Posts
    5

    draw simple shapes (rectangle, round ...)

    Good evening, eg you help me I have a final project study I'm working on unity 3d I like to know how to draw simple shapes (line, rectangle, round ...) help me please and give me solutions.

  18. Volunteer Moderator
    Posts
    23,746
    Quote Originally Posted by MentalFish View Post
    Update: it works on Android but no go on iPod, so it must be an iOS/Xcode issue:
    That's pretty weird. Glad you got it working anyway.

    Quote Originally Posted by mohamed20 View Post
    Good evening, eg you help me I have a final project study I'm working on unity 3d I like to know how to draw simple shapes (line, rectangle, round ...) help me please and give me solutions.
    Vectrosity does that nicely.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  19. Volunteer Moderator
    Posts
    23,746
    Quote Originally Posted by mohamed20 View Post
    Help me plz
    http://www.starscenesoftware.com/vectrosity.html Scroll to the bottom, and click on one of the yellow buttons. I'm happy to give support, but I'm sure you understand that you must be a customer first.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes

Page 49 of 122 FirstFirst ... 3947484950515999 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •