create your own

Papvervision 3D programming tutorial - Casting Shadows

69
rate or flag this page

By phyxx


Papervision 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


Comments

RSS for comments on this Hub

delphi  says:
10 months ago

wooow!!! cool

Research Analyst profile image

Research Analyst  says:
9 months ago

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.

Duke  says:
6 months ago

That works nicely!

Thanks for sharing

Michiel van der Ros  says:
6 months ago

Your page title says Papvervision :)

Submit a Comment

Members and Guests

Sign in or sign up and post using a hubpages account.


optional


  • No HTML is allowed in comments, but URLs will be hyperlinked
  • Comments are not for promoting your hubs or other sites

working