Preloader for Prefab BSP-Project

14 views
Skip to first unread message

le_unam

unread,
Oct 18, 2010, 5:48:08 AM10/18/10
to Away3D.dev
Hey, i have finished my first bsp project and now i want to create a
preloader cause it is not really nice, if the user has a white screen
first and the textures show up step by step. so how to do a preloader
when created a project with prefab? any tipps?

Fabrice3D

unread,
Oct 18, 2010, 6:34:46 AM10/18/10
to away3...@googlegroups.com
Just bulk load the images, once loaded you init the awd file

Fabrice

le_unam

unread,
Oct 18, 2010, 6:49:07 AM10/18/10
to Away3D.dev
what does bulk load mean? never heard about it = /

Michael Iv

unread,
Oct 18, 2010, 6:58:11 AM10/18/10
to away3...@googlegroups.com
You may use open source BulkLoader (see gogle code) powerful lib for managing multiple loads

le_unam

unread,
Oct 18, 2010, 7:42:52 AM10/18/10
to Away3D.dev
do i add the bulkloader code to the as-file coming out of prefab or do
i create an own swf for loading with bulk which loads the 3d swf?

i have downloaded the source of bulkloader, but how to implement it
into flash? i dont understand this :((((((((((((((((((((((((((((((((((

On 18 Okt., 12:58, Michael Iv <explomas...@gmail.com> wrote:
> You may use open source BulkLoader (see gogle code) powerful lib for
> managing multiple loads
>
> On Mon, Oct 18, 2010 at 12:49 PM, le_unam <le_u...@hotmail.de> wrote:
> > what does bulk load mean? never heard about it = /
>
> > On 18 Okt., 12:34, Fabrice3D <fabric...@gmail.com> wrote:
> > > Just bulk load the images, once loaded you init the awd file
>
> > > Fabrice
>
> > > On Oct 18, 2010, at 11:48 AM, le_unam wrote:
>
> > > > Hey, i have finished my first bsp project and now i want to create a
> > > > preloader cause it is not really nice, if the user has a white screen
> > > > first and the textures show up step by step. so how to do a preloader
> > > > when created a project with prefab? any tipps?
>
> --
> Michael Ivanov ,Programmer
> Neurotech Solutions Ltd.
> Flex|Air |3D|Unity|www.neurotechresearch.comhttp://blog.alladvanced.nethttp://www.meetup.com/GO3D-Games-Opensource-3D/
> Tel:054-4962254
> explomas...@gmail.com
> t...@neurotech.co.il

Michael Iv

unread,
Oct 18, 2010, 7:49:57 AM10/18/10
to away3...@googlegroups.com
Man ,now you are talking about general programming methodology . I suggest you to serf blogs and forums on these subjects

le_unam

unread,
Oct 18, 2010, 8:25:04 AM10/18/10
to Away3D.dev
kk thanks ;-)

le_unam

unread,
Oct 19, 2010, 4:18:05 AM10/19/10
to Away3D.dev
hey, now i know how the bulkloader works and it works fine, but for
away3d i need some information please. when i added the images
(textures) to the bulkloader and the load is complete are they
available for away3d, too? Or do i have to change the path, where away
can find the textures now? ive read things about getContent and
something like this, after the bulkloader loaded the files, but this
would say the path to the images is incorrect right? would be really
nice if you can help me. i think you did things like this more than
one time :)
> > Flex|Air |3D|Unity|www.neurotechresearch.comhttp://blog.alladvanced.nethttp://www.meetup...
> > Tel:054-4962254
> > explomas...@gmail.com
> > t...@neurotech.co.il

Michael Iv

unread,
Oct 19, 2010, 4:22:51 AM10/19/10
to away3...@googlegroups.com
After you have finished loading any assets into Away3D the engine doesn't care about its URL anymore but expects the data.What I mean is that if you have got a BitmapMaterial that you need to connect with a texture that you loaded with BulkLoader so you just take the loaded texture ,  and pass its bitmapdata into your BitmapMaterial . This is it .

le_unam

unread,
Oct 19, 2010, 4:45:51 AM10/19/10
to Away3D.dev
okayright, but when creating my project with prefab, it works
with .awd-file and the texture links are embedded there, arent they? i
cant find any path in my .as-file :-/

Michael Iv

unread,
Oct 19, 2010, 4:48:16 AM10/19/10
to away3...@googlegroups.com
If your textures are embedded (and that is the case with prefab as far as I know) they are not loaded but compiled Into the executable (aka SWF) .So in this case I don't understand why would you need BulkLoader at all?

le_unam

unread,
Oct 19, 2010, 4:55:07 AM10/19/10
to Away3D.dev
hmmm i dont know how it all works, but when i start my swf online the
textures show up step by step ... the swf works, but the images are
loaded after that step by step ... i want to load all textures before
the swf starts

Fabrice3D

unread,
Oct 19, 2010, 4:59:48 AM10/19/10
to away3...@googlegroups.com
awd doesn't embed the sources

you could alter the awdata parser where materials are generted, instead, pass them to your custom loader

var matBitmap:BitmapFileMaterial = new BitmapFileMaterial(resolvedP+line)

or easyer, add a feed to your bulk loader in centralLibrary class.
onLoadedComplete, start rendering

also, loading all images then fire the awd as you do now should work as well, since urls/sources should be cached

Fabrice

Michael Iv

unread,
Oct 19, 2010, 5:07:12 AM10/19/10
to away3...@googlegroups.com
Sorry , I thought he meant AS3 exported files :)

le_unam

unread,
Oct 19, 2010, 5:10:53 AM10/19/10
to Away3D.dev
hey fabrice ... my testing loader code is this:

public function Rdy()
{
var loader:BulkLoader = BulkLoader.createUniqueNamedLoader();
loader.add("images/aw_0.jpg");
loader.addEventListener(BulkLoader.PROGRESS, loading);
loader.addEventListener(BulkLoader.COMPLETE, loaded);
loader.start();
}

function loading(e:Event):void
{
var loader:BulkLoader = e.currentTarget as BulkLoader;
trace(loader.percentLoaded);
}

private function loaded(e:Event):void
{
addEventListener(Event.ADDED_TO_STAGE, init);
}


.......

and here follows the standard as code from prefab, but after the image
is loaded, the 3d things dont show up. why?
do u have a simple example for me how it should work? i hoped for the
caching thing, so that all pix are loaded into the cache and i just
start rendering when all loading is done, but as you see above it
doesnt work :-/

On 19 Okt., 10:59, Fabrice3D <fabric...@gmail.com> wrote:
> awd doesn't embed the sources
>
> you could alter the awdata parser where materials are generted, instead, pass them to your custom loader
>
> var matBitmap:BitmapFileMaterial = new BitmapFileMaterial(resolvedP+line)
>
> or easyer, add a feed to your bulk loader in centralLibrary class.
> onLoadedComplete, start rendering
>
> also, loading all images then fire the awd as you do now should work as well, since urls/sources should be cached
>
> Fabrice
>
> On Oct 19, 2010, at 10:48 AM, Michael Iv wrote:
>
> > If your textures are embedded (and that is the case with prefab as far as I know) they are not loaded but compiled Into the executable (aka SWF) .So in this case I don't understand why would you need BulkLoader at all?
>
> > > Flex|Air |3D|Unity|www.neurotechresearch.comhttp://blog.alladvanced.nethttp://www.meetup...
> > > Tel:054-4962254
> > > explomas...@gmail.com
> > > t...@neurotech.co.il
>
> > --
> > Michael Ivanov ,Programmer
> > Neurotech Solutions Ltd.
> > Flex|Air |3D|Unity|
> > explomas...@gmail.com
> > t...@neurotech.co.il

le_unam

unread,
Oct 19, 2010, 5:30:43 AM10/19/10
to Away3D.dev
hey okay, thank you ... i thought about it and understood a little bit
more then a few minutes before ;-)

i did it with a boolean doRender variable. only when its true the
scene would be rendered and it gets true if bulk loading is complete.
do you think its a performance problem if it always asks for this
variable status? not really right?

le_unam

unread,
Oct 19, 2010, 5:35:56 AM10/19/10
to Away3D.dev
sorry michael if i explained it a little bit misunderstandly, but my
english isn the best on earth ;-)

i think i can go on now, thanks for support!

On 19 Okt., 11:07, Michael Iv <explomas...@gmail.com> wrote:
> Sorry , I thought he meant AS3 exported files :)
>
>
>
> On Tue, Oct 19, 2010 at 10:59 AM, Fabrice3D <fabric...@gmail.com> wrote:
> > awd doesn't embed the sources
>
> > you could alter the awdata parser where materials are generted, instead,
> > pass them to your custom loader
>
> > var matBitmap:BitmapFileMaterial = new BitmapFileMaterial(resolvedP+line)
>
> > or easyer, add a feed to your bulk loader in centralLibrary class.
> > onLoadedComplete, start rendering
>
> > also, loading all images then fire the awd as you do now should work as
> > well, since urls/sources should be cached
>
> > Fabrice
>
> > On Oct 19, 2010, at 10:48 AM, Michael Iv wrote:
>
> > If your textures are embedded (and that is the case with prefab as far as I
> > know) they are not loaded but compiled Into the executable (aka SWF) .So in
> > this case I don't understand why would you need BulkLoader at all?
>

le_unam

unread,
Oct 19, 2010, 5:46:34 AM10/19/10
to Away3D.dev
hey okay ... one problem still exists .... the objects created by
away3d cover my normal flash objects like dynamic textfield, for
percent status for example. how can i give my textfield a higher level
than away3d objects?

Michael Iv

unread,
Oct 19, 2010, 5:48:58 AM10/19/10
to away3...@googlegroups.com
Man you are fine! English is not my mother language ether ,You know I just thought If Away3D team were to award for this Forum activity You would receive the first place ;))   (kidding )

I am always ready to help but have little time indeed ...

Michael Iv

unread,
Oct 19, 2010, 5:51:33 AM10/19/10
to away3...@googlegroups.com
All away stuff resides inside View3D which is Sprite. So put it into deepest depth ( what a saying ,..) You know just regular AS3 method addChildAt() and pass index lower then the rest of content. (Hope now I got you , too tired today)

le_unam

unread,
Oct 19, 2010, 5:55:11 AM10/19/10
to Away3D.dev
jep thanks ... addchildat will help me i think, thanks = )
> Flex|Air |3D|Unity|www.neurotechresearch.comhttp://blog.alladvanced.nethttp://www.meetup.com/GO3D-Games-Opensource-3D/
> Tel:054-4962254
> explomas...@gmail.com
> t...@neurotech.co.il

banal

unread,
Oct 19, 2010, 8:39:03 AM10/19/10
to Away3D.dev
Slightly off-topic, but if you like BulkLoader, have a look at
"LoaderMax" (https://www.greensock.com/loadermax/).
It's my new Bulk-Loader of choice :-)

On Oct 18, 12:58 pm, Michael Iv <explomas...@gmail.com> wrote:
> You may use open source BulkLoader (see gogle code) powerful lib for
> managing multiple loads
>
> On Mon, Oct 18, 2010 at 12:49 PM, le_unam <le_u...@hotmail.de> wrote:
> > what does bulk load mean? never heard about it = /
>
> > On 18 Okt., 12:34, Fabrice3D <fabric...@gmail.com> wrote:
> > > Just bulk load the images, once loaded you init the awd file
>
> > > Fabrice
>
> > > On Oct 18, 2010, at 11:48 AM, le_unam wrote:
>
> > > > Hey, i have finished my first bsp project and now i want to create a
> > > > preloader cause it is not really nice, if the user has a white screen
> > > > first and the textures show up step by step. so how to do a preloader
> > > > when created a project with prefab? any tipps?
>
> --
> Michael Ivanov ,Programmer
> Neurotech Solutions Ltd.

Michael Iv

unread,
Oct 19, 2010, 8:41:29 AM10/19/10
to away3...@googlegroups.com
You are absolutely right it is even better in some aspects than Bulk BUT it is not free for commercial use.

banal

unread,
Oct 20, 2010, 8:45:47 AM10/20/10
to Away3D.dev
You probably misread the license then. It is free for commercial use,
*except* for projects where you charge a fee from the users that are
using the product.
In the words of the author:
----
The code will be used in a commercial game, web site, component, or
software product for which a usage/access/license/microtransaction fee
is collected from multiple customers.
----

That's the only case where you need to buy a "commercial" license. In
most cases, this doesn't apply.

le_unam

unread,
Oct 21, 2010, 4:35:40 AM10/21/10
to Away3D.dev
hey ehm im sorry but i still have some questions about loading. i
understand bulkloader and i can work with it, but i dont understand
where/how to make it work with prefab as. how did you did it? do you
have small example for me? did you do it with an extra swf which loads
the away swf in it? or did you add the bulk code into the away as
file? please please give me some explainations again :)

Michael Iv

unread,
Oct 21, 2010, 6:33:59 AM10/21/10
to away3...@googlegroups.com
That what I meant under "commercial project " :) 

Sent from my iPhone

le_unam

unread,
Oct 21, 2010, 8:05:54 AM10/21/10
to Away3D.dev
how can i tell the _tree = BSPTRee(AWData.parse .... should get the
images from the library than from images-directory?

On 21 Okt., 12:33, Michael Iv <explomas...@gmail.com> wrote:
> That what I meant under "commercial project " :)
>
> Sent from my iPhone
>

Fabrice3D

unread,
Oct 21, 2010, 11:21:55 AM10/21/10
to away3...@googlegroups.com
as I wrote in previous mail, just alter the awdata where it generates the bitmapfileMaterial

you could have a tmp small bmd, to pass instead of using bitmapfilematerial, then when loaded asign it to the material predefined.
dunno what these loaders api are doing, but building a loading queue is not rocket science. All you need is pass to queue item the ref to the material.
This would require one or two lines changes in awdata to be fully working.

Fabrice

le_unam

unread,
Oct 22, 2010, 5:16:04 AM10/22/10
to Away3D.dev
well i`m sure for you its no problem, but im not a pro like you ^^
maybe you can help me when i give you some code.

as you know the awdata-line is the following:

_tree = BSPTree(AWData.parse(new BSPFile()));

i get access to the loaded images like this:

loader.getBitmap("filename.jpg");

what can i do with this? how can i change the awdata line :-/


im really sorry for my missing knowledge

Fabrice3D

unread,
Oct 22, 2010, 5:52:02 AM10/22/10
to away3...@googlegroups.com
I do not recall speak about loaders anywhere.

Let me try one last time:

where AWData defines a material, it uses bitmapfilematerial

replace that with a normal bitmapMaterial
make a tmp bitmapdata like 16x16
pass it to material.

--> now you have replaced "load automatically the source image" by "I make a temp material with very tiny image"

Add after that your queue object or whatever name that is in the api you use

var queueItem:QueueItem = new QueueItem(urlfile, material);
yourWhateverBulkLoader.addToQueue(queueItem);
you probably will have to import your class in awd for this.

--> now you have passed to your api, the url to load the image, and the material refference

in the event where your queueloader triggers per loaded image
somefunctionImageLoaded(queueLoaderEvent:QueueLoaderEvent):void
{
BitmapMaterial(queueLoaderEvent.data).bitmap = queueLoaderEvent.bitmapdata;
}

--> each time an image is loaded, you replace the 16x16 tmp bitmap by the right one that has just finished to load

In your main project:
yourWhateverBulkLoader.addONEverythingLoaded(startawd);

--> when all images are loaded, its time to start the 3d party. all materials will have the propper bitmap set

Again, do not copypaste or argue on methods name, its a speudocode principle to show you how to implement.
It will very on api and your project construct.


But if you simply load all your images first then start your project when all loaded as now, with zero changes
the images to be loaded by awdata (already preloaded by the bulkloader) are probably cached and would be there instantly.

Fabrice

le_unam

unread,
Oct 22, 2010, 7:55:04 AM10/22/10
to Away3D.dev
thanks for spending so much time for me ... well i dont want to get
the whole code for my problem, so i dont want to use copy and paste
and i can follow your instructions and i know what you want to tell
me. my problem is that i dont know where and how awdata defines a
material, cause in the as-file is nothing like bitmap or bitmapfile or
bitmapfilematerial. im sure i have to look more behind, but some words
like "parse" dont have any clear meaning for me, so its difficult for
me. cant you tell me simple where the awdata defines the material? the
prefab code for this is everytime same isnt it? it would be really
nice and this really will be my last question for this thing. you
helped me very well with your informations, although it looks like you
didnt ^^

Fabrice3D

unread,
Oct 22, 2010, 8:32:59 AM10/22/10
to away3...@googlegroups.com
really really really last time :))

> my problem is that i dont know where and how awdata defines a
> material, cause in the as-file is nothing like bitmap

AWData is in loaders package, it has nothing to do with the as Prefab outputs.
search in AWData class "BitmapFileMaterial" and reread (carefully) previous mail

in the as that Prefab output or in your project file,
just add a listener to start the render once your bulkloader as done its job

Again: have you tried feed your bulkloader with the urls (to be found in the awd file)
and simply start your project after that?
Chances are that all images are cached and will be displayed at init with zero code changes!

Fabrice

le_unam

unread,
Oct 22, 2010, 8:44:00 AM10/22/10
to Away3D.dev
thank you fabrice = )

i will try it as you say, my thoughts were that anywere must awdata be
told where to get the images, but now i think this is set by default
and only if you want to change something you have to add something, so
i can search my whole live for this ^^

well of course i tried the caching thing and it doesnt work ... the
preloader loads all images then hte 3d starts and all images come up
step by step again, so its double loaded. when i dont start the whole
3d after loading, but only call the _view.render after loading it
seems to work, but i cant be sure that the images are double loaded
too, in the background. i think they will, so i want to go a safe way.
i try to follow your explaination. i think i understand what you want
to tell me ... thank you very much.
and dont forget, i`m really very sorry ;-)

j...@justinfront.net

unread,
Oct 22, 2010, 1:20:45 PM10/22/10
to away3...@googlegroups.com
Not followed all this thread but...

In AWData class around line 242, the materials are set

var matBitmap:BitmapFileMaterial = new BitmapFileMaterial(resolvedP
+line)

if you look at the file loaded you will see the materials are defined
near the end of the file.

Its easy loading your own materials ( so don't bother with
bulkloader ) but not so easy to overwrite AWD materials with the
current way the AWData and BSPTree are set up as once the material is
set on the BSPTree it is set on every face, there is a replaceMaterial
method, but it assumes you know the CentralLibrary material used so
that you can search and replace on every face to do the swap.

Take a look at my posts on the ghost material they may give you some
ideas as was trying similar stuff.


Cheers

;j

le_unam

unread,
Oct 26, 2010, 4:34:34 AM10/26/10
to Away3D.dev
hey i tried a little bit and i found the centralmateriallirbary ... my
thoughts were that i replace the materials of centralmateriallirbrary
with my materials. that works when tracing the materials, but in the
tree the original materials are shown. where are the
centralmateriallirbrarie-materials loaded to the bsp_tree? i dont want
to add my loader code to the awdata class. hope you understand what i
want to say ^^

On 22 Okt., 19:20, "j...@justinfront.net" <j...@justinfront.net>
wrote:
> Not followed all this thread but...
>
> In AWData class around line 242, the materials are set
>
> var matBitmap:BitmapFileMaterial = new BitmapFileMaterial(resolvedP
> +line)
>
> if you look at the file loaded you will see the materials are defined  
> near the end of the file.
>
> Its easy loading your own materials ( so don't bother with  
> bulkloader ) but not so easy to overwrite AWD materials with the  
> current way the AWData and BSPTree are set up as once the material is  
> set on the BSPTree it is set on every face, there is a replaceMaterial  
> method, but it assumes you know the CentralLibrary material used so  
> that you can search and replace on every face to do the swap.
>
> Take a look at my posts on the ghost material they may give you some  
> ideas as was trying similar stuff.
>
> Cheers
>
> ;j
>
> On 22 Oct 2010, at 13:44, le_unam wrote:
>
> > thank you fabrice = )
>
> > i will try it as you say, my thoughts were that anywere must awdata be
> > told where to get the images, but now i think this is set by default
> > and only if you want to change something you have to add something, so
> > i can search my whole live for this ^^
>
> > well of course i tried the caching thing and it doesnt work ... the
> >preloaderloads all images then hte 3d starts and all images come up
> > step by step again, so its double loaded. when i dont start the whole
> > 3d after loading, but only call the _view.render after loading it
> > seems to work, but i cant be sure that the images are double loaded
> > too, in the background. i think they will, so i want to go a safe way.
> > i try to follow your explaination. i think i understand what you want
> > to tell me ... thank you very much.
> > and dont forget, i`m really very sorry ;-)
>
> > On 22 Okt., 14:32, Fabrice3D <fabric...@gmail.com> wrote:
> >> really really really last time :))
>
> >>> my problem is that i dont know where and how awdata defines a
> >>> material, cause in the as-file is nothing like bitmap
>
> >> AWData is in loaders package, it has nothing to do with the as  
> >>Prefaboutputs.
> >> search in AWData class "BitmapFileMaterial" and reread (carefully)  
> >> previous mail
>
> >> in the as thatPrefaboutput or in your project file,
> >> just add a listener to start the render once your bulkloader as  
> >> done its job
>
> >> Again: have you tried feed your bulkloader with the urls (to be  
> >> found in the awd file)
> >> and simply start your project after that?
> >> Chances are that all images are cached and will be displayed at  
> >> init with zero code changes!
>
> >> Fabrice
>
> >> On Oct 22, 2010, at 1:55 PM, le_unam wrote:
>
> >>> thanks for spending so much time for me  ... well i dont want to get
> >>> the whole code for my problem, so i dont want to use copy and paste
> >>> and i can follow your instructions and i know what you want to tell
> >>> me. my problem is that i dont know where and how awdata defines a
> >>> material, cause in the as-file is nothing like bitmap or  
> >>> bitmapfile or
> >>> bitmapfilematerial. im sure i have to look more behind, but some  
> >>> words
> >>> like "parse" dont have any clear meaning for me, so its difficult  
> >>> for
> >>> me. cant you tell me simple where the awdata defines the material?  
> >>> the
> >>>prefabcode for this is everytime same isnt it? it would be really
> >>>>>>>>>>>>>>>preloadercause it is not really nice, if the user has  
> >>>>>>>>>>>>>>> a white
> >>>>>>>>>>> screen
> >>>>>>>>>>>>>>> first and the textures show up step by step. so how to  
> >>>>>>>>>>>>>>> do a
> >>>>>>>>>>>preloader
> >>>>>>>>>>>>>>> when created a project withprefab? any tipps?

le_unam

unread,
Oct 26, 2010, 5:06:08 AM10/26/10
to Away3D.dev
i searched around and i found something like _tree.replaceMaterial,
but it seems to doesnt exist anymore. Anything like this to replace
materials?
> ...
>
> Erfahren Sie mehr »

le_unam

unread,
Oct 27, 2010, 4:00:46 AM10/27/10
to Away3D.dev
ehm ... as i see, the awdata-class adds the materials only with an
array, so i dont understand why adding them to the central material
library after that. Of course, then they are accessable later but as i
tried, it has no effect to change the materials in the central
material lirbrary. is there any chance to say "now look in the central
material lirbrary, look for updated materials and apply them them to
meshes? my thoughts were, that i add all materials to the central mat
lib with same values as awdata would do and delete the cent mat lib -
adds in awdata, so that the awdata would take my images instead. but
this doesnt work, because it seems that it doesnt matter what is in
cent mat lib cause it works with the _materials array. But any reason
must be there that all images are added to the cent mat lib. hope you
understand what i want to say.

j...@justinfront.net

unread,
Oct 28, 2010, 11:51:22 AM10/28/10
to away3...@googlegroups.com
http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/graphs/bsp/BSPTree.as
see line 604

Basically if you know the material ( which is kind of tricky and not
really viable ) then you can replace it. If you want to replace all of
them with a single material then my approach is to loop through all
materials in the BSPTree and substitute it for my ghost class. The
basic idea is that the ghost class allows you to set the material to
null ( when using collada model as visual ) or allows you to update it
without always looping all materials, it does this via proxying the
render events. I am not sure if it fits your needs but it should work
and I have already posted enough code for you to try it.

http://groups.google.com.ph/group/away3d-dev/browse_thread/thread/97d078b526b343c6

If you have some opensource model you have built and some code example
you can opensource I can take a look and amending the code for you and
publish the example back to the list if time permits.

But I think you need to modify the away source files to get more
control of AWD materials.

Cheers

;j

Reply all
Reply to author
Forward
0 new messages