Discussion:
Sketchup 8 dae's
Creighton, Gerry
2010-09-07 20:34:04 UTC
Permalink
Anybody else having issues when changing materials with DAE files lately? I exported several from Sketchup 7 Pro and those DAE’s and my DAE parsing code work great, however, that trial has since expired so I can no longer export kmz or dae files that work with PV3D DAE parsing. I sought older Mac Sketchup versions but no luck. I now have two 3D files that I need to export and their materials aren’t being replaced like my previous sample.
I can trace out the materials in the dae and have looked through the dae structure to get the material id’s but can not replace those materials now.
Here is my function so you can see what I’m doing, nothing special but it works with DAE’s exported from Sketchup 7 Pro but not any other versions.

Any insight would be appreciated.

-Gerry



The following function is called each time a DAE file is loaded. I have an array of two DAE path strings to pull from.

var count:Number = 0;

private function setDAE(e:FileLoadEvent):void{
//

var daeModel:DisplayObject3D = e.target as DisplayObject3D;
var backDAE:DisplayObject3D = new DisplayObject3D();
var frontDAE:DisplayObject3D = new DisplayObject3D();
// color materials in 3D object
var whtMat:ColorMaterial = new ColorMaterial(0xEDEDED,.5);
var blkMat:ColorMaterial = new ColorMaterial(0x000000,1);
var redMat:ColorMaterial = new ColorMaterial(0x990000,.6);//color mat to use for testing to show dae layers

trace("/////////////////////////// count: “+count+” | dae materials: \n"+daeModel.materials+"\n/////////////////////////// count:\n"+count);
if(count == 0){
/* Lid */

daeModel.replaceMaterialByName(whtMat,"ID5");
FrontDO = new DisplayObject3D();
FrontDO.addChild(daeModel);

count = count+1;
loadDAEFiles(count);
//

}else if(count == 1){
/* Tray */

if(packageType == "PKG120-00004"){
//black tray
daeModel.replaceMaterialByName(blkMat,"ID5");
}else{
//clear tray - should show traycard art on both sides
daeModel.replaceMaterialByName(redMat,"ID5");
}
BackDO = new DisplayObject3D();
BackDO.addChild(daeModel);

//There is a call here to another method that does some other things to load other assets then adds the FrontDO and BackDO to the stage.
}

}
Creighton, Gerry
2010-09-13 16:45:29 UTC
Permalink
I figured out last week a way to get my materials colored the way that I wanted/needed.

For my loading function I set all materials to one color:

redMat = new ColorMaterial(0x990000,.6);

model.load(str,new MaterialsList({all:redMat});


Then after each DAE is loaded I can change the color of the material to what I need:


var whtMat:ColorMaterial = new ColorMaterial(0xEDEDED,.4);

var daeModel:DisplayObject3D = e.target as DisplayObject3D;
daeModel.replaceMaterialByName(whtMat,"all");


Just thought I’d pass along my solution to the problem I was having.

-Gerry


On 9/7/10 4:34 PM, "Creighton, Gerry" <gcreighton-***@public.gmane.org> wrote:

Anybody else having issues when changing materials with DAE files lately? I exported several from Sketchup 7 Pro and those DAE’s and my DAE parsing code work great, however, that trial has since expired so I can no longer export kmz or dae files that work with PV3D DAE parsing. I sought older Mac Sketchup versions but no luck. I now have two 3D files that I need to export and their materials aren’t being replaced like my previous sample.
I can trace out the materials in the dae and have looked through the dae structure to get the material id’s but can not replace those materials now.
Here is my function so you can see what I’m doing, nothing special but it works with DAE’s exported from Sketchup 7 Pro but not any other versions.

Any insight would be appreciated.

-Gerry



The following function is called each time a DAE file is loaded. I have an array of two DAE path strings to pull from.

var count:Number = 0;

private function setDAE(e:FileLoadEvent):void{
//

var daeModel:DisplayObject3D = e.target as DisplayObject3D;
var backDAE:DisplayObject3D = new DisplayObject3D();
var frontDAE:DisplayObject3D = new DisplayObject3D();
// color materials in 3D object
var whtMat:ColorMaterial = new ColorMaterial(0xEDEDED,.5);
var blkMat:ColorMaterial = new ColorMaterial(0x000000,1);
var redMat:ColorMaterial = new ColorMaterial(0x990000,.6);//color mat to use for testing to show dae layers

trace("/////////////////////////// count: “+count+” | dae materials: \n"+daeModel.materials+"\n/////////////////////////// count:\n"+count);
if(count == 0){
/* Lid */

daeModel.replaceMaterialByName(whtMat,"ID5");
FrontDO = new DisplayObject3D();
FrontDO.addChild(daeModel);

count = count+1;
loadDAEFiles(count);
//

}else if(count == 1){
/* Tray */

if(packageType == "PKG120-00004"){
//black tray
daeModel.replaceMaterialByName(blkMat,"ID5");
}else{
//clear tray - should show traycard art on both sides
daeModel.replaceMaterialByName(redMat,"ID5");
}
BackDO = new DisplayObject3D();
BackDO.addChild(daeModel);

//There is a call here to another method that does some other things to load other assets then adds the FrontDO and BackDO to the stage.
}

}

Loading...