So, I have been learning some of the basics of programming for the Android, and one of the things I'm trying to find out now is how to check and see if a "drawn GUI line" (Vectrosity Line) has overlapped a 3D object and if so to count it as a collision. I also want to let the 3D object to be notified of this (Like a SendMessage)
Edit: I am now using Vectrosity to draw my lines, which is a BIG help, but now I need to use check and see if a line was drawn over a particular object on screen
Also, i'm not trying to cut anything or looking for a complex collision, i just want to see if the line overlaps a certain object.
Before I write a lengthy answer that doesn't answer your question: with a line 'over' a 3d object do you mean that the line intersects or that the line is 'above' the object?
What exactly are you doing? Do you have basic shapes (sphere, box) that you just want to know were intersected by the line and you don't care where? Or do you have complex geometry, where you need to know exactly where the cut is? Or something else? 2D or 3D?
Well, as I see it you don't really have to calculate if the line intersected the objects.
Your input is the touch interface. All you have to do is check if at any time did the user moved his finger over one of the objects (unless you don't want to consider a half-way cut object as a success - in which case you'll need some math).
I don't know how worried you are with performance, but if a raycast is too expensive for some reason, you might even try and use the OnMouseOver event. It might just work.
OnMouseOver is just raycasting anyway (except with GUITextures), so there is no difference.
Additionally, it is important to note that if the player swipes quickly and great distances across the screen, there is a chance of the target object being "skipped over" because the finger might be over the collider in between raycasts. The solution for this was to insure a high frame rate.
I don't think there is an easy solution for this, especially if your objects have a complex geometry and you need very accurate information about where the object was slashed.
However the solution might be to calculate an "on-screen-bounding-box" for your object. To do this you could transform the vertices of your object's bounding box to ScreenSpace (using Camera.WorldToScreenPoint). That leaves you with 8 points. Now find the 4 that form the bounding box (contain the other 4 points). Now you have a rectangle. Checking if your line intersects this rectangle should be straightforward maths.
This one seems a bit more complex than I'm looking for.
I would approach this by transforming the collider of your 3d objects into screen space, and using a Line to Line collision test for each polygon in your model.
I also assume that your collision info for the line is an actual line or an array of line segments for your curvature. You can do some early logic to help the performance:ie: segment.bounds overlaps model.bounds
Before I write a lengthy answer that doesn't answer your question: with a line 'over' a 3d object do you mean that the line intersects or that the line is 'above' the object?
– anon73820239Above. sorry should have made that clear...
– SrBilyonLike the line is traced on the object like in the diagram.
– SrBilyonSwiping/Slashing an object on screen is my intention
– SrBilyonWhat exactly are you doing? Do you have basic shapes (sphere, box) that you just want to know were intersected by the line and you don't care where? Or do you have complex geometry, where you need to know exactly where the cut is? Or something else? 2D or 3D?
– Eric5h5