Want to add addMethod(fogMethod) to my loaded .awd file

Software: Away3D 4.x

Biegzie, Jr. Member
Posted: 28 August 2012 07:47 PM   Total Posts: 39

Hello,

Can’t find the way to add addMethod(fogMethod) to my Mesh.
It’s an awd that will be loaded with loader3D.
Someone knows how to do it?

private function onModelParseComplete(e:AssetEvent):void
  {
 
  switch (String(e.asset.assetType))
  {
  case “mesh”:
   
    var obj:Mesh = e.asset as Mesh;
   
    init_3Dobject();

    break;

  case “material”:
    break;
 
 
  default:
    break;
  }
 
 
  }
}

   

Biegzie, Jr. Member
Posted: 29 August 2012 06:41 PM   Total Posts: 39   [ # 1 ]

No one here that ever did an addMethod fog on a loaded 3D object?

   

John Wilson, Member
Posted: 29 August 2012 07:57 PM   Total Posts: 62   [ # 2 ]

Hi,

You have to add the FogMethod to the object’s material.

var fm:FogMethod = new FogMethod(10030000x5f5e6e);
yourMaterial.addMethod(fm); 
   

Biegzie, Jr. Member
Posted: 29 August 2012 08:12 PM   Total Posts: 39   [ # 3 ]

yes.. but the object his material (object.material) has no addMethod function.
there is no object.material.addMethod()

I am using Away3D 4.0.9 Gold.

   

John Wilson, Member
Posted: 29 August 2012 08:46 PM   Total Posts: 62   [ # 4 ]

That’s odd. The following works for using the latest GitHum Release Branch 4.0.9:

mat = new TextureMaterial(new BitmapTexture(new BitmapData(512512true0xee6002040)));
mat.alpha .99999;
var 
fm:FogMethod = new FogMethod(10030000x5f5e6e);
mat.addMethod(fm);
mesh = new Mesh(new PlaneGeometry(50005000), mat); 
   

Biegzie, Jr. Member
Posted: 29 August 2012 09:04 PM   Total Posts: 39   [ # 5 ]

Yes, it is no problem to addMethod to an Texturematerial (or colormaterial of whatever).

But my loader3D Mesh (.awd) is already loaded with a kind of material on it.
obj.material

I don’t want to add a new TextureMaterial (with addmethod) onto obj.material. But rather use the material autoloaded by the loader3D and on that add the addMethod(fog).

   

John Wilson, Member
Posted: 29 August 2012 09:22 PM   Total Posts: 62   [ # 6 ]

You don’t need to use another material, you need to access the material loaded with your .awd file and assign a FogMethod to it.  In the following, “loader” is a Loader3d.

var m:Mesh loader.getChildAt(0).getChildAt(0) as Mesh;
tm:TextureMaterial m.material as TextureMaterial
var fm:FogMethod = new FogMethod(10030000x5f5e6e);
tm.addMethod(fm); 
   

Biegzie, Jr. Member
Posted: 29 August 2012 09:26 PM   Total Posts: 39   [ # 7 ]

m.material as TextureMaterial

ah something like that is possible?

   

John Wilson, Member
Posted: 29 August 2012 09:30 PM   Total Posts: 62   [ # 8 ]

Well, it works for me.

   

Biegzie, Jr. Member
Posted: 29 August 2012 09:43 PM   Total Posts: 39   [ # 9 ]

it doesn’t work :(

the objectArray[a][2] is the mesh i get from loader3D


newObject = objectArray[a][2].clone();
       
        var tm:TextureMaterial = newObject.material as TextureMaterial
        var fm:FogMethod = new FogMethod(20, 30, 0x5f5e6e);
        tm.addMethod(fm);


But there is no fog on the objects…

   

John Wilson, Member
Posted: 30 August 2012 08:47 AM   Total Posts: 62   [ # 10 ]

Hi, having looked a bit further at this it seems to me that you have to assign a LightPicker to the material before you apply the FogMethod.

   

Biegzie, Jr. Member
Posted: 30 August 2012 08:50 AM   Total Posts: 39   [ # 11 ]

I’m not adding a lightPicker indeed, will try it tonight

   

Biegzie, Jr. Member
Posted: 30 August 2012 07:25 PM   Total Posts: 39   [ # 12 ]

hello, just tried it with the lightpicker, didn’t work, than I tried to put a totally new texturemeterial on the mesh, didn’t work as well :s any idea?

var obj:Mesh e.asset as Mesh;
     
var 
tm:TextureMaterial = new TextureMaterial(new BitmapTexture(new Body().bitmapData));
tm.lightPicker lightPicker;
tm.specular 0.1;
tm.addMethod(new FogMethod(1,20x444444));
     
obj.material tm
   

Biegzie, Jr. Member
Posted: 30 August 2012 08:31 PM   Total Posts: 39   [ # 13 ]

I GOT IT!!

switch (String(e.asset.assetType))
   
{
    
case "mesh":
     
     var 
obj:Mesh e.asset as Mesh;
      
     
objectArray[currentI][2] obj;
     
objectArray[currentI][2].scale(0.01);
     
     
currentI++;
     
     
init_3Dobject();
     
     for 
each (var m:SubMesh in objectArray[currentI-1][2].subMeshes){
     
var tm:ColorMaterial = new ColorMaterial(0xff0000,1);
     
tm.lightPicker lightPicker;
     
tm.specular 0.1;
     
tm.addMethod(fogMethod);
     
     
m.material tm;
     
}
     
break; 
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X