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 / Moving a 3D object in 2 Dimensions

Author
Message
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 12th May 2003 10:12
I have a 3D Object and I want to move it to a certain position on the screen using 2D, finding the coordinates is easy enough because I can use "Object Screen X()" and "Object Screen Y()", but when I've found these new 2D Coords, how do I then convert them back to 3D?
"Computers are useless they can only give you answers."
Danmatsuma
21
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 12th May 2003 10:28
You've kind of got your answer in the question, if you've got something like:

2d screen coordinate is:

x=object screen x(object)
y=object screen y(object)

then you find out the 3d coordinates by

x#=object position x(object)
y#=object position y(object)

but post more details 'cos surely it can't be that simple

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Vandetta
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 12th May 2003 11:16
I think what he wants to do is keep it so the 3d object is always in front of the camera and he wants to know how to use the object screen x command to position the object in 3d space that always moves in the viewport to stay in front of the camera. But Im not sure how to do this.

Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 12th May 2003 13:32
Yeah, sort of.

For instance, I use Object Screen X() to find my object is at the Screen coordinates 160, 120 - Now say I want to double those coordinates, my new set is 320, 240 - I want to move my object to these new coordinates ON the screen. So theoritcally if I was running the program in 640*480 display, the object would then be in the very center of the screen.

May as well just tell you what I want it for - I'm trying to make a dynamic targeting reticle that moves around the screen when you move. The reticle itself is a 3d plain object and I'm working out the new position of the reticle using 2d coordinates. But now I need to change these back to 3D to move the plain.

"Computers are useless they can only give you answers."
Danmatsuma
21
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 12th May 2003 15:48
In that case, I'm not sure why you're doing the screen coordinate checking, seems like a kind of cumbersome way to do it.

If say you want the recticle to move when you move but dynamically shift back to the centre of the screen then you could probably be clever with the set camera to follow object and make the recticle the object... That way it moves about the screen but when you do your position code, you position the recticle itself. Now you can math a line between the camera/weapon position and the recticle's centre, and extend it through 3d space towards a target.

I'm guessing here but my assumption is you want an element of innacuracy to shooting, if you're not standing still but moving.

So in the above scenario, your recticle will seem to drift about the centre of the screen when you're running/moving, but when you stand still it'll centre itself on the screen's centre

To do it with the screenx/y checks, you'd need to include a view angle calculation etc, not as simple a proposition as the above one

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 12th May 2003 16:43
Yeah, I would normally do something like that as well but I did this funky 2D math to make it constantly drifting around for a really cool effect and it works fine and well in VB but now that I've converted the coding to DB I can't make the coords 3D again lol.

I'm sure I'll find a way... sooner or later.

"Computers are useless they can only give you answers."
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 12th May 2003 16:58
Problem solved lol.

If I use the "Lock Object On" command, I can then alter the position of the plain as if the camera had never been moved. Hence, the Z position of the object doesn't really matter too much and I can move the plain in just X and Y. Knew it could be done.

"Computers are useless they can only give you answers."
Danmatsuma
21
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 12th May 2003 19:49
Congrats Now you have to find a way to aim through it at something though, hehehe

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.

Login to post a reply

Server time is: 2024-09-20 07:26:26
Your offset time is: 2024-09-20 07:26:26