Usage AWData class

16 views
Skip to first unread message

wsvdmeer

unread,
Nov 17, 2009, 5:56:04 AM11/17/09
to away3d.dev
Can someone explain how to use the AWData class?
I have a .awd model exported from Prefab already but i have no idea
how to load/parse/add the model

Fabrice3D

unread,
Nov 17, 2009, 6:14:58 AM11/17/09
to away3...@googlegroups.com
Hi wsvdmeer,

Its very easy and is very similar to other loading processes.
first you need to import like for any other loaders the AWData class

import away3d.loaders.AWData;

via loaders

var loader:Loader3D;
loader = AWData.load(file_url);
loader.addOnSuccess(onLoaderSuccess);
loader.addOnError(onLoaderError);

or
var loader:Loader3D = new Loader3D();
loader.addOnSuccess(onLoaderSuccess);
var awd: AWData = new AWData();
loader.loadGeometry(file_url, awd);

private function onLoaderSuccess(e:Loader3DEvent):void
{
this.object3d = e.loader.handle;
view.scene.addChild(this.object3d);
// note: the use of this is optional here, it just to show you a
class var use as Object3D
}

if you have changed the default export "images" folder relative to the
awd
you can set a custom url for the sources using pathToSources setter or
via initobject;

var awd: AWData = new AWData();
awd.pathToSources = mynewpathurl;
loader.loadGeometry(file_url, awd);

you also can embed the file or load the string file from database
and give it to the AWData.parse(myclassembed);
in this case also, if the "images" default folder is not located where
swf plays, pass a custom path using pathToSources setter


Fabrice

wsvdmeer

unread,
Nov 17, 2009, 6:58:56 AM11/17/09
to away3d.dev
Hey Fabrice thanks for the help:)
I'm still having problems getting it to work.
I've build my project in Flashdevelop and i'm getting the following
errors with the static function parse/load and the variable
_container:
(I'm to lazy to translate it and i know your dutch :P)

\src\away3d\loaders\AWData.as(299): col: 29 Error: Aanroep van een
mogelijk niet-gedefinieerde methode parse via een verwijzing van het
type 'static' Class.
return Loader3D.parse(data, AWData, init).handle;
^
\src\away3d\loaders\AWData.as(317): col: 29 Error: Aanroep van een
mogelijk niet-gedefinieerde methode load via een verwijzing van het
type 'static' Class.
return Loader3D.load(url, AWData, init);
^
\src\away3d\loaders\AWData.as(233): col: 25 Error: Gebruik van niet-
gedefinieerde eigenschap _container.
_container = isMesh? mesh : aC[0];
^

Fabrice3D

unread,
Nov 17, 2009, 8:01:04 AM11/17/09
to away3...@googlegroups.com
I'm not dutch, I'm french but I indeed speak this strange language :)

Het probleem is simpel: je zet je parse methode op de Loader object,
terwijl het moet op de AWData object zijn.

Fabrice

wsvdmeer

unread,
Nov 17, 2009, 8:38:01 AM11/17/09
to away3d.dev
Hey Fabrice, sorry thought you were dutch my bad :)

I'm using the following code to load the model:

var loader:Loader3D = new Loader3D();
loader = AWData.load("../assets/models/model.awd");
loader.addOnSuccess(onLoaderSuccess);

Changed _container in AWData to container i think this is a typo cause
the variable is not declaired anywhere.
Doing this i got rid of one of the errors but im still getting the
static function errors:S

Fabrice3D

unread,
Nov 17, 2009, 8:51:19 AM11/17/09
to away3...@googlegroups.com
oh you are on f9?
if not let me know, makes me think I have probably updated only f10
and not f9 for this...

look at example in first respons, there are 2 ways to load
one if you require no access to something and just want to addchild
the other one allows access to parsers setters/methods etc before you
actually load anything

and would be handy to be able to read the errors...


> sorry thought you were dutch my bad :)
Ik woon in Nederland bijna half mijn leven, dus benk toch een beetje
Nederlander.
Zeg maar de crunchy mix of kaas en brood :)

Fabrice

wsvdmeer

unread,
Nov 17, 2009, 9:09:09 AM11/17/09
to away3d.dev
Hey Fabrice i'm on fp10 and i'm using the class from :

http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/loaders/AWData.as
As you can see on line 233 it says "_container" instead of "container"

I now tested with :

var loader:Loader3D = new Loader3D();
loader.addOnSuccess(onLoaderSuccess);
var awd: AWData = new AWData();
loader.loadGeometry("../assets/models/model.awd", awd);

With the same result and errors:(

"Ik woon in Nederland bijna half mijn leven, dus benk toch een
beetje
Nederlander.
Zeg maar de crunchy mix of kaas en brood :)"

Ik ben een Fries dus ben zelf ook een halve Nederlander :D

Fabrice3D

unread,
Nov 17, 2009, 9:39:54 AM11/17/09
to away3...@googlegroups.com
just tried on latest trunk and I have no issues
make sure you have updated the whole package

AWData F9 is untested yet, will try later on.

Fabrice

