[SWF(width="1280", height="720", frameRate="60", backgroundColor="0x000000")] public class adria extends Sprite { private var _view : View3D; private var _loader : Loader3D;
private var _light : PointLight;
[Embed(source="/../embeds/adria/AdriaBoyC.obj", mimeType="application/octet-stream")] private var OBJData : Class;
[Embed(source="/../embeds/adria/Adria_A_diff.png")] private var Albedo : Class;
[Embed(source="/../embeds/adria/Adria_A_spec.png")] private var Specular : Class;
//signature variables private var Signature : Sprite;
private var _camController : HoverDragController; private var _count : Number = 0; private var _subsurfaceMethod : SubsurfaceScatteringDiffuseMethod; private var _diffuseMethod : BasicDiffuseMethod; private var _material : BitmapMaterial; private var _fresnelMethod : FresnelSpecularMethod; private var _specularMethod : BasicSpecularMethod;
public function adria() { _view = new View3D(); _view.antiAlias = 4; this.addChild(_view);
private function initMesh() : void { Loader3D.enableParser(OBJParser);
_loader = new Loader3D(); _loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete); _loader.parseData(OBJData, null, new AssetLoaderContext(false)); _loader.x = 0; _loader.y = 0; _loader.z = 0; _view.scene.addChild(_loader);
_material = new BitmapMaterial(new Albedo().bitmapData); _subsurfaceMethod = new SubsurfaceScatteringDiffuseMethod(2048, 2); _diffuseMethod = new BasicDiffuseMethod(); _fresnelMethod = new FresnelSpecularMethod(true); _specularMethod = new BasicSpecularMethod();
80prozent, Sr. Member Posted: 12 November 2011 12:25 PM Total Posts: 430
[ # 3 ]
hi
you would have to change this code:
private function onResourceComplete(event : LoaderEvent) : void { var mesh : Mesh; for (var i : int = 0; i < _loader.numChildren; ++i) { mesh = Mesh(_loader.getChildAt(i)); mesh.geometry.scale(100); mesh.material = _material } }
into this:
private function onResourceComplete(event : LoaderEvent) : void { var mesh : Mesh; for (var i : int = 0; i < _loader.numChildren; ++i) { mesh = Mesh(_loader.getChildAt(i)); mesh.geometry.scale(100); mesh.material = _material
for (var j:uint=0;j<mesh.geometry.subGeometries.length;j++){ for (var k:uint=1;k<mesh.geometry.subGeometries[j].UVData;k+=2){ mesh.geometry.subGeometries[j].UVData[k]=1-mesh.geometry.subGeometries[j].UVData[k]; } mesh.geometry.subGeometries[j].updateUVData(mesh.geometry.subGeometries[j].UVData) }
} }
i didnt test this code, but i think it should work
Monguron, Newbie Posted: 12 November 2011 03:15 PM Total Posts: 27
[ # 4 ]
I get this error meassage:
C:\3D\away3d-away3d-examples-broomstick-20a270c\src\adria.as(119): col: 19 Error: Comparison between a value with static type uint and a possibly unrelated type __AS3__.vec:Vector.<Number>.
line 119 is:
for (var k:uint=1;k
80prozent, Sr. Member Posted: 12 November 2011 04:19 PM Total Posts: 430
[ # 5 ]
sorry
try this:
for (var k:uint=1;k
Monguron, Newbie Posted: 12 November 2011 04:52 PM Total Posts: 27
[ # 6 ]
Thanks 80prozent! You are a God!
It’s working, so the texture is properly fit to the model.
I only have two problems left:
1) when the light is moving around the model, it generates strange orange surface on the poligons (see picture).
2) I would like to see the model from an upper left corner, and to simply rotate it with the mouse only horizontally (at the moment the sample .as file I use rotates it quite funny)
80prozent, Sr. Member Posted: 12 November 2011 05:24 PM Total Posts: 430
[ # 7 ]
for the orange light: i think that is because of the material you are using.
change this:
_material = new BitmapMaterial(new Albedo().bitmapData); _subsurfaceMethod = new SubsurfaceScatteringDiffuseMethod(2048, 2); _diffuseMethod = new BasicDiffuseMethod(); _fresnelMethod = new FresnelSpecularMethod(true); _specularMethod = new BasicSpecularMethod();
for moving your object: right now you are not moving your object, you use the HoverDragController to move the Camera. try using a normal camera instead.
replace:
_camController = new HoverDragController(_view.camera, stage);
[SWF(width="500", height="400", frameRate="60", backgroundColor="0xd7d7d7")] public class adria extends Sprite { private var _view : View3D; private var _loader : Loader3D;
private var _light : PointLight;
[Embed(source="/../embeds/adria/AdriaBoyC.obj", mimeType="application/octet-stream")] private var OBJData : Class; // adria/AdriaBoyC.obj
[Embed(source="/../embeds/adria/Adria_A_diff.png")] private var Albedo : Class; // adria/Adria_A_diff.png
[Embed(source="/../embeds/adria/Adria_A_spec.png")] private var Specular : Class;
private var _camController : HoverDragController; private var _count : Number = 0; private var _subsurfaceMethod : SubsurfaceScatteringDiffuseMethod; private var _diffuseMethod : BasicDiffuseMethod; private var _material : BitmapMaterial; private var _fresnelMethod : FresnelSpecularMethod; private var _specularMethod : BasicSpecularMethod;
public function adria() { _view = new View3D(); _view.antiAlias = 4; this.addChild(_view);
_light = new PointLight(); _light.x = 15000; _light.z = 15000; _light.color = 0xffddbb; _view.scene.addChild(_light); //_camController = new HoverDragController(_view.camera, stage);
//new camera _view.camera.x=800; _view.camera.y=-1000; _view.camera.z=-500; _view.camera.lookAt(new Vector3D(0, 0, 0));