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 / Pixels, Vectors, Collision, and Confusion

Author
Message
Crelus
22
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 1st Feb 2005 00:11
Hi,

This might have been answered already, but I haven't been able to find a reference to my question so here goes:

Suppose you have your standard 3D game, maybe an RPG, with a screen resolution of 800x600. Now, I click the mouse on the screen at pixel 200,200. From here I need to figure out which, if any, of the moveable/reachable locations have been clicked and what the world coordinate of the intersection is.

I'm thinking this would involve something like this:

1: Create a plane that has the same orintation as the cameras view port.

2: Convert the 2D pixel coordinates into a set of world coordinates on the plane.

3: Case a perpendicular(sp?) ray from the point on the 2D plane. (Is this a normal or something like that?)

4: Using something like nuclear glory (which I have) I'd test to see if the ray hits a floor surface. If it does I'd figure out which one.

5: From there I'd figure out the exact world coordinate of the intersection.

6: I'd calculate a path and start moving my "avatar" towards that spot.

Am I making this more difficult? Is there an easier way or am I totally off track here? What I'm looking for is something like the way that Bioware's Never Winter Nights works with regards to movement.

Any help would be appreciated.
Thanks
Zokomoko
22
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 1st Feb 2005 00:56
An easier solution to your situation would be to use a 3d mouse.
Basically, you place a dummy object like a cube, and transfer the mouse 2d coordinates to 3d coordinates, and then place the cube at that location.

I think there may be some snippets about this.
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 1st Feb 2005 00:59
or pick object..

I think its:
pick object(x, y, start, end)

where x and y are screen coord (from mousex() and mousey()) and start and end are object numbers in the range (ed start testing for objects at 10 and end at 20, etc (NOT DISTANCE.. I made that mistake )

Any help?

My Website:
IanG
20
Years of Service
User Offline
Joined: 25th Sep 2004
Location: Cyberspace
Posted: 1st Feb 2005 01:12
pick object if i remeber correctly is very slow

Used to be Phoenix_insane registered in september 2003 despite what the date says to the left <--
PC - amd athlon 2.0ghz, 512mb, GeForce FX 5200 128mb, 200gb, xp pro sp2
RiiDii
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 1st Feb 2005 02:01
Pick object works fine if you limit the number of object being tested for to only a few, or one. I like Zokomoko's suggestion personally...
Quote: "An easier solution to your situation would be to use a 3d mouse."

...but I'm not the one asking.

"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
Phaelax
DBPro Master
22
Years of Service
Recently Online
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Feb 2005 07:22
There are several examples that already demonstrate this if you just search the forums.

"eureka" - Archimedes
sadsack
21
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 1st Feb 2005 08:20
read this it is great and I thank you Phaelax for it. see down load


renny

Attachments

Login to view attachments
Crelus
22
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 4th Feb 2005 04:04
Thanks for the information. This really helped. I'm reading the RTS Tutorial now and I'm sure this will give me what I needed.

Thanks again!

Login to post a reply

Server time is: 2025-06-10 05:57:29
Your offset time is: 2025-06-10 05:57:29