Papervision 3D and DAE material bug

59 Comments 7 May 2009

Maybe not a bug as such, more an issue with collada and 3D Studio Max but thought it was worth mentioning anyway in case someone else gets stumped with the same thing!

Basically I had a (very realistic) model of an RAF red arrow created for me by Fed for an augmented reality project I’m currently working on, complete with a material map (with very good baked in shadows that Fed likes to go on about). The code to get this into Papervision is very simple and should look like this.

var collada:Collada = new Collada("assets/meshes/red_arrow.dae");
addChild(collada);

This sort of worked, I had my model, but no material just a wire mesh as below and this warning message.

WARNING: Collada material _8_-_Default_1 not found.


(Click and drag the plane to rotate it)

After a bit of Googling I found a lot of people have had the same problem and to solve it I had to do the following.

var mat:BitmapFileMaterial = new BitmapFileMaterial("assets/image/red_arrow.jpg");
var mp:MaterialsList = new MaterialsList();
mp.addMaterial(mat, "mat0");

var collada:Collada = new Collada("assets/meshes/red_arrow.dae", mp);
addChild(collada);

But I still got the wire frame plane with no material, and the same error message! Well, this had me stumped, what was this mysterious ‘_8_-_Default_1′ collada material and why was it not being found? I did a quick search in the .dae file (it’s a lot of code but kind of makes sense) and I found 2 references to ‘_8_-_Default_1′. As a wild stab in the dark I replaced these for ‘mat0′, the name I gave to my BitmapFileMaterial in the code above and it worked!


(Click and drag the plane to rotate it, but now taking in all the glorious baked in shadows – thanks Fed)

Bit of a weird bug and I’m sure it’s caused by the .dae export from Studio Max rather than an error with Papervision but the above is a simple fix so I hope it helps people. I will post something on the augmented reality side of this project soon as I’m sure most people will be interested in that.


Posted in 3D, ActionScript

