can’t get the lighting right [away3d 4.0.9]

Software: Away3D 4.x

r.moreira, Newbie
Posted: 11 September 2012 10:33 AM   Total Posts: 3

Hello everyone,

I’m having some problems getting the lighting right in a scene.. Having played with several attributes and with PointLight and DirectionalLight, I still couldn’t make it right. So, now I’m turning to you for any possible help smile

Attached to this message goes an image which demonstrates what I have and how I want it to be. The colors of the cylinders are exactly the same, only the lighting is different.

Here is also some code I think might be useful for you to see how I built the scene..


cylinders

for(var i:int=0;i<8;i++){
      cylinderArray[i] 
= new CylinderGeometry(10,10,100);
      
cylinderMaterialArray[i] = new ColorMaterialCYLINDER_COLORS_3D[i] );   
      
      
cylinderMaterialArray[i].lightPicker lightPicker;
      
cylinderMeshArray[i] = new Mesh(cylinderArray[i]cylinderMaterialArray[i]);
      
cylinderMeshArray[i].mouseEnabled true;
      
setCylinderY(cylinderArray[i].height/2,i);
      
      
scene.addChild(cylinderMeshArray[i]);
     

 

Textures of the numbers on the top of the cylinders (I wasn’t able to put text there rendering correctly, so I went for some images with the numbers. My main issue are the lights, but if you have some advice to improve this, I would appreciate)

var floorTexture:BitmapTexture;
     var 
floorMaterial:TextureMaterial;
     
     for(var 
i:int=0i<8;i++){
       
switch(i){
       
case 0floorTexture = new BitmapTexture(new number1Img().bitmapData);
        break;
       case 
1floorTexture = new BitmapTexture(new number2Img().bitmapData);
        break;
       case 
2floorTexture = new BitmapTexture(new number3Img().bitmapData);
        break;
       case 
3floorTexture = new BitmapTexture(new number4Img().bitmapData);
        break;
       case 
4floorTexture = new BitmapTexture(new number5Img().bitmapData);
        break;
       case 
5floorTexture = new BitmapTexture(new number6Img().bitmapData);
        break;
       case 
6floorTexture = new BitmapTexture(new number7Img().bitmapData);
        break;
       case 
7floorTexture = new BitmapTexture(new number8Img().bitmapData);
        break;
       default:
        break;
      

      
      floorMaterial 
= new TextureMaterial(floorTexture);
      
floorMaterial.smooth true;
      
floorMaterial.alphaBlending=true;
      
floorMaterial.gloss 100
      
numbersImgArray[i] = new Mesh(new PlaneGeometry(1616), floorMaterial);
      
      
scene.addChild(numbersImgArray[i]);
     

 

Lights! can’t get them to work as needed

private function initLights():void
    {    
     
//create a light for the camera
        
pointLight = new PointLight();
     
pointLight.color 0xFFFFFF;
     
pointLight.ambient 0.5;
     
pointLight.specular 0;
     
pointLight.diffuse 0.5;
     
     
//top light to lid the top of the cylinders
     
topLight = new DirectionalLight(0,-2,-0.005);
     
topLight.color 0xFFFFFF;
     
     

     
     
scene.addChild(topLight);
     
scene.addChild(pointLight);
     
     
     
// In version 4, you'll need a lightpicker. Materials must then be registered with it (see initObject)
     
lightPicker = new StaticLightPicker([topLight,pointLight]);
    


To finish, I should point out that i’m using a HoverCamera which i’m limiting in movement to one axel ( yy ), moving to left or to right. The camera is at a distance of 600. the foot texture is at Y=0. The cylinder with number 1 (the red one), has the center of its bottom at (0,0,0).

Thanks in advance!

Regards,
Ricardo

 

   

Avatar
Dexx, Newbie
Posted: 11 September 2012 11:31 AM   Total Posts: 6   [ # 1 ]

Try adding a directional light that looks to the same direction, the camera is. As I see, your point light, is at the same position as the red bar (0, 0) which doesn’t really do anything, Except for the ambient light from the light base it’s inheriting. Thus you could as well put a radius and fall of of 0 to it, if you’re only using it for ambiance.

   

Avatar
Fabrice Closier, Administrator
Posted: 11 September 2012 08:22 PM   Total Posts: 1265   [ # 2 ]

If you load your model in Prefab, add/place/play with your lights. Once satisfied, press the little away logo in lightpanel…

   

r.moreira, Newbie
Posted: 12 September 2012 10:42 AM   Total Posts: 3   [ # 3 ]

Thank you all for your answers!

Fabrice Closier - 11 September 2012 08:22 PM

If you load your model in Prefab, add/place/play with your lights. Once satisfied, press the little away logo in lightpanel…

Forgive me my lack of knowledge, but I believe I don’t have a model. You are talking about something like a 3ds model?
What I have is AS3 code importing a .png into a texture and some meshs with cylinderGeometry appearing on top of the texture.
I’ve tested Prefab and created a cylinder there, but i can’t seem to be able to replicate the scene..

   

Avatar
Fabrice Closier, Administrator
Posted: 12 September 2012 03:50 PM   Total Posts: 1265   [ # 4 ]

using the primitive generator, you make one cylinder. apply. then copy, paste, till you have your amount of cyl as on scenery. make new colormaterials. apply them. select all, go to light panel, make a dir light, a picker, press apply btn. Play with directionpicker(the spherical tool)
once happy, press away logo, it will give you all init as3 for the light(s)

   

r.moreira, Newbie
Posted: 12 September 2012 03:57 PM   Total Posts: 3   [ # 5 ]
Fabrice Closier - 12 September 2012 03:50 PM

using the primitive generator, you make one cylinder. apply. then copy, paste, till you have your amount of cyl as on scenery. make new colormaterials. apply them. select all, go to light panel, make a dir light, a picker, press apply btn. Play with directionpicker(the spherical tool)
once happy, press away logo, it will give you all init as3 for the light(s)

Thanks for your step-by-step. It’s very well explained! Will try it today!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X