hey guys ,
I need to highlight vertices if mouse comes within a specified range , wat ‘s the way to go about it.
Do i have to do the picking and get all nodes intersected and than take their vertices and than by calulation see which vertices is within the range ,seems not a good solution. :’(
Any help is well appreciated …
If you want to do that an efficient way, it’s not that easy.
A naive solution would be, as you said (but I’ll try to say it in a clear way) :
- To do picking
- Retrieve the list of all intersected Shape3D from PickResult
- Retrieve the pick position from PickResult
- For each Shape3D in the list :
- For each Coordinate in the Shape3D :
- Test distance with pick position : if(dist < range)
- Highlight this vertice
- Test distance with pick position : if(dist < range)
- For each Coordinate in the Shape3D :
Is this what you wanted to say ?
I should note, that if you only want the nearest Shape3D to the view it’s by far faster than testing all the Shape3D. (Check the getPickNearest() or getPickAll() functions).
Thanks a lot for framing the question properly , my mistake i didnt wrote in a readable manner.
Yaa that is exactly what i wanted to do ,
only change is i am not concerned with the nearest Shape3D ,
but with the nearest vertice (which lies within specified range ) to the pick ray , for ex.
1.) Lets assume that working plane is XY plane with Z=0.
2) And if pick ray is formed at X=10,Y=10, Z=0 with ray going towards -Z Axis.
3) So for me any vertice at X=10 ,Y=10, and any Negative Z value is the Closet Vertice.
I would be very happy to know the efficent way , although it may be hard ,may be i'll learn something new in the process :).
Well, I’m afraid there’s not a more effeicient way of doing that, except if your geometry is pretty much static (in which case you could manage to use a space partitioning algorithm to speed up the whole).
Hmm…thanks for the reply , let me study the space partitioning algorithm and see how useful it can be
You may find these pages interesting :
http://en.wikipedia.org/wiki/Quadtree (if your geometry is 2D)
http://en.wikipedia.org/wiki/Octree
EDIT : You should anyway try to implement the naive method first, and see if the performances are acceptable. Someone said “Premature optimization is the root of all evil”… Probably you’ll need some optimization here but evaluate first. If your geometry < 5000 polys, it might be acceptable (or you could try to split your geometry in multiple Shape3D…)