At Mon, 31 May 2010 09:48:56 +0200, Fabrice3D wrote: > > You do not see directly the lighting because the map is not drawn yet > while you have already set an enterframe. Use Prefab instead, if your > model is complex or map large.
I had tried adding the enterFrame event listener at the end of traceComplete, but then I don't see anything. Marko > Fabrice > > Sent from an iPhone without Flash > > On May 31, 2010, at 1:02, "Marko Schütz Schmuck" <[email protected] > m> wrote: > > > Hi all, > > > > I'm trying to use the NormalMapGenerator, but I seem to make a mistake > > somewhere. I don't see where... > > > > Following the discussions about NormalMapGenerator, I put the code > > below > > > > package { > > import Math; > > import away3d.cameras.HoverCamera3D; > > import away3d.containers.View3D; > > import away3d.core.base.Mesh; > > import away3d.core.math.Number3D; > > import away3d.core.utils.Cast; > > import away3d.events.MouseEvent3D; > > import away3d.events.TraceEvent; > > import away3d.lights.DirectionalLight3D; > > import away3d.lights.PointLight3D; > > import away3d.materials.BitmapMaterial; > > import away3d.materials.PhongBitmapMaterial; > > import away3d.materials.Dot3BitmapMaterial; > > import away3d.materials.utils.NormalMapGenerator; > > import away3d.primitives.Cube; > > import away3d.primitives.Sphere; > > import flash.display.BitmapData; > > import flash.display.Sprite; > > import flash.events.Event; > > > > public class NormalMapGeneratorExample extends Sprite { > > > > [Embed(source="assets/gold_texture2.jpg")] > > public static var goldTexture:Class; > > > > private var _view : View3D = new View3D(); > > private var sphere : Sphere = new Sphere({radius: 1000, segmentsH: > > 35, segmentsW:35, material:null}); > > private var mat : Dot3BitmapMaterial; > > private var camera : HoverCamera3D; > > private var lightD : DirectionalLight3D; > > private var lightP : PointLight3D; > > private var mapgen : NormalMapGenerator; > > private var colorsource : BitmapData; > > public function NormalMapGeneratorExample():void { > > _view.x = 275; > > _view.y = 200; > > addChild(_view); > > colorsource = Cast.bitmap(goldTexture); > > > > mapgen = new NormalMapGenerator(sphere, 800, 200); > > mapgen.addOnTraceComplete(traceComplete); > > initLights(); > > initCamera(); > > mat = new Dot3BitmapMaterial(colorsource, colorsource); > > sphere.material = mat; > > _view.scene.addChild(sphere); > > addEventListener(Event.ENTER_FRAME, onEnterFrame); > > } > > private function traceComplete(e:TraceEvent):void { > > mat = new Dot3BitmapMaterial(colorsource, mapgen.normalMap); > > sphere.material = mat; > > } > > private function initLights():void { > > lightD = new DirectionalLight3D({color:0xFFFFFF, ambient:0.25, > > diffuse:0.75, specular:0.9}); > > lightD.direction.x = 5000; > > lightD.direction.z = 0; > > lightD.direction.y = 5000; > > _view.scene.addLight( lightD ); > > } > > private function initCamera():void { > > camera = new HoverCamera3D(); > > camera.zoom = 3; > > camera.focus = 200; > > camera.distance = 4000; > > camera.yfactor = 1; > > > > camera.panAngle = -10; > > camera.tiltAngle = 20; > > camera.hover(true); > > _view.camera = camera; > > } > > private function onEnterFrame(ev : Event) : void { > > sphere.rotationY += 5; > > _view.render(); > > } > > } > > } > > > > The call to Dot3BitmapMaterial(colorsource, colorsource) is only in > > there to make sure that I'm not making a substantial mistake using > > this function. > > > > The sphere is rotating with its weird Dot3BitmapMaterial which never > > (at least not after minutes) gets updated. > > > > Where is the mistake? > > > > Thanks for any hint and best regards, > > > > Marko
pgprhoex1MJNb.pgp
Description: PGP signature
