Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
How to keep objects on screen?
Old
zwx650
Junior Member
 
Status: Offline
Posts: 2
Join Date: Feb 2012
Question How to keep objects on screen? - 02-16-2012, 01:52 AM

Hi,

I am new to the forum. I tried to search for a similar thread, but couldn't find anything:

What should I do to find out if an object has moved to the edge of the screen and is about to be invisible, and then reposition the object to the center of the screen?

Thanks in advice for any helps!

zwx
   
Reply With Quote
Old
Mr Kidnapper
Senior Member
 
Status: Offline
Posts: 442
Join Date: Feb 2011
Default 02-16-2012, 02:43 AM

You need some math for that. First you need to find out the field of view angle of the camera. I don't know this either, but a good estimate is just by sticking an object at the edge at a fair distance away, You then use the arctan2 function on this object. Your first parameter for the arctan function is the object distance to the left of the camera, and your second parameter is the object distance in front of the camera. What do you get? I don't know. At any rate, the result should be more or less the same as long as you keep the object more or less at the edge of the camera. Then you make a hardcoded (preset) number variable consisting of the result of the arctan function.
Congrats. you found the field of view angle.

Now you need to make sure that whenever your objects reach this edge (field of view angle), it teleports to the center of the screen.
For this, you make an if/else function. One thing you need to take note of is that you must also do the arctan thing on every object you intend on teleporting to the center of the screen. You should also save it as a number variable. So, if the arctan of the object is greater than positive FoV angle or greater than the negative FoV angle (The FoV, just with a negative sign), it does some method to move the object to the center.

This method is kind to you. You can do it simply by getting the distance to the left of the camera and having the object move that (negative) distance.
   
Reply With Quote
Many thanks!
Old
zwx650
Junior Member
 
Status: Offline
Posts: 2
Join Date: Feb 2012
Default Many thanks! - 02-16-2012, 12:28 PM

That's quite some computation involved Hopefully I will find time to give it a try and report back.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2020, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.