yeah, thanks a lot... it was the use of the clone method which was the problem, thanks you Rob
On 26 juil, 19:40, Rob Bateman <[email protected]> wrote: > well, the materialLibrary will be cloned along with everything else, so it's > very easy to loop through all the materials used in a cloned object. The > other thing is you seem to be using the clone method incorrectly, and in > this particular instance i would use the similarly titled "cloneAll()" > method which duplicates geometry as well as mesh data: > > this["floor"+i] = floorGab.cloneAll(); > var matLib:MAterialLibraray = this["floor"+i].materialLibrary; > for each (var matData:MaterialData in matLib) { > if(matData.material is ColorMaterial) > matData.material = new ColorMaterial((matData.material as > ColorMaterial).color); > > } > > this will reset the material property on all cloned faces to the same > appearing ColorMaterial, but with a different ColorMaterial instance. Then > when your rollover event is triggered, resetting the color using the > material grabbed from the cloned materialLibrary should not affect the > original objects materials, or any other clones > > Rob > > > > On Sun, Jul 26, 2009 at 2:41 PM, Colir <[email protected]> wrote: > > > well i see the trouble, however i dont see how to realise this. > > > also in my code > > function showFloorInfo(evt:MouseEvent3D):void{ > > var currentFloor = evt.object as Mesh > > > for(var j:int=0;j<currentFloor.faces.length-1;j++){ > > var fd:Face = currentFloor.faces[j] as Face; > > fd.material = selectedFloorMat; > > } > > TweenMax.to(currentFloor,0.2,{alpha:0.7,ease:Linear.easeNone}) > > > getServicesList(overedFloorID) > > } > > i don't understand why all the material are linked with the use of > > faces.... > > How i can isolate material from one floor ? > > is in my clone function ? but how ? > > thanks > > > On 26 juil, 02:58, Rob Bateman <[email protected]> wrote: > > > Hey Colir > > > > the problem with clone and materials is that material references are kept > > > intact, so the same materials are used for each collada object. This is > > > mainly to save memory, but i guess you could loop through the material > > > library to set all materials to new material instances, and then the > > colors > > > would be independent of each other > > > > the reason for your null error in the MouesEvent3D listener is that > > casting > > > all obejcts returned as Mesh will cause nulls where objectcontainers are > > > encountered. you will need to check for this in your listener to avoid > > > errors > > > > also, the reason why material properties are null in the mesh is that the > > > collada file is not using them. mesh.material like a global material > > setter > > > on all geometry in teh mesh, but collada (and a nuber of other formats) > > only > > > deal with face mateiral properties, so that material inatances are set > > > individually on a face. using the mateiralLibrary object as you do is the > > > easiet way to access collada faces outside the geometry structure > > > > hth! > > > > Rob > > > > On Thu, Jul 23, 2009 at 8:31 AM, Colir <[email protected]> wrote: > > > > > someone can help me please > > > > thanks > > > > > On 21 juil, 18:41, Colir <[email protected]> wrote: > > > > > yo ben, this my code: > > > > > > var floorGab = Collada.load("floorGab.dae",{autoLoadTextures : > > > > > true,scaling:0.005}); > > > > > floorGab.addOnSuccess(gabLoadSucess) > > > > > function gabLoadSucess(evt:LoaderEvent):void{ > > > > > floorGab = ObjectContainer3D(evt.loader.handle); > > > > > floorGab.position = new Number3D(0,0,0); > > > > > > for(var i:int=0;i <= nbFloor;i++){ > > > > > floorGab.clone(this["floor"+i]) > > > > > this["floor" + i].name = "floor" + i > > > > > this["floor" + i].y = 20*i > > > > > hospital.addChild(this["floor" + i]) > > > > > this["floor" + i].addOnMouseOver(showFloorInfo); > > > > > this["floor" + i].addOnMouseOut(hideFloorInfo); > > > > > this["floor" + i].addOnMouseUp(getTheFloor); > > > > > this["floor" + i].ownCanvas=true > > > > > } > > > > > > floorMat = floorGab.materialLibrary.getMaterial("floorID") > > > > > floorMat.material = gabFloorMat; > > > > > } > > > > > > function showFloorInfo(evt:MouseEvent3D):void{ > > > > > var currentFloor = evt.object as Mesh > > > > > > currentFloor.mouseEnabled = true > > > > > currentFloor.useHandCursor = true > > > > > > for(var j:int=0;j<currentFloor.faces.length-1;j++) { > > > > > var fd:Face = currentFloor.faces[j] as Face; > > > > > fd.material = selectedFloorMat; > > > > > } > > > > > > } > > > > > > thanks > > > > > > On 21 juil, 15:43, ben <[email protected]> wrote: > > > > > > > 1. ok, my fault, the habit of simple MouseEvent, yes this e.object: > > > > > > MouseEvent.target == MouseEvent3D.object > > > > > > > 2.... well ? show me how you did the whole cloning and > > colorchange... > > > > -- > > > Rob Bateman > > > Flash Development & Consultancy > > > > [email protected] > > -- > Rob Bateman > Flash Development & Consultancy > > [email protected]
