@ -71,6 +71,7 @@ public class RenderDeviceJme implements RenderDevice {
private final Quad quad = new Quad ( 1 , - 1 , true ) ;
private final Quad quad = new Quad ( 1 , - 1 , true ) ;
private final Geometry quadGeom = new Geometry ( "nifty-quad" , quad ) ;
private final Geometry quadGeom = new Geometry ( "nifty-quad" , quad ) ;
private final Material niftyMat ;
private final Material niftyMat ;
private final Material niftyQuadMat ;
private boolean clipWasSet = false ;
private boolean clipWasSet = false ;
private BlendMode blendMode = null ;
private BlendMode blendMode = null ;
@ -93,8 +94,10 @@ public class RenderDeviceJme implements RenderDevice {
quadModTC . setUsage ( Usage . Stream ) ;
quadModTC . setUsage ( Usage . Stream ) ;
niftyMat = new Material ( display . getAssetManager ( ) , "Common/MatDefs/Nifty/Nifty.j3md" ) ;
niftyMat = new Material ( display . getAssetManager ( ) , "Common/MatDefs/Nifty/NiftyTex .j3md" ) ;
niftyMat . getAdditionalRenderState ( ) . setDepthTest ( false ) ;
niftyMat . getAdditionalRenderState ( ) . setDepthTest ( false ) ;
niftyQuadMat = new Material ( display . getAssetManager ( ) , "Common/MatDefs/Nifty/NiftyQuad.j3md" ) ;
niftyQuadMat . getAdditionalRenderState ( ) . setDepthTest ( false ) ;
}
}
public void setResourceLoader ( NiftyResourceLoader niftyResourceLoader ) {
public void setResourceLoader ( NiftyResourceLoader niftyResourceLoader ) {
@ -211,7 +214,6 @@ public class RenderDeviceJme implements RenderDevice {
@Override
@Override
public void renderFont ( RenderFont font , String str , int x , int y , Color color , float sizeX , float sizeY ) {
public void renderFont ( RenderFont font , String str , int x , int y , Color color , float sizeX , float sizeY ) {
//TODO find out what the f1 param is for
if ( str . length ( ) = = 0 )
if ( str . length ( ) = = 0 )
return ;
return ;
@ -230,7 +232,6 @@ public class RenderDeviceJme implements RenderDevice {
textCacheCurrentFrame . put ( key , text ) ;
textCacheCurrentFrame . put ( key , text ) ;
niftyMat . setColor ( "Color" , convertColor ( color , tempColor ) ) ;
niftyMat . setColor ( "Color" , convertColor ( color , tempColor ) ) ;
niftyMat . setBoolean ( "UseTex" , true ) ;
niftyMat . getAdditionalRenderState ( ) . setBlendMode ( RenderState . BlendMode . Alpha ) ;
niftyMat . getAdditionalRenderState ( ) . setBlendMode ( RenderState . BlendMode . Alpha ) ;
// niftyMat.getAdditionalRenderState().setBlendMode(convertBlend());
// niftyMat.getAdditionalRenderState().setBlendMode(convertBlend());
text . setMaterial ( niftyMat ) ;
text . setMaterial ( niftyMat ) ;
@ -238,8 +239,10 @@ public class RenderDeviceJme implements RenderDevice {
float width = text . getLineWidth ( ) ;
float width = text . getLineWidth ( ) ;
float height = text . getLineHeight ( ) ;
float height = text . getLineHeight ( ) ;
float x0 = x + 0 . 5f * width * ( 1f - sizeX ) ;
// System.out.println("----------------------------------------------------");
float y0 = y + 0 . 5f * height * ( 1f - sizeY ) ;
// System.out.println("POS "+x+" "+width+" "+sizeX);
float x0 = x + 0 . 5f * width * ( 1 . 0f - sizeX ) ;
float y0 = y + 0 . 5f * height * ( 1 . 0f - sizeY ) ;
tempMat . loadIdentity ( ) ;
tempMat . loadIdentity ( ) ;
tempMat . setTranslation ( x0 , getHeight ( ) - y0 , 0 ) ;
tempMat . setTranslation ( x0 , getHeight ( ) - y0 , 0 ) ;
@ -261,7 +264,6 @@ public class RenderDeviceJme implements RenderDevice {
niftyMat . getAdditionalRenderState ( ) . setBlendMode ( convertBlend ( ) ) ;
niftyMat . getAdditionalRenderState ( ) . setBlendMode ( convertBlend ( ) ) ;
niftyMat . setColor ( "Color" , ColorRGBA . White ) ;
niftyMat . setColor ( "Color" , ColorRGBA . White ) ;
niftyMat . setTexture ( "Texture" , texture ) ;
niftyMat . setTexture ( "Texture" , texture ) ;
niftyMat . setBoolean ( "UseTex" , true ) ;
setColor ( color ) ;
setColor ( color ) ;
float imageWidth = jmeImage . getWidth ( ) ;
float imageWidth = jmeImage . getWidth ( ) ;
@ -308,7 +310,6 @@ public class RenderDeviceJme implements RenderDevice {
niftyMat . getAdditionalRenderState ( ) . setBlendMode ( convertBlend ( ) ) ;
niftyMat . getAdditionalRenderState ( ) . setBlendMode ( convertBlend ( ) ) ;
niftyMat . setColor ( "Color" , ColorRGBA . White ) ;
niftyMat . setColor ( "Color" , ColorRGBA . White ) ;
niftyMat . setTexture ( "Texture" , jmeImage . getTexture ( ) ) ;
niftyMat . setTexture ( "Texture" , jmeImage . getTexture ( ) ) ;
niftyMat . setBoolean ( "UseTex" , true ) ;
setColor ( color ) ;
setColor ( color ) ;
quad . clearBuffer ( Type . TexCoord ) ;
quad . clearBuffer ( Type . TexCoord ) ;
@ -328,10 +329,8 @@ public class RenderDeviceJme implements RenderDevice {
}
}
public void renderQuad ( int x , int y , int width , int height , Color color ) {
public void renderQuad ( int x , int y , int width , int height , Color color ) {
niftyMat . getAdditionalRenderState ( ) . setBlendMode ( convertBlend ( ) ) ;
niftyQuadMat . getAdditionalRenderState ( ) . setBlendMode ( convertBlend ( ) ) ;
niftyMat . setColor ( "Color" , ColorRGBA . White ) ;
niftyQuadMat . setColor ( "Color" , ColorRGBA . White ) ;
niftyMat . clearParam ( "Texture" ) ;
niftyMat . setBoolean ( "UseTex" , false ) ;
setColor ( color ) ;
setColor ( color ) ;
tempMat . loadIdentity ( ) ;
tempMat . loadIdentity ( ) ;
@ -339,7 +338,7 @@ public class RenderDeviceJme implements RenderDevice {
tempMat . setScale ( width , height , 0 ) ;
tempMat . setScale ( width , height , 0 ) ;
rm . setWorldMatrix ( tempMat ) ;
rm . setWorldMatrix ( tempMat ) ;
niftyMat . render ( quadGeom , rm ) ;
niftyQuad Mat . render ( quadGeom , rm ) ;
// System.out.println("renderQuad (Solid)");
// System.out.println("renderQuad (Solid)");
}
}
@ -359,17 +358,15 @@ public class RenderDeviceJme implements RenderDevice {
buf . flip ( ) ;
buf . flip ( ) ;
quadColor . updateData ( buf ) ;
quadColor . updateData ( buf ) ;
niftyMat . getAdditionalRenderState ( ) . setBlendMode ( convertBlend ( ) ) ;
niftyQuadMat . getAdditionalRenderState ( ) . setBlendMode ( convertBlend ( ) ) ;
niftyMat . setColor ( "Color" , ColorRGBA . White ) ;
niftyQuadMat . setColor ( "Color" , ColorRGBA . White ) ;
niftyMat . clearParam ( "Texture" ) ;
niftyMat . setBoolean ( "UseTex" , false ) ;
tempMat . loadIdentity ( ) ;
tempMat . loadIdentity ( ) ;
tempMat . setTranslation ( x , getHeight ( ) - y , 0 ) ;
tempMat . setTranslation ( x , getHeight ( ) - y , 0 ) ;
tempMat . setScale ( width , height , 0 ) ;
tempMat . setScale ( width , height , 0 ) ;
rm . setWorldMatrix ( tempMat ) ;
rm . setWorldMatrix ( tempMat ) ;
niftyMat . render ( quadGeom , rm ) ;
niftyQuad Mat . render ( quadGeom , rm ) ;
//
//
// System.out.println("renderQuad (Grad)");
// System.out.println("renderQuad (Grad)");
}
}