wsvdmeer

unread,
Nov 17, 2009, 10:19:45 AM11/17/09
to away3d.dev
Oke updated everything to the latest fp10 version.
The previous problems are resolved but i am getting a new error :

[Fault] exception, information=TypeError: Error #1010: Een term is
ongedefinieerd en heeft geen eigenschappen.
Fault, AWData.as:142
[Fault] exception, information=TypeError: Error #1009: Kan geen
eigenschap of methode benaderen via een verwijzing naar een object dat
null is.
Fault, notifySuccess() at Loader3D.as:139

It has to do with this line:

objs[id].geo = geos[id];

I'm using the following code to load the model:

var loader:Loader3D = new Loader3D();
loader.addOnSuccess(onLoaderSuccess);
var awd:AWData = new AWData()
loader.loadGeometry("../assets/models/model.awd", awd);

On 17 nov, 15:39, Fabrice3D <fabric...@gmail.com> wrote:
> just tried on latest trunk and I have no issues
> make sure you have updated the whole package
>
> AWData F9 is untested yet, will try later on.
>
> Fabrice
> On Nov 17, 2009, at 3:09 PM, wsvdmeer wrote:
>
>
>
> > Hey Fabrice i'm on fp10 and i'm using the class from :
>
> >http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/a...

Fabrice3D

unread,
Nov 17, 2009, 10:45:57 AM11/17/09
to away3...@googlegroups.com
if you drop the awd back in prefab, do you see the model or not?
otherwize if possible, send me the awd file so I can reproduce/test
and eventually fix

It might be some incompatibilty with the new loaders and the previous
exports.
but can't say for sure before I can study the output.

Fabrice

wsvdmeer

unread,
Nov 17, 2009, 10:51:25 AM11/17/09
to away3d.dev
Hm it does have to do with the model i loaded/dropped the file in
prefab and nothing happend.
I've put up the files here : labs.speak.nl/3d/away3d/demo19/model.rar
It also contains the original .md2 and texture.

Fabrice3D

unread,
Nov 17, 2009, 11:02:45 AM11/17/09
to away3...@googlegroups.com
thx, I have work over my head, but will try tonite
Fabrice

wsvdmeer

unread,
Nov 17, 2009, 11:27:00 AM11/17/09
to away3d.dev
Thanks very much for the help i to am very familiar with the "work
over my head" problem :P

wsvdmeer

unread,
Nov 18, 2009, 5:51:58 AM11/18/09
to away3d.dev
Hey Fabrice did you find the problem with my model?

Fabrice3D

unread,
Nov 18, 2009, 3:31:47 PM11/18/09
to away3...@googlegroups.com
Hi wsvdmeer,
Sorry I couldn't get back to you earlyer

found the issue,
and you can fix in a sec :)

open the file with a text editor and search this line

is outputed as
#t:mesh#o

while should be
#t:mesh
#o

this means a return is forgotten in case of single meshes in the
generator
I'll fix the svn asap.

So you just have to add that return by hand to make your file work
Unfortunaly due to the many many internal changes and new features in
both away and Prefab, I'm not in state of
releasing a patch for Prefab before a few days.

Fabrice

wsvdmeer

unread,
Nov 19, 2009, 2:54:44 AM11/19/09
to away3d.dev
Hey Fabrice

That did the trick:)
Thank you very much for your help.
What kind of benefits does this fileformat have apart from the
filesize (38kb to 8kb!)?

Fabrice3D

unread,
Nov 19, 2009, 5:56:15 AM11/19/09
to away3...@googlegroups.com
Nice to hear you're back on track

> What kind of benefits does this fileformat have apart from the
> filesize (38kb to 8kb!)?

- small file size (as you can see in your case)
Note that it's not allways the case for md2 and 3ds at this stage,
But my latest researches on compressions methods might bring some
changes to this :)

- dragdrop reedit support in Prefab

- Implementation
You choose the way you load the data in your project,
that is from url as you use to do for external 3d files, from
database, embedded in your project class...
the small size makes it ideal for project where many files need to be
loaded runtime.

- cross engine versions and types
you can reuse same file for away3d f9, f10 and Away3DLite. This is not
true for as3 format.
The idea is to allow to allow the same file to be loaded in future
version of the Away3D suite with no need to reexport
to a specific engine version, making an upgrade to a new engine
version easyer if you have lots of models involved.


svn was updated last nite
and next Prefab update will of course have the fix as well.


Fabrice

wsvdmeer

unread,
Nov 19, 2009, 10:57:32 AM11/19/09
to away3d.dev
Hey Fabrice,

What happens to the bitmapmaterial and bitmapdata after loading?
Are the objects null'ed for garbage collection?
> ...
>
> meer lezen »

Fabrice3D

unread,
Nov 19, 2009, 3:46:25 PM11/19/09
to away3...@googlegroups.com
why would they be nulled?
you want to see your map right?

if you do not see your map, its because its not in default images map
that should be next to awd file,
use the sourcepath handler of the AWData parser before load or parse

Fabrice
Reply all
Reply to author
Forward
0 new messages