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 / mouse-over coords for spinning object

Author
Message
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 23rd May 2009 02:55
ok so say you can rotate the camera around an object, how would you out where to position screen sensor objects (small planes hidden that are positioned at the top-left and bottom-right corners of an object to see where on the screen the main object is using the object screen x() and y() commands)

anyway how would you take the camera angle and use it to find out where those corners are?

There are only 10 kinds of people in the world, those who understand binary and those who dont
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 24th May 2009 06:37 Edited at: 24th May 2009 06:39
Does the camera rotate on all axes or does it stay fixed (not including zooming or strafing)? And what about the objects? Do they rotate on all axes or on 1 or 2 ?

Enjoy your day.
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 24th May 2009 07:18
like a situation such as this:



note the camera is rotating around the object, the object remains still

There are only 10 kinds of people in the world, those who understand binary and those who dont
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 24th May 2009 20:56
There are 2 scenarios:

1. the coordinates are relative to the camera - This means that the 2d positions will always be facing the camera in the exact same way no matter how much the camera rotates.

2. The coordinates are relative to the object - This means that the 2d positions will always be at the object's corners. They will rotate as the object rotates or as the camera angle changes.

When you ask
Quote: "anyway how would you take the camera angle and use it to find out where those corners are?"

It makes me think you are asking about scenario 1.

In any case, the way to do it is:
1. Find the center of the object (x y z)
2. Find the dimensions of the object (x y z) use object size x() object size y() object size z()
3. Divide each object size value by 2.0
4. use the 3 half sizes to calculate the distance to a corner
sqrt(halfx#^2 + halfy#^2 + halfz#^2)
5. find the slope between halfx and halfz (y angle to the corner) and convert that to an angle
ang#=atanfull(halfx#,halfz#)
6. use newxvalue and newzvalue and the camera angle or the object angle (depending on scenario 1 or 2) and the slope angle and the distance to find the x and z of the corner positions
7. position the scensor object(s) at the corner positions
8. get the 2d screen positions of the scensor object(s)

If you have trouble figuring out the details, let me know. I wrote up a function to test out the idea and it works fine so the method seems sound.

Enjoy your day.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th May 2009 14:16
Are you trying to see if the mouse is colliding with the object? I think I saw an example of that somewhere on the codebase, can't seem to find it right now... You will need sparky's DLL and enhanced DB for it to work though...

TheComet


Make the path of your enemies easier with Waypoint Pro!

Login to post a reply

Server time is: 2025-06-08 08:52:56
Your offset time is: 2025-06-08 08:52:56