VertexController

Started by tomzwo, March 09, 2005, 04:08:04 PM

Previous topic - Next topic

tomzwo

Since I need non-uniform scaling, I implemented a simple vertex controller based on the sample found under http://www.jpct.net/forum/viewtopic.php?t=58&sid=32df672d03d554c73d05aea39064604e

However, the apply() method gets never called (I check this via some System.out.println()). Contrary to the mentioned sample, I use this not with a  plane but with a cylinder.

source parts:

Object3D tmp = new Object3D(source[n]);
tmp.build();
NUScale scaler = new NUScale(this, middle);
if(tmp.getMesh().setVertexController(scaler, IVertexController.PRESERVE_SOURCE_MESH) == false)
         return(null);

// ....

public class NUScale extends GenericVertexController
{
//...
 public void apply()
 {
   env.debug("NUScale.apply");
  }
// ...

(never mind that the source looks strange - I've omitted a few things)

While we're at it: a few more questions on VertexControllers (please forgive me if some answers may be found elsewhere):

- what about other modifications applied to the object (i.e. translate() and rotate()) - are they reflected into the mesh/normals? if so, what is the order?

- are the vector coordinates in sourceMesh / sourceNormals world-coordinates or object-coordinates?

Thanks in advance
-------------
Tom

EgonOlsen

Well, the example that i've written in that thread ommits an important step: How to apply the assigned controller... :wink: But it's quite simple. Just call
applyVertexController(); on the Object3D's Mesh and it will be applied.
Vertices and normals in the controller are all in object space, so that transformations don't matter. If you need to pre-transform the object, have a look at rotateMesh() and translateMesh() in Object3D.

tomzwo

that explains a lot (I might have fond it had I looked closely at the Mesh documentation...) I'll try it first thing tomorrow.

Did I get this right: applying VertexController Things and other transformations go together quite well? That would make things very easy: translate and rotate with the standard methods - (btw: being able to set the rotation pivot spot is very useful) and do some non-uniform scaling with VertexController.

Something else: I found a - in my eyes - rather smart solution for the obstacle of not being able to apply colors to objects. Interested, anyone? if(InterestList.length > 0) postExample();

Regards
-------------
Tom

EgonOlsen

Quote from: "tomzwo"Did I get this right: applying VertexController Things and other transformations go together quite well? That would make things very easy: translate and rotate with the standard methods - (btw: being able to set the rotation pivot spot is very useful) and do some non-uniform scaling with VertexController.
That's the way it's supposed to work.

QuoteSomething else: I found a - in my eyes - rather smart solution for the obstacle of not being able to apply colors to objects. Interested, anyone? if(InterestList.length > 0) postExample();
I'm not sure what you mean, but i think that i'm interested... :wink:

tomzwo

tried it and it works like a charm (exactly as you described it) - thank you very much.

Regarding the color thingy: see other post
-------------
Tom