Hey!
I have a problem with shadows in papervision 3d. Im not strong in programing but im trying to do this game that needs it. Anyway i struck at a wall now with shadows. There are a couple of examples on the web, thing is I dont understand them too well and dont know what im doing wrong. I made this little example:
Code:
package
{
import shadowcaster.*;
import flash.display.Graphics;
import flash.display.MovieClip;
import com.greensock.TweenMax;
import flash.display.BlendMode;
import flash.filters.BlurFilter;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
import flash.display.Stage;
import org.papervision3d.materials.MovieMaterial;
public class shadow extends BasicView
{
protected var cube:Cube;
protected var mat:FlatShadeMaterial;
protected var mat2:FlatShadeMaterial;
protected var plane:Plane;
var shadowCaster:ShadowCaster = new ShadowCaster("shadow1",0x000000,BlendMode.NORMAL,1);
var luch = new PointLight3D ;
private var mMat:MovieMaterial;
private var koza:MovieClip = new MovieClip ;
public function shadow():void
{
super();
init();
}
protected function init():void
{
createChildren();
commitProperties();
startRendering();
}
protected function createChildren():void
{
var koza:MovieClip = new MovieClip;
koza.graphics.beginFill(0xefefef);
koza.graphics.drawRect(0,0,3000,3000);
koza.graphics.endFill();
mMat = new MovieMaterial(koza,false,false,true);
mat = new FlatShadeMaterial(luch,0xFFFFFF,0x469942);
plane = new Plane(mMat,3000,3000,10,10);
cube = new Cube(new MaterialsList({all:mat}),200,200,200);
cube.x = 0;
cube.y = 200;
luch.x = 0;
luch.y = 700;
scene.addChild(plane);
scene.addChild(cube);
shadowCaster.setType(ShadowCaster.DIRECTIONAL);
shadowCaster.castModel(cube,luch,plane,false,false);
}
protected function commitProperties():void
{
//Set properties of our plane
plane.material.doubleSided = true;
plane.pitch(90);
plane.y = -100;
cube.y = 400;
cube.x = -500;
TweenMax.to(cube,5,{x:1000});
camera.x = 200;
camera.z = 1500;
camera.y = 1000;
}
}
}
Is there anybody who would wave their magic wand and solve my problem?
thx