Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How to do Snaps  (Read 1088 times)
0 Members and 1 Guest are viewing this topic.
Offline khangharoth

Junior Member




There is more to life than JAVA...But Java Rocks


« Posted 2006-08-10 14:04:47 »

 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. Cry
                   Any help is well appreciated .............

Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #1 - Posted 2006-08-10 14:25:13 »

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

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).

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline khangharoth

Junior Member




There is more to life than JAVA...But Java Rocks


« Reply #2 - Posted 2006-08-10 15:27:45 »

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  Smiley.

                   
       



                                                                                               

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #3 - Posted 2006-08-10 16:24:27 »

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).

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline khangharoth

Junior Member




There is more to life than JAVA...But Java Rocks


« Reply #4 - Posted 2006-08-11 05:28:38 »

Hmm.......thanks for the reply , let me study the space partitioning algorithm and see how  useful it can be

Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #5 - Posted 2006-08-11 14:42:53 »

You may find these pages interesting :
http://en.wikipedia.org/wiki/Binary_space_partitioning
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..)

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (5 views)
2014-07-23 20:17:25

ctomni231 (39 views)
2014-07-18 06:55:21

Zero Volt (36 views)
2014-07-17 23:47:54

danieldean (29 views)
2014-07-17 23:41:23

MustardPeter (32 views)
2014-07-16 23:30:00

Cero (47 views)
2014-07-16 00:42:17

Riven (48 views)
2014-07-14 18:02:53

OpenGLShaders (38 views)
2014-07-14 16:23:47

Riven (37 views)
2014-07-14 11:51:35

quew8 (33 views)
2014-07-13 13:57:52
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!