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 / help needed - how to translate 2d coordinates to 3d ?

Author
Message
Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 11th Jan 2006 19:15
MY question is how to translate 2d coordinates to 3d .

I mean like i make 10 boxes on the screen , each one close to another , and it is viewed from the TOP pespertive , i want to know how to make when i click on some of that boxes , something heppens .


Can someone please help ?


FROGGIE!
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: in front of my computer
Posted: 11th Jan 2006 19:29
There are 2 ways of doing this, The first is to use the PICK OBJECT command, this will let you know if the cursor is over an object, i cant rember it exactly so you'll have to look it up.

The second is (in your case may be better) to work out where the boxes actually are on the screen e.g. which pixel each of the corners are in and then work out if the camera is within this range. So:



However the 2nd method will only work if the screen doesnt change and all the objects are boxes (or rectangular from perspective).
Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 11th Jan 2006 19:34
thank`s for help , but for the first way , it looks like db classic doesn`t have pick object command , i think that only dbpro has it.


FROGGIE!
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: in front of my computer
Posted: 11th Jan 2006 19:40
Oh sorry yeah i forgot this is the DBC thread.
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 11th Jan 2006 19:42
If you make your boxes to the scale of pixels then move your camera Z -500 from the boxes you will have pixel perfect coordinates. Best to use plains to make your boxes. So a Plain 32*32 is 32 pixels by 32. Texture it with an image 32*32. Point the camera at it, and move it back -500. Now you can use screen coordinates for collision.

That works for 800*600, 1024*768 I think you just move the camera to a different position. I have done both anyway, and it works.

Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 11th Jan 2006 19:54
ok , thanks


new programmer
19
Years of Service
User Offline
Joined: 20th Dec 2005
Location: right behind you.
Posted: 11th Jan 2006 21:16
Quote: " oh sorry forgot this was DBC thread "


no, its not the DB thread, its "help needed - how to translate 2d coordinates to 3d ?" thread in DarkBASIC board in TGC apollo forum.

Your signature has been erased by a mod, none of whom are dumber than you.
Bluestar4
19
Years of Service
User Offline
Joined: 19th Dec 2005
Location: USA
Posted: 16th Jan 2006 21:52 Edited at: 16th Jan 2006 21:55
dodic, I see several ways to do what your wanting,
if you dont plan on moving the camera just insert code to take a snap shot , and get the x,y co-ordinates from the bitmap you saved, if however, you are planing on either the camera or the objects moving you'll need to use the object screen x() and object screen y() commands in conjunction with the mousex() and mouse y() commands like so



also, rather than making it a top perspecitive and adjusting the camera view, simply adjust the objects y co-coordinates. I promise it will be a lot easier that way , anyhow, hope this helps ya

also, forgot to add that you can place that code in a loop to check for every object you have in the game ... just replace the 1's with a variable and do a for-next loop.

Bluestar4~
Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 16th Jan 2006 22:08
Thank`s , i added a few things to Bluestars4 code and get just what i wanted


With Racer generator you will be easily able to put track , checpoints , cars , set up preferences , Set up world with ease..
Bluestar4
19
Years of Service
User Offline
Joined: 19th Dec 2005
Location: USA
Posted: 16th Jan 2006 22:12
anytime dodic.

Bluestar4~

Login to post a reply

Server time is: 2025-05-23 02:07:58
Your offset time is: 2025-05-23 02:07:58