Sign in to follow this  
BaSSraf

Value of world transform - to move all objects out of the frustum

Recommended Posts

Hey guys, It should be so simple, but I cant get my mind wrapped around it. I'll try to explain what I want to do, i'm creating a 3D (title) roll with objects scattered over multiple scenes rolling from the bottom of the screen upwards until they are all out. The problem is, I need to determine the length of the entire roll, in other words I need to know how much I need to translate all the world transforms up to gradually move all objects out of the viewing frustum, normally in 2D you'd simply take the lowest pixel visible and calc (have) its Y position. In 3D however objects in the distance (Z) move slower than objects in front of them.. so how would I calculate the distance (over Y) needed to move those objects out of the screen? (frustum) I have the OBB's, Frustum etc in world space, how would I calc the ammount of Y offset needed to move ALL objects out of the frustum? Thanks in advance :)

Share this post


Link to post
Share on other sites
Ok, I'm assuming that you know how deep in to the screen you want to draw these objects and how far appart you want each object to be - so really you just take the distance from the first object to the last (the sum of the distances between all objects) and add it to the 'height' of the frustum at the depth you're drawing the objects at.

Share this post


Link to post
Share on other sites
Quote:
in other words I need to know how much I need to translate all the world transforms up to gradually move all objects out of the viewing frustum
Maybe I'm misunderstanding your question, but surely a general approach of incrementing the position of the general transform (hence all the objects you're "rolling" out) and then clip them against the frustum planes? When an object has entered and then left the frustum stop drawing it; when the last object has entered and left the frustum stop the whole sequence?

Jack

Share this post


Link to post
Share on other sites
Hehe, I wasnt clear enough and the funny thing is, because of that, both of your answers are true but wont work for me..

Wudan: I'm not the one designing the scenes, so I dont know how deep objects will be, otherwise it'd be no problem as you said.

Jack: The problem is, I need to set the speed in advance so the user can set a duration for the entire roll, so before starting, I need to know the length to set the speed accordingly...

Sorry for the lack of information guys..


I think the only solution is doing an "in memory" fake roll which doesnt render but transforms the bounding boxes etc like it was rolling.. and loop this until the end matches the user-duration-time .. its a lame solution, but at first I'd make large increases in speed (double it), and once I passed the duration I increment the speed with half the previous increment until I reach a certain threshold (if the movement isnt noticable between frames)..

Now I think about it.. scenes can hold animations.. so ... that makes it almost imposible to determine their positions in advance...

Er.... thanks guys.. i'll first have a go at what I just described.. but any ideas are always welcome.

Share this post


Link to post
Share on other sites
Ok, how about you just keep track of the very last item and check it against the 'top of the screen' frustum plane? Since the object is either going to be 'in front' or 'behind' the plane, and it's the last one, just test it ( you don't even necessarily need to check it every frame .) That way you don't necessarily need to calculate the length of anything, it'll be done when it's done.

Share this post


Link to post
Share on other sites
Quote:
I need to know in advance when its done.
So, in order to do this, you need to know the distance "travelled" by the objects. In knowing this you can adapt the speed of the objects accordingly so that they take "x" seconds to scroll?

Do you have the position of the last object before the animation is supposed to start (i.e. on the first frame)? From what you've posted, you say you don't. However, you must have access to the raw geometry that you're displaying. Thus you should be able to calculate a bounding box - and at least get some indication of the size/depth of your "roll"...

If you can get this, a bit of ray-casting from the bottom of the box through to the top of the frustum should tell you how far you have to translate everything.

hth
Jack

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this