Kaynağa Gözat

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

PSp..om 13 yıl önce
ebeveyn
işleme
86a3b0532c
1 değiştirilmiş dosya ile 18 ekleme ve 1 silme
  1. 18 1
      engine/src/core/com/jme3/font/BitmapText.java

+ 18 - 1
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);
+            }
         }
     }
 }