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
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 ColorMaterial( CYLINDER_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=0; i<8;i++){
switch(i){
case 0: floorTexture = new BitmapTexture(new number1Img().bitmapData);
break;
case 1: floorTexture = new BitmapTexture(new number2Img().bitmapData);
break;
case 2: floorTexture = new BitmapTexture(new number3Img().bitmapData);
break;
case 3: floorTexture = new BitmapTexture(new number4Img().bitmapData);
break;
case 4: floorTexture = new BitmapTexture(new number5Img().bitmapData);
break;
case 5: floorTexture = new BitmapTexture(new number6Img().bitmapData);
break;
case 6: floorTexture = new BitmapTexture(new number7Img().bitmapData);
break;
case 7: floorTexture = 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(16, 16), 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