Picking terrain

Hi i have a terrain that i want to be able to pick and return the coord the ray intersects the terrain shape.

As far as i know the View.pick function only returns the shape3D object but i need the actual absolute location the pickray intersected the terrain shape.

Can anybody give me an idea how to go about this??

Thanks

Hi, there are several threads that deal with picking.

I use a triangle-plane buffer based on the terrain geometry and compute the intersection between a pick ray and the terrain geometry. This gives you local object coordinates which can be transformed to virtual world coordinates.

K do you have any examples of that?? i gave a look for some tutorials but found very little but will give another look maybe i overlooked something :slight_smile:

Oh, I’m afraid I am using a lot of my own libraries to do that outside xith. I need this for simulations that not necessarily need visualization.

What you basically need is the computation of a pick ray (I think this is done by xith) and the computation of the ray-triangle intersection (given your geometry is triangle based).

Contact me via this forums PM and I will send you the classes and how to use them.

Maybe you should do a tutorial concerning this.
I’m interested too… ;D

More specifically, I need to know wich triangle of a geom is picked to select it. ( As in a 3D modeler ).

I am having major problems with this. I cannot seem to find any clear examples anywhere and all the explanations I find just go over my head. I have an XY plane where Z is 0 and I need the XY coords of where they click on that plane. Can anyone help?

I have done my own code and it’s working fine with all shapes.
You get the triangle picked in the shape and the position of the intersection.
It is taking 0,02 milliseconds/triangle to calculate it.

I guess I’m not really looking to “pick” I just need the coordinates on my XY plane.

[quote]I have done my own code and it’s working fine with all shapes.
You get the triangle picked in the shape and the position of the intersection.
It is taking 0,02 milliseconds/triangle to calculate it.
[/quote]
Perfect !
And… where can we get your code ? ;D Maybe it’s a good idea to put it on xith-tk ?

There’s some code on this thread posted by Jacke:

http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=xith3d;action=display;num=1092602165;start=0#0

Worked a treat for me with a couple of mods!

Thanks Macca! I do have a question about it though, please refer to the posted thread.