Author Topic: How can i read some point position from Mesh?  (Read 5367 times)

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
How can i read some point position from Mesh?
« on: September 23, 2007, 07:20:52 pm »
Hi,

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

Code: [Select]
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can i read some point position from Mesh?
« Reply #1 on: September 24, 2007, 11:18:44 am »
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?

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: How can i read some point position from Mesh?
« Reply #2 on: September 24, 2007, 12:29:34 pm »
Ok, i got it. It's a bit slow because it's need to copy whole Mesh first, but it works.

Thanks

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can i read some point position from Mesh?
« Reply #3 on: September 24, 2007, 12:35:57 pm »
How big that mesh so that copying its data is a performance issue?

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: How can i read some point position from Mesh?
« Reply #4 on: September 24, 2007, 12:51:34 pm »
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.
« Last Edit: September 24, 2007, 01:01:09 pm by Klaudiusz »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can i read some point position from Mesh?
« Reply #5 on: September 24, 2007, 02:51:48 pm »
What do you mean with "when used twice"?

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: How can i read some point position from Mesh?
« Reply #6 on: September 24, 2007, 03:13:09 pm »
For example regarding this source:

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

The oryginal code is:

Code: [Select]
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:

Code: [Select]
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can i read some point position from Mesh?
« Reply #7 on: September 24, 2007, 03:26:15 pm »
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.