Font3DRenderState

This isn't much of a contribution, but awhile ago I had to apply renderstates to my font3ds (specifically clipstates). Perhaps we should add this to com.jmex.font3d.effects so that everyone can apply renderstates to their 3d fonts – or maybe I am missing an easier way to do this.



import com.jme.scene.state.RenderState;
import com.jmex.font3d.Font3D;
import com.jmex.font3d.effects.Font3DEffect;

/**
 * This class will apply a RenderState to a font. The reason this
 * has to be done this way is because of some locking/unlocking and other
 * internal things of the Font3D/Text3D.
 *
 * @author aeneas
 *
 */
public class Font3DRenderState implements Font3DEffect
{
   private RenderState rs = null;
   
   public Font3DRenderState(RenderState rs)
   {
      this.rs = rs;
   }

   public void applyEffect(Font3D font)
   {
      boolean mesh_locked = font.isMeshLocked();
      if(mesh_locked)
      {
          font.unlockMesh();
      }
      
      // Apply the render state
      font.getRenderTriMesh().setRenderState(rs);
      
      if(mesh_locked)
      {
          font.lockMesh();
      }
   }
}