Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (416)
games submitted by our members
Games in WIP (306)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  shapes vanishing  (Read 631 times)
0 Members and 1 Guest are viewing this topic.
Offline aNt

Senior Member




AFK


« Posted 2004-06-09 18:26:29 »

hello all!  Grin

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 Sad

any pointers out there on how i can get around this?
Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #1 - Posted 2004-06-09 18:34:39 »

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

Kev

Offline aNt

Senior Member




AFK


« Reply #2 - Posted 2004-06-09 18:43:35 »

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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
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);
  }
}


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
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);
  }
}


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
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 Sad

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


*nods head*
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline aNt

Senior Member




AFK


« Reply #3 - Posted 2004-06-13 21:34:16 »

1  
2  
3  
4  
5  
6  
7  
8  
    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! Smiley
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Try the Free Demo of Revenge of the Titans

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
Jesse_Attard (12 views)
2013-06-18 22:03:02

HeroesGraveDev (56 views)
2013-06-15 23:35:23

Vermeer (56 views)
2013-06-14 20:08:06

davedes (55 views)
2013-06-14 16:03:55

alaslipknot (50 views)
2013-06-13 07:56:31

Roquen (71 views)
2013-06-12 04:12:32

alaslipknot (56 views)
2013-06-10 19:30:18

HeroesGraveDev (73 views)
2013-06-09 04:36:03

alaslipknot (60 views)
2013-06-09 03:40:19

CodeHead (60 views)
2013-06-09 02:55:41
Smoothing Algorithm Question
by UprightPath
2013-05-28 02:58:26

Smoothing Algorithm Question
by UprightPath
2013-05-28 02:57:33

Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!