use of org.concord.energy3d.model.PickedHousePart in project energy3d by concord-consortium.
the class SelectUtil method pickPart.
public static PickedHousePart pickPart(final int x, final int y, final Class<?>[] typesOfHousePart) {
pickResults.clear();
final Ray3 pickRay = SceneManager.getInstance().getCamera().getPickRay(new Vector2(x, y), false, null);
for (final Class<?> typeOfHousePart : typesOfHousePart) {
if (typeOfHousePart == null) {
PickingUtil.findPick(SceneManager.getInstance().getLand(), pickRay, pickResults, false);
} else {
for (final HousePart part : Scene.getInstance().getParts()) {
if (!part.getLockEdit() && typeOfHousePart.isInstance(part)) {
PickingUtil.findPick(part.getCollisionSpatial(), pickRay, pickResults, false);
}
}
}
}
final PickedHousePart picked = getPickResultForImportedMesh();
if (picked != null) {
return picked;
}
return getPickResult(pickRay);
}
use of org.concord.energy3d.model.PickedHousePart 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;
}
use of org.concord.energy3d.model.PickedHousePart in project energy3d by concord-consortium.
the class SelectUtil method pickPart.
public static PickedHousePart pickPart(final int x, final int y, final Mesh mesh) {
pickResults.clear();
final Ray3 pickRay = SceneManager.getInstance().getCamera().getPickRay(new Vector2(x, y), false, null);
PickingUtil.findPick(mesh, pickRay, pickResults, false);
final PickedHousePart picked = getPickResultForImportedMesh();
if (picked != null) {
return picked;
}
return getPickResult(pickRay);
}
use of org.concord.energy3d.model.PickedHousePart in project energy3d by concord-consortium.
the class SceneManager method getPickedLocationOnMesh.
Vector3 getPickedLocationOnMesh(final Mesh mesh) {
if (pickMouseState != null) {
final PickedHousePart pick = SelectUtil.pickPart(pickMouseState.getX(), pickMouseState.getY(), mesh);
if (pick != null) {
return pick.getPoint().clone();
}
pickMouseState = null;
}
return null;
}
use of org.concord.energy3d.model.PickedHousePart in project energy3d by concord-consortium.
the class SceneManager method getPickedLocationOnLand.
public Vector3 getPickedLocationOnLand() {
if (pickMouseState != null) {
final PickedHousePart pick = SelectUtil.pickPart(pickMouseState.getX(), pickMouseState.getY(), land);
if (pick != null) {
return pick.getPoint().multiply(1, 1, 0, null);
}
pickMouseState = null;
}
return null;
}
Aggregations