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.

Code Snippets / [DBP] - Custom PICK OBJECT implementation (supports orthographic cameras)

Author
Message
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd Nov 2013 17:29
While pondering my cascaded shadow mapping issues as of late, I happened to realize a way that works for implementing the same functionality as provided by the built-in DBPro function pick object.
There are some advantages to this;
It supports any kind of camera projection, such as orthographic. (The built-in function does not).
It is written in pure DBPro (or well, it uses IanM's M1U, but what doesn't these days?). As such you can extend / change it to fit your requirements. One of the most important things this allows you to do is pick objects from a list instead of having to use a contiguous range of object id's (ie. 100 - 499) like with the built-in function.
Potential to be more efficient than the built-in function. Using the built-in intersect object function, as is done in the demonstration below, this runs about 20% slower than the standard pick object function. However, using a more efficient raycasting function, like can be found in most third party physics / collision dll's, you can make this run significantly faster than the standard implementation, which is obviously a big plus when picking a large amount of objects in realtime. For example, using the raycasting function from Paul Johnston's ("Sparky"'s) free collision library, this function only requires ~19.7% of the executing time of the built-in version.


The actual function:



A small, ugly demonstration program (no external media required, just copy, paste and compile):



"Why do programmers get Halloween and Christmas mixed up?"
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 4th Nov 2013 05:32
Whoa, awesome work Rudolpho!

I'm looking forward to simplifying your example so that I can understand it. Good stuff!

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Nov 2013 06:36
Quote: "
Unlike the built-in function, this will work with orthographic (and presumably any other kind of) camera projections"


Does the integrated pick object command not work with different camera projections? I would assume it works in very much the same way as your function does, by referencing the current camera projection and view matrix.

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 4th Nov 2013 09:59
@Burning Feet Man: thanks, it's pretty well commented so hopefully that shouldn't be a problem

@Phaelax: you would think so, but try it - it really doesn't for whatever reason.


"Why do programmers get Halloween and Christmas mixed up?"

Login to post a reply

Server time is: 2024-04-27 03:06:43
Your offset time is: 2024-04-27 03:06:43