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 / Any Matrix Tile Mouse Selection Routines?

Author
Message
Darkcoder
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 29th Apr 2003 11:23
Hi Folks!

There are a few 3D Object mouse selection routines out there, but does anyone know if a Matrix Tile mouse selection routine exists?

Maybe someone has an idea how one could work?

Thanks
System: 1.333Ghz Athlon Thunderbird, 512meg, Geforce 4 Ti 4400.

Hardware /nm./: the part of the computer that you can kick.
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 29th Apr 2003 22:26
I've got object but it's not on this pc. I'll try and get it soon.

You are the th person to view this signature.
Programmers don't die, they just Gosub without return....
andrew11
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 30th Apr 2003 00:18
Once, I had a plain with different sections to select. I put smaller, hidden plains arranged in a grid slightly above the plain and used an object select function to see which one I was clicking on. It uses alot of polies, but it worked. Maybe this would work with matricies. If your matrix is 100*100 and has 10*10 tiles, arrange 100 hidden 10*10 plains above the matrix. You could use get matrix height to determine how far above to position the plains.

"All programmers are playwrites and all computers are lousy actors" -Anon
Muddleglum
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: New Zealand
Posted: 30th Apr 2003 00:23 Edited at: 1st May 2003 05:43
Just in case someone looks again here i will EDIT it to be more exact.

basic view control pretty much standard.
The camera view moved about over the matrix.
up down /arrows forward and back using 'move' command.
arrow left /right to yrotate camera
change camera height with shift/ctrl

( you can use acceleration /inertia on these so as to be able to move very fast when needed )

Advantage of system is you could quickly set your view to include the area you wanted - even in the folds of matrix hills etc - and 'reach out' up/down, left /right, with the mouse to set a tile. If you could see it , you could change it.

Instead of using the mouse cursor, a sphere object rotated with the camera and then was, each loop, set at camera position and then 'moved' forward a small distance to produce a visible cursor effect.
The object yrotated with the camera angle y but in addition had its own yrotate taken from the mouse y and could rotate up/down from x mouse. Thus moved about screen as usual cursor.

The tile 'aimed at' was always in the line of sight, so once you 'mouse clicked' a loop was started and held, in which the object was simply 'moved' forward in small steps and tested for below matrix ground height. WITHOUT SYNCING - of course.
As soon as below ground was detected one divided the x,z co-ord of the object by the tile size ... giving tile x,z.
The matrix was at 0,0,0 but i suppose one could use an offset for both sets of coords.

On my slow computer it could do up to 300 loop steps forward in one sync without any visible slowdown.( you can use quite small step moves for accuracy )
I used keys to set which tile would be pasted before the mouse clicking, but I guess it could be changed at any point.

oh... If the camera is unlikely to be close to a tile the 'move' loop can started from a little way out so as not to waste time.


Aha ...found the thing ...

remember - before this routine the camera and sphere object 22 are rotating together - sphere angles then added to, by current mousex/y

tileselect:
if mouseclick()=2

position object 22, ex#,alt#,zed# ; `` camera coords
move#=20.0 : ` change for scale of matrix/size tile
for x=0 to 150
move object 22, move#
tex#= object position x(22)
twy#= object position y(22)
tzed#= object position z(22)
test# = get ground height( 1, tex#, tzed#)

if twy# < test#
xtile =tex#/333: ztile= tzed#/333 : `333 was tile size
if xtile>-1 and xtile <across and ztile>-1 and ztile <away : ` stops tile number errors
tile(xtile,ztile)=currentile : ` an array store for saving to file
set matrix tile 1,xtile,ztile, currentile
update matrix 1
endif
exit:` once the tile has been changed exit
endif

next x
endif
return

You could do the same thing with newx, newy, and newzvalue by coords and sine/cosine I guess. .. but i just love these simpler methods.
The same method was good enough to jump to the nearest vertex and give continuous raise and lower of vertex height

cheers
Darkcoder
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 30th Apr 2003 10:25
Thanks guys,

Certainly given me something to think about.

andrew11: I was thinking of doing something like that but, as you say, it would use a lot of plains depending on the Matrix. It's intended for an editor rather than a game so maybe it doesn't matter?

Muddlegum: Thanks for your input. I think I'll use andrew11's method for now but maybe I'll come back and look at yours!

Thanks again for all your input.

System: 1.333Ghz Athlon Thunderbird, 512meg, Geforce 4 Ti 4400.

Hardware /nm./: the part of the computer that you can kick.
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 30th Apr 2003 22:18
Here's how I would do it:

Put this at the beginning of your code:



Then this code will store the tile you are on in the variables x and y:



You are the th person to view this signature.
Programmers don't die, they just Gosub without return....
andrew11
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 1st May 2003 00:45 Edited at: 1st May 2003 00:46
Not a matrix made out of plains. Just above the matrix. They wouldn't be there in a game.

If you had a vary large matrix then the number of polies might be a problem, but the plains aren't being drawn because they are hidden.

"All programmers are playwrites and all computers are lousy actors" -Anon

Login to post a reply

Server time is: 2024-09-20 07:53:24
Your offset time is: 2024-09-20 07:53:24