Papervision3d はじめの10歩 Light PointLight3D
PointLight3D(showLight:Boolean = false, flipped:Boolean = false)
Bitmapに陰影を使いたい場合はShadedMaterialを使い、陰影の設定はShaderを利用する。
この考え方に行くまで結構迷った。
最初はGouraudMaterial,GouraudShaderとかの使い分けがよくわからなかったけど、
GouraudMaterialは、あくまでColorMaterialの延長、そしてライトが必要なので設定が必要。
Shader系はShadedMaterialの陰影設定するためのもの。でいいとおもわれ。
だんだんわかってきた。

- showLight: A Boolean value indicating whether the light is visible.
ライトのオブジェクトを可視化するかを示すブール値 -
flipped : A Boolean value indicating whether to flip the light-direction (needed for correct DAE-shading).
ライト方向を 反転 するかかどうかを示すブール値 かな?
Bitmapに陰影を使いたい場合はShadedMaterialを使い、陰影の設定はShaderを利用する。
この考え方に行くまで結構迷った。
最初はGouraudMaterial,GouraudShaderとかの使い分けがよくわからなかったけど、
GouraudMaterialは、あくまでColorMaterialの延長、そしてライトが必要なので設定が必要。
Shader系はShadedMaterialの陰影設定するためのもの。でいいとおもわれ。
だんだんわかってきた。

package { import flash.display.Sprite; import flash.events.Event; import org.papervision3d.lights.PointLight3D; import org.papervision3d.materials.BitmapFileMaterial; import org.papervision3d.materials.BitmapMaterial; import org.papervision3d.materials.ColorMaterial; import org.papervision3d.materials.shadematerials.FlatShadeMaterial; import org.papervision3d.materials.shadematerials.GouraudMaterial; import org.papervision3d.materials.shaders.FlatShader; import org.papervision3d.materials.shaders.GouraudShader; import org.papervision3d.materials.shaders.ShadedMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Cube; import org.papervision3d.materials.utils.MaterialsList; import org.papervision3d.objects.primitives.Sphere; import org.papervision3d.view.BasicView; import flash.display.BitmapData; import flash.display.StageScaleMode; import flash.display.StageAlign; [SWF(width = "640", height = "480", backgroundColor = "0x000000", frameRate = "24")] public class Main extends Sprite { private var cube:Cube; private var sphere:Sphere; public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; removeEventListener(Event.ADDED_TO_STAGE, init); // entry point var light:PointLight3D = new PointLight3D(true, false); light.x = 300; light.y = 200; light.z = -100; var bmpMaterial:BitmapMaterial = BitmapMaterial(new BitmapFileMaterial("1.jpg")); var flatShade:FlatShader = new FlatShader(light, 0xFF0080, 0xFF8040); var gouraudShader:GouraudShader = new GouraudShader(light, 0x000000, 0x000000); var shadedMaterial:ShadedMaterial = new ShadedMaterial(bmpMaterial, gouraudShader); var gourand:GouraudMaterial = new GouraudMaterial(light, 0x00FFFF,0xFF8000); var materialsList:MaterialsList = new MaterialsList( { all: shadedMaterial }); cube = new Cube(materialsList, 200, 200, 200, 1, 1, 1); sphere = new Sphere(gourand,200,10,10); sphere.x = -200; cube.x = 200; var basicView:BasicView = new BasicView(640, 480); basicView.scene.addChild(sphere); basicView.scene.addChild(cube); basicView.startRendering(); addChild(basicView); basicView.scene.addChild(light); addEventListener(Event.ENTER_FRAME, onFrameHandler); } private function onFrameHandler(e:Event):void { cube.rotationX += 5; cube.rotationY += 4; cube.rotationZ += 3; sphere.rotationX += 5; sphere.rotationY += 4; sphere.rotationZ += 3; } } }
