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 / selecting matrix tiles with a mouse

Author
Message
Powersoft
22
Years of Service
User Offline
Joined: 1st Aug 2003
Location: United Kingdom
Posted: 3rd Dec 2003 19:55
hi there im currently working on a project but have stumbled across a problem. selecting matrix tiles and 3d objects with the mouse. do you have any clue how it could be done.

Resist the power of the ring...
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 3rd Dec 2003 20:02
You cant use pick object (unfortunately) - you would have to write your own system. I dont know how though...


Mirrors are more fun than television. Well, that was fun, in a not-so-fun sort of way...
Powersoft
22
Years of Service
User Offline
Joined: 1st Aug 2003
Location: United Kingdom
Posted: 3rd Dec 2003 20:08
oh...
my...
god...
nooooooooooooooooooooooooo!
ok well how does anyone think i should go about it.
you know how i mean the way you click things in the sims command and conquer etc...

Rich

Resist the power of the ring...
xtom
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Ireland
Posted: 3rd Dec 2003 20:47
When you click, run an object over the visible area of the matrix in a grid pattern and then check it against the mouse.
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 3rd Dec 2003 21:05
Couple of ways come to mind, you could build a mesh of the matrix, and thus use pick object against the mesh. That'd work, but if your matrix is dynamic in some way, it could be a bit of hassle -rebuilding the mesh/dummy object all the time.

The easier way is to project a ray from the click point to some future point and then 'sample' the ground at a user defined step. This works fairly well, you'll get a few errors here and there on sharp terrain, but it's a lot easier.

There's some old DB classic code on my site for this..

http://www.DBcode.UnderwareDesign.com

or, there's an older pick library for DB classic here. Dunno how well (or even if) it works in DBpro..

http://www.DBLibraries.UnderwareDesign.com

Kevin Picone
Play Basic - Visible Worlds - Kyruss II
[url]www.underwaredesign.com[/url]
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 3rd Dec 2003 21:06
Here's a snippet I wrote some time ago to allow selecting of a tile on a matrix however hilly the matrix is and whatever your camera angle is. Code may need tidying up a bit.

I am using this in my alien compo game as part of the level editor and it hasn't let me down yet. It only sometimes gets slightly confused selecting tiles on very edge of matrix if camera is at a weird angle.




Boo!
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 3rd Dec 2003 21:24
I posted a snippet in the codebase to do exactly this

3d mouse:



Working out which tile an object is on:



"Help! My keyboard is stuckkkkkkkkkkkkkkkkkkkkkkkkkkkkk"

Mercenaries in Space demo @ http://www.davidtattersall.me.uk
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 4th Dec 2003 03:17 Edited at: 4th Dec 2003 03:19
Heres one [matrix selection] I did a while a go to help out somebody or other on the DBP IRC channel



For object selection I normally do something like:




God created the world in 7 days, but we're still waiting for the patch.
Powersoft
22
Years of Service
User Offline
Joined: 1st Aug 2003
Location: United Kingdom
Posted: 4th Dec 2003 19:13
cheers but i still cant understand it.

Resist the power of the ring...
D Man
23
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 4th Dec 2003 19:23 Edited at: 4th Dec 2003 19:23
Try that one.
http://darkbasicpro.thegamecreators.com/?m=forum_view&t=13689&b=6
It gives you the position on the matrix and you can convert it back to the tilenumber.

God is real, unless declared integer.
Powersoft
22
Years of Service
User Offline
Joined: 1st Aug 2003
Location: United Kingdom
Posted: 4th Dec 2003 19:35
cheers i understand it now.

Resist the power of the ring...

Login to post a reply

Server time is: 2026-07-26 20:16:35
Your offset time is: 2026-07-26 20:16:35