Unity Community |
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:
using UnityEngine; using System.Collections; { private VectorLine myline; private Material myMat; private GameObject Line1; private GameObject Line2; private GameObject Line3; private GameObject Line4; private GameObject Line5; private const int MAX_SEGMENTS = 50; private GameObject MyLineNULL; // Use this for initialization { myline = new VectorLine("MyLine",new Vector3[MAX_SEGMENTS+1], myMat, 5.0f, LineType.Continuous, Joins.Weld); // Set the points of the array linePoints at the positions Vector.MakeSplineInLine (myline, linePoints, MAX_SEGMENTS); VectorManager.useDrawLine3D = true; myline.minDrawIndex = 10; myline.maxDrawIndex = 20; VectorManager.ObjectSetup(MyLineNULL, myline, Visibility.Always, Brightness.None, false); } // Update is called once per frame { { myline.minDrawIndex = 30; myline.maxDrawIndex = 40; } } }
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
FlyingText3D: real 3D text with TTF fonts | Vectrosity: fast & easy line drawing | Fractscape: fast & fun terrains
Nifty utilities! Stitch terrains together - runtime model importing - file browser
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?
Find Answers!
The Google Custom Search Engine for Unity3D: http://tinyurl.com/Unity3dSearchEngine
-
Learning Resources for Unity3D:
On the Unity3D forum | Unity3D Resources | Getting Started with Coding for Unity
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
FlyingText3D: real 3D text with TTF fonts | Vectrosity: fast & easy line drawing | Fractscape: fast & fun terrains
Nifty utilities! Stitch terrains together - runtime model importing - file browser
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.
Find Answers!
The Google Custom Search Engine for Unity3D: http://tinyurl.com/Unity3dSearchEngine
-
Learning Resources for Unity3D:
On the Unity3D forum | Unity3D Resources | Getting Started with Coding for Unity
aah!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
I made the same mistake as psdev.
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?
Yep, that should work.
--Eric
FlyingText3D: real 3D text with TTF fonts | Vectrosity: fast & easy line drawing | Fractscape: fast & fun terrains
Nifty utilities! Stitch terrains together - runtime model importing - file browser
Quick question. How do I go about parenting a 3D line to a GameObject?
Petter Sundnes
MentalFish.com
VectorLine.vectorObject is a reference to the line's GameObject, so you can use that.
--Eric
FlyingText3D: real 3D text with TTF fonts | Vectrosity: fast & easy line drawing | Fractscape: fast & fun terrains
Nifty utilities! Stitch terrains together - runtime model importing - file browser
Thanks a bunch, just what I needed.
Petter Sundnes
MentalFish.com
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?
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
FlyingText3D: real 3D text with TTF fonts | Vectrosity: fast & easy line drawing | Fractscape: fast & fun terrains
Nifty utilities! Stitch terrains together - runtime model importing - file browser
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?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
That sounds like it would work; you can use VectorLine.depth for that.
--Eric
FlyingText3D: real 3D text with TTF fonts | Vectrosity: fast & easy line drawing | Fractscape: fast & fun terrains
Nifty utilities! Stitch terrains together - runtime model importing - file browser
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
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.
That's pretty weird. Glad you got it working anyway.
Vectrosity does that nicely.
--Eric
FlyingText3D: real 3D text with TTF fonts | Vectrosity: fast & easy line drawing | Fractscape: fast & fun terrains
Nifty utilities! Stitch terrains together - runtime model importing - file browser
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
FlyingText3D: real 3D text with TTF fonts | Vectrosity: fast & easy line drawing | Fractscape: fast & fun terrains
Nifty utilities! Stitch terrains together - runtime model importing - file browser