How Does AWD2 Handle Materials?

Software: Other

cbrown, Jr. Member
Posted: 02 August 2011 07:28 PM   Total Posts: 39

Hi Richard,

I was wondering if you could give me an idea of how AWD2 embeds the file paths for materials.  Seeing as how AWD2 is a binary format, it’s obviously not possible to look inside the AWD2 files I am generating with the Maya exporter. 

Basically I just want to know what happens when I check the “Include Materials” and/or “Embed Materials” check boxes.  I am assuming “Embed Materials” does pretty much what it says—embeds the bitmaps directly into the .awd file.  But I am unable to get the AWD2Parser using AssetLoaderContext to find them either way.

 Signature 
signature_image

whatever is good to know is difficult to learn

   

John Brookes, Moderator
Posted: 03 August 2011 08:53 AM   Total Posts: 732   [ # 1 ]

The image path should be the same as the “Image Name” in Maya (backslashes converted to forward).

If you exported an awd2 without checking embed images

//load awd2 no embeds

Loader3D.enableParser(AWD2Parser);
var 
context:AssetLoaderContext = new AssetLoaderContext(true)

AssetLibrary.load(new URLRequest("../src/YourAWD.awd"), new AWD2Parser(),context);
AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete); 

//load awd2 no embeds swap image

Loader3D.enableParser(AWD2Parser);
var 
context:AssetLoaderContext = new AssetLoaderContext()
context.mapUrl("images/car_b_white_tex.jpg""../src/images/my_other_image.jpg")
AssetLibrary.load(new URLRequest("../src/YourAWD.awd"), new AWD2Parser(),context);
AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete); 

//AWD2 embedded into script without embeded images and swap image

var context:AssetLoaderContext = new AssetLoaderContext()
context.mapUrl("images/car_b_white_tex.jpg""../src/my_new_image.jpg")
AssetLibrary.parseData(new AWDAsset(), new AWD2Parser(),context);
AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete); 


If you exported an awd2 with checking embed images. (yep images will be embedded into the awd wink

//everything embedded into awd2 file and awd2 file embedded into script

Loader3D.enableParser(AWD2Parser);
AssetLibrary.parseData(new AWDAsset(), new AWD2Parser());
AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete); 

But what I’ve not been able to do is. Export awd2 without embedding images. Embed that awd2 file into the script and load the images. Like you would do for awd1
eg

Loader3D.enableParser(AWD2Parser);
var 
context:AssetLoaderContext = new AssetLoaderContext(false"images/")
AssetLibrary.parseData(new AWDAsset(), new AWD2Parser(),context);
AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete); 


ps
If anybody wants to do a howto build awd sdk with Vs2010 for realy thick people. I would be very happy.

   

Richard Olsson, Administrator
Posted: 03 August 2011 01:23 PM   Total Posts: 1192   [ # 2 ]

Thanks John for the breakdown! Saves me some typing. smile

But bottom line is that yes, when “embed textures” is checked, the textures will be embedded. The “include materials” checkbox basically defines whether materials should be included at all. If unchecked, no materials will be defined in the file so Away3D will use default materials for any meshes.

When “embed textures” is not checked, the Maya exporter will use the MEL command “workspace” to get the path to the textures, relative to the current Maya project. So if you keep your textures in the default Maya “sourceImages” folder inside your project folder, then Away3D will look for them in a folder with that same name, relative to the AWD file.

@John:
Your last example should work, provided that the path is correct. As for building with VS2010, you should be able to use more or less the exact steps explained in the build guide in the wiki at http://awd.googlecode.com even ,though they are intended for VS2008.

   

John Brookes, Moderator
Posted: 03 August 2011 01:37 PM   Total Posts: 732   [ # 3 ]

The path is correct as thats the path in the awd file ( if there not zipped you can read the path with a text editor).

But I am still using that awdSDK you gave me so maybe..

As for vs2010. Compiling python.
As soon as you open the pcbuild.sln it converts it saying its an old version.
Then do build (release), it fails.
After that Im stuck.
Sorry never used VS before, total noob.

Sort of need it as can’t currently use the latest Git with these old awd2 Ive got.

   

Richard Olsson, Administrator
Posted: 03 August 2011 01:47 PM   Total Posts: 1192   [ # 4 ]

In the instructions in the wiki I mention that some projects in the solution might fail. Have you tried removing them and then rebuild? If it still doesn’t work, I suggest you downgrade to VS2008 which is still available and which I know works. I have gotten VS2010 to work as well though, for my 64b builds, but I can’t remember if I had to tweak some stuff to get it to build.

By using “images/” as the dependencyBasePath like you’re doing, you’re saying that whatever is in the AWD file should be prepended with “images/”. That means that if your AWD file says that a texture is “sourceImages/mytexture.jpg” it will try to find it at “images/sourceImages/mytexture.jpg”. Judging by how you’ve gotten mapUrl() to work, my guess is that you may have misunderstood how to use the dependencyBasePath. Could I be right?

   

cbrown, Jr. Member
Posted: 03 August 2011 02:45 PM   Total Posts: 39   [ # 5 ]

FYI, in the ASDoc comment in AssetLoaderContext.as for dependecyBaseURL it says “appended” instead of “prepended.”  When I first saw it I figured they probably meant “prepended” but just thought I’d call it to attention as it makes things a little murkier.  wink

As for my original question re how AWD2 handles the material paths, thank you very much to both of you!  That helps a lot.

 Signature 
signature_image

whatever is good to know is difficult to learn

   

Richard Olsson, Administrator
Posted: 03 August 2011 02:48 PM   Total Posts: 1192   [ # 6 ]

@cbrown: Thanks for letting us know. I have fixed the code comment.

   

cbrown, Jr. Member
Posted: 03 August 2011 02:48 PM   Total Posts: 39   [ # 7 ]

awesome

 Signature 
signature_image

whatever is good to know is difficult to learn

   

John Brookes, Moderator
Posted: 03 August 2011 03:52 PM   Total Posts: 732   [ # 8 ]

Downloaded vs2008
Yay it works smile

Ill figure out awd2 embed with texture load when I need it. Using pure embed at the moment.
Ps
woo hoo cameras lights materials
well done that man smile

Just tried LZMA
Does lzma work? Didnt with that last version.

   

cbrown, Jr. Member
Posted: 04 August 2011 06:05 PM   Total Posts: 39   [ # 9 ]

Hi Guys,

So I have the AWD2 exporter for Maya working for the most part.  RIght now, however, I’m having 2 problems. 

You can download example files I prepared here

My problems are:

1.  I included a maya file with 3 objects in it, each with a bitmap material applied and proper uv’s.  If you Export All using the AWD2 exporter with “include materials” checked, you should see the Maya output window showing 0 materials for each object. 

Compiling using the included FLA compiles fine.  If you view the trace output you should see each mesh.material property tracing null and, of course, the objects do not show up in the scene (except for a test sphere primitive I dropped in). 

Any idea why the materials are not being exported?


2.  Also, you will notice I had to place my jpg’s two folders down in assets/img.  This is because the AWD2 exporter would place a slash / at the beginning of the path string which was throwing dependency retrieval errors.  If I, however, place the img folder in a second folder called assets, and then set the dependencyBaseURL in AssetLoaderContext to “assets”,  it will work.  However, I’m probably doing something wrong because I’m sure this shouldn’t be necessary. 

Any help, much obliged!

 Signature 
signature_image

whatever is good to know is difficult to learn

   

cbrown, Jr. Member
Posted: 05 August 2011 07:27 PM   Total Posts: 39   [ # 10 ]

bump ...

 Signature 
signature_image

whatever is good to know is difficult to learn

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X