« Return to Thread: Problems applying MovieMaterial + Shader combos to .dae

Re: Problems applying MovieMaterial + Shader combos to .dae

by vrabete :: Rate this Message:

Reply to Author | View in Thread

I have the exact same problem, but it doesn't get solved this way :(.
If I build the Sphere with shaders, it works just fine, but if I load a .dae object by

daeFile = new DAE();
daeFile.load("collada.DAE",myMatList);

where myMatList has a shaded material defined exactly as the Sphere one.
Neither of the approaches seems to work, the daeFile.replaceMaterialByName and the myMatList.addMaterial ones. I get the same #1009 error and the part doesn't display.

If I use a movieAssetMaterial instead... no problem, all works fine.

Any clues?
Thanks.


Happy New Year everyone,

Well, I think I figured this one out, and I thought I'd share it for the benefit of future generations. :)

I had complete success with using something like this:

------
objectName.replaceMaterialByName (newShadedMaterialName, "originalMaterialName");
------

or in case of my particular example:

------
object.replaceMaterialByName (shadedMat, "blinn1SG");
------

This works beautifully, even multiple material+shader combos or shaded materials can be applied per loaded .dae object.

That's about it.
Enjoy.



EToth wrote:
I continued experimenting with this... tried it with a BitmapMaterial + Shader combo instead of using a MovieMaterial. No luck, the same error remains:


TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at org.papervision3d.materials.shaders::ShadedMaterial/drawTriangle()
        at org.papervision3d.core.render.command::RenderTriangle/render()
        at org.papervision3d.render::BasicRenderEngine/org.papervision3d.render:BasicRenderEngine::doRender()
        at org.papervision3d.render::BasicRenderEngine/renderScene()


This is highly annoying. I don't know if I'm missing something here, but I'm wondering if anyone has successfully managed to replace a material on a .dae with a material + shader combo... any ideas would be greatly appreciated.




EToth wrote:
Hi all,

I'm running into puzzling problems when loading a .dae, and trying to replace its single placeholder material with my own MovieMaterial + Shader combination.

The basic setup looks something like this:

--------
myMatList = new MaterialsList();
myMat = new MovieMaterial (texture, false, false);
cellShader = new CellShader (pointLight, 0x00ff00, 0x000000);
shadedMat = new ShadedMaterial (myMat, cellShader);
--------


If I do this:
-----
myMatList.addMaterial(myMat, "blinn1SG");
object = new Collada ("et.dae", myMatList);
-----
..., everything works fine, and the .dae's material is replaced by myMat, which of course points to a MovieClip in the library.


However, if I try to do this to apply the MovieMaterial + Shader combo to the object:
-----
myMatList.addMaterial(shadedMat, "blinn1SG");
object = new Collada ("et.dae", myMatList);
-----
...the the renderer.renderScene (scene3d, camera, viewport); line throws the following error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at org.papervision3d.materials.shaders::ShadedMaterial/drawTriangle()
        at org.papervision3d.core.render.command::RenderTriangle/render()
        at org.papervision3d.render::BasicRenderEngine/doRender()
        at org.papervision3d.render::BasicRenderEngine/renderScene()

I'm usually pretty good at tracking down and fixing issues, but I'm clueless at this point. I tried to experiment with the .dae export settings, tried .dae objects of different complexity, tried different MovieMaterial + shader combinations, tried to apply straight FlatShadeMaterials / CellMaterials instead of combos, all to no avail.
To make matters worse, if I use the DAE parser instead of the Collada one, the object does not show up at all (not even with only the MovieMaterial applied). But this is a separate issue for later... :)

Thanks in advance for any insight into this.

-E-

 « Return to Thread: Problems applying MovieMaterial + Shader combos to .dae