use of spacegraph.space3d.phys.shape.SimpleBoxShape in project narchy by automenta.
the class Cuboid method onTouch.
@Override
public Surface onTouch(Finger finger, Collidable body, ClosestRay r, short[] buttons, SpaceGraphPhys3D space) {
if (body != null) {
// rotate to match camera's orientation (billboarding)
Object d = body.data();
if (d instanceof SimpleSpatial) {
SimpleSpatial sd = (SimpleSpatial) d;
// Quat4f target = Quat4f.angle(-space.camFwd.x, -space.camFwd.y, -space.camFwd.z, 0);
// Quat4f target = new Quat4f();
// sd.rotate( -space.camFwd.x, -space.camFwd.y, -space.camFwd.z, 0, 0.2f);
// com.jogamp.common.util.SyncedRingbuffer
// Transform bt = body.worldTransform;
// // TODO somehow use the object's local transformation ? sd.transform().getRotation(...);
// target.setAngle(
// space.camFwd.x-bt.x,
// space.camFwd.y - bt.y,
// space.camFwd.z -bt.z,
// (float) Math.PI
// );
//
// target.normalize();
//
// sd.rotate(target, 0.2f); //new Quat4f());
// //System.out.println(" : " + sd.transform().getRotation(new Quat4f()));
}
//
Surface s0 = super.onTouch(finger, body, r, buttons, space);
if (s0 != null)
return s0;
}
if (front != null) {
Transform it = Transform.t(transform).inverse();
v3 localPoint = it.transform(v(r.hitPointWorld));
if (body != null && body.shape() instanceof SimpleBoxShape) {
SimpleBoxShape shape = (SimpleBoxShape) body.shape();
float frontZ = shape.z() / 2;
float zTolerance = frontZ / 4f;
if (Util.equals(localPoint.z, frontZ, zTolerance)) {
// top surface only, ignore sides and back
this.mousePick = r.hitPointWorld;
fingered = finger;
return fingered.on(front, localPoint.x / shape.x() + 0.5f, localPoint.y / shape.y() + 0.5f, buttons);
// return mouseFront.update(null, localPoint.x, localPoint.y, buttons);
}
} else {
if (fingered != null && fingered.off()) {
fingered = null;
}
}
}
return null;
}
Aggregations