Papvervision 3D programming tutorial - Casting Shadows
69Papervision doesn’t have native support for shadowing built in (yet), but the guys over at http://blog.zupko.info/?p=146 have present a neat little solution for displaying shadows onto a plane. Unfortunately their solution doesn’t allow the model that is the source of the shadow to be translated (i.e. moved or rotated) in any way. Since I wanted to see shadows against a moving object I decided to try and patch the ShadowCaster class so it would support casting shadows against a translated mesh. As it turns out it only took about 3 lines of code.
The line in the function castFaces that used to say
for each(var t:Triangle3D in target.geometry.faces)
should new read
var clonedAndTransformedGeometry:GeometryObject3D = target.geometry.clone(); clonedAndTransformedGeometry.transformVertices(target.transform); for each(var t:Triangle3D in clonedAndTransformedGeometry.faces)
With this small change you can now project shadows from a translated mesh.
Check out the demo here, and download the source code here.
Find more Flash tutorials here.
Papervision 3D shadows screenshot
PrintShare it! — Rate it: up down flag this hub
Comments
I agree that shadows against a moving object is better for a more virtual 3D effectm thanks for sharing the code for duplicating this function.
That works nicely!
Thanks for sharing
Your page title says Papvervision :)











delphi says:
10 months ago
wooow!!! cool