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

Started by
5 comments, last by jollyjeffers 19 years, 4 months ago
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 :)
huraay!
Advertisement
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.
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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.
huraay!
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.
Yes, but the problem is, I need to know in advance when its done.
Users can set the duration of the roll, so I need to know the length in advance to set the speed accordingly.


huraay!
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement