Trouble getting a glow to look correct

Started by newsomjk, October 11, 2012, 02:23:14 PM

Previous topic - Next topic

newsomjk



This is the horrible glow that I'm getting. The issues are that 1) it's a square of color? but the texture is transparent background with lightning bolts on it. and 2) It's sooooo dim?!

What am I doing wrong? Here's the code for the glowing object:
public void createGlow(){
    if(model!=null){
          glow = new Object3D(2);

            float off = 25;
            float zoff = 5;
           
             glow.addTriangle(new SimpleVector(-off,-off,-zoff),
            new SimpleVector(-off,off,-zoff),
            new SimpleVector(off,off,-zoff)
            );
            glow.addTriangle(new SimpleVector(off,off,-zoff),
            new SimpleVector(off,-off,-zoff),
            new SimpleVector(-off,-off,-zoff)
            );
           
            glow.setBillboarding(Object3D.BILLBOARDING_ENABLED);
            glow.setTexture("glow");
            glow.translate(model.getTransformedCenter());
            glow.setTransparency(0);
            glow.setTransparencyMode(Object3D.TRANSPARENCY_MODE_ADD);

            glow.setLighting( Object3D.LIGHTING_NO_LIGHTS);
            glow.setAdditionalColor( new Color( 255,255,255) );
            glow.build();
    }
}


and the code for loading the texture:

TextureManager.getInstance().addTexture("glow",new Texture(this.getClass().getResourceAsStream("resource/glow.png"),true));



any help would be much appreciated

EgonOlsen


newsomjk

Yeah sorry,



I've also tried with a black background.

EgonOlsen

Your object has no texture coordinates, so the whole plane will be textured with the pixel at 0,0. You might want to use a plane created by the Primitives class instead of add coordinates to your own one.

newsomjk

Ok so I changed it to this, and now nothing shows up:


public void createGlow(){
    if(model!=null){
glow = Primitives.getPlane(2,3f);
            float off = 25;
            float zoff = 5;
           
            glow.setBillboarding(Object3D.BILLBOARDING_ENABLED);
            glow.setTexture("glow");
            glow.translate(model.getTransformedCenter());
            glow.setTransparency(0);
            glow.setTransparencyMode(Object3D.TRANSPARENCY_MODE_ADD);

            glow.setLighting( Object3D.LIGHTING_NO_LIGHTS);
            glow.setAdditionalColor( new Color( 255,255,255) );
            glow.build();
    }
}

EgonOlsen

I'm not sure which is the default orientation of the plane....try to rotate it -PI/2 around x and make rotation permanent, i.e.


plane.rotateX((float) Math.PI/2f);
plane.rotateMesh();
plane.clearRotation();

newsomjk

Still nothing, if it helps any I changed the object to a sphere and tried just the plain white texture and that looks fine, nice and bright but still translucent but I want to get the lightning bolt appearance on the sphere and that texture still just shows a dim yellow.


glow = Primitives.getSphere(6,25f);
           
            glow.setTexture("glow");
            glow.translate(model.getTransformedCenter());
            glow.setTransparency(0);
            glow.setTransparencyMode(Object3D.TRANSPARENCY_MODE_ADD);

            glow.setLighting( Object3D.LIGHTING_NO_LIGHTS);
            glow.setAdditionalColor( new Color( 255,255,255) );
            glow.build();


Am I loading the texture incorrectly somehow?

EgonOlsen

No, all is fine with the texture. No object from Primitives except for the plane has texture coordinates, so your sphere has the problem as your own plane. It has to work with the plane from Primitives though. Can you post the code that includes the rotation, please?

newsomjk

ah gotcha,

glow = Primitives.getPlane(2,3f);
            float off = 25;
            float zoff = 5;
           
            glow.setBillboarding(Object3D.BILLBOARDING_ENABLED);
            glow.setTexture("glow");
            glow.translate(model.getTransformedCenter());
            glow.setTransparency(0);
            glow.setTransparencyMode(Object3D.TRANSPARENCY_MODE_ADD);
   
            glow.setLighting( Object3D.LIGHTING_NO_LIGHTS);
            glow.setAdditionalColor( new Color( 255,255,255) );
            glow.rotateX((float) (Math.PI*-1)/2f);
            glow.rotateMesh();
            glow.clearRotation();
            glow.build();

EgonOlsen

Maybe it's PI/2, not -PI/2...as said, i can't remember the planes orientation ATM. Try this:


glow = Primitives.getPlane(2,3f);
            float off = 25;
            float zoff = 5;
           
                    glow.rotateX((float) Math.PI/2f);
            glow.rotateMesh();
            glow.clearRotation();
                    glow.setCulling(false);

            glow.setBillboarding(Object3D.BILLBOARDING_ENABLED);
            glow.setTexture("glow");
            glow.translate(model.getTransformedCenter());
            glow.setTransparency(0);
            glow.setTransparencyMode(Object3D.TRANSPARENCY_MODE_ADD);
   
            glow.setLighting( Object3D.LIGHTING_NO_LIGHTS);
            glow.setAdditionalColor( new Color( 255,255,255) );
       
            glow.build();

newsomjk

#10
nothing =( Tried Pi/2 -Pi/2 and tried without rotation all without culling set to false. I'll try and keep reading the api and figure it out.

EDIT--
Sorry, scale was just too small. Got em showing now, so I'm gonna mess with the rotation. thanks for the help!

Guess my last question is how would I go about attaching this to a sphere?

EgonOlsen

The texture? You need a sphere with proper texture coordinates for that. It should be easy to find one on the net.