Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (808)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (872)
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  
  Mouse Picking  (Read 5742 times)
0 Members and 1 Guest are viewing this topic.
Offline Hydroque

JGO Coder


Medals: 25
Exp: 5 years


I'm always inspiring a good time.


« Posted 2016-06-15 12:35:41 »


I've worked out code to gather a ray from screen space to world space. I am having trouble detecting what lies on this ray. I am trying to select a certain triangle in a mesh of triangles.

I looked around on google and found nothing comprehensive for this.

Can anyone share pseudo code or explain the details on this?

Thanks! <3

You think I haven't been monitoring the chat? http://pastebin.java-gaming.org/c47d35366491fHere is a compilation <3
Offline KaiHH

JGO Kernel


Medals: 820



« Reply #1 - Posted 2016-06-15 12:40:29 »

There has been someone on the LWJGL forum with exactly the same question.
I'll just link it here: http://forum.lwjgl.org/index.php?topic=6242.0
Offline ShadedVertex
« Reply #2 - Posted 2016-06-15 12:52:16 »


I've worked out code to gather a ray from screen space to world space. I am having trouble detecting what lies on this ray. I am trying to select a certain triangle in a mesh of triangles.

So basically, you're trying to detect ray-triangle intersection (intersection of a ray and a triangle).

There are several websites with articles and tutorials about detecting intersection (ray-triangle, ray-plane, ray-sphere, ray-point, etc.)

Here's one that looks promising: http://www.lighthouse3d.com/tutorials/maths/ray-triangle-intersection/

You could try the 3D Math Primer for Graphics and Game Development (it's a book, not a website). It has an entire chapter about detecting intersection. Also, make sure your method of transforming screen coordinates to normalized device coordinates actually works the way it should.

If you don't want to implement ray-? intersection tests yourself, you could use a physics engine (jBullet, as I'm sure you already know, is the most popular, if not the only, physics engine for Java. It's a port of the ever-popular Bullet physics engine, which was written in C++. Bullet Physics is tied in first place with Nvidia's PhysX on the popularity rankings, but I'm pretty sure Bullet is easier to use than PhysX).

I think Bullet has a rayTest function to detect ray-? intersection, not too sure. Bullet can be a royal pain in the neck (it's not very easy to use), but...hey, no complaints! It's awesome!

Good luck and have fun! Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Hydroque

JGO Coder


Medals: 25
Exp: 5 years


I'm always inspiring a good time.


« Reply #3 - Posted 2016-06-15 16:17:52 »

Thanks kaihh, I skimmed through it and it looked like a good artical. I searched through jgo, but not lwgl forums.

ShadedVertex, I'm opposed to using libraries like that. As you already know, but that information on what it was is great. Good reply. I won't be using jbullet and I will definitely check out that link. I haven't skimmed it yet. Unfortunately, I have no access to books or means to go get books with money. So that is difficult.

Once I figure this all out I'll be sure to leave a contribution in the wiki. My movement article had a load of hits above the others in the front page. So I hoped I helped someone out.

You think I haven't been monitoring the chat? http://pastebin.java-gaming.org/c47d35366491fHere is a compilation <3
Offline ShadedVertex
« Reply #4 - Posted 2016-06-16 10:35:36 »

ShadedVertex, I'm opposed to using libraries like that. As you already know, but that information on what it was is great. Good reply. I won't be using jbullet and I will definitely check out that link. I haven't skimmed it yet. Unfortunately, I have no access to books or means to go get books with money. So that is difficult.

Hm...yes, I do know that you particularly dislike 3rd-party libraries that spoon-feed you. Your dislike for external libraries such as jBullet and PhysX will be a major inconvenience, especially if you're working with 3D.

Also, I've got a piece of advice that can benefit you greatly if you take heed of it: if you can't acquire what you need, you're not searching in the right places. I'm doing my best to be enigmatic with my words right now, because (strictly speaking) I'm advocating something I shouldn't be.

Pages: [1]
  ignore  |  Print  
 
 

 
mercenarius (13 views)
2020-06-04 19:26:01

mercenarius (21 views)
2020-06-04 19:13:43

Riven (865 views)
2019-09-04 15:33:17

hadezbladez (5847 views)
2018-11-16 13:46:03

hadezbladez (2656 views)
2018-11-16 13:41:33

hadezbladez (6272 views)
2018-11-16 13:35:35

hadezbladez (1517 views)
2018-11-16 13:32:03

EgonOlsen (4748 views)
2018-06-10 19:43:48

EgonOlsen (5803 views)
2018-06-10 19:43:44

EgonOlsen (3297 views)
2018-06-10 19:43:20
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
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!