Texture Material

Software: Away3D 4.x

bardo, Member
Posted: 01 March 2012 12:01 PM   Total Posts: 79

hi all , another noob question ....

is there a way to add light(s) to a texture material? (bitmap material dont work anymore , an i haven’t understand the light picker mechanics ..yet)

thanks!

   

Torham, Newbie
Posted: 01 March 2012 01:56 PM   Total Posts: 2   [ # 1 ]

I had the same problem and I have found the answer from Advanced_TerrainDemo example file. Here:

import away3d.lights.DirectionalLight;
import away3d.materials.lightpickers.StaticLightPicker;
import away3d.materials.TextureMaterial;
import away3d.textures.BitmapTexture;
...
private var 
light:DirectionalLight;
private var 
lightPicker:StaticLightPicker;
...
light = new DirectionalLight(0, -10);
light.color 0xffddbb;
scene.addChild(light);
lightPicker = new StaticLightPicker([light]);

texture = new BitmapTexture(bitmapData);
material = new TextureMaterial(texture);
material.lightPicker lightPicker

Worked for me, hope that helps.

   

bardo, Member
Posted: 01 March 2012 01:56 PM   Total Posts: 79   [ # 2 ]

k , iset up a directional lighter and lightpicker , but it seems to not work :

https://www.socialnetworkserver.it/wrball/  -> example


this is the code :

directionalLight = new DirectionalLight();
  directionalLight.diffuse = .2;
  directionalLight.specular = .3;
  directionalLight.position = new Vector3D(0, 200, 0);
  lightPicker = new StaticLightPicker([directionalLight]);
  scene.addChild(directionalLight);
// in material set up
mat.lightPicker = lightPicker ;
mat.bothSides = true;

it seems no plane is affected by lights!

   

bardo, Member
Posted: 01 March 2012 01:57 PM   Total Posts: 79   [ # 3 ]

thnks thoram .... but it seems not working ! (eheh i was posting in the same moment as you!)

   

bardo, Member
Posted: 01 March 2012 03:38 PM   Total Posts: 79   [ # 4 ]

do u see the planes affected by light?

   

Mr Margaret Scratcher, Sr. Member
Posted: 02 March 2012 02:59 AM   Total Posts: 344   [ # 5 ]

The above does not work for me:

caseMaterials = new TextureMaterial(new BitmapTexture(caseBMD))
    
caseMaterials.ambientColor 0x505080;
    
caseMaterials.gloss 500;
    
caseMaterials.specular .6;
    
caseMaterials.lightpicker lightPicker

gives me the error:

Error: Access of possibly undefined property lightpicker through a reference with static type away3d.materials:TextureMaterial.

   

Torham, Newbie
Posted: 02 March 2012 07:42 AM   Total Posts: 2   [ # 6 ]

@bardo : Yes, my plane is definitely affected by the light, because I can see the difference when I do not set the lightPicker property.

@Margeret : the correct line should be “caseMaterials.lightPicker = lightPicker;” where the property name is “lightPicker” with capital “P”.

   

bardo, Member
Posted: 02 March 2012 08:53 AM   Total Posts: 79   [ # 7 ]

@thoram : as u can see from my link , no planes are affected by light: the light is in the center of the sphere , i expect shadows on the etrnal surfaces , and light on the internals ... maybe is the bothSide property the problem?

   

bardo, Member
Posted: 02 March 2012 10:31 AM   Total Posts: 79   [ # 8 ]

quite solved ... guys the frame rate , with a lot of path animator and lights , is impressive. at 25fps base , i have an average of 26.

i love the away3d team.

   

Mr Margaret Scratcher, Sr. Member
Posted: 06 March 2012 08:06 PM   Total Posts: 344   [ # 9 ]

@Torham… DOH! Thanks!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X