I am trying to hide a simple BSPTree's material when it is only used
for BSP and a separate more complex model is used for the visual.
My initial approach was to modify AWData to make it store the BSPTree
with the material ( currently it seems to store null as the mesh ),
but the material id name does not seem to be stored on the handle, so
you have to trace out the name so after some modifications I was able
to hack hiding....
(CentralMaterialLibrary.getBSPTreeFromMaterialName( 'building' ) as
BSPTree
).replaceMaterial(CentralMaterialLibrary.getMaterial( 'building' ),
new MovieMaterial(new MovieClip()), true );
but this is probably not really cutting down on render. Looking in
BSPTree I found I could directly modify the material of each face to
reduce rendering, so my current solution is to add this method to
BSPTree, when loaded I can access it via (AWData.handle as
BSPTree).hide();
public function hide()
{
var loop:int = _faces.length;
var face: Face;
var wire: WireframeMaterial = new WireframeMaterial();
wire.wireAlpha = 0;
for(var i:int = 0;i<loop;++i)
{
face = _faces[i];
face.back = null;
// minimize drawn faces
face.invert();
face.material = wire;
}
}
I am considering creating a NullMaterial as currently when I set
face.material = null it trys to be too helpful and instead renders a
color wireframe, for the moment alpha simple wireframe inverted with
no back is probably lowest overhead.
Maybe I am missing something obvious, but if you try to visible false
the whole BSPTree then I think it stops doing BSP collisions, maybe
there is already a solution.... or a better approach.
Cheers
:j