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 / Opposite of 'object screen x'?

Author
Message
Duncanla
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 9th Apr 2003 23:43
Is there a way to do the opposite of object screen x or is there a way to figure out the screen position of a position that's not an object. I'm usin DBC by the way. I'm trying to make a program where you can click on a 3d object and drag it around.

I'm going to use it in a program that the user puts in lacrosse plays and it animates it for them. I'm a varsity lacrosse player and i know that it gets old looking at the plays. This way, you will also be able to change camera angles and stuff.

Thanks for any help in advance. Later
Duncanla
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 9th Apr 2003 23:46 Edited at: 9th Apr 2003 23:48
wow, being my stupid self i forgot to tell you the problem.

I'd like to have the opposite of object screen x object or finding the screen position of a position that's not an objects o i can find the position of the mouse and see if it's over the object. I can do the same now but It only points to the exact center of the object and if i just add to the screen position then it will change when i back up and get closer to the object. Any ideas? Any Algorithms would be cool too if there isn't a specific command.

Edit: And i just figured out how to edit, wish i would've known that before i posted this one. My bad
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 10th Apr 2003 00:05
im not sure what you mean...
if you want to be able to tell if you are clicking on a 3d object, and which object it is, i have some code you can use...
Duncanla
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 10th Apr 2003 00:13 Edited at: 10th Apr 2003 00:14
yeah that would be great.
I'll try to explain it a little better this time.

I want to make a program that lets you select objects with a mouse and drag them around. The problem is that when i use object screen x and object screen y, then that only gives the position of the center of the object. I want to make it so that the second the mouse touches the object, and it is clicked, it is selected. And, I want it to work at any camera angle and distance.

That's the problem. Mysolution where to find the mouse coordinates in 3d and then use a little distance formula to figure if it's touching the object. I just don't know how i could accomplish this.

Is that a little better? If not, then tell me what you're confused about. Thanks
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 10th Apr 2003 01:41 Edited at: 10th Apr 2003 01:45
no prob ill post my code


just call that code constantly in your main loop and it will return which object is under the mouse

EDIT: this code WILL NOT work for objects that are locked to the screen... you have to edit the checks to get that to work
deathAngel
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location:
Posted: 10th Apr 2003 07:36 Edited at: 10th Apr 2003 07:45
Hi guys. I was looking for the same code as Duncanla, and i found few different ways to do the same as yours code BluNtMan n ChRoNiC.
my problem is that all the objects i have are different in size, plus when i change the screen resolution, the object looks smaller on screen. so that one: " if (object screen x(i) > x-30) doesn't work for me.
i was thinking, is there any way to find the size of the object as it seen on screen, i mean if the object size is actually 100, but whe the distance betwen the camera and the object are 6000 the object would look smaller in size.

Thanks. (Sorry for my bad English)

matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 10th Apr 2003 21:15
just use object size x(object)/2
Duncanla
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 11th Apr 2003 04:49 Edited at: 11th Apr 2003 05:06
thanks
yeah, i got that far with my own coding but what i want to do is change it when you zoom out and in.

for instance, when you are zoomed up really close to an object it can take up a whole screen so that code wont work on the whole thing just the center and 30 units in each direction.

Also, if you zoom out really far, it gets really small and then the 30 units in each direction is too big. Is there a way to fix that or will I just have to deal with it? I could just change the 30 units depending how far the camera is away but are there any ratios of distance to screen size or algorithms or anything so i can get it just right?
Duncanla
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 12th Apr 2003 04:38
Any ideas?
deathAngel
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location:
Posted: 12th Apr 2003 10:27
That's exactly what i meant in the last post.
i found excellent function that works perfectly for me. Duncanla you shuld try it:
http://www.darkbasicpro.com/apollo/view.php?t=7911&b=6&p=0

Duncanla
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 13th Apr 2003 06:51
Yeah, i saw that before but you i can't find anything for DBC and you can actually read where i asked if it could be written in DBC and they said that it couldn't
deathAngel
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location:
Posted: 13th Apr 2003 13:11
sorry i missed this part. :-s
wish i could help, but can't.


(sorry for the bad English)

Login to post a reply

Server time is: 2024-09-20 03:44:58
Your offset time is: 2024-09-20 03:44:58