suztv
10-29-2007, 02:19 PM
I posted a request in the scripts request section in Aenhancers - but after working with one of my programmer guru friends I just have to share this with you. In the video comps that I produce I have to create 3D reflections of items moving around in 3D space with camera moves etc. If I select the continuously rasterize feature on the layer sometimes it works and sometimes, well - it doesn't work so great (camera's seem to get confused and then jump). What I wanted was a way to reflect the object without having to precompose positional information. In other words if I have a phone with a 3D spin brought in and I have it come into my scene with camera moves and spins - it gets pretty confusing and time consuming to pre-compose, apply continual rasterization and then hope the camera works correctly. Also the reflections don't always work out the way they should. So here is the expression that we came up with that works great! The only caveat is that your anchor point must be at the bottom of your "object" and any z spins you must do in a precompose (but this isn't nearly as intense as keying out an entire positional sequence and then tweaking them for the reflection).
Duplicate your main object - this will be the reflection. Apply the following expression in the position. You will also have to invert the scale on y (x=100% y=-100%).
// name of the variable for the main object you want to reflect
V=thisComp.layer("Object");
//get the positional information from your main object
VPOS=V.transform.position;
// name of the variable for the floor plane
F=thisComp.layer("Floor");
//position information of the floor
FPOS=F.transform.position;
//the distance between the floor and the object you want to reflect
Distance=VPOS-FPOS;
//this line is where the information is applied to the reflection and viola! your reflection is acting the way it should
NEWPOS=FPOS+Distance;
[NEWPOS[0], NEWPOS[1]+(NEWPOS[2]/4), NEWPOS[2]]
You will need to duplicate the object and apply what ever falloff or blur attributes necessary. Also scrubbing through and finding the lowest point that the reflection should touch at and setting the reflections anchor point is a good idea. I cannot tell you how much time this has saved me and I hope that some of you can get some mileage out of it.
Duplicate your main object - this will be the reflection. Apply the following expression in the position. You will also have to invert the scale on y (x=100% y=-100%).
// name of the variable for the main object you want to reflect
V=thisComp.layer("Object");
//get the positional information from your main object
VPOS=V.transform.position;
// name of the variable for the floor plane
F=thisComp.layer("Floor");
//position information of the floor
FPOS=F.transform.position;
//the distance between the floor and the object you want to reflect
Distance=VPOS-FPOS;
//this line is where the information is applied to the reflection and viola! your reflection is acting the way it should
NEWPOS=FPOS+Distance;
[NEWPOS[0], NEWPOS[1]+(NEWPOS[2]/4), NEWPOS[2]]
You will need to duplicate the object and apply what ever falloff or blur attributes necessary. Also scrubbing through and finding the lowest point that the reflection should touch at and setting the reflections anchor point is a good idea. I cannot tell you how much time this has saved me and I hope that some of you can get some mileage out of it.
