Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / 2D Coordinates on a 3D Plane

Author
Message
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 13th Sep 2012 00:32
Basically how do you work out the 2D coordinates (x/y) at mouse position on a 3D plane?

I need to manipulate an image via a 3D plane. Not painting, but using the returned coordinates to update things in the image.
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 13th Sep 2012 00:56
Try Ray Casting?

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 13th Sep 2012 05:18
Search "Vectors Don't Bite" on the forum, in that pdf there's a raycasting example of it.

There's also this post:
http://forum.thegamecreators.com/?m=forum_view&t=180210&b=1

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 13th Sep 2012 19:14 Edited at: 15th Sep 2012 13:16
I remember posting that using RayCasting, but ultimately your math and Kira's code stole the show. But I was thinking if we are revisiting this. Could there be another possible method?
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Sep 2012 20:14
There's this : http://forum.thegamecreators.com/?m=forum_view&t=197498&b=1&msg=2360518#m2360518

TheComet

"Why geeks like computers: unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep." - Unknown
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 15th Sep 2012 13:08 Edited at: 15th Sep 2012 18:10
Finally worked out a method that supports full rotations on a quad. I guess you could adapt it to any object, but for now it just works for a quad.

I rayhit each triangle and worked out the barycentric coordinates to calculate the UV's which I converted into texture coordinates. This became difficult when rotating since vertex positions don't update with rotation. So I used the object direction vector to move the points then do the calculations. I think the code still needs a bit of work, especially when it comes to working out the texture coordinates between faces, but least it's working.



Edit: After a little testing and so far I haven't found a bug, I can say this is twice as fast as Kira's method. I'm guessing all that matrix maths is slow.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 20th Sep 2012 22:14
Is there a better way of retrieving vertex positions of a rotating object?
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 20th Sep 2012 23:42
calculate limb world matrix and use it to transform local vertex coords

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 21st Sep 2012 01:22 Edited at: 25th Sep 2012 15:34
Quote: "calculate limb world matrix and use it to transform local vertex coords"

Yeah, you could do:



But I don't think anything will beat limbs in terms of speed:

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 25th Sep 2012 15:33
Is there a better way of using barycentric coordinates on different face due to the UV's being reversed?

Login to post a reply

Server time is: 2026-07-07 23:01:44
Your offset time is: 2026-07-07 23:01:44