Recent topics
Recent Comments 
Help with "distance/size ratio" !A math guru in the place ? Here is my problem : I have a sprite with a widht/height of 1 in a 3D transform patch. I change the width/height of the sprite to 0.5. (Or a size from 0 to 1) Now i want to calculate the 3D transform Z position offset to see the sprite with the same size (as when it was 1) on screen... Thanks for your help... Regards; More like this

Alright, it's been years since I took any math courses, or any 3d graphics courses, so this is just off the top of my head. Somebody please confirm that I'm making sense here before anyone uses this for anything important.
The apparent size of the object is dependent upon the angle it takes up of your field of vision  that is to say, if you're looking right at the base of the sprite, and you make a triangle whose sides are 1.) the height of the sprite 2.) the line from you to the base of the sprite and 3.) the distance from you to the top of the sprite, then if the angle between sides 2 and 3 stays constant, the apparent size stays constant. Given the way I described the scenario, with us facing straight at the base of the sprite (or to put it another way the base of the sprite touching the z axis of our camera), we have a right triangle with side 3 as the hypotenuse, so the ratio of side 1 (the sprite's height) to side 2 (the distance from the sprite) is the tangent of the angle between sides 2 and 3. To keep that angle's tangent (and therefore the angle) constant when we halve side 1 (the height of the sprite), we merely need halve side 2 (the distance from the sprite).
So to sum up, I'm fairly certain that if you make the object half as big, you need to be twice as close. So if your old size was 1, just multiply your Z position by your new size. Or for any old size x and new size y, multiply your Z position by y/x. (Assuming camera is at the origin of the Z axis.) Intuitively, I'm pretty sure this is correct, but hopefully someone can verify for you.
bmellen is right with his explanation, but Quartz Composer makes things just a bit more confusing. The origin is at the center of the screen for all 3 axes. That means z=0 at the screen, is negative behind, and positive in front of the screen.
Imagine that you are looking at the screen center with your eye at z=+1 with your sprite exactly filling the screen. You see a 2x2 rectangle (1 to +1 along both x and y axes). The lines from your eye through the corners makes a pyramid. All of your ztranslated sprites are the intersection of that pyramid with planes parallel to the original sprite. If you move your sprite away from your eye to z=1 and keep it parallel to the screen, you have doubled the distance. If you want it to appear to be the same size and fill the screen, you would have to double its height and width. If you halved the distance from your eye, and moved the sprite to z=+0.5 you would have to halve the height and width. Whatever multiple of the original distance from the eye you decide to go with, you simply multiply the height and width by the same thing.
It isn't so easy going the other way though. If you first doubled your size and then merely multiplied your z position by 2, you would still have z at 0. You need to think in terms of relative distances and how they change. There may be a better way, but I would suggest establishing an arbitrary eye position and making sure that any change in z is calculated in relation to that. It would seem to me that it would be best to keep your sprites a nice comfortable distance from your eye position. If, for example, instead of having your eye at z=+1 in the scenario above, you had it at z=+0.1, the height and width would double at z=0.1. If your eye was at z=+10, the rest wouldn't double until z=10. You obviously have a reason for wanting to do this, so that may dictate some of what you have to do, but just keep in mind that it is relative distances that matter. Once you have that down, you can add or subtract to move things where you want in relation to the origin or other objects.
Thanks Bloubloy and bmellen you give me the way...there is a litlle problem, because the 3D transform patch isn't orthographic, so it as an "unknow" field of view, that give a difficulty... I have to do this because i'am doing a plugin with a QC base that is embed in differents video host softwares.Those softwares can change there resolution (half, third,quarter, etc...) to accelerate the rendering preview speed. When doing this, the resolution change but width/height are the same, so the scene is scale with an inverse factor... For differents reason i can't just scale dynamicaly scene elements. As my scene is embed in a 3D transform patch, Offset the Z is a good way to resolve it . Now the question is : What is the field of view of the 3D transform patch ? As i'am a visual person, i must see to understand...and i'am on it !
here is a screenhot of the modelised principes...:) (PS: if someone have the steve jobs phone number, ask him what is the FOV of the 3D transform patch :)
Regard
the default fov for most opengl stuff is 90°. 3D Transformation follows this (unless you whip out the FOV private patch or FOV GLTools patch, then all bets are off)
that's a good point !
Thanks !