I looked at the Away3D book and all the classes involved extensively this afternoon and evening but it did not seem to be setup for what I wanted to do, in the end I have had to directly modify Loader3D but very unhappy to do that, added this public method I tried some tricks but private in as3 really is a pain... there is no sensible way to get round it! Probably needs some testing... maybe there is a better approach?

// add to Loader3D

        public function get fractionTextureLoad(): Number
        {

return _loadQueue.currentItemIndex * 1 / _loadQueue.numItems + ( _bytesLoaded /_bytesTotal ) / _loadQueue.numItems;

        }

// and my loader is

package loaders
{
    //TODO: remove unused imports
    import flash.events.Event;
    import flash.events.ProgressEvent;
    import flash.display.Loader;
    import flash.display.Sprite;

    import away3d.loaders.Collada;
    import away3d.core.base.Object3D;
    import away3d.loaders.Loader3D;
    import away3d.loaders.LoaderCube;
    import away3d.core.base.Mesh;
    import away3d.events.Loader3DEvent;
    import org.osflash.signals.Signal;
    import away3d.loaders.Loader3D;
    import away3d.loaders.utils.*;


    public class ColladaLoader
    {

        public var loader:      Loader3D;
        //private var ratio:      Number;
        private var file:       String;
        public var content:     Object3D;
        public var finished:    Signal = new Signal();
        public var progressed:  Signal = new Signal();
        public var fraction:    Number;


public function ColladaLoader( _file: String )//, _ratio: Number )
        {

            //ratio                       = _ratio;
            file                        = _file;

        }


        public function load()
        {

loader = Collada.load( file, { scaling: 1, bothsides: false } );
            loader.loaderSize   = 0;
loader.addEventListener( Loader3DEvent.LOAD_SUCCESS, loaded ); loader.addEventListener( Loader3DEvent.LOAD_ERROR, onError );
            loader.z            = -2000;
            fraction                    = 0;
loader.addEventListener( Loader3DEvent.LOAD_PROGRESS, loaderProgress );

        }


        private function loaded( e: Loader3DEvent )
        {

            content = loader.handle as Object3D;
            trace( content );
            finished.dispatch();

        }


        private function onError( e: Loader3DEvent )
        {

            trace( 'error loading ' + file );

        }


        private function loaderProgress ( e : Loader3DEvent )
        {

if( loader.handle.bytesLoaded != 0 && loader.handle.bytesTotal != 0 )
            {

                if( loader.handle.mode == 'loading_textures' )
                {
                    // TODO: Change 0.5 to ratio
fraction = 0.5 + ( loader.handle as Loader3D ).fractionTextureLoad/2;

                }
                else
                {
fraction = 0.5*loader.handle.bytesLoaded / loader.handle.bytesTotal;
                }
                progressed.dispatch();

            }
        }
    }
}


On 23 Apr 2011, at 16:12, [email protected] wrote:

Thanks Rob I will take a look tomorrow morning, it's one of the main issues I need to get sorted so our friend can get his project out the door, which is looking nice but quite a set of downloads.

For the new build your using adobe code for the shaders, have you considered the haXe shaders instead any thoughts on this, any tests on performances?


On 23 Apr 2011, at 15:47, Rob Bateman wrote:

Hey Justin

Loaders are getting a complete overhaul in broomstick after it was recognised that the current implementation is 3.6 is not flexible enough for all use cases. So things should be a lot simpler once that area of development has been completed

For the existing approach in 3.6, the LoaderCube object is an example implementation of a 3D 'progress bar" and should give you all the functionality you need to have a visual output of the loading progress - the intention has always been for LoaderCube to be hacked and re-purposed for your own specific visual needs

Rob



On Sat, Apr 23, 2011 at 2:26 PM, [email protected] <[email protected] > wrote: Bump - no suggestions, maybe it's basic question, but not used 3d stuff for awhile.

I think I have to "tap into the loadercube class"... what ever that means?

Can anyone give me a headstart, as I said not working on this for fun or money, just trying to help a friend out, so really don't want to spend all of tomorrow rewritting away code if there is a simple way to do this, I presume I set the collada loader running and then somehow hook up the loadercube but not show it and then listen on that??

We found this snipit .... but must admit it makes little sense to me and seems rather obscure approach.

snippet:

"Hey Kakarlus

1
0
0
0.8681069768057965
1
dae/ch_dagger_1h_t1_01_base.DAE

my question is why is there a 1 up there...

ProgressEvent is fired the instant a file starts loading. However at this point both bytesLoaded and bytesTotal haven't been set yet. you will be
dividing aero by aero which returns 1.

and another question,

how do i remove the cubeloader?

to get rid of it altogether is the same  approach as replacing it:

obj = Collada.load("dae/ch_dagger_1h_t1_01_base.DAE",
{loader:Object3DLoader});

the loader property in the init object can be any class definition that
extends Object3DLoader, or if you want no visual feedback at all,
Object3DLoader itself

cheers

Rob

On Mon, May 4, 2009 at 9:48 AM, kakarlus <[email protected]> wrote:

and another question,

how do i remove the cubeloader?
"

To be honest I have always found the loaders for away a pain to work with maybe I need to rewrite them to be user friendly, they seem to be sort along the lines of flash's loader which I don't like either, but maybe I just don't understand them well enough, but was hoping to just hook into an event that tells me the amount loaded, if I need to feed it the total that's fine but seems this would be something most people need... rather than an event giving random numbers.


Cheers

;j



On 17 Apr 2011, at 23:42, [email protected] wrote:

Hi helping a friend on some away3d, but really unsure on how to proceed with a preloader on some collada, we have one for each section and some streaming 3d music but thats besides the point.

currently I listen to the loading..

loader.addEventListener( Loader3DEvent.LOAD_PROGRESS, loaderProgress );

and dispatching a signal...

if( loader.handle.bytesLoaded != 0 && loader.handle.bytesTotal != 0 )
           {
fraction =loader.handle.bytesLoaded / loader.handle.bytesTotal;
               if( Math.round( fraction ) != 1 )
               {

                   progressed.dispatch();

               }

           }

but it seems to be giving results for all the assets ( all the images in the scene ) as they are loaded so I have a yo yo loading bar, just unsure on the best approach, do I set the collada images to a single 0 size image by hacking the collada file and then replace them at run time from a separately loaded swf - that would be a real pain and not easy, do I go down the prefab route (or tell him to), probably sorted this before but no idea where my old code is. Was hoping there was an event I could hook into that would save me having to do lots of work, just assumed this is a common thing and the engine would have something set up for this. Sorry if I should read the documents more I looked through some of the away classes but did not find any clues in the code and googled but did not find an clues.

Currently looking at the standard as3 away3d version would love to play with molehill and maybe help on the haxe part but need to get my friends project out the door in as3, and I seem to have lost all motivation to code as3 :).

Many Thanks for any tips cheers

;j





--
Rob Bateman
Flash Development & Consultancy

[email protected]
www.infiniteturtles.co.uk
www.away3d.com


Reply via email to