Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (576)
games submitted by our members
Games in WIP (498)
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 740 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.

 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (18 views)
2014-04-15 18:08:23

BurntPizza (15 views)
2014-04-15 03:46:01

UprightPath (28 views)
2014-04-14 17:39:50

UprightPath (13 views)
2014-04-14 17:35:47

Porlus (29 views)
2014-04-14 15:48:38

tom_mai78101 (54 views)
2014-04-10 04:04:31

BurntPizza (111 views)
2014-04-08 23:06:04

tom_mai78101 (212 views)
2014-04-05 13:34:39

trollwarrior1 (181 views)
2014-04-04 12:06:45

CJLetsGame (187 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
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!