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 Discussion / Matrix Tile Selecting

Author
Message
Relativity
20
Years of Service
User Offline
Joined: 29th Mar 2005
Location: Position is relative.
Posted: 21st Jun 2005 11:01
I'm attempting to create a matrix editor and have already gotten a good way into it. However, I'm having trouble with being able to select individual matrix tiles to texture the matrix. I would like to be able to use the mouse to select a tile. However, I can not think of a way to use the two dimensional mouse position with the two dimensional and/or three dimensional matrix tile position. Any ideas? FYI, I have objects at every point of the matrix and triangles that match the matrix shape if they would be useful for reference. Thanks for your input.

"It's against my programming to impersonate a deity!"~C-3P0
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 22nd Jun 2005 05:20
make the objects clickable with the commands:
object screen x(object)
object screen y(object)

somthing like this:

(Not tested)

Immunity and Annihalation makes Immunihalation...
SageTech
20
Years of Service
User Offline
Joined: 3rd Dec 2004
Location: Orlando, Florida
Posted: 22nd Jun 2005 06:38
I got code for doing this from the forums, search around and you should find it.

Sagetech forums currently down
Relativity
20
Years of Service
User Offline
Joined: 29th Mar 2005
Location: Position is relative.
Posted: 25th Jun 2005 00:12 Edited at: 25th Jun 2005 00:13
Not quite what I had in mind. I want to be a little more specific for where I click. I want to be able to click all of the matrix tile to select it and get none of the surrounding tiles as well. I have a couple of ideas to do this but I'm not sure how they will work out.

1. I could have a hidden 3D object come out from the camera position to about 5000 units and then detect for object collision.

2. I could get equations for 2D lines between the four points on a tile and then use <= and >= statements to find if the mouse is within the required area. This is the way I'm currently going with, but it has hidden complexities. If anybody has any easier ideas please share them.

"It's against my programming to impersonate a deity!"~C-3P0
Jake Blues
20
Years of Service
User Offline
Joined: 19th Jun 2004
Location: United States
Posted: 25th Jun 2005 00:20
Here is how you would do it(Code by Spooky):


Robot
20
Years of Service
User Offline
Joined: 27th May 2004
Location:
Posted: 25th Jun 2005 00:28
Thats only for dbpro on a dbc board.

The happenings of tommorow are behind us now
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 25th Jun 2005 00:51
SithSpawn,

Vector math is the knowledge you need for this type of circumstance. I am still in the slow process of learning it myself, due to other higher priorities. Below is a link to what I believe to be a very simplified, however powerful lesson on vector math. The author, Mark Feldman, does an excellent job at portraying this subject.

http://www.geocities.com/SiliconValley/2151/math3d.html


+NanoBrain+
Jake Blues
20
Years of Service
User Offline
Joined: 19th Jun 2004
Location: United States
Posted: 25th Jun 2005 06:39 Edited at: 25th Jun 2005 06:44
Here is the link to the vector functions for dbc:
http://forum.thegamecreators.com/?m=forum_view&t=50609&b=10

Here is the link to the pick object\screen commands for dbc:
http://forum.thegamecreators.com/?m=forum_view&t=20490&b=5

Relativity
20
Years of Service
User Offline
Joined: 29th Mar 2005
Location: Position is relative.
Posted: 14th Jul 2005 06:33
I actually think I found another way. I'm still perfecting it but I think it is going well. I noticed that for every tile, at least a triangle of the tile is visible. So I basically drew lines between the three corners of the triangle and used < and > statements to see if the mouse is within the area I want it to be. I'll post the code when I'm done.

"It's against my programming to impersonate a deity!"~C-3P0
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 14th Jul 2005 06:38
im making a matrix editor too, the way i did it is you move around a red object, and a blue object sorta follows you, but snaps to the tile your on, and youn just press mousekeys to chenge heights

http://forum.thegamecreators.com/?m=forum_view&t=57150&b=10

Your signature has been erased by a mod because it's larger than 600x120...
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 14th Jul 2005 22:43 Edited at: 14th Jul 2005 22:44
what you could do is select a tile with a texture by moving the texture around and changing that tile

Your signature has been erased by a mod because it's larger than 600x120...
Relativity
20
Years of Service
User Offline
Joined: 29th Mar 2005
Location: Position is relative.
Posted: 17th Jul 2005 02:25
This is the code I use. Sorry, but the variables may be a little confusing.



"It's against my programming to impersonate a deity!"~C-3P0
Relativity
20
Years of Service
User Offline
Joined: 29th Mar 2005
Location: Position is relative.
Posted: 17th Sep 2005 19:05
I realize it has been a while since I've posted to this thread but I'm having other issues involving vectors. The method I used above works just fine with some tweaking, but it just wasn't fast enough, so I decided to use vectors as NanoBrain suggested. I camer up with a code based on vectors, but there is something wrong with it and I just can't figure it out. This is the code I came up with:


The PickScreen() function is the same one I posted in the codebase but I reformed it so it always calculates a unit vector. Also, note that I have placed an object at the matrix vertices and the variable TOTOBJ refers to the number of objects on the vertices. Also, NORMAL(objnum,1,3) and NORMAL(objnum,2,3) are the K constants in the plane equation found in the website NanoBrain gave above. Basically what I am trying to do with this code is find out if (1) The vector the mouse directs from the camera intercepts each individual plane of the matrix and (2) If the vector intercepts the matrix between the three points of a matrix plane. I realize this is somewhat of a long code and post and I thank you in advance for any assistance you can render.

The force will be with you. Always.

Login to post a reply

Server time is: 2025-05-22 13:51:12
Your offset time is: 2025-05-22 13:51:12