interacting with Dynamic Geometry

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.

Use GeometryUpdater.

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


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.

Thanks for the answer :slight_smile:
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.

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…

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

the uodating stuff for texture coordinates


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]);
		/////////////////
		
		
	}

[quote="<MagicSpark.org [ BlueSky ]>,post:4,topic:28207"]
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.
[/quote]
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  :)