Mediating PaperVision3D Objects
Hi,
I am having troubles with trying to mediate MovieMaterial on PaperVision3D planes.
In theory I would assume this should work, although I am getting the following error:
Exception fault: TypeError: Error #1034: Type Coercion failed: cannot convert com.example.materials.video::Panel1Video$ to com.example.materials.video.Panel1Video.
Placing a trace in the constructor of the Panel1Video
class traces out, so I know it exists.
The steps I am taking are as follows:
in PrepViewCommand
I have
mediatorMap.mapView ( Panel1Video , Panel1Mediator );
// where Panel1Video is a MovieMaterial applied to a pv3D plane
then once I know the 3D scene has been created I dispatch
dispatch ( new ControlEvent ( ControlEvent.SCENE_COMPLETE ) );
this executes AddSceneMediatorsCommand
override public function execute () : void {
`commandMap.unmapEvent ( ControlEvent.SCENE_COMPLETE, AddSceneMediatorsCommand, ControlEvent );
mediatorMap.createMediator ( Panel1Video ); `
}
I can't seem to figure out what is going wrong, I know that Classes I am passing are correct.
Am I approaching this in the correct way?
Any help would be greatly appreciated.
G.
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Stray on 02 Oct, 2010 11:10 PM
Hi George,
any chance that you've got an app domain issue?
Are you loading a swf perhaps? Modules?
I'm afraid I've no Papervision experience at all, but this looks more general.
Usually when I have this kind of error it means that there are 2 different versions of this class loaded into memory. Could that be the case?
Stray
2 Posted by George M on 02 Oct, 2010 11:24 PM
Hi Stray,
In this case I am not using Modules, and the only other place I reference Panel1Video is in PrepModelCommand where I register the class:
registerClassAlias ( "com.example.materials.video.Panel1Video", Panel1Video );
as the Class (MovieClip) is embedded into the SWF and is instantiated using :
var Clazz : Class = getDefinitionByName ( reference ) as Class;
var movieclip : MovieClip = new Clazz () as MovieClip;
as the movie material reference is parsed from an XML document.
The MovieMaterial does appear and draws fine.
It is feasible that PV3D creates 2 or more instances of the MovieMaterial, but I am imagine I would see more than 1 constructor trace appearing in the output.
Is there another approach I could try?
George
3 Posted by Stray on 03 Oct, 2010 01:27 PM
So - you're getting the wrong definition when you do getDefinitionByName. It differs from the one that you've compiled into the code that does the mapping.
This indicates to me that there's more than one applicationDomain in play.
Look into application domains - I'm thinking that you're simply not setting the application domain correctly when you load the swf containing Panel1Video.
Or do you mean that the swf that is the robotlegs main swf has this class attached to an item exported in the library of the main swf?
4 Posted by Stray on 03 Oct, 2010 01:35 PM
Hi George,
I see from twitter that you're not loading swfs at runtime.
What I also see, from a quick google, is that these type conversion issues are very common in papervision.
Are you an experienced papervision user? Is what you're trying to do something that you've done before, without robotlegs?
Stray
5 Posted by George M on 03 Oct, 2010 01:38 PM
Hi Stray,
There is one SWF only, the main SWF.
The main SWF has Panel1Video in its library as well as various other mc's. So I can't understand why (or even how) I could set the application domain on only 1 SWF as surely all the classes included in the SWF fall under the same app domain?
In the case of my app, I use the XML to sequence the animations / PV3D planes to add and which material to apply to it.
The material is a MovieClip, referenced by its package and class name, i.e.
com.example.materials.video.Panel1Video
Hence why I have to use getDefinitionByName to retrieve the movieclip reference from the library so I can apply it as the material and why I have to register the class alias otherwise the material will not be exported.
Thanks
George
6 Posted by Stray on 03 Oct, 2010 01:50 PM
I've definitely had these frustrations myself in flash before - so I understand it's a nightmare to debug.
Other people using papervision and instantiating from the library seem to be having similar issues - possibly one of their solutions will help you.
Fingers crossed!
Stray
Support Staff 7 Posted by Shaun Smith on 03 Oct, 2010 04:10 PM
Hi George,
I haven't done any PV3D in a while, but back when I did MovieMaterials weren't actual MovieClips on the stage - they were rasterized onto planes. If this is still the case, then RL will not be able to see any of the MovieMaterials land on stage (because they never do), and hence won't be able to automatically mediate them.
Could that be the problem?
8 Posted by George M on 03 Oct, 2010 04:24 PM
Hi Shaun,
I have thought this too, but using a hack (I have the MovieMaterial listening to a real Singleton - need to get the job done - had to hack it - sorry) I can update the frames in the MovieMaterial, so in essence the MovieMaterial does exist somewhere, and as you say a bitmap grab of that is being drawn onto the PV3D Plane.
Although, I am not trying to automatically mediate them, I set up
mediatorMap.mapView ( Panel1Video , Panel1Mediator );
in my PrepViewCommandIn the Best Practices it mentions I can manually create mediators ☛ http://bit.ly/dq2cQV
so, once I know the 3D model has been constructed I trigger another command where I run:
mediatorMap.createMediator ( Panel1Video );
In my opinion I would have thought this train of logic is sound, but I have been wrong lots before :o)
Is there a way I can Mediate classes that are not attached to a physical stage?
Cheers,
George
Support Staff 9 Posted by Shaun Smith on 03 Oct, 2010 05:47 PM
Hi George,
"Is there a way I can Mediate classes that are not attached to a physical stage?"
Yes, use
createMediator()
. But please note:createMediator()
expects a view component instance, not a class (as you have it above):10 Posted by George M on 03 Oct, 2010 06:45 PM
Hi Shaun,
❝Yes, use
createMediator()
. But please note:createMediator()
expects a view component instance, not a class (as you have it above)❞I am a little lost now, are you telling me that I can't Mediate Panel1Video as it isn't attached to the stage?
After all, the PaperVision3D MovieMaterial is simply grabbing and redrawing the bitmap data of Panel1Video (which extends MovieClip). And using the FDT profiler can see that it still exists during runtime.
Support Staff 11 Posted by Shaun Smith on 03 Oct, 2010 07:12 PM
Hey George,
"I am a little lost now, are you telling me that I can't Mediate Panel1Video as it isn't attached to the stage?"
No, I'm just saying that you need to pass an instance to
createMediator()
:For example:
The view component doesn't have to be on stage, but you do have to have a reference to it.
Hope that helps!
12 Posted by George M on 03 Oct, 2010 07:38 PM
I getcha now! and Bingo! I just did a
dirty test
and it works!Now to refactor and implement!
Sweet!
Cheers You Guys!
George
Support Staff 13 Posted by Shaun Smith on 03 Oct, 2010 08:45 PM
Glad you're back on track!
George M closed this discussion on 16 Nov, 2010 12:57 PM.