Modifying the mesh during drawing process

Started by Thomas., February 25, 2012, 01:00:13 AM

Previous topic - Next topic

Thomas.

I have problem with GenericVertexController. I use these parts of code, but nothing happened, what magic is for modify of objects mesh? :)

I create object by this
build();
compile(true);
waterMesh = this.getMesh();
waterMesh.setVertexController(new Modificator(), false);


modify
public void apply() {
     SimpleVector[] s = getSourceMesh();
     SimpleVector[] d = getDestinationMesh();
     for (int i = 0; i < polyCount; i++) {
   SimpleVector cd = d[i];
   SimpleVector cs = s[i];
   cd.x = cs.x;
   cd.y = height[i];
   cd.z = cs.z;
     }
}


and in every frame is caled waterMesh.applyVertexController();

EgonOlsen

You have to call Object3D.touch() after applying the controller.

Thomas.

Nothing is happened...
waterMesh.applyVertexController();
this.touch();

EgonOlsen

Switch the calls to build and compile or assign the controller before calling build. jPCT auto-detects if an object needs dynamic compilation. If no controller and no animation has been attached, it will use static compilation. The later call to compile doesn't change that anymore.

Thomas.

Thanks, thanks, it looks nicer than I expected :) But surface is very dark, I look at it...

Thomas.

#5
I also copy source normals to destination, but still it is dark. When I call calcNormals() every frame everything is OK, but very slow... And next problem is, that I create plane with 10*10 square (two triangle), mesh have 121 vertices, but I think, that should be 100?
edit: Oh, I created same plane in 3Ds Max and of course it also have 121 :-[ But normals is still bad

EgonOlsen

Try to add a calcNormals(); before assigning the controller. Getting this in the correct order can be a bit tricky and isn't very intuitive, but i couldn't find a better solution yet...

Thomas.


Thomas.

Is there any way how to faster calculating normals? It is almost flat plane...

EgonOlsen

You can always set them on your own in the controller. Apart from that, no. Normal calculation is pretty much optimized as it is.

Thomas.

Ok thanks, and how can I hide message about calculation normals from logger?

EgonOlsen

You can change the log level, but that will suppress other messages too.

Thomas.

In javadoc for method calcNormals() is wroted about two different methods for calculating the normals and about configuration of this with optimizeNormalCalcTH value in Config, but in Config isn't this value.

EgonOlsen

jPCT-AE only uses one method for this, the docs are outdated. I'll fix them.

Thomas.

#14
OK, and could you are add support for multi thread calculating normals, please? I mean, that not so time demanding to implement this, thanks :)