im loading a model by Loader3D, and this model (is a complete map) has a some subgeometries and some sub textures (im new in this, maybe this is the usual). The problem is everything seems to plain like the lightpicker is not being applied to the materials.
Here i load the map:
_light = new DirectionalLight(-1, -1, 1);
_light.color = 0xFFFFFF;
_light.ambient = 0
_light.diffuse = 1
_light.specular = 1;
_scene.addChild(_light);
_lightPicker = new StaticLightPicker([_light]);
_loader = new Loader3D();
_loader.addEventListener(AssetEvent.ASSET_COMPLETE, onAssetComplete);
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE,onResourceComplete);
_loader.load(new URLRequest('./assets/models/maptest.awd'));
in the assetEvent, i assign the lightPicker to the textures:
private function onAssetComplete(e : AssetEvent) : void
{
var asset:IAsset = e.asset;
trace(asset.name+" Cargado!");
if (asset.assetType == AssetType.MATERIAL)
{
if(asset is TextureMaterial)
{
var material:TextureMaterial = asset as TextureMaterial
material.shadowMethod = new FilteredShadowMapMethod(_light);
material.shadowMethod.epsilon = 0.1;
material.lightPicker = _lightPicker;
material.specular = 0.5;
}
if (asset is ColorMaterial)
{
var cmaterial:ColorMaterial = asset as ColorMaterial
cmaterial.shadowMethod = new FilteredShadowMapMethod(_light);
cmaterial.shadowMethod.epsilon = 0.1;
cmaterial.lightPicker = _lightPicker;
cmaterial.specular = 0.5;
}
trace("Texture processed");
}
}
and in the Complete event, add the mesh to the scene:
private function onResourceComplete(e : LoaderEvent) : void
{
var mesh:Mesh = _loader.getChildAt(0) as Mesh
_scene.addChild(mesh);
}
i also tried in this way:
//Loading complete resource
private function onResourceComplete(e : LoaderEvent) : void
{
var mesh:Mesh = _loader.getChildAt(0) as Mesh
var mat:* = mesh.material;
mat.shadowMethod = new FilteredShadowMapMethod(_light);
mat.shadowMethod.epsilon = 0.1;
mat.lightPicker = _lightPicker;
mat.specular = 0.5;
_scene.addChild(mesh);
}
The textures are correctly loaded and the lights projects a very weak shadow on the material, but there is no ambient light at all. no light ranges, plain.
I’ve tried changing light values but the same.
Any suggestion?
ps: i’ve tried to what is in this post http://away3d.com/forum/viewthread/3865/ howev,er i couldnt load the map with the AssetManager.