Hi I am trying to place a geometry in my scene based on the location of the end of a line in a pivot node, but without much luck.
I created a pivot node which is given its location and rotation from VR controller. In the pivot node is a geometry showit where I draw a line,the length of the lidar reading, down the z axis of showit . I want to place a geometry at the end of the line in the rootNode space, but I can’t figure out how to get that end point ( location vector ) in world space or rootNode space. I can see the point or where the placement should be, but how do I get the vector in the rootNode space so I can place a geometry at that location.
Node pivot;
Line l3 = new Line(Vector3f.ZERO, new Vector3f(0f, 0f, .01f));
private Geometry line;
Geometry showit;
showit = new Geometry("Ball", smallSphere);
showit.setMaterial(mat);
showit.setLocalRotation(new Quaternion(0.47458643f, -0.001760408f, 9.491699E-4f, 0.8802066f));
Geometry zline = new Geometry("Line", l3);
pivot = new Node(“pivot node”);
pivot.setLocalRotation(new Quaternion(0.47458643f, -0.001760408f, 9.491699E-4f, 0.8802066f));
pivot.attachChild(leftHand);
line = new Geometry(“Line”, smallSphere);
pivot.attachChild(line);
rootNode.attachChild(pivot);
// Update pivot
Quaternion q = VRApplication.getVRinput().getFinalObserverRotation(index);
Vector3f v = VRApplication.getVRinput().getFinalObserverPosition(index);
if (q != null && v != null) {
Q1 = q.clone();
v1 = v.clone();
pivot.setCullHint(CullHint.Dynamic); // make sure we see it
pivot.setLocalTranslation(v);
pivot.setLocalRotation(q);
}
// In a thread updating lidar reading
lidar = distance / 100.0f;// convert centimeters to meters
x = Float.parseFloat(data[1]);
y = Float.parseFloat(data[2]);
z = Float.parseFloat(data[3]);
w = Float.parseFloat(data[4]);
accuracy = Float.parseFloat(data[5]);
Q1.set(x, y, z, w);
if (showit != null) {
v1 = zline.getLocalTranslation().add(new Vector3f(0f, 0f, lidar));
//v1 = Q1.mult(v1);
direction = new Line(showit.getLocalTranslation(), v1);
}
// In the simpleUpdate method
zline.setLocalTranslation(showit.getLocalTranslation());emphasized text
zline.setLocalRotation(showit.getLocalRotation());
if (direction != null) {
line = new Geometry("liDarMeasure", direction);
line.setMaterial(mat);
line.setLocalRotation(showit.getLocalRotation());
}
pivot.detachAllChildren();
pivot.attachChild(zline);
pivot.attachChild(line);
pivot.attachChild(showit);