[Papervision3D] Loading multiple collada objects
dsdsdsdsd
shannonhburnett at hotmail.com
Wed Oct 22 08:14:28 PDT 2008
yes, you do need to wait until the .dae has loaded fully ( I should have
mentioned that earlier );
also, I believe that Collada is not really supposed to be used any more, but
instead DAE class;
also, I do not know if Collada or DAE will work without calling their load
method ( see below ) ;
so ...
package
{
import org.papervision3d.objects.parsers.DAE ;
public class some_class
{
private var colla : DAE ;
private var pvb_DAE_is_complete : Boolean = false ;
public function some_class ( ) : void
{
colla = new DAE( ) ; // MAYBE DO NOT reference the .dae here
colla.load ( "Car.dae" ) ; // BUT instead here;
om_setup_event_handlers ( ) ;
} ;
private function om_setup_event_handlers ( ) : void
{ colla.addEventListener( FileLoadEvent.LOAD_COMPLETE ,
om_handleLoadComplete ) ;
colla.addEventListener( FileLoadEvent.LOAD_ERROR ,
om_handleLoadError ) ;
colla.addEventListener( FileLoadEvent.LOAD_PROGRESS ,
om_handleProgress ) ;
colla.addEventListener( FileLoadEvent.SECURITY_LOAD_ERROR ,
om_handleSecurity ) ;
colla.addEventListener( FileLoadEvent.COLLADA_MATERIALS_DONE ,
om_handleMaterialsDone ) ;
} ;
private function om_remove_event_handlers ( ) : void
{ colla.removeEventListener( FileLoadEvent.LOAD_COMPLETE ,
om_handleLoadComplete ) ;
colla.removeEventListener( FileLoadEvent.LOAD_ERROR
, om_handleLoadError ) ;
colla.removeEventListener( FileLoadEvent.LOAD_PROGRESS ,
om_handleProgress ) ;
colla.removeEventListener( FileLoadEvent.SECURITY_LOAD_ERROR ,
om_handleSecurity ) ;
colla.removeEventListener( FileLoadEvent.COLLADA_MATERIALS_DONE ,
om_handleMaterialsDone ) ;
} ;
// ...
//------------------------------------------------------------------
// event handlers, such as ...
private function om_handleMaterialsDone( argo_event : FileLoadEvent ) : void
{ trace( "om_handleMaterialsDone" );
om_check_ready_status ( ) ;
};
private function om_handleLoadComplete( argo_event : FileLoadEvent ) : void
{ trace("om_handleLoadComplete");
om_check_ready_status ( ) ;
};
//------------------------------------------------------------------
private function om_check_ready_status ( )
{ // BOTH
// FileLoadEvent.LOAD_COMPLETE
// FileLoadEvent.COLLADA_MATERIALS_DONE
// need to fire before the .dae is complete
if ( pvb_DAE_is_complete == true )
{ om_remove_event_handlers ( ) ;
om_handle_DAE_now_fully_loaded ( ) ;
}
else
{ pvb_DAE_is_complete = true ;
} ;
} ;
//--------------------------------------------------
// now you know that .dae is fully loaded ...
private function om_handle_DAE_now_fully_loaded () : void
{ trace( "handle_DAE_now_fully_loaded , colla : " + colla
) ;
var car_model : DisplayObject3D = colla.getChildByName(
"the_name_of_a_model" , true ) ;
trace( "handle_DAE_now_fully_loaded , car : " + car_model
) ;
trace( "handle_DAE_now_fully_loaded , geometry : " + car_model.geometry
) ;
trace( "handle_DAE_now_fully_loaded , a face : " +
car_model.geometry.faces[ 0 ] ) ;
trace( "handle_DAE_now_fully_loaded , material A : " +
car_model.geometry.faces[ 0 ].material ) ;
trace( "handle_DAE_now_fully_loaded , material B : " +
car_model.material ) ;
var temp_colla : DisplayObject3D = car_model.clone() ;
};
} // end class
} // end package
Shannon
CodeyCody wrote:
>
>
> dsdsdsdsd wrote:
>>
>>
>> you need to get the model out of the Collada ( dae ):
>> var colla : Collada = new Collada("Car.dae");
>> var car_model : DisplayObject3D = colla.getChildByName( "the_car" , true
>> ) ;
>>
>> var temp_colla:DisplayObject3D = car_model.clone() ;
>>
>> Shannon
>>
>>
>
> Thanks again for replying.
>
> I wrote the code you gave me, and its giving me an error about referencing
> a null object.
>
> In debug mode, I've now realised that the collada object itself ("colla")
> is null, and so is its geometry etc.
>
> Is this because it hasn't loaded yet?
>
> Or am I getting the error simply because there's no child "the_car"?
>
> (Bear with me: what is a child?)
>
> Help appreciated.
>
--
View this message in context: http://www.nabble.com/Loading-multiple-collada-objects-tp20089903p20112964.html
Sent from the Papervision3D mailing list archive at Nabble.com.
More information about the Papervision3D
mailing list