Away3D Gold and Collada files on iOS (iPad)?

Software: Away3D 4.x

Delfeld, Newbie
Posted: 27 July 2012 03:48 AM   Total Posts: 16

Cannot get a Collada—exported from Blender—to load on iPad.  These are the tests I have done:

- cube renders on desktop and iPad
- cube colored on desktop and iPad
- DAE loads and is textured correctly on desktop—not on iPad

My desktop does not have a GPU that can handle Stage3D, so it is rendering on the display list at that point (right?).  I have set “direct” mode for the iPad output.  The basic View3D does appear, and I can interact with it.

Below is the basic Collada loading code.  Let me know if more details are needed.

(. . .)

[Embed(source="/../embeds/someBlenderModel.dae",mimeType="application/octet-stream")]
  
public static var SomeModel:Class;

(. . .)

loader = new Loader3D();
   
_loader.scale(300);
   
_loader.= -200;
   
_loader.addEventListener(AssetEvent.ASSET_COMPLETEassetCompleteHndfalse0true);
   
_loader.loadData(new SomeModel()

(. . .)

private function 
assetCompleteHnd(e:AssetEvent):void
  {
   trace
("t e.asset.assetType = " e.asset.assetType);
   
   if (
e.asset.assetType == AssetType.MESH)
   
{
    mesh 
e.asset as Mesh;
    
mesh.castsShadows true;
    
mesh.rotate(new Vector3D(100), 90);
   
}
  } 
   

Richard Olsson, Administrator
Posted: 27 July 2012 08:40 AM   Total Posts: 1192   [ # 1 ]

Are you getting any errors, e.g. load errors? Are the asset events getting traced? Have you gone into the AIR packager settings and made sure that the DAE file is included in the AIR package?

Stage3D never runs in the display list, but it can run in software mode. But if you have already managed to get a primitive cube running on the iPad, I doubt that it’s the project set-up that is causing problems. It’s more likely something with the packaged assets, or something like that.

   

Delfeld, Newbie
Posted: 28 July 2012 04:06 AM   Total Posts: 16   [ # 2 ]

Thanks for the hint.  Yes, it was not in the AIR package.  So I did some testing and found that even though it was “embedded” in the AS3 file, I still had to manually include the DAE and PNG files. 

(This is probably in the docs, but I am adding it here in case someone does not know.  I am using Flash CS6, so this is found in the AIR settings popup.  Find or open the “Properties” window, under the “Publish” area select the target as “AIR x.x for iOS”.  Then click on the “wrench” icon to the right.  In the popup, go to the “General” tab, there is an area called “Included files”; this is where the files are added.)

I was under the impression that the embed tag already included the files in the SWF/AIR package.  If Away3D is using URLLoader to access these files, what is the point in embedding?  And, how do I access the embedded files instead?  Admittedly, this is a Flex process, so it is doomed to never again be a part of Flash, but in the meantime, is there a way to access the already embedded file, without manually “Including” the file?

   

Abracad, Newbie
Posted: 28 July 2012 06:41 AM   Total Posts: 17   [ # 3 ]

Normaly when you embed a file it it included into the compiled swf file and you access it as in you exemple, or about (not sure the loader got to loadData but to parseData). There is nothing more to do on the packaging side of the application.

The other way is to specify the folders you are going to include to your app and then use a loader3d to load the objects dynamically at runtime.
I’m not a flash/flex user so i can’t help you with the steps to reproduce in flash but basicly, in the batch file where everything is declared (certificate, password, mobileprovision, config xml, root swf…) you can specify folders that will by part of the package.

   

Richard Olsson, Administrator
Posted: 28 July 2012 09:30 AM   Total Posts: 1192   [ # 4 ]

If you embedded the file, load it using the loadData() method instead of the load() method on whatever loading class you’re using (Loader3D, AssetLoader or AssetLibrary.)

If your file has dependencies, and it sounds like it does (textures) those will be loaded from their respective URLs. To avoid this, and embed those as well, use AssetLoaderContext and it’s mapUrlToData() method to “trick” the loader to retrieve the embedded data, thinking it’s actually an external file.

Google the names of these classes and the mapUrlToData() method and you will find a bunch of threads on this forum, as well as information elsewhere, about how to use AssetLoaderContext to achieve this.

   

Delfeld, Newbie
Posted: 30 July 2012 05:26 AM   Total Posts: 16   [ # 5 ]

@Richard Olsson, the problem was that

AssetLoaderContext.mapUrlToData(someURLStringsomeClassOrByteArray

has to map “someURLString” to the texture URL within the model file itself. 

Even though I embedded the texture’s PNG file using the URL “../embeds/texture.png”, the DAE file references the texture using the URL “texture.png”.  Therefore, the mapping has to be:

[Embed(source="/../embeds/beeUVcomplete.png")]
public static var TextureClass:Class;

. . . 

var 
alc:AssetLoaderContext = new AssetLoaderContext();
alc.mapUrlToData("texture.png"TextureClass);

. . . 

because the model is going to be automatically loading the texture using the URL “texture.png”.

   

Richard Olsson, Administrator
Posted: 30 July 2012 07:06 AM   Total Posts: 1192   [ # 6 ]

Yes of course. When you embed a file in Flash, it’s URL is not remembered. Flash cannot possibly automatically map a URL to an embedded file, even if that embedded file was embedded from the exact URL that is referenced in your collada file.

What you explain is 100% expected and exactly what you should be doing to be able to embed dependencies.

I’m glad it worked out!

   

Delfeld, Newbie
Posted: 30 July 2012 07:01 PM   Total Posts: 16   [ # 7 ]

Actually, the AIR/IPA does map to the correct file using the file-system specified path if the file is “included” using the AIR settings panel.  It is confusing.  For my scenario, it was getting loaded when ‘included’, but not if ‘embedded’, due to different mapUrlToData() URLs. 

The correct URL to use is not explained clearly in the docs.  Any chance that this could be clarified?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X