Look into Basic_LoadModel.as inside trunk/fp10/examples/Away3D/as/src/ On Wed, Feb 2, 2011 at 1:52 PM, Michael Iv <[email protected]> wrote:
> Man you should assign your material not to the Loader but to the model > after it has finished loading. Also you have to designate the material name > which You gave to the model inside 3d modelling program.Look into Away3D > examples directory .You have got what you need there . > > > On Wed, Feb 2, 2011 at 1:48 PM, Nathan Queija <[email protected]>wrote: > >> Thanks for the response! >> How can I do this? >> Here is the code: >> >> import away3d.cameras.*; >> import away3d.containers.*; >> import away3d.core.base.*; >> import away3d.core.filter.*; >> import away3d.core.render.*; >> import away3d.events.*; >> import away3d.materials.*; >> import away3d.primitives.*; >> import away3d.loaders.Loader3D; >> import away3d.loaders.Collada; >> >> >> import flash.display.*; >> import flash.events.*; >> >> >> //engine variables >> var scene:Scene3D; >> var camera:HoverCamera3D; >> var renderer:BasicRenderer; >> var view:View3D; >> >> >> >> //navigation variables >> var move:Boolean = false; >> var lastPanAngle:Number; >> var lastTiltAngle:Number; >> var lastMouseX:Number; >> var lastMouseY:Number; >> >> init(); >> >> function init():void >> { >> initEngine(); >> initObjects(); >> initListeners(); >> } >> >> function initEngine():void >> { >> scene = new Scene3D(); >> >> //camera = new HoverCamera3D({focus:50, distance:1000, >> mintiltangle: >> 0, maxtiltangle:90}); >> camera = new HoverCamera3D(); >> camera.focus = 50; >> camera.distance = 1000; >> camera.minTiltAngle = 0; >> camera.maxTiltAngle = 90; >> >> camera.panAngle = 45; >> camera.tiltAngle = 20; >> camera.hover(true); >> >> >> >> >> //view = new View3D({scene:scene, camera:camera, >> renderer:renderer}); >> view = new View3D(); >> view.scene = scene; >> view.camera = camera; >> >> addChild(view); >> >> >> >> } >> >> function initObjects():void >> { >> >> var mat: ShadingColorMaterial = new ShadingColorMaterial(0x888888); >> //plane = new Plane({y:-20, width:1000, height:1000, pushback:true, >> segmentsW:20, segmentsH:20}); >> plane = new Plane(); >> plane.y = -20; >> plane.width = 1000; >> plane.height = 1000; >> plane.pushback = true; >> plane.segmentsW = 20; >> //plane.material = materialPhong; >> plane.segmentsH = 20; >> >> scene.addChild(plane); >> >> var loader:Loader3D = Collada.load("ball.dae"); >> loader.scale(50); >> loader.material = mat; >> scene.addChild(loader); >> >> //sphere = new Sphere({x:300, y:160, z:300, radius:150, >> segmentsW:12, >> segmentsH:10}); >> sphere = new Sphere(); >> sphere.x = 300; >> sphere.y = 160; >> sphere.z = 300; >> sphere.radius = 150; >> sphere.segmentsW = 12; >> sphere.segmentsH = 10; >> >> scene.addChild(sphere); >> >> //cube = new Cube({x:300, y:160, z:-80, width:200, height:200, >> depth: >> 200}); >> cube = new Cube(); >> cube.x = 300; >> cube.y = 160; >> cube.z = -80; >> cube.width = 200; >> cube.height = 200; >> cube.depth = 200; >> >> scene.addChild(cube); >> >> //torus = new Torus({x:-250, y:160, z:-250, radius:150, tube:60, >> segmentsR:12, segmentsT:10}); >> torus = new Torus(); >> torus.x = -250; >> torus.y = 160; >> torus.z = -250; >> torus.radius = 150; >> torus.tube = 60; >> torus.segmentsR = 12; >> torus.segmentsT = 10; >> >> scene.addChild(torus); >> >> } >> >> >> function initListeners():void >> { >> >> >> >> addEventListener(Event.ENTER_FRAME, onEnterFrame); >> stage.addEventListener(MouseEvent.MOUSE_DOWN, clicou); >> stage.addEventListener(MouseEvent.MOUSE_UP, soltou); >> stage.addEventListener(Event.RESIZE, onResize); >> onResize(); >> } >> >> function onEnterFrame(event:Event):void >> { >> if (move) { >> camera.panAngle = 0.3 * (stage.mouseX - lastMouseX) + >> lastPanAngle; >> camera.tiltAngle = 0.3 * (stage.mouseY - lastMouseY) + >> lastTiltAngle; >> } >> >> camera.hover(); >> view.render(); >> } >> >> >> function clicou(event:MouseEvent):void >> { >> lastPanAngle = camera.panAngle; >> lastTiltAngle = camera.tiltAngle; >> lastMouseX = stage.mouseX; >> lastMouseY = stage.mouseY; >> move = true; >> stage.addEventListener(Event.MOUSE_LEAVE, onStageMouseLeave); >> } >> >> >> function soltou(event:MouseEvent):void >> { >> move = false; >> stage.removeEventListener(Event.MOUSE_LEAVE, onStageMouseLeave); >> } >> >> >> function onStageMouseLeave(event:Event):void >> { >> move = false; >> stage.removeEventListener(Event.MOUSE_LEAVE, onStageMouseLeave); >> } >> >> >> function onResize(event:Event = null):void >> { >> view.x = stage.stageWidth / 2; >> view.y = stage.stageHeight / 2; >> } >> >> On 2 fev, 05:08, Michael Iv <[email protected]> wrote: >> > You should access material name that you defined in your 3d package in >> order >> > to assign a material to external model.Can you post the code? >> > >> > On Wed, Feb 2, 2011 at 1:05 AM, Nathan Queija <[email protected]> >> wrote: >> > > Hello from Brazil! =) >> > > I don't speak english very well, sorry for any error, but I think you >> > > can understand me! >> > > I'm trying to load a model into Away 3D, that's ok, the model is >> > > loaded perfectly, but when i try to apply a simple texture, like >> > > colorshading, or even wirecolor I can't, the model stay black, I tried >> > > with all types: obj, dae, 3ds and in all cases i get the same result. >> > > Model in black. >> > > Can you help me, please? >> > > Thank you very much! >> > >> > -- >> > Michael Ivanov ,Programmer >> > Neurotech Solutions Ltd. >> > Flex|Air |3D|Unity|www.neurotechresearch.comhttp://blog.alladvanced.net >> > Tel:054-4962254 >> > [email protected] >> > [email protected] > > > > > -- > Michael Ivanov ,Programmer > Neurotech Solutions Ltd. > Flex|Air |3D|Unity| > www.neurotechresearch.com > http://blog.alladvanced.net > Tel:054-4962254 > [email protected] > [email protected] > > -- Michael Ivanov ,Programmer Neurotech Solutions Ltd. Flex|Air |3D|Unity| www.neurotechresearch.com http://blog.alladvanced.net Tel:054-4962254 [email protected] [email protected]
