How to embed mtl into swf as the same time obj embed?

Software: Away3D 4.x

liuyi, Member
Posted: 15 September 2011 02:14 AM   Total Posts: 65

If we embed a obj files, but can not embed its .mtl file.

so when parse this obj file, it will load the mtl file.

I want we can embed all assets include mtl file,
can we?

   

Reaven99, Newbie
Posted: 31 August 2013 03:56 PM   Total Posts: 6   [ # 1 ]

I would like to know how to embed a mtl file aswell.

   

Avatar
Fabrice Closier, Administrator
Posted: 31 August 2013 09:18 PM   Total Posts: 1265   [ # 2 ]

you cannot embed an mtl. Because the obj uses the “useMTL” tag to access the mtl, which holds the urls to the dependencies. As you would need to embed the dependencies as well, the mtl has no use.

If you want to embed, simply load your obj with Prefab3D or AwayBuilder, and export as awd2 with the option “embed” on. Then once you have exported, simply embed this awd file. It will once you parse it (see examples) rebuild the object(s) with textures as in the original obj+mtl+dependencies.
The only difference will only be the size (much smaller in awd format) and in your code the parser: AWD2Parser instead of OBJParser.

   

ActionFrob, Newbie
Posted: 01 September 2013 08:22 AM   Total Posts: 10   [ # 3 ]

Hi,

my way to embed mtl is the following:

[Embed(source="assets/model.obj"mimeType="application/octet-stream")]
private var Model:Class;
[Embed(source="assets/model.mtl"mimeType="application/octet-stream")]
private var ModelMTL:Class;
[Embed(source="assets/model.png"mimeType="application/octet-stream")]
private var ModelPNG:Class; 

And the function to load the OBJ contains the following:

AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
var 
context AssetLoaderContext;
context = new AssetLoaderContext();
context.mapUrlToData("model.mtl"ModelMTL);
context.mapUrlToData("model.png"ModelPNG);
AssetLibrary.loadData(new Model(),context); 

The function onAssetComplete then handles adding the Model to stage.

Hope this helps!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X