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.

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Nov 2017 23:33
How would i go about positioning the camera so that one or more objects would (roughly) fill the window.
Same as a "Frame object(s)" function in a 3D proggy
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 5th Nov 2017 23:45
this thread should have your answer
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Nov 2017 01:29
Very interesting thread, however it is for a 2D camera. I am looking for something for a 3D camera
Green7
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: Switzerland
Posted: 7th Nov 2017 13:20 Edited at: 7th Nov 2017 13:20
hm, how about to create a third object. then get the distance from both objects you want to see to the third object. move the third object towards the higher value so it will be centered between the two objects. there you place your cam. then move your cam out by maybe the distance to both objects? now you have the cam centered and if the objects separate further the cam will move out, and if they get closer to each other the cam moves in.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 7th Nov 2017 21:32
Thanks Mr Green i will ponder that
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 9th Nov 2017 02:24 Edited at: 9th Nov 2017 02:25
Hope I understood you right:
There are the GetObjectSizeMaxX/Y/Z and MinX/Y/Z commands then you would need the field of view of the camera and the rest should be trigonometry.
You need to sort the min/max positions so you get the most top,left,far position and the most bottom,right,near position i.e. min and max of all objects in the screen.
And then ...well i'm sure its possible but right now I don't have the patience to do the math ..maybe because its so late again
Hope you got the idea...
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 9th Nov 2017 02:57
Yes i think that is they way. The Min/Max values will always return the original bounding box of the object when it is first loaded so i guess i have to somehow re-calculate the bounds if it has been rotated and/or scaled
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 9th Nov 2017 08:18 Edited at: 9th Nov 2017 08:21
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 9th Nov 2017 08:35 Edited at: 9th Nov 2017 08:41
I think that is getting a 3D point from a point on the screen. I kind of need the opposite.
I have cobbled together a rudimentary one that works on only one plane using the GetObjectSizeMin/Max functions and the GetobjectInScreen() function
It's good enough for me
Thanks for the thread, it was a very interesting read
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 10th Nov 2017 05:54
I've done a little research and testing on this and i think i have a solution. It is based on the very unusual nature of the FixObjectToObject() command.

1. It seems that when you Fix an object to another it will attach the object as if the object that is being attached to was in its original state position/scale/rotation then the attached object will adopt the parent objects position/scale/rotation once FixObjectToObject() is called
2. So you can place an object, say a small box, at the Maximum and Minimum X/Y/Z co-ordinates as returned by GetObjectSizeMin/Max/X/Y/Z for the target object
3. Then fix those objects to the target object using the FixObjectToObject(). At which point the attached boxes will adopt the position/rotation/scale of the target object
4. By then querying the position (World co-ordinates) of these boxes you can determine the bounding box (in 3d space) of the objects

5. You could then use evil math to frame the bounding box or just move the camera away until GetobjectInScreen() tells you that the bounding boxes are on the screen

6. It's probably not something you would do every frame by it should be ok every now and then. As a function of an editor say
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 30th Nov 2017 17:47 Edited at: 30th Nov 2017 17:49
Quote: "I think that is getting a 3D point from a point on the screen. "

No, it does the opposite of that.
Quote: "I kind of need the opposite."

That's handy then

This gets the position in 3D space that you would need to place an object in-order for it to be at a specific point on the screen.
In your case the position of the boxes attached to your object perhaps?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 30th Nov 2017 19:08
Ok. That makes sense. I Have actually incorporated that code into my game for another reason. i will revisit it

Login to post a reply

Server time is: 2024-04-26 06:23:27
Your offset time is: 2024-04-26 06:23:27