I have a collada object (a cocacola bottle) and starting with basic
demos and
code i found here and there, but i'm not totally sure to understand
what i'm doing.
So i load the collada object and launch the normal map generator but
then
i'm not sure what to do to apply this to a cylinder

here is the full code, i'm pretty sure there is thing not needed, and
thing to
add but i'have no idea what and how.

****************************************************************************
// import containers
import away3d.containers.*;
// import core library
import away3d.core.base.*;
// import geometry primitives
import away3d.primitives.*;
  import away3d.cameras.HoverCamera3D;
  import away3d.containers.ObjectContainer3D;
  import away3d.containers.Scene3D;
  import away3d.containers.View3D;
  import away3d.core.render.Renderer;
  import away3d.core.utils.Cast;
  import away3d.lights.DirectionalLight3D;
  import away3d.materials.Dot3BitmapMaterial;
  import away3d.materials.EnviroBitmapMaterial;
  import away3d.primitives.Plane;
  import away3d.primitives.Sphere;
  import away3d.loaders.Collada;
    import away3d.loaders.Object3DLoader;
        import away3d.materials.utils.NormalMapGenerator;

  import flash.display.Bitmap;
  import flash.display.BitmapData;
  import flash.display.Sprite;
  import flash.display.StageAlign;
  import flash.display.StageScaleMode;
  import flash.events.Event;
  import flash.events.MouseEvent;

// create a 3D-viewport
var view:View3D = new View3D({x:300, y:200});
addChild(view);

// create primitives
var loader:Object3DLoader = Collada.load('coke.dae',
{autoLoadTextures:false});
var mesh:Mesh = Mesh((loader.handle as
ObjectContainer3D).getChildByName('Polygon'));
var mapgen:NormalMapGenerator = new NormalMapGenerator(mesh,1200,
1200, null, 0, 100);

var mat:Dot3BitmapMaterial = new Dot3BitmapMaterial
(mapgen.normalmap,mapgen.normalmap);

var plane:Object3D = new Plane({material:"yellow#", name:"plane",
y:-100, width:1000, height:1000, pushback:true});
var sphere:Object3D = new Cylinder({material:"red#", name:"sphere",
segmentsH:6,segmentsW:15,heigth:670,radius:70});
var cube:Object3D = new Cube({material:"blue#", name:"cube", x: 300, y:
160, z: -80, width:20, height:200, depth:200});
var torus:Object3D = new Torus({material:"limegreen#", name:"torus",
x:-250, y:160, z:-250, radius:15, tube:6, segmentsR:8, segmentsT:6});

// add primitives to the scene
view.scene.addChildren(sphere, cube, plane, torus);

// set camera in space
view.camera.moveTo(torus.x, torus.y, torus.z);
view.camera.lookAt(cube.position);
view.camera.moveBackward(1500);
view.camera.moveUp(1500);
view.camera.lookAt(plane.position);

// every frame
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(event:Event):void {
        // rerender viewport on each frame
        view.render();
}
*********************************************************************
i can find demo on the net, but no tutorial or example file
If my code is not too F***ed, somebody could help me ?

thanks

Reply via email to