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 (407)
games submitted by our members
Games in WIP (293)
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  
  Odd bug with geometry updates.  (Read 647 times)
0 Members and 1 Guest are viewing this topic.
Offline Alfryd

Junior Member





« Posted 2005-10-17 19:56:31 »

Probably best if you just take a look for yourself.  It hangs, inexplicably, once it's live and I call the updateData method for the geometry (down near the end.)  All the appropriate capability bits seem to be set, I'm at a loss.

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  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
  
 
  /*  Very basic rectangular piece of geometry that displays a single texture.  */
  static class Element extends Shape3D implements GeometryUpdater {
   
    final static Color3f WHITE = new Color3f(1, 1, 1);
    final static Color3f BLACK = new Color3f(0, 0, 0);
    final static int CAPABILITIES = GeometryArray.COORDINATES |
                                    GeometryArray.BY_REFERENCE |
                                    GeometryArray.TEXTURE_COORDINATE_2;
    final static TransparencyAttributes TRANSATT = TRANSATT();
    final static TransparencyAttributes TRANSATT() {
      TransparencyAttributes transAtt = new TransparencyAttributes();
      transAtt.setTransparencyMode(TransparencyAttributes.BLENDED);
      return transAtt;
    }
    final static TextureAttributes TEXATT = TEXATT();
    final static TextureAttributes TEXATT() {
      TextureAttributes texAtt = new TextureAttributes();
      texAtt.setTextureMode(TextureAttributes.MODULATE);
      texAtt.setTextureBlendColor(1, 1, 1, 1);
      return texAtt;
    }
    final static RenderingAttributes RENDATT = RENDATT();
    final static RenderingAttributes RENDATT() {
      RenderingAttributes rendAtt = new RenderingAttributes();
      rendAtt.setIgnoreVertexColors(true);
      return rendAtt;
    }
    final static PolygonAttributes POLYATT = POLYATT();
    final static PolygonAttributes POLYATT() {
      PolygonAttributes polyatt = new PolygonAttributes();
      polyatt.setCullFace(PolygonAttributes.CULL_NONE);
      return polyatt;
    }  //Should be common to all elements.
    final static Material MATERIAL = new Material(BLACK, WHITE, BLACK, BLACK, 0); //only emissive colour shows.
    final static float UV[] = {
      0, 0,
      0, 1,
      1, 0,
      0, 1,
      1, 0,
      1, 1
    };
    //final static Vector3f NORMALS[] = { NORMAL, NORMAL, NORMAL, NORMAL, NORMAL, NORMAL };
   
    float xpos, ypos, xdim, ydim, depth;
   
    Point3f c1 = new Point3f(), c2 = new Point3f(), c3 = new Point3f(), c4 = new Point3f(), corners[] = new Point3f[6];
    float coordinates[] = new float[18];
   
    TriangleArray geometry;
    Appearance surface;
   
   
    Element(float xp, float xd, float yp, float yd, float deep, Texture texture) {
      depth = 0 - deep;
     
      corners[0] = c1;
      corners[1] = c2;
      corners[2] = c3;
      corners[3] = c2;
      corners[4] = c3;
      corners[5] = c4;
     
      surface = new Appearance();
      surface.setTexture(texture);
      surface.setTextureAttributes(TEXATT);
      surface.setMaterial(MATERIAL);
      surface.setTransparencyAttributes(TRANSATT);
      surface.setRenderingAttributes(RENDATT);
      surface.setPolygonAttributes(POLYATT);
     
      geometry = new TriangleArray(6, CAPABILITIES);
      geometry.setCoordRefFloat(coordinates);
      geometry.setTexCoordRefFloat(0, UV);
     
      setGeometry(geometry);
      setAppearance(surface);
      geometry.setCapability(GeometryArray.ALLOW_REF_DATA_READ);
      geometry.setCapability(GeometryArray.ALLOW_REF_DATA_WRITE);
     
      reset(xp, xd, yp, yd);
    }
   
    void position(float xp, float yp) {
      xpos = xp;
      ypos = yp;
      reset();
    }
    void resize(float xd, float yd) {
      xdim = xd;
      ydim = yd;
      reset();
    }
    void reset(float xp, float xd, float yp, float yd) {
      xpos = xp;
      ypos = yp;
      xdim = xd;
      ydim = yd;
      reset();
    }
    void reset() {
      float xmax = xpos + xdim, ymax = ypos + ydim;
      c1.set(xpos, ypos, depth);
      c2.set(xpos, ymax, depth);
      c3.set(xmax, ypos, depth);
      c4.set(xmax, ymax, depth);
      update();
    }
   
   
    void update() {
      System.out.println("updating data?");
      geometry.updateData(this);  //_HANGS HERE._
      System.out.println("done.");
    }
   
    public void updateData(Geometry data) {  //argument unused.
      System.out.println("updating data!");
      int entry = 0, c = 0;
      Point3f corner;
      while(c < 6) {
        corner = corners[c++];
        coordinates[entry++] = corner.x;
        coordinates[entry++] = corner.y;
        coordinates[entry++] = corner.z;
      }
    }
  }
Offline Alfryd

Junior Member





« Reply #1 - Posted 2005-10-20 14:20:52 »

Ah, my apologies.  I just realised I was indirectly calling the update() method from within the preRender() method of a subclassed Canvas3D.  Which is illegal.  Should have said.  Never mind.
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!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

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!
cubemaster21 (92 views)
2013-05-17 12:29:12

alaslipknot (100 views)
2013-05-16 12:24:48

gouessej (130 views)
2013-05-15 15:53:38

gouessej (125 views)
2013-05-15 15:17:58

theagentd (136 views)
2013-05-15 06:01:13

theagentd (124 views)
2013-05-15 06:00:54

StreetDoggy (165 views)
2013-05-14 06:56:26

kutucuk (187 views)
2013-05-12 08:10:36

kutucuk (190 views)
2013-05-12 06:36:09

UnluckyDevil (197 views)
2013-05-11 20:09:57
Complex number cookbook
by Roquen
2013-04-24 03:47:31

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

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

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

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

Noise (bandpassed white)
by Roquen
2013-04-03 07:17:38

Java Data structures
by Roquen
2013-03-29 04:21:12

Topic Request
by kutucuk
2013-03-22 12:42:01
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!
Page created in 0.287 seconds with 21 queries.