# Translating nodes by interaction

Hi,

I’m playing around with the TestBezierMesh demo and my P5 glove to see the potential for a virtual sculpting demo.

(inspired by the shape editor http://www.axel.nm.ru/p5glove/programs/manual.html )

I tried collision detection first, but then thought I might just see if you can do some form of distance related checking between the p5 glove cursor and target bezier patch node. Selection of the node is also triggered by using one of the glove fingers.

Code snip and output is below:

float distance = p5node.getLocalTranslation().distance(t4.getLocalTranslation());

if (FastMath.abs(distance) < 6.0f && input.getP5().getFingers()[0][0] > 50) {

t4.setLocalScale(3.0f);

t4.setLocalTranslation(deltaPos);

bez.tessellate();

System.out.println("t4 pos - " + t4.getLocalTranslation());

}

else {

t4.setLocalScale(1.0f);

System.out.println("t4 pos - " + t4.getLocalTranslation());

}

Example output:

t4 pos - com.jme.math.Vector3f [X=-2.2637925, Y=-2.7097688, Z=-1.9720104]

t4 pos - com.jme.math.Vector3f [X=-2.6870944, Y=-2.5143986, Z=-2.3953123]

t4 pos - com.jme.math.Vector3f [X=-2.6870944, Y=-2.5143986, Z=-2.3953123]

t4 pos - com.jme.math.Vector3f [X=-2.6870944, Y=-2.5143986, Z=-2.3953123]

t4 pos - com.jme.math.Vector3f [X=-4.2349854, Y=-2.3736813, Z=-3.3803337]

t4 pos - com.jme.math.Vector3f [X=-4.2349854, Y=-2.3736813, Z=-3.3803337]

t4 pos - com.jme.math.Vector3f [X=-4.2349854, Y=-2.3736813, Z=-3.3803337]

t4 pos - com.jme.math.Vector3f [X=0.0, Y=0.0, Z=0.0]

t4 pos - com.jme.math.Vector3f [X=0.0, Y=0.0, Z=0.0]

t4 pos - com.jme.math.Vector3f [X=0.0, Y=0.0, Z=0.0]

t4 pos - com.jme.math.Vector3f [X=0.0, Y=0.0, Z=0.0]

t4 pos - com.jme.math.Vector3f [X=0.0, Y=0.0, Z=0.0]

t4 pos - com.jme.math.Vector3f [X=0.0, Y=0.0, Z=0.0]

t4 pos - com.jme.math.Vector3f [X=0.0, Y=0.0, Z=0.0]

t4 pos - com.jme.math.Vector3f [X=0.0, Y=0.0, Z=0.0]

t4 pos - com.jme.math.Vector3f [X=0.0, Y=0.0, Z=0.0]

t4 pos - com.jme.math.Vector3f [X=0.0, Y=0.0, Z=0.0]

Two problems:

. translating the node in tandem with the glove cursor, triggered by distance threshold and finger, works ok - but when I let the finger up the target node jumps to position 0,0,0 instead of locking at the last position - as seen above. Clicking the finger again, while maintaining cursor position, snaps the node back to it’s last position. ??? Something to do with patches?

. translating the bezier patch node as above and doing a bez.tessellate() seems to have no effect on the patch structure. Any ideas?

I have done a rootNode.updateGeometricState(0.0f, true); at the end of simpleUpdate but no effect.

Am I missing something obvious here? Any help appreciated.

Many thanks,

pc

Question… why not use a regular Trimesh since Bezier is based on a curve formula rather than something arbitrarily molded.

That’s my next test, but I wanted to see what the pros and cons of bezier mesh real time manipulation were.

as far as the node’s local translation being reset, I don’t see anything obvious from what you have posted. Try printing out deltaPos components as the come in just to get as much info as possible.

oops…bp.setAnchor(0, 3, t4.getLocalTranslation()); does the trick on the bezier patch updating and re-tessellation.

Can’ t seem to see anything obvious in the components infro, but I’ll keep looking.