I have an issue I am straggling to solve and hoped for some help.
I have build a scene with a loaded 3DS model. I run through all mesh names in loaded model and add specular map & normal map to each based on it’s name.
I also add to all meshs:
FresnelSpecularMethod
EnvMapAmbientMethod
BasicAmbientMethod
The problam is with the spacular map.
All maps works fine but the specular, the specular maps of all meshs is destroyed and replaces by the last specular map added to a mesh in the model.
I have a mesh called “final” in my model. It is the last asset loaded (last asset loaded event to dispatch). All meshs in the scene got “final” specular map even though the normals is correct and each was assigned with uniqe map.
My AsserLoaded function
private function onAsset(event:AssetEvent):void
{
if(event.asset.assetType == "mesh")
{
var mesh:Mesh;
var mat_maps:Array;
//create mesh of current part
mesh = Mesh(event.asset);
city_container.addChild(mesh);
//create materials
mat_maps = materials.getMaps(mesh.name);
TextureMaterial(mesh.material).normalMap = mat_maps["norm"];
TextureMaterial(mesh.material).specularMap = mat_maps["spec"];
TextureMaterial(mesh.material).gloss = mat_maps["gloss"];
TextureMaterial(mesh.material).specularMethod = mat_maps["spec_method"];
TextureMaterial(mesh.material).ambientMethod = mat_maps["amb_method"];
mesh.material.lightPicker = lightPicker;
}
}
My getMaterial function
public function getMaps(obj_name:String):Array
{
var maps:Array = new Array;
var map_norm:Texture2DBase;
var map_spec:Texture2DBase;
if(obj_name.substr(0, 5) == "space")//column
{
maps["norm"] = new BitmapTexture(new ShipNorm().bitmapData);
maps["spec"] = new BitmapTexture(new ShipSpec().bitmapData);
maps["gloss"] = 50;
maps["spec_method"] = fresnal_specular_method;
maps["amb_method"] = ambient_env_method;
maps["cast_shadow"] = false;
}
else if(obj_name.substr(0, 5) == "brick")//wall
{
maps["norm"] = new BitmapTexture(new WallNorm().bitmapData);
maps["spec"] = new BitmapTexture(new WallSpec().bitmapData);
maps["gloss"] = 50;
maps["spec_method"] = fresnal_specular_method;
maps["amb_method"] = ambient_env_method;
maps["cast_shadow"] = false;
}
else if(obj_name == "final")//floor
{
maps["norm"] = new BitmapTexture(new FinalNorm().bitmapData);
maps["spec"] = new BitmapTexture(new FinalSpec().bitmapData);
maps["gloss"] = 50;
maps["spec_method"] = fresnal_specular_method;
maps["amb_method"] = ambient_env_method;
maps["cast_shadow"] = false;
}
return maps;
}
I have exhausted every option I could think about…
Any help will be great. If any other clerification needed please ask.