59 Responses to Papervision 3D and DAE material bug

  1. 8 May 2009

    Sponsored Plugfest in Paris on Monday, 11th!
    http://www.khronos.org/news/events/detail/paris_collada_plugfest/

    Meet Tim Knip from Papervision and the developers of the 3ds Max and Maya exporter/importer for COLLADA and lots of other COLLADA enthusiasts.

    Meanwhile: what version and which exporter did you use to get your content from 3ds Max? Can you provide the original Max file, the DAE and the flash code? Did you post a bug report to us at http://sf.net/tracker/?group_id=136478&atid=1088677

    Sebastian

  2. 21 July 2009
    Pim

    First of all, what an beautiful model!
    Second, thank you for describing this problem. I had the same.

    Pim.

  3. 6 August 2009
    Roovin

    Nicely done!, were there any issues with UV mapping?

  4. 7 August 2009
    FlashMonkey

    Thanks and nope no issues with the UV mapping. Have I mentioned that the textures have baked in ambient occlusion?

  5. 16 August 2009
    Serkan Buldan

    Hi, thank you for the post, it saved me alot of headache’s. But i must admit that i found it easier to put “_8_-_Default_1″ in place of “mat0″,that way you do not need to touch dae. I just copy paste when the compiler warns me.

    Best Regards.

  6. 16 August 2009
    FlashMonkey

    Thanks for the comment Serkan and indeed your right, it would be much easier to use “_8_-_Default_1″ (or whatever missing material name Papervision displays as a warning) as the name when adding your material. I’m sure your comment will help people save even more time when encountering this issue.

  7. 25 September 2009

    hey monkey!
    i’m trying to follow your example here, as i’m having the same problem.
    However everytime I try to make this work, my computer just freezes up,
    I’m guessing i’m doing something wrong here
    anyway you could add a link to your code here so i could take a look at what exactly you did??

    it would save my life,
    thank you
    ~m

  8. 25 September 2009
    FlashMonkey

    Hey Matt, what’s the exact error message your getting? Rather than trying to edit the DAE file I would suggest following Serkan’s advise. I can’t post my dae file here but if you zip up your code and send me a link to it I would be happy to take a look tomorrow and see if I can figure out what’s going wrong for you.

  9. 25 September 2009

    hey monkey

    thanks so much for your time and thoughts on this, its been making me go bald!
    i’ve included everything in this folder, ever the max file if you need to mess with it.

    leba 3d basketball

    on a second note, I also need to add a jsphere or something of that sort to give this basketball some physics for my scene, if you could shed any light on that i’d be a very happy camper.

    thanks bunches!
    ~m

  10. 25 September 2009

    oh btw the error i’m gettin is Collada material _balldefault not found.

  11. 25 September 2009
    FlashMonkey

    Hey Matt, it seems like you got close to fixing this yourself, as the correct code existed but was commented out. I have got it working now and the files are here:

    3d_bball.zip

    One thing though, the DAE your loading just seems to be a sphere, so it might be an idea just to use the Papervision Sphere Class. I’ve created an example for you and put the files in the zip above. Hope that helps.

  12. 26 September 2009

    hey monkey!
    I tried the files you sent me, even the sphere demo, and when I try to publish and test, my swf publish window opens to a black screen, and flash freezes out on me.

    maybe i’m running an old version of papervision or something, i doubt it because I did just grab an svn update last week, so i’m stumped.

    the reason the code was commented out was because it was throwing this same error to me, so i figured I had it incorrect, it runs fine for you though?

    thanks again for everything!

    ~matt!

  13. 26 September 2009
    FlashMonkey

    That is strange, if you grab my files again and look at the SWFs before re-compiling you’ll see the material mapped fine. With the Sphere example you don’t even see a wireframe sphere just a blank screen? Here is the files I made with the Papervision classes also included:

    3d_bball2.zip

  14. 27 September 2009

    yeah your files work great.
    I took your org/ folder and replaced mine, and it works fine now,
    must’ve been something with my classes,

    thank you so much
    now i’m on to the physics, would you happen to know of any good tuts for adding physics to the basketball?

    i would like to just use the sphere, but the texturing doesnt look quite right,
    i’m gonna play around with that, and see if i can get it to look better, but If i cant i’m gonna have to use the basketball model, any help you could give me would be awsome!

    thanks for everything, you have some good karma coming your way
    ~matt!

  15. 27 September 2009
    FlashMonkey

    No worries Matt, pleased to help. I would definitely recommend editing the texture to work with the Sphere rather than using the DAE, as it’s lower polys. With regards to Physics it really depends on how complex you want to go. For something simple like making the ball just bounce up and down I would write some basic physics yourself, Keith Peter’s Making Things Move book will help if your new to basic Physics. However, if your after something a bit more advanced I’d go for a Physics engine like Box2D, there’s some example files here. Finally, you should avoid basing your physics on an enter frame loop, as frame rate can change and the physics will look unrealistic on a slow machine. Read Glenn Fielder’s post on fixed timestep physics. Good luck and let me know how it goes.

  16. 2 October 2009
    matt

    oops forgot to ask, do you have any performance tips? ways to make the swf less taxing on the users cpu?

    you rule monkey

  17. 23 October 2009
    martin

    Hi monkey,

    greate work this was what i was looking for i knew that it could be done, but i’m not so good in 3d Max(baking textures). I would like to ask one question. The model was firstly textured in 3d max then while exported to the DAE it did keep the UV maping, or you had to texture it(UV map) again in p3d?
    In steps does it look like this ?

    1. make model
    2. texture it
    3. bake occlusion
    4. combine texture with baked occlusion
    5. export to DAE
    6. import model and baked texture :)

  18. 23 October 2009
    FlashMonkey

    Hi Martin. All the shadows etc are baked into the image as can be seen here, there is no UV map or lighting or anything with Papervision, just a DAE with a material map.

    With regards to 3D Max, I used to be fairly handy with it back when I was at university but to be honest I never really use it now. Fed Selmi put that model together, I’ve told him about your question and I’m sure he’ll post a comment here to help you.

  19. 23 October 2009
    martin

    Hi monkey,

    thank you for the quick answear :) . I hopped that there will be no UV maping in the p3d. Btw i will be in London next week on stack overflow devdays. Are you going there ? Or we could have a beer somewhere.

    thank you

  20. 25 October 2009
    debosotnas

    hi! and thanks to this article…
    i leave a link where can see all process (like martin tell us)
    http://www.gotoandlearn.com/play?id=106

    Bytes!!

  21. 26 October 2009

    Hi Martin

    That’s correct, you have to map the model in 3ds max, and when you export the model as a DAE file it will remember the coordinates, as long as you have not changed the texture since. You can change colors, add more details etc but not the position.

    Be sure to visit http://www.cocomino.com soon for what should be a very fun papervision project!

    If you have any question email me at federico@cocomino.com.

  22. 29 January 2010

    Thanks Flash Monkey! I have been searching for a year trying to figure out how to get this to publish directly from Flash. I added the code you mentioned above but I was still getting the wireframe and the error message. I looked around some more and found that the Collada Class has an option to pass the Bitmap Material in as another parameter. So I changed my code to read:

    var mat:BitmapFileMaterial = new BitmapFileMaterial(“texture.jpg”);
    var mp:MaterialsList = new MaterialsList();
    mp.addMaterial(mat, “phong1SG1″);
    collada = new Collada(“ColladaTest.dae”, mp);

    This fixed the problem and everything is working beautifully now. Note that I modeled in Maya and exported to DAE using the OpenCollada plugin so perhaps this problem is unique to Maya.

    Also I thought I would share what I learned about animation:
    Papervision as two kinds of Collada parsers, the Collada Class and the DAE class. Collada is the first version and DAE is the improved version. While both can be animated in Flash, only the DAE Class will accept animation that you have created in 3D software. Note that you must convert your animation to vertex animation in order for it to display properly in Papervision 3D.

    Hope this is helpful.

  23. 29 January 2010
    FlashMonkey

    Thanks for the comment and tip about animations Doug :)

  24. 9 March 2010
    Martijn

    Hello,

    I have some problems with my model/texture. A part of the model/texture is disappearing? How can I fixed that? I have tried now for weeks but I can get it right.

    Thanks a lot,

    Martijn

  25. 9 March 2010
    FlashMonkey

    Hey Martijn – do you have a link to the SWF so I can take a look at it?

  26. 9 March 2010
    Martijn

    Hey FlashMonkey,

    THanks for the reply. I am working on a AR project so I can’t give you a SWF but here is a screen: http://student.cmd.hro.nl/0789753/jaar4/bbvh/problem.jpg

    When I move the camera around it looks in some directions okay but then there are another spots that doesn’t look right. I think it has to do something with clipping/cullin??? But I can get it fixed.

    THanks a lot!

  27. 9 March 2010
    Martijn

    Sorry I forgot something to say, In the image the object has already a texture. ( i did some texture baking with 3dsmax ).

    When I import the model without any texture, you don’t see the model good ( because there is no shadow ) but then the model looks okay! So mayby its also a texture problem. I don’t know.

    Thanks again!!!

  28. 9 March 2010
    FlashMonkey

    Sorry Martijn, I’m not sure I’ll be too helpful without being able to take a look at the source files.

    Do you get the same problem when just viewing the model without the AR stuff? The problem isn’t related to the issue described in this post, I would suggest posting something on the Papervision forum – I’m sure someone has experienced something similar and will be able to help you.

    Good luck, I hope you find a solution.

  29. 28 April 2010
    Derek Rhode

    I have been spending forever on a personal project trying to make it work. Could you by any chance be able to upload your AS and Dae files for this project for me to be able to track down the problem through comparison? You would be my savior if you could.

  30. 28 April 2010
    FlashMonkey

    Hi Derek, unfortunately I can’t upload the files but if you send me over your source code I will take a look at it and see if I can help.

  31. 28 April 2010
    Derek Rhode

    Heres my Flash Builder project folder.
    http://www.derekrhode.com/MiscHosting/tempupload/MyCollada.zip

    Let me know if you need anything else. The problem is it just keeps showing the wireframe of the model only.

  32. 29 April 2010
    FlashMonkey

    Hi Derek, when I compile I get this error:

    WARNING: Collada material initialShadingGroup not found.

    A quick google found this post on the Papervision forum:

    http://forum.papervision3d.org/viewtopic.php?f=16&t=247

    Are you using Maya or 3D Studio Max? I’m guessing it’s something to do with the export settings.

  33. 29 April 2010
    Derek Rhode

    I’m using Maya, It’s weird I didn’t see that error when exporting are you using flash builder? I tried taking the advice exactly the way they said in that topic but its still not working. I looked at the code within the dae file for library images and it looks fine. The material is listed as lambert2 inside of the dae. Do you see anything in the actionscript that may be causing the problem?

  34. 30 April 2010
    Derek Rhode

    Fixed it, it was a matter of opening the dae file in dreamweaver and doing a find and replace and replacing any reference to the material name in maya and changing it to initialShadingGroup

  35. 30 April 2010
    FlashMonkey

    Hey Derek! Cool glad you found a solution :)

  36. 27 May 2010
    EM

    Thanks so much Monkey, I was having the hardest time getting my materials to show up on my Collada file, now at least I can see my textures! This thread is a great resource. Much thanks! :)

  37. 8 June 2010
    Antigoni

    Hello FlashMonkey!

    Thanks a lot for your help.. I was able to import my 3d models into flash finally..after hours and hours..i suddenly fount your tutorial. I still have a problem though.. All I have untill now is models imported to flash from Blender with the use of Papervision3d only under the condition that I assigned the materials with UV Mapping.
    The problem is that I don’t want to use UV mapping. I just need to create my materials into blender and then export them somehow and import them into flash..Any idea about that?

    I have some detailed description here: http://designnoop.wordpress.com/ (the bulb as it is in blender and the bulb imported into flash)

    Thx a lot in advance!:)

  38. 12 June 2010
    FlashMonkey

    Hey Antigoni, glad the post helped you. Unfortunately I can’t help you with the other issue as I’ve never used Blender and I’m also currently travelling in Central/South America so far far away from my laptop and a copy of Flash! Good luck figuring it out and please post the solution here to help others!

  39. 19 July 2010
    galih

    hi,
    i want to know about the collada’s file.
    is collada’s file (.dae) that is exported from blender, an animation?
    and when it’s imported by papervision3d, can it move on (animated) otomatically while executed by papervision3d?

  40. 20 July 2010

    Ok this is great! But how to change this material to another in runtime??

  41. 20 July 2010
    FlashMonkey

    galih – you can read about .dae files here. basically it´s an open standard XML schema for describing a digital asset, so in the case of Blender a 3D model. I´m not sure off the top of my head if you can export an animation but I seem to remember this is possible (have a search on google or maybe post something on the Papervision forum)

    Ziemowit – I´m currently in the middle of a 6 month trip from Mexico to Argentina so am a very long way from my laptop and Flash and can´t remember off the top of my head how to do this but it is possible. Again maybe post something on the Papervision forum. Sorry I can´t help, if I was near my computer I would have created an example for you!

    Good luck to both of you! :)

  42. 5 August 2010
    Peaters

    Hi, please help me. I use Maya to create .dae model, but if I create some simple wire model, Papervision doesn’t load it. I’m sure the problem is in export settings, but don’t know where. Any suggestion how to setup export?
    Thanks a lot.

  43. 10 September 2010

    Ok, I´ll realy apreciate if someone could explain a way to generate textured .DAE files from any 3D software. I have download Blender and its impossible, I did install the last Phyton and nothing, also download 3D Max and when I export for .DAE the file always shows erros on flash. Download Maya and also install the TAVAE PLUGIN for Maya 2011 and the model shows in wire only NO texture. Proyect links:

    http://www.hhumantron.com.mx/gym/
    http://www.hhumantron.com.mx/gym2/
    http://www.hhumantron.com.mx/gym2/index3.html

    Im giving up on PV3D… is there any true and simple way of making this .DAE texture files?

  44. 23 September 2010
    rocciax

    Hello!

    My problem –> WARNING: Collada material Standard_1_1 not found.

    code:

    ——–> before: load bitmap file

    private function pngList(evt:Event, beDae:String):void {
    // ligth
    light = new PointLight3D();
    light.z = -300; light.y = 250;

    // bitmap
    var loader:Loader = Loader(evt.target.loader);
    var image:Bitmap = Bitmap(loader.content);
    var bitmapMaterial:BitmapMaterial = new BitmapMaterial(image.bitmapData, true);
    bitmapMaterial.smooth = true;

    // shaders
    var cellShader:CellShader = new CellShader(light, 0xffffff, 0×000000, 10);
    var shadedMaterial:ShadedMaterial = new ShadedMaterial(bitmapMaterial, cellShader);

    // materials
    var matlist:MaterialsList = new MaterialsList();
    matlist.addMaterial(shadedMaterial, “Material01″);
    matlist.addMaterial(bitmapMaterial, “Bitmap01″);

    var newObj:DisplayObject3D = new Collada(beDae, matlist);
    newObj.addEventListener(FileLoadEvent.LOAD_COMPLETE, Universal.argsFunc(daeList, newObj));
    }

    ——–> after: scene.addChild(newObj);

    HOW add shader Collada file? (more material)?

    Pls help me. And thank you, your time.

    Hi, Peter

  45. 27 September 2010
    Ryan

    Thanks,
    I’ve been trying to figure out this problem for weeks.

  46. 29 September 2010
    alejo

    My friends, the final solution, to that problem, after googling like two day all people have the same issue…
    so i start deguging the colada.as “new Cololada(daeFile.dae)”
    here is the solution !!!!!!!!, two lines in colada.as

    http://code.google.com/u/danielszak/updates

  47. 17 November 2010

    Thanks for posting this. I was having the exact same problem. Now it works.

  48. nabgraph » papervision3d collada material bug
  49. 2 January 2011
    Ryan

    Hi There,
    Any chance you could email me the source code for this I could take a look at? Problem being, I’m able to upload my collada file into PV fine, but I want it to rotate and ease to a stop once the user has clicked and dragged, as you have shown with your plane. Any help would be appreciated as im a bit of a newbie using PV and i’m tearing my hair out, LOL!!! Thanks

  50. 5 January 2011
    FlashMonkey

    Hi Ryan, sorry but I won’t be able to send over the exact source code but I can send over the spinning code. I first need to find it though as I think it may be on an old computer. Once I find it I’ll email it over to you!

  51. 5 January 2011
    Ryan

    Yes, all I need is the code to get the collada spinning.You would be a life saver if you could find the code soon as my uni project that I need this for needs handing in soon!! Thankyou

  52. 28 January 2011

    Oh my!

    Nice workout but the dae is HUGE!!!

  53. 28 January 2011
    FlashMonkey

    Hey Osman. Do you mean your DAE is huge? You could search/replace. Alternatively change the name within your ActionScript to match the name in the DAE, e.g. instead of renaming ‘_8_-_Default_1′ to ‘mat0′ in the DAE, rename mat0 to ‘_8_-_Default_1′ in your ActionScript like this:

    mp.addMaterial(mat, “mat0″);

    becomes

    mp.addMaterial(mat, “_8_-_Default_1″);

  54. 4 March 2011
    Abhishek Saxena

    Hello FlashMonkey,
    well i have been working on papervision for last few months, and successfully developed some applications by using papervision in flex, now i am working on complex objects like making a tshirt in papervision.
    i have loaded the tshirt dae file in my application, applied colormaterial too, but what would i do if i want to put some bitmap data on the collada file, supposed the bitmap data is of any tshirt, containing 4 views, front back ,and the other two sides.howz that possible to show it on collada/dae tshirt file.
    can u provide some help,
    Thanks
    Abhishek

  55. 10 March 2011
    FlashMonkey

    Hey Abhishek, I haven’t used Papervision for quite sometime and will be focusing more on Away3D in the future. Maybe you should post on the Papervision Forum, there is a lot of very helpful people on there who I’m sure could give you some great advice.

  56. 4 April 2011
    Abhishek Saxena

    Thanks Flashmoneky, for your suggestion,
    i was busy in some other work so replying you so late. i will surely post my comment on that forum,but i just have one question for you, can we apply bitmap material on dae file and change it at a runtime ?
    may be you have worked on that in past, its really important for me, if you have any kinda demo or links to study ,
    do gimme a reply,
    i’m eagrly awating for this.
    Thanks

    Abhishek.

  57. 12 January 2012
    Ashley

    Hi FlashMonkey

    Ive tried your suggestion above but no matter what i do i cant get my dae file to show up on my augmented reality project with textures … please can you assist me as i cant find a solution anywhere.

    I really want to get this ready for my Final year project – any assistance would be greatly appreciated

    god bless you

    ash

  58. 13 January 2012
    FlashMonkey

    Hey Ashley,

    I haven’t actually used Papervision for a long time as I moved over to using Away3D. I wrote this bug fix well over 2 years ago so the code base may have changed since then. Maybe trying posting something on the Papervision forum. Good luck – hope you figure it out before your deadline.

  59. 11 September 2012

    Hello there, You have done an incredible job. I will definitely digg it and for my part suggest to my friends. I’m sure they will be benefited from this site.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>