From 86a3b0532c121c16ed116180cf58ea0a5660059e Mon Sep 17 00:00:00 2001 From: "PSp..om" Date: Mon, 24 Sep 2012 18:06:00 +0000 Subject: [PATCH] Save and restore the color in the nifty-optimization method: render(RenderManager rm, ColorRGBA color) So that it doesn't clobber other BitmapText that just happens to be using the font. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9769 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/src/core/com/jme3/font/BitmapText.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/engine/src/core/com/jme3/font/BitmapText.java b/engine/src/core/com/jme3/font/BitmapText.java index a1f9b77ee..c03107210 100644 --- a/engine/src/core/com/jme3/font/BitmapText.java +++ b/engine/src/core/com/jme3/font/BitmapText.java @@ -33,6 +33,7 @@ package com.jme3.font; import com.jme3.font.BitmapFont.Align; import com.jme3.font.BitmapFont.VAlign; +import com.jme3.material.MatParam; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.renderer.RenderManager; @@ -110,7 +111,7 @@ public class BitmapText extends Node { * * @param text String to change text to */ - public void setText(String text) { + public void setText(String text) { text = text == null ? "" : text; if (text == block.getText() || block.getText().equals(text)) { @@ -387,12 +388,28 @@ public class BitmapText extends Node { needRefresh = false; } + private ColorRGBA getColor( Material mat, String name ) { + MatParam mp = mat.getParam(name); + if( mp == null ) { + return null; + } + return (ColorRGBA)mp.getValue(); + } + public void render(RenderManager rm, ColorRGBA color) { + for (BitmapTextPage page : textPages) { Material mat = page.getMaterial(); mat.setTexture("ColorMap", page.getTexture()); + ColorRGBA original = getColor(mat, "Color"); mat.setColor("Color", color); mat.render(page, rm); + + if( original == null ) { + mat.clearParam("Color"); + } else { + mat.setColor("Color", original); + } } } }