[Papervision3D] KMZ files and pv3d 2.1

Paul Tondeur paul at paultondeur.nl
Sat Jul 11 07:35:02 PDT 2009


Hi list,

I'm experiencing some problems with KMZ files since the major updates  
on model parsing. The problem is that the model is only shown as a  
wireframe and materials are never mapped to the object.

The materials are loaded properly from the kmz zip archieve, however  
they will never be assigned as the material of a mesh.

I've spend a couple of hours on tracing this back and trying to find a  
fix. The problem lies in buildMaterialInstance() which is a method of  
the DAE class. Here it only checks if there's an daeImage and  
daeImage.bitmapData value, however it could also be the case that  
there's a daeImage whithout bitmapData, because its loaded from a  
zipfile in the KMZ class. I compared this to how this was done  
previously before pv3d 2.1 and came up with the following quick fix  
for the buildMaterialInstance() method.

At the end of this method we can check if the material is still null,  
just before returning it. If its still equal to null, we can have a  
look in the materialsList to see if there's a material with this same  
name. If so, a material value can be set and returned. If not, the  
material will still be null.

if(material==null)
{
	var symbol:String =  
this.document.materialTargetToSymbol[ daeMaterial.id ];
	material = this.materials.getMaterialByName(symbol);
}

It's a quick fix, but it seems to perfectly do its job. Tim, maybe you  
have an idea on how to turn this quick fix into something that only  
does this for KMZ models exclusively and not for all other DAE based  
models. It would be great if someone could have a look at this.

I've tested this with several of my own projects that contain both KMZ  
files and DAE files. So I think the quick fix will be stable enough to  
implement.

To finish this mail, I have to say that I love the updates for loading  
and modifying models. The workflow between the modeller (who uses  
Cinema4D) and me is so much smoother. I don't have to change DAE files  
anymore, it just works out of the box. I'm really thankful for this!

Paul



More information about the Papervision3D mailing list