Papervision 3D and DAE material bug

2009 May 7
by FlashMonkey

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.

The Flash plugin is required to view this object.


(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!

The Flash plugin is required to view this object.


(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.

42 Comments leave one →
2009 May 8

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

2009 July 21
Pim permalink

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

Pim.

2009 August 6
Roovin permalink

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

2009 August 7
FlashMonkey permalink

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

2009 August 16
Serkan Buldan permalink

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.

2009 August 16
FlashMonkey permalink

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.

2009 September 25

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

2009 September 25
FlashMonkey permalink

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.

2009 September 25

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

2009 September 25

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

2009 September 25
FlashMonkey permalink

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.

2009 September 26

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!

2009 September 26
FlashMonkey permalink

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

2009 September 27

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!

2009 September 27
FlashMonkey permalink

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.

2009 October 2
matt permalink

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

you rule monkey

2009 October 23
martin permalink

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 :)

2009 October 23
FlashMonkey permalink

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.

2009 October 23
martin permalink

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

2009 October 25
debosotnas permalink

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!!

2009 October 26

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.

2010 January 29

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.

2010 January 29
FlashMonkey permalink

Thanks for the comment and tip about animations Doug :)

2010 March 9
Martijn permalink

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

2010 March 9
FlashMonkey permalink

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

2010 March 9
Martijn permalink

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!

2010 March 9
Martijn permalink

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!!!

2010 March 9
FlashMonkey permalink

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.

2010 April 28
Derek Rhode permalink

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.

2010 April 28
FlashMonkey permalink

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.

2010 April 28
Derek Rhode permalink

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.

2010 April 29
FlashMonkey permalink

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.

2010 April 29
Derek Rhode permalink

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?

2010 April 30
Derek Rhode permalink

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

2010 April 30
FlashMonkey permalink

Hey Derek! Cool glad you found a solution :)

2010 May 27

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! :)

2010 June 8
Antigoni permalink

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!:)

2010 June 12
FlashMonkey permalink

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!

2010 July 19
galih permalink

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?

2010 July 20

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

2010 July 20
FlashMonkey permalink

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! :)

2010 August 5
Peaters permalink

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.

Leave A Comment

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS