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.

Newcomers DBPro Corner / 3D Point Relative to Camera's 2D Plane?

Author
Message
Mr909
12
Years of Service
User Offline
Joined: 2nd Jun 2012
Location:
Posted: 20th Nov 2012 01:28
Is there a command that works like OBJECT SCREEN X (MatrixUtils) but with a 3d point? Or has someone figured out a function for this?
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 20th Nov 2012 03:42 Edited at: 20th Nov 2012 04:09
before a math guru steps in to solve, try this:




trust me when i say i did understand your question. your solution was right in front of you all along

changed code to make it a bit more obvious.

also, object screen x is native dbpro code, or did i miss something?

Virtual Nomad @ California, USA . DBPro V7.7 . Matrix1Utils 05.27.12
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Brendy boy
19
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 20th Nov 2012 06:24
you need a camera projection matrix and use it to transform a vector with 3d point coordinates

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 20th Nov 2012 06:31
Well I'm no math guru, so I just let DB do the calculations for me.



This snippet is also on my website.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Mr909
12
Years of Service
User Offline
Joined: 2nd Jun 2012
Location:
Posted: 20th Nov 2012 20:07 Edited at: 20th Nov 2012 20:49
@VN: Yeah, well I didn't want to create objects where it was unnecessary. I want to have some points that are, well, points. The objects are just 2d drawings where that point is, so why waste an object that is invisible anyway?

@BB and Phaelax: Thanks guys. I know there's a more math-based way to do it, but since I can't find anyone who knows it I guess I'm stuck with this method. Thanks Phaelax, that really helps, I can't express that enough. If anyone wants to step it that knows the mathematically correct way, I would LOVE to see how it compares in a speed test.

EDIT: Do I have to create a separate Vector3 for each point I intend to draw? I intend to use a lot of points. :\
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Nov 2012 09:31
Quote: "EDIT: Do I have to create a separate Vector3 for each point I intend to draw? I intend to use a lot of points. :\"


Not if you don't need the data from the vector after reading each one. If you're just drawing some points, then simply: project, draw, repeat. It'll just overwrite whats in that vector from before but won't change what you've drawn already.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Mr909
12
Years of Service
User Offline
Joined: 2nd Jun 2012
Location:
Posted: 21st Nov 2012 16:12
I tested a draw code with two separate 3d-based points and it only conformed to the second one, even though the draw code was in between. I think it had something to do with how it loaded... I undid the code but I might try to replicate it sometime within the next day or so...

Login to post a reply

Server time is: 2024-11-21 19:08:26
Your offset time is: 2024-11-21 19:08:26