3ds file loading (urgent)

Software: Away3D 4.x

mole, Newbie
Posted: 23 February 2012 12:12 PM   Total Posts: 29

I’m working on a project where I need to display a complex 3D model (around 16000 polygons). I used the 3ds file loader, because that seemed the easiest route to load a model made in 3D studio max.
I soon had a proof of concept running. However, then I heard from my client he was getting some errors:  Cannot create property transparent on flash.display.Stage3D to be more precise.
I read somewhere that this was because of a change in the new flash player version, and that it was fixed. So I downloaded a more recent version of away3d from github… recompiled… and nothing happended… nothing on screen. Looks like 3Ds file loading was broken in that version. So I tried 3-4 other recent versions. No succes.
I urgently need a stable version of away3d 4, with working 3Ds file loading. Can anyone tell me what version I should download?

   

Avatar
theMightyAtom, Sr. Member
Posted: 23 February 2012 01:21 PM   Total Posts: 669   [ # 1 ]

Here’s a link to a zip of the last stable version I was using before the recent Beta release.
I am still using it, and loading .3DS models, no problem.
http://www.videometry.net/broomstick/away3d-away3d-core-fp11-18098e8.zip

There are a lot of changes in the Beta, which is what you now get when you update from the main branch on github.
How are you debugging? There should be some clues as to why it’s not working.

If you’re really desperate, you are welcome to send it to me ( ps at videometry dot net) and if there’s a quick fix, I’ll do it :0)

Good Luck!

   

mole, Newbie
Posted: 26 February 2012 03:37 PM   Total Posts: 29   [ # 2 ]

That version doesn’t give me compile errors, but my code no longer works, and I don’t have a clue what I’m doing wrong!
Nothing appears.

What I’m doing is this:

Parsers.enableAllBundled();
  modelLoader = new Loader3D();
  modelLoader.addEventListener(AssetEvent.ASSET_COMPLETE, assetCompleteHandler);
  modelLoader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, resourceCompleteHandler);
  modelLoader.load(new URLRequest(‘assets/model.3DS’));

Then in the asset complete handler, I check if the asset is the mesh, if so, I assign a new material. Even if I don’t do this, nothing appears on screen, so this isn’t the problem.

In the resource complete handler, I add the model loader to the stage.

   

mole, Newbie
Posted: 26 February 2012 03:38 PM   Total Posts: 29   [ # 3 ]

Euhm.. i mean I add it to the scene:

private function resourceCompleteHandler(evt:LoaderEvent):void{
   trace
("resource complete");
   
view.scene.addChild(modelLoader);
   
modelLoader.removeEventListener(AssetEvent.ASSET_COMPLETEassetCompleteHandler);
   
modelLoader.removeEventListener(LoaderEvent.RESOURCE_COMPLETEresourceCompleteHandler);
   
  
   

Avatar
theMightyAtom, Sr. Member
Posted: 26 February 2012 08:57 PM   Total Posts: 669   [ # 4 ]

The only difference I see compared to how I do it, is that I don’t use ASSET_COMPLETE, and add materials on LoaderEvent.RESOURCE_COMPLETE.

If you don’t assign a material in resourceCompleteHandler, that can be why you’re not seeing anything. I gave up early on with the AssetLoader, never could figure it out.

public function loadModel(model:String):void {
 Loader3D
.enableParser(Max3DSParser);
 
_loader = new Loader3D();
 
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETEonModelLoaded);
_loader.load(new URLRequest(model));

  
}

private function onModelLoaded(LoaderEvent) : void
{
 _loader
.removeEventListener(LoaderEvent.RESOURCE_COMPLETEonModelLoaded);
 
_view.scene.addChild(_loader);
 
 
mat =  new ColorMaterial(0xCCCCCC1);
 
mat.lights [_light];
 
 var 
i:int;
 var 
mesh:Mesh;
 var 
tot:int =  _loader.numChildren;
 for (
0tot; ++i{
  mesh 
Mesh(_loader.getChildAt(i));
  
mesh.material mat;
 
}
   

Alex Bogartz, Sr. Member
Posted: 26 February 2012 10:45 PM   Total Posts: 216   [ # 5 ]

In my own workflow, if you assign a bitmap texture in your 3D program and make sure it has unwrapped UVs, you don’t need to assign the materials at all in code, but you do need to embed the textures and map the bitmapData to the material name in the 3DS files.

My tactic usually involves loading the file using AssetLoader, then mapping the textures one at a time when the parser hits an error.  Once it’s all done you will see your whole scene with all textures applied.

   

mole, Newbie
Posted: 26 February 2012 10:59 PM   Total Posts: 29   [ # 6 ]

Something must have changed to the camera between the version I was using, and the version you linked to.
Turns out the model was loading… but the camera code I was using turned the camera away from it. The away stats indicated 0 polygons, so I assumed it was a loader error.
So… what’s wrong with this code?? (from the hoverdrag controller I copied from one of the examples)

if (_dragupdateRotationTarget();

            
_radius _radius + (_targetRadius _radius)*dragSmoothing;
   
_xRad _xRad + (_targetXRad _xRad)*dragSmoothing;
   
_yRad _yRad + (_targetYRad _yRad)*dragSmoothing;

   
// simple spherical position based on spherical coordinates
   
var cy Number Math.cos(_yRad)*_radius;
   
_camera._target.Math.sin(_xRad)*cy;
   
_camera._target.Math.sin(_yRad)*_radius;
   
_camera._target.Math.cos(_xRad)*cy;

   
_camera.lookAt(_target); 

if I don’t do a lookAt(), it seems like the camera is still orbiting the model fine. However, I noticed my model is mirrored. That’s no good, but I can look into that later.
Anyway, my model is located at (0,0,0). I’m using a new Vector3D(0,0,0) as the target for the camera controller. So lookat() should point the camera in the direction of the model.
This all works fine if I go back a couple of versions (!!)

   

Alex Bogartz, Sr. Member
Posted: 26 February 2012 11:17 PM   Total Posts: 216   [ # 7 ]

You model may not be centered in the 3D world.  So even though it says it’s at 0,0,0, it may in face be somewhere else. Open it up in Blender and make sure it’s centered.  If it’s not, center it, apply the transforms, then export as 3DS again.

   

mole, Newbie
Posted: 27 February 2012 09:07 AM   Total Posts: 29   [ # 8 ]

That doesn’t seem to be the problem. Because if I add a sphere object programmatically, the sphere is in the center of my model. Because of this, I know my model is indeed in the center of the scene.

   

Alex Bogartz, Sr. Member
Posted: 27 February 2012 03:42 PM   Total Posts: 216   [ # 9 ]

One thing to remember is that even though the mesh is in the center of the scene, the geometry…the vertices and faces…may be offset.  The only way to know for sure is to open the 3DS in a program like Blender, center it on the grid, then re-export.

   

mole, Newbie
Posted: 27 February 2012 04:45 PM   Total Posts: 29   [ # 10 ]

Like I said, that’s not what’s happening. I Tested it by adding a sphere at 0,0,0. That way I can visually see the scene center. And my model is located there.
The camera is still rotating around it (or at least it appears that way). But camera lookat() doesn’t work (camera then looks away from the model). Very strange! Especially because this all worked fine before.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X