Desperate about loading 3ds with multi-textures

Software: Away3D 4.x

C., Newbie
Posted: 15 January 2012 06:34 PM   Total Posts: 9

Hello everyone,

when I try to load a 3DS model with more than one texture (in Away3D 4 alpha), the swf always crashes, saying that Error #1009 occured. (“Cannot access a property or method of a null object reference.”)

I am totally new to Away3D and Actionscript. At this point, I´ve read most of the tutorials for away3d 4, that I was able to find. But there is still a lot of experience missing. To get into it, I wanted to first try and load a custom model. Lets say this one: Example

I am using the examplecode(Basic_Load3DS.as) from github. When I run the examples, they work fine(So I guess Flashdevelop, FLEX SDK etc. are set up correctly).
Even my own models(without textures) are working and I can manipulate them. Just textured ones seem to crash all the time. Traced in debug-mode it happens when the “onAssetComplete” event is fired. Then he crashes at line 245 because material is null.

my assetLoader looks like this:

var assetLoaderContext:AssetLoaderContext = new AssetLoaderContext();
   
assetLoaderContext.mapUrlToData("raumgliederung.3ds.textures/image_0.png", new AntTexture()); 

and in the beginning I embedded:

[Embed(source "/../embeds/raumgliederung/image_0.png")]
  
private var AntTexture:Class; 

I am already playing around with this since four hours now and start becoming a bit desperate about it. Maybe he crashes, because he hasn´t got all textures, but I dont know how to do this with the assetloader. I was reading several post, googleing around ... but couldnt find an answer to this problem. So this is my last approach to get help from you guys. smile

Thank you in advance!

 

   

Alex Bogartz, Sr. Member
Posted: 15 January 2012 06:52 PM   Total Posts: 216   [ # 1 ]

Just a shot in the dark here, but if you have a complex model with both procedural textures and bitmap textures, make sure you don’t try and affect the procedural one with things like alpha blending.

Procedurals seem to load as a ColorMaterial and not a BitmapMaterial from the parser.

Also, make sure any mesh with a BitmapMaterial has its UVs unwrapped.  It could be looking for UV info.

   

Alex Bogartz, Sr. Member
Posted: 15 January 2012 06:54 PM   Total Posts: 216   [ # 2 ]

P.S.

Are you using a proper debugger?  If you use FlashDevelop, you can put a break point on the line that just crashed and then explore the object it’s trying to work with.  Getting the name of the mesh or material in question would go a long way towards solving your bug.

Not directed at you personally, but I’m sometimes shocked at how many people use traces instead of a debugger to fix bugs.

   

C., Newbie
Posted: 16 January 2012 08:13 AM   Total Posts: 9   [ # 3 ]

Hello Alex,

thank you for your response. As far as I know, there should be no procedural textures used in the model.

I think the uvs are allready unwrapped. But I´m not sure about it. I will check this, when I come back home.

I am not taking it personally. smile
I was using the FlashDevelop- Debugger. But since I am new to 3D- Programming, I´ve got no clue what to look for.

The error happens in the last line, where material is null:

private function onAssetComplete(event:AssetEvent):void
  {
   
if (event.asset.assetType == AssetType.MESH{
    
var mesh:Mesh event.asset as Mesh;
    
mesh.castsShadows true;
   
else if (event.asset.assetType == AssetType.MATERIAL{
    
var material:BitmapMaterial event.asset as BitmapMaterial;
    
material.shadowMethod = new FilteredShadowMapMethod(light); 

event.asset is a ColorMaterial. Seems like it cant be parsed to bitmap, which makes sense in a way. But I dont really know where the Colormaterial is coming from, because in AssetLoaderContext I defined to load a png. Even with the debugger I am not able track back where the colormaterial is coming from.

Actually I´m confused about the Assetloader in general. Shouldnt the model “know” by its own, where the assets are - by relative paths?

Best regards
Constantin

 

   

Alex Bogartz, Sr. Member
Posted: 16 January 2012 05:04 PM   Total Posts: 216   [ # 4 ]

Ah yes, you have a material on one of your objects that’s not a bitmap material.  Just run a check in that function:

if(event.asset is ColorMaterial){
  //do nothing here or something else
}else{
  //yay, I found a bitmap material!
}

   

Alex Bogartz, Sr. Member
Posted: 16 January 2012 05:08 PM   Total Posts: 216   [ # 5 ]

Oh, you also have to map the url of the image to your loaded image using just that last bit (remove the slashes).

So in your case:

assetLoaderContext.mapUrlToData(“image_0.png”, new AntTexture());

At least that’s what works for me, exporting models from Blender 2.6.

   

C., Newbie
Posted: 17 January 2012 01:15 PM   Total Posts: 9   [ # 6 ]

Hello Alex,

once more I´d like to thank you for your help. That solved the texture problem for me. But it turned out, that I already had that state a bit earlier.(without mapping textures)
But since there was another problem which caused the same error, I didn´t notice it.

So a bit further in the code it crashes again in Max3DSParser at line 457

private function constructObject(obj ObjectVOpivot Vector3D null) : ObjectContainer3D
  {
   
if (obj.type == AssetType.MESH

But the problem seems to be in parseObjectAnimation()

// If name is "$$$DUMMY" this is an empty object (e.g. a container)
   // and will be ignored in this version of the parser
   // TODO: Implement containers in 3DS parser.
   
if (name != '$$$DUMMY' {
    vo 
_unfinalized_objects[name];
    
obj constructObject(vopivot);
    
    
finalizeAsset(objvo.name);
    
    
delete _unfinalized_objects[name];
   
}
  } 

he is looking for MESH_1229 in _unfinalized_objects. But they only go to 1163.

What could be the mistake here? Does that mean, that my Model is simply “broken”? But it happens with several other 3ds- Files, too.

Best regards,
Constantin

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X