shapes vanishing

hello all! ;D

just a quick one. when i turn my ‘view’ all my shapes seem to vanish before they have
compleaty scrolled off the screen.

i have some BillBoards that are in a TransformGroup they are then put into another bigger
TransformGroup then that is then added to the main BranchGroup.

soon as i move the center point of the bigger TransformGroup off to the side of the
screen all my BillBoards vanish :frowning:

any pointers out there on how i can get around this?

This could well be a bounds computing problem, I’ve had the same thing when the bounds haven’t worked out right.

Kev

well my code is simple at the moment. i would guess its somthing im doing wrong (most of the time it is).



package ant.xith3d.mod;

import javax.vecmath.*;

import com.xith3d.scenegraph.*;

public class ParticleEmitter extends TransformGroup {
  private Transform3D transform = new Transform3D();
  private Vector3f origin = null;

  public ParticleEmitter(Vector3f origin) {
    this.origin = origin;
    transform.setTranslation(this.origin);
    this.setTransform(transform);
  }

  public void makeParticles(int numberOfParticles) {
    float ofs = 50f;
    this.removeAllChildren();

    for(int i = 0; i < numberOfParticles; i++) {
      Vector3f ranorg = new Vector3f((getRandom(ofs)-(ofs/2f)), (getRandom(ofs)-(ofs/2f)), (getRandom(ofs)-(ofs/2f)));
      this.addChild(addParticle(ranorg));
    }
  }

  private Particle addParticle(Vector3f location) {
    Particle p = new Particle(10, new Vector3f(0f, 0f, 0.2f), new Color4f(1f, 1f, 1f, 1f), location);
    p.loadTexture("images/particles/star.png");
    p.setLocation(location);
    return(p);
  }

  public TransformGroup getParticles() {
    return(this);
  }

  private float getRandom(float num) {
    return((float)Math.random()*num);
  }
}




package ant.xith3d.mod;

import com.xith3d.scenegraph.*;

import javax.vecmath.*;

public class Particle extends Plane2D {
  public float lifeTime = 10f;
  public Vector3f vectorSpeed = null;
  public Color4f particleColor = null;

  public Particle(float lifetime, Vector3f speed, Color4f color, Vector3f location) {
    this.lifeTime = lifetime;
    this.vectorSpeed = new Vector3f(speed);
    this.particleColor = new Color4f(color);
  }

  public void setLocation(Vector3f loc) {
    this.getTransform().setTranslation(loc);
  }

  public Particle getParticle() {
    return(this);
  }
}




package ant.xith3d.mod;

import java.awt.image.*;

import com.xith3d.scenegraph.*;
import com.xith3d.loaders.texture.*;

import javax.vecmath.*;

public class Plane2D extends TransformGroup {
  private Material mat = null;
  private TransparencyAttributes ta = null;
  private Texture2D texture = null;
  private TextureLoader tloalder = new TextureLoader();

  public Plane2D() {
    innit();
  }

  public void innit() {
   mat = new Material();
   mat.setLightingEnable(false);
   ta = new TransparencyAttributes();
 }


  public void loadTexture(String textureLocation) {
    BufferedImage bufferedImage = null;
    java.net.URL url = getClass().getResource(textureLocation);
    texture = (Texture2D) TextureLoader.getInstance().getTexture(textureLocation);

    try {
      bufferedImage = javax.imageio.ImageIO.read(url);
    }
    catch (Exception e) {
      try {
        bufferedImage = javax.imageio.ImageIO.read(new java.io.File(
            textureLocation));
      }
      catch (Exception newE) {}
    }


    texture = (Texture2D) tloalder.constructTexture(
        bufferedImage,
        "RGBA",
        false,
        Texture.BASE_LEVEL,
        Texture.BASE_LEVEL_LINEAR,
        Texture.WRAP,
        false,
        TextureLoader.SCALE_DRAW_BEST);

    Appearance app = new Appearance();
    app.setMaterial(mat);
    app.setTexture(texture);

    ta.setTransparencyMode(TransparencyAttributes.BLENDED);
    ta.setDstBlendFunction(TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA);
    ta.setSrcBlendFunction(TransparencyAttributes.BLEND_SRC_ALPHA);
    ta.setTransparency(0.5f);

    app.setTransparencyAttributes(ta);

    Billboard billboard = new Billboard(GeometryArray.COORDINATES |
                                        GeometryArray.TEXTURE_COORDINATE_2,
                                        (float) texture.getWidth() / 10f,
                                        (float) texture.getHeight() / 10f);

    this.addChild(new Shape3D(billboard, app));
  }

  public void setTransparency(float tansparency) {
    ta.setTransparency(tansparency);
  }

  public float getTransparency() {
    return (ta.getTransparency());
  }
}



then the ParticleEmitter is added the the main BranchGroup… simple as that? but i get the bounds problem :frowning:



    Vector3f org = new Vector3f(0f, 0f, 0f);
    ParticleEmitter pm = new ParticleEmitter(org);
    pm.makeParticles(100);
    scene.addChild(pm);


nods head


    float psize = 200f;

    Billboard billboard = new Billboard(GeometryArray.COORDINATES |
                                        GeometryArray.TEXTURE_COORDINATE_2,
                                        psize,
                                        psize);

    billboard.setCachedBounds(new BoundingSphere(new Vector3f(), 200f));

seems to work! :slight_smile: