Search in sources :

Example 1 with Pickable

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);
        }
    }
}
Also used : PrimitivePickResults(com.ardor3d.intersection.PrimitivePickResults) ReadOnlyVector2(com.ardor3d.math.type.ReadOnlyVector2) Vector2(com.ardor3d.math.Vector2) Spatial(com.ardor3d.scenegraph.Spatial) Pickable(com.ardor3d.intersection.Pickable) Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh) PrimitivePickResults(com.ardor3d.intersection.PrimitivePickResults) PickResults(com.ardor3d.intersection.PickResults) Ray3(com.ardor3d.math.Ray3)

Example 2 with Pickable

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;
}
Also used : UserData(org.concord.energy3d.model.UserData) Pickable(com.ardor3d.intersection.Pickable) Mesh(com.ardor3d.scenegraph.Mesh) PickData(com.ardor3d.intersection.PickData) PickedHousePart(org.concord.energy3d.model.PickedHousePart)

Aggregations

Pickable (com.ardor3d.intersection.Pickable)2 Mesh (com.ardor3d.scenegraph.Mesh)2 PickData (com.ardor3d.intersection.PickData)1 PickResults (com.ardor3d.intersection.PickResults)1 PrimitivePickResults (com.ardor3d.intersection.PrimitivePickResults)1 Ray3 (com.ardor3d.math.Ray3)1 Vector2 (com.ardor3d.math.Vector2)1 ReadOnlyVector2 (com.ardor3d.math.type.ReadOnlyVector2)1 Node (com.ardor3d.scenegraph.Node)1 Spatial (com.ardor3d.scenegraph.Spatial)1 PickedHousePart (org.concord.energy3d.model.PickedHousePart)1 UserData (org.concord.energy3d.model.UserData)1