[Broomstick] awd and obj dispose and embeds

191 views
Skip to first unread message

John Brookes

unread,
May 31, 2011, 1:25:51 PM5/31/11
to away3d-dev

Both OBJ and awd don't clean up when using dispose(true) on the mesh.
Theres always the same number of meshes and geometry hanging around.
Do I need to do anything more than ?
Mesh(themesh).dispose(true)




Trying to embed awd files and images
Something along the lines of

Loader3D.enableParser(AWDParser);

imgCntxt = new AssetLoaderContext(false,null);
//Tried various paths etc
// imgCntxt.mapUrlToData("Models/TreeScotPineAWD/images/", new treeBranchIMG());
// imgCntxt.mapUrlToData("../src/Models/ScotsPine/images/polySurface1.jpg", new treeTrunkIMG() as ByteArray);

AssetLibrary.parseData(new awdFile(), new AWDParser(),imgCntxt);
AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onLoadComplete);

Gone through every random guess but cant get embedded awd and images.
Only thing I've found to work is to set
imgCntxt = new AssetLoaderContext(false,null);

and then apply the materials without mapurltoData through new bitmapmaterial.
so erm how?

richardolsson

unread,
May 31, 2011, 2:27:23 PM5/31/11
to Away3D.dev
Am I understanding you correctly in that you have two problems, one
regarding memory management and one regarding how to embed
dependencies?

First of all, memory management of meshes, geometries et c has nothing
to do with the file format from where those came. That's something
that we've tried to make absolutely certain in Away4. Are you really
only experiencing memory cleanup issues with AWD and OBJ? Have you
tried other formats and not had the same issues? Do you know what
memory it is that's leaking?

Concerning mapUrlToData(), you obviously need to fill out the correct
URL. If you are uncertain about what URL your file is referencing, try
to load without any mapping. You should get an error saying that the
file cannot be found, and as part of that error you should get the URL
at which it was expected. Use that URL in your mapUrlToData() mapping.

If you have already done this and are certain that the URL is correct,
please send the file for me to debug.



Cheers
/R

John Brookes

unread,
May 31, 2011, 4:02:14 PM5/31/11
to away3...@googlegroups.com
Yes,two issues.
Memory, I see geometry and mesh still hanging around.
Subg/materials/methods etc all cleaned

screens from an OBJ that contains 8 cubes.


As for the embed, a working example would help(not just me). The awd is no different from any other.
http://dl.dropbox.com/u/20426629/Models.rar
profile2.png
profile.png

richardolsson

unread,
Jun 1, 2011, 4:25:20 AM6/1/11
to Away3D.dev
We will take a look at memory leaks ASAP, although probably not in the
alpha cycle (right now we are focusing on restoring as much
functionality as possible from old Away3D versions into Away4, and
bugs like these will need to be taken care of in the beta cycle.)

As for the embedding, just do:

[Embed(source="path/to/image.jpg",
mimeType="application/octet-stream")] // MIME-type important!
var ImageData : Class;

var context : AssetLoaderContext = new AssetLoaderContext();
context.mapUrlToData('path/to/image.jpg', ImageData);

var loader : Loader3D = new Loader3D();
loader.load(new URLRequest('model.awd'), null, context);
myScene.addChild(loader);


This is no different from what has been posted in previous threads on
this list. It has been tested and should be working absolutely fine.
It is however extremely important that the URL/path that is passed to
mapUrlToData() is the exact same as the one used in the AWD file. If
it's not, then the resolver won't be able to find a matching mapping.

When you say it's not working, what exactly is it that's not working?
Are errors being thrown?

Obviously documentation would help, but we are not focusing on
documentation this early in the development cycle. Proper
documentation will be released alongside the final version of Away3D
4.0, and then maintained for future dot-releases, but we cannot spend
time on documenting an API that may still change, because that will
have been wasted time. I hope you understand.


Cheers
/R
>  profile2.png
> 165KViewDownload
>
>  profile.png
> 153KViewDownload

John Brookes

unread,
Jun 1, 2011, 5:12:52 AM6/1/11
to away3...@googlegroups.com
var context : AssetLoaderContext = new AssetLoaderContext();
context.mapUrlToData('images/polySurface1.jpg', new treeBranchIMG());

Loader3D.enableParser(AWD1Parser);
loader = new Loader3D();
            loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onLoadComplete);
loader.load(new URLRequest('../src/Models/ScotsPine/ScotsPine.awd'), null, context);

Works, image replaced

BUT Im embedding the awd and images
swapping loader.load for
loader.parseData(new awdFile(),null,context)

No oncomplete fires

richardolsson

unread,
Jun 1, 2011, 5:13:02 AM6/1/11
to Away3D.dev
My code in the previous post uses load() to do the loading of the main
file (even though the dependency is embedded.) This is perfectly valid
-- embedded dependencies can be mixed in any way. But I imagine you
also want to see the Loader3D.parseData() in action. Then just replace
the loader3D section in the above code with:

[Embed(source="model.awd", mimeType="application/octet-stream")]
var ModelData : Class;

var loader : Loader3D = new Loader3D();
loader.parseData(ModelData, null, context);
myScene.addChild(loader);


Cheers
/R

richardolsson

unread,
Jun 1, 2011, 5:15:25 AM6/1/11
to Away3D.dev
@John:
I see, the event doesn't fire? Thanks for clarifying the problem. I
will look into this.

/R

richardolsson

unread,
Jun 1, 2011, 6:23:57 AM6/1/11
to Away3D.dev
@John:
It seems like the problem you were having (no events dispatched) were
actually because the AWD1Parser didn't properly implement the file
format auto-detection system. That means it actually never even
started parsing! I have fixed this (and also in the AC3DParser) so
hopefully you should be able to use embedded AWD1 files now.

I will also be uploading an example in a second.

Cheers
/R

John Brookes

unread,
Jun 1, 2011, 6:43:08 AM6/1/11
to away3...@googlegroups.com
Tried both loader3d and assetlibrary
All working (so far ;)

On the mesh/geometry memory thing, just a random guess. Maybe the bounds.

thnx
Reply all
Reply to author
Forward
0 new messages