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 (408)
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  
  interacting with Dynamic Geometry  (Read 1080 times)
0 Members and 1 Guest are viewing this topic.
Offline khangharoth

Junior Member




There is more to life than JAVA...But Java Rocks


« Posted 2006-08-29 12:39:01 »

Hi,
    their is a interface for interaction with Dynamic geometry    "com.xith3d.scenegraph.GeomInterface" ,
     Is anybody using it for updating Geometry dynamicallly.

         What is the way to implement Dynamic geometry ,
                             say on User Action we want to change location of one Vertex of a Geometry.


   

Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #1 - Posted 2006-08-29 15:20:21 »

Use GeometryUpdater.

This is easy (code not error-proof just mind dump) :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
public class MyGeomModificator implements GeometryUpdater {

  private Geometry geom;

  public MyGeomModificator(Geometry geom) {

    this.geom = geom;

  }

  public void update() {

    geom.update(this);

  }

  public void update(Geometry geom) {

    geom.setVertice(i, new Vector3f());

  }

}


It should be working very well.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline khangharoth

Junior Member




There is more to life than JAVA...But Java Rocks


« Reply #2 - Posted 2006-08-30 17:32:33 »

Thanks for the answer  Smiley
                         Does it make sense that my Shape3D sub classes implements this interface
                          and so responsibility of changing remains within the Shape class.
                Is their any resaon why this interface is not implemented in existing classes.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #3 - Posted 2006-08-30 20:26:02 »

Thanks for the answer  Smiley
                         Does it make sense that my Shape3D sub classes implements this interface
                          and so responsibility of changing remains within the Shape class.
                Is their any resaon why this interface is not implemented in existing classes.
Well it doesn't matter from where update() is called (as long as it is not when the canvas is rendering.
By "existing classes" you mean all those in com.xith3d.* and org.xith3d.* ? Shape3D isn't necessarily dynamic so don't need to implement GeometryUpdater or whatever.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline hawkwind

Junior Member




Java games rock!


« Reply #4 - Posted 2006-08-30 23:19:37 »

while not exactly the same thing you can look at my animated texture demo for an idea on using update calls

http://xith.org/showsrc.php?src=tutes/GettingStarted/examples/TexturesFun/TextureFun3.java

the render loop....


1  
2  
3  
while (true) {
         quadriver.updateData(this);
         view.renderOnce();


the uodating stuff for texture coordinates


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  
public void updateData(Geometry geometry) {
      String filename = "";
      //crds.setFloats(0, fred[0], fred[1], fred[2]);

      GeomDataInterface texCrds0 = quadriver.getTexCoordData(0);
      GeomDataInterface texCrds1 = quadriver.getTexCoordData(1);

      float[] texCoords0 = texCrds0.getFloatData();
      float[] texCoords1 = texCrds1.getFloatData();

      ///////////////////////////////////////
     long tim = System.currentTimeMillis();
      long d = (System.currentTimeMillis() - lastTime);
      float delta = (float) d;
      //System.out.println(
     //   "delta " + delta + " tim " + tim + " lst " + lastTime);
     lastTime = System.currentTimeMillis();
      //
     //         texCoords1 = water.getTextureCoordinates1();
     //         texCoords2 = water.getTextureCoordinates2();
     //
     int tt = 0;

      for (int i = 0; i <= texCoords1.length - 1; i++) {
         float st = texCoords1[i];
         texCoords1[i] = texCoords1[i] + 0.01f; //f * delta;

         if (false) {
            if (tt == 0) {
               tt = 1;

               texCoords1[i] = texCoords1[i] + 0.01f; //f * delta;
           } else {
               tt = 0;
               texCoords1[i] = texCoords1[i] - 0.01f; //f * delta;
           }
         }
         //   System.out.println(i+" st "+st+texCoords1[i]);
     }

      //          texCrds0.setFloats(6, texCoords0[6], texCoords0[7]);

      texCrds1.setFloats(0, texCoords1[0], texCoords1[1]);
      texCrds1.setFloats(2, texCoords1[2], texCoords1[3]);
      texCrds1.setFloats(4, texCoords1[4], texCoords1[5]);
      texCrds1.setFloats(6, texCoords1[6], texCoords1[7]);
      /////////////////
     
     
   }
Offline khangharoth

Junior Member




There is more to life than JAVA...But Java Rocks


« Reply #5 - Posted 2006-08-31 07:04:15 »

Well it doesn't matter from where update() is called (as long as it is not when the canvas is rendering.
By "existing classes" you mean all those in com.xith3d.* and org.xith3d.* ? Shape3D isn't necessarily dynamic so don't need to implement GeometryUpdater or whatever.
            Yaa you are right  Shape3D isn't necessarily dynamic so don't need to implement GeometryUpdater...it does'nt  make sense to have  unnecessary funtionality in the classes.

    Hawkwind , thanks for pointing out the example,will go through this  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!
cubemaster21 (140 views)
2013-05-17 21:29:12

alaslipknot (149 views)
2013-05-16 21:24:48

gouessej (180 views)
2013-05-16 00:53:38

gouessej (173 views)
2013-05-16 00:17:58

theagentd (183 views)
2013-05-15 15:01:13

theagentd (168 views)
2013-05-15 15:00:54

StreetDoggy (212 views)
2013-05-14 15:56:26

kutucuk (236 views)
2013-05-12 17:10:36

kutucuk (235 views)
2013-05-12 15:36:09

UnluckyDevil (240 views)
2013-05-12 05:09:57
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

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

Topic Request
by kutucuk
2013-03-22 21: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.165 seconds with 21 queries.