OK, away3d have huge bug with methods and multiply maps. How u can reach this bug:
Case 1: You use one mesh with normalmap and specular map + mesh with no normal map and specular map with Fog and Shadow methods. [Mesh material missing]
Case2: You use all meshes with normals specular maps with unique FOG and shadow method [working fine]
Case3: You use all meshes with normals specular maps with unique FOG and shadow method + TERRAIN HAVE TerrainDiffuseMethod [Register overflow!]
Case4: You use one main player mesh with normal map and specular map. You use terrain with TerrainDiffuseMethod and normal map. You use statics object with only TextureMaterial in cases:
- You turn on Fog method for all objects [Object with diffuse method came one color and with red orb of bugging fog method].
- You turn on Shadow Method(any of) [Terrain object or static object without normal and speculars maps are destroy their material and they makes invisible for ppl eye]
HOW TO AVOID: To avoid this huge bug u need or not use normal and specular maps or use it for all object and not using terrain diffuse method. (If you need to use fog and shadow method).
SOLVE FOR ME: So im just reject using for a while from specular maps and fog methon and now I can use TerrainDiffuse + DiffuseTexture + NormalMap and TripleShadowMethod.
[-] FogMethod, [-] SpecularMaps..
Where I can found good books or tutorials for learning AGAL?
#########################################################
Ok now. I have class what create dynamicly terrain from xml.
Kinda:
public function loadLevelByXML(id:String,myXML:XML):void {
init loading...
then initObjects(getMaterial(myXML),myXML);
}
getMaterial code:
private function getMaterial(mXML:XML):TextureMaterial
{
if(mXML.terrain[0].defusemethod) {
var terrainMethod:TerrainDiffuseMethod = new TerrainDiffuseMethod([new BitmapTexture( main_root.UOLoader.images[mXML.terrain[0].defusemethod[0].item[0].@value].bitmapData), new BitmapTexture( main_root.UOLoader.images[mXML.terrain[0].defusemethod[0].item[1].@value].bitmapData), new BitmapTexture( main_root.UOLoader.images[mXML.terrain[0].defusemethod[0].item[2].@value].bitmapData)], new BitmapTexture( main_root.UOLoader.images[mXML.terrain[0].defusemethod[0].@splat].bitmapData) ,[1, 1, 1, 100]);
}
var terrainMaterial:TextureMaterial = new TextureMaterial(new BitmapTexture(main_root.UOLoader.images[mXML.terrain[0].@texture].bitmapData));
if(mXML.terrain[0].defusemethod) {
terrainMaterial.diffuseMethod = terrainMethod;
}
terrainMaterial.normalMap = new BitmapTexture(main_root.UOLoader.images[mXML.terrain[0].@normalmap].bitmapData);
terrainMaterial.mipmap = true;
terrainMaterial.ambientColor = 0x303040;
terrainMaterial.ambient = 0.5;
terrainMaterial.specular = .2;
terrainMaterial.lightPicker = main_root.game.lightPicker;
terrainMaterial.addMethod(main_root.game.fogMethod);
terrainMaterial.shadowMethod = main_root.game.filteredShadowMapMethod;
return terrainMaterial;
}
then adding to scene:
ground = new Mesh(new PlaneGeometry(mXML.@height * 75 , mXML.@width * 75, mXML.@height, mXML.@width), mat);
ground.castsShadows = false;
ground.x = mXML.@fromy * 75 + mXML.@width * 75 / 2;
ground.z = mXML.@fromx * 75 + mXML.@height * 75 / 2;
work perfectly but then i place on it my Character mesh with castShadows=true, terrain missing.
2 pics. First without shadow method, the second one with.