How can i read some point position from Mesh?

Started by Klaudiusz, September 23, 2007, 07:20:52 PM

Previous topic - Next topic

Klaudiusz

Hi,

I want to read point position from the Mesh. I used VertexController:

private class getPointPosition extends GenericVertexController {
 
     int PointNr;
     
     getPointPosition(int Nr) {
       PointNr=Nr;
     }

     public void apply() {
       SimpleVector[] srcMesh=this.getSourceMesh();
       System.out.println(srcMesh[PointNr]);
       }

}


I works, i mean it read the SimpleVector, but i want to return srcMesh[PointNr]. Unfortunatelly apply() can't return anything.

Is there some other way to do this?

EgonOlsen

The PolygonManager can do something similar, but it returns the values in world space, which may not be what you want. Why don't you abuse the VertexController a little in a way that you apply it once, store the mesh data and add a method that returns a given point from the stored data, or something like that?

Klaudiusz

Ok, i got it. It's a bit slow because it's need to copy whole Mesh first, but it works.

Thanks

EgonOlsen

How big that mesh so that copying its data is a performance issue?

Klaudiusz

#4
It's some 28000 points. I would like to use part of them as as particles position.

btw.seems like PRESERVE_SOURCE_MESH doesn't work. It works exactly like ALTER_SOURCE_MESH when used twice.

EgonOlsen


Klaudiusz

For example regarding this source:

http://www.jpct.net/forum2/index.php/topic,58.0.html

The oryginal code is:

DemoVertexControlerr demoControl = new DemoVertexControlerr();
obj.getMesh().setVertexController(demoControl,IVertexController.PRESERVE_SOURCE_MESH);
obj.setOrigin(new SimpleVector(0, 0, 0));
obj.getMesh().applyVertexController();


i used VertexController twice:

DemoVertexControlerr demoControl = new DemoVertexControlerr();
obj.getMesh().setVertexController(demoControl,IVertexController.PRESERVE_SOURCE_MESH);
obj.setOrigin(new SimpleVector(0, 0, 0));
obj.getMesh().applyVertexController();
obj.getMesh().applyVertexController(); //used again


If i understood the documentation correclty, no matter how many times VertexController with option PRESERVE_SOURCE_MESH is used, effects is still the same because source Mesh=oryginal Mesh.

So the object should be the same, but has bigger waves.

EgonOlsen

The vertex controller reads the mesh's data directly from the mesh when initializing. When doing this with a modified mesh, it reads them from the modified mesh in the modified form. Then mesh preservation happens in the context of the controller, not in the mesh. The docs may be a bit misleading regarding this. I'll see if i can find a better wording.