use of com.ardor3d.intersection.Pickable in project energy3d by concord-consortium.
the class Foundation method pickMesh.
public void pickMesh(final int x, final int y) {
selectedMesh = null;
if (importedNodes != null) {
final PickResults pickResults = new PrimitivePickResults();
pickResults.setCheckDistance(true);
final Ray3 pickRay = SceneManager.getInstance().getCamera().getPickRay(new Vector2(x, y), false, null);
for (final Node node : importedNodes) {
for (final Spatial s : node.getChildren()) {
if (s instanceof Mesh) {
PickingUtil.findPick(s, pickRay, pickResults, false);
}
}
}
if (pickResults.getNumber() > 0) {
final Pickable pickable = pickResults.getPickData(0).getTarget();
if (pickable instanceof Mesh) {
selectedMesh = (Mesh) pickable;
drawMeshSelection(selectedMesh);
}
} else {
setMeshSelectionVisible(false);
}
}
}
use of com.ardor3d.intersection.Pickable in project energy3d by concord-consortium.
the class SelectUtil method getPickResultForImportedMesh.
// if this is an imported mesh, do it here. getPickResult method below returns incorrect result.
private static PickedHousePart getPickResultForImportedMesh() {
if (pickResults.getNumber() > 0) {
final PickData pick = pickResults.getPickData(0);
final Pickable pickable = pick.getTarget();
if (pickable instanceof Mesh) {
final Mesh m = (Mesh) pickable;
final UserData u = (UserData) m.getUserData();
// the user data of land can be null
if (u != null && u.isImported()) {
return new PickedHousePart(u, pick.getIntersectionRecord().getIntersectionPoint(0), u.getRotatedNormal() == null ? u.getNormal() : u.getRotatedNormal());
}
}
}
return null;
}
Aggregations