My HUD problems

i never did it myself, but there are similar topics on the board like placing the name tag above a player and such.

Either use an ortho quad like you did, but then you need to convert the enemy (3d) coordinates to screen coordinates (2d).



Or use a Billboard Quad which is rendered in 3d and always aligned to the viewer.



i'd use the 2nd option as there is a sample Class someone posted which you can use see the links in ths thread :slight_smile:

Right. So im trying to use the textlabel example. I believe the code needs a bit of changing for jme2.0 and have done quite a bit of it myself. However im still stuck with one part - the bit of converting the FloatBuffer to texCoords on this method:




public Quad getQuad(float height){
        Vector2f scales = new Vector2f();
        BufferedImage img = getImage(scales);
        float w = img.getWidth() * scales.x;
        float h = img.getHeight() * scales.y;
        float factor = height / h;
        Quad ret = new Quad("textLabel2d", w * factor , h * factor);
        TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
        Texture tex = TextureManager.loadTexture(img, Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear, true);
       
        FloatBuffer texCo = ret.getTextureBuffer(0, 0);
        FloatBuffer newTC = BufferUtils.createFloatBuffer(texCo.limit());
        texCo.rewind();
        for(int i=0; i<texCo.limit(); i+=2){
            float u = texCo.get();
            float v = texCo.get();
            newTC.put(u*scales.x);
            newTC.put(v*scales.y);
        }
        ret.setTextureBuffer(0, newTC);
        ret.updateGeometricState(0, true);
       
//        tex.setScale(new Vector3f(scales.x, scales.y, 1));
        ts.setTexture(tex);
        ts.setEnabled(true);
        ret.setRenderState(ts);
       
        ret.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
       
        BlendState bs = DisplaySystem.getDisplaySystem().getRenderer().createBlendState();
        // activate blending
        bs.setBlendEnabled(true);
        // set the source function
        bs.setSourceFunctionAlpha(BlendState.SourceFunction.SourceAlpha);
        // set the destination function
        bs.setDestinationFunctionAlpha(BlendState.DestinationFunction.OneMinusSourceAlpha);
        bs.setTestEnabled(false);
        bs.setEnabled(true);
        ret.setRenderState(bs);
       
        ret.setLightCombineMode(Spatial.LightCombineMode.Off);
        ret.updateRenderState();
        return ret;
    }



In particular :


FloatBuffer texCo = ret.getTextureBuffer(0, 0);
        FloatBuffer newTC = BufferUtils.createFloatBuffer(texCo.limit());
        texCo.rewind();
        for(int i=0; i<texCo.limit(); i+=2){
            float u = texCo.get();
            float v = texCo.get();
            newTC.put(u*scales.x);
            newTC.put(v*scales.y);
        }
        ret.setTextureBuffer(0, newTC);
        ret.updateGeometricState(0, true);



I have studied the example from the hud tutorial which was changed and updated however I cannot work out what this example should be converted into to make it function correctly.

Please help,

Andy

JME Games threads seem to be grabbing more attention than support threads :frowning: bumpedy bump

just comment the TextureCoords stuff out for now :slight_smile:



i don't think its needed at all is it ?

got it showing at least, but if its not needed at all, why is it there at all? }:-@