Author Topic: Trouble getting a glow to look correct  (Read 3366 times)

Offline newsomjk

  • byte
  • *
  • Posts: 6
    • View Profile
Trouble getting a glow to look correct
« on: October 11, 2012, 02:23:14 pm »


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:
Code: [Select]
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:
Code: [Select]
TextureManager.getInstance().addTexture("glow",new Texture(this.getClass().getResourceAsStream("resource/glow.png"),true));

any help would be much appreciated

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Trouble getting a glow to look correct
« Reply #1 on: October 11, 2012, 04:53:48 pm »
Can you post the glow texture as well!?

Offline newsomjk

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Trouble getting a glow to look correct
« Reply #2 on: October 12, 2012, 03:19:15 pm »
Yeah sorry,



I've also tried with a black background.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Trouble getting a glow to look correct
« Reply #3 on: October 12, 2012, 06:28:09 pm »
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.

Offline newsomjk

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Trouble getting a glow to look correct
« Reply #4 on: October 12, 2012, 09:11:39 pm »
Ok so I changed it to this, and now nothing shows up:

Code: [Select]
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();
    }
}

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Trouble getting a glow to look correct
« Reply #5 on: October 12, 2012, 09:17:34 pm »
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.

Code: [Select]
plane.rotateX((float) Math.PI/2f);
plane.rotateMesh();
plane.clearRotation();

Offline newsomjk

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Trouble getting a glow to look correct
« Reply #6 on: October 12, 2012, 09:46:02 pm »
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.

Code: [Select]
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Trouble getting a glow to look correct
« Reply #7 on: October 12, 2012, 10:13:49 pm »
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?

Offline newsomjk

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Trouble getting a glow to look correct
« Reply #8 on: October 12, 2012, 11:01:54 pm »
ah gotcha,
Code: [Select]
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();

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Trouble getting a glow to look correct
« Reply #9 on: October 12, 2012, 11:21:55 pm »
Maybe it's PI/2, not -PI/2...as said, i can't remember the planes orientation ATM. Try this:

Code: [Select]
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();

Offline newsomjk

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Trouble getting a glow to look correct
« Reply #10 on: October 13, 2012, 12:31:37 am »
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?
« Last Edit: October 13, 2012, 12:35:48 am by newsomjk »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Trouble getting a glow to look correct
« Reply #11 on: October 13, 2012, 02:38:36 pm »
The texture? You need a sphere with proper texture coordinates for that. It should be easy to find one on the net.