Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
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 794 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

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« 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.

 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (23 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!