Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (563)
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 1348 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 10: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 13: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 15: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 18: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 21: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 05: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.

 

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

The first screenshot will be displayed as a thumbnail.

radar3301 (12 views)
2014-09-21 23:33:17

BurntPizza (29 views)
2014-09-21 02:42:18

BurntPizza (19 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (27 views)
2014-09-20 20:14:06

BurntPizza (31 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

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

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

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!