Search in sources :

Example 6 with PickedHousePart

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);
}
Also used : Vector2(com.ardor3d.math.Vector2) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) Ray3(com.ardor3d.math.Ray3) PickedHousePart(org.concord.energy3d.model.PickedHousePart)

Example 7 with PickedHousePart

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;
}
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)

Example 8 with PickedHousePart

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);
}
Also used : Vector2(com.ardor3d.math.Vector2) Ray3(com.ardor3d.math.Ray3) PickedHousePart(org.concord.energy3d.model.PickedHousePart)

Example 9 with PickedHousePart

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;
}
Also used : PickedHousePart(org.concord.energy3d.model.PickedHousePart)

Example 10 with PickedHousePart

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;
}
Also used : PickedHousePart(org.concord.energy3d.model.PickedHousePart)

Aggregations

PickedHousePart (org.concord.energy3d.model.PickedHousePart)18 HousePart (org.concord.energy3d.model.HousePart)12 Foundation (org.concord.energy3d.model.Foundation)8 Ray3 (com.ardor3d.math.Ray3)5 Vector2 (com.ardor3d.math.Vector2)5 UserData (org.concord.energy3d.model.UserData)5 Vector3 (com.ardor3d.math.Vector3)4 Window (org.concord.energy3d.model.Window)4 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)3 Roof (org.concord.energy3d.model.Roof)3 MouseState (com.ardor3d.input.MouseState)2 PickData (com.ardor3d.intersection.PickData)2 Mesh (com.ardor3d.scenegraph.Mesh)2 CullHint (com.ardor3d.scenegraph.hint.CullHint)2 Component (java.awt.Component)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 CustomRoof (org.concord.energy3d.model.CustomRoof)2 GambrelRoof (org.concord.energy3d.model.GambrelRoof)2 HipRoof (org.concord.energy3d.model.HipRoof)2