use of com.ardor3d.scenegraph.Mesh in project energy3d by concord-consortium.
the class Roof method updateDashLinesColor.
public void updateDashLinesColor() {
for (final Spatial roofPart : roofPartsRoot.getChildren()) {
if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
final Node roofPartNode = (Node) roofPart;
final Mesh dashLinesMesh = (Mesh) roofPartNode.getChild(5);
dashLinesMesh.setDefaultColor(ColorRGBA.RED);
}
}
}
use of com.ardor3d.scenegraph.Mesh in project energy3d by concord-consortium.
the class Roof method setPrintVertical.
public void setPrintVertical(final Spatial roofPartNode, final boolean isVertical) {
roofPartPrintVerticalMap.put(roofPartNode, isVertical);
flattenQuadTriangle((Node) roofPartNode, 1.0);
roofPartNode.updateGeometricState(0);
final Mesh roofPartMesh = (Mesh) ((Node) roofPartNode).getChild(0);
final ReadOnlyVector3 center = computeOrientedBoundingBox(roofPartMesh);
orgCenters.put((Node) roofPartNode, center);
}
use of com.ardor3d.scenegraph.Mesh in project energy3d by concord-consortium.
the class HousePart method computeNormalAndKeepOnSurface.
protected ReadOnlyVector3 computeNormalAndKeepOnSurface() {
if (container == null) {
return null;
}
if (container instanceof Rack) {
final Rack rack = (Rack) container;
final PickResults pickResults = new PrimitivePickResults();
final Ray3 ray = new Ray3(getAbsPoint(0).multiplyLocal(1, 1, 0), Vector3.UNIT_Z);
PickingUtil.findPick(container.getCollisionSpatial(), ray, pickResults, false);
if (pickResults.getNumber() != 0) {
final PickData pickData = pickResults.getPickData(0);
final Vector3 p = pickData.getIntersectionRecord().getIntersectionPoint(0);
points.get(0).setZ(p.getZ());
} else {
if (rack.getBaseHeight() < Math.abs(0.5 * rack.getRackHeight() / Scene.getInstance().getAnnotationScale() * Math.sin(Math.toRadians(rack.getTiltAngle())))) {
final Ray3 ray2 = new Ray3(getAbsPoint(0).multiplyLocal(1, 1, 0), Vector3.NEG_UNIT_Z);
PickingUtil.findPick(container.getCollisionSpatial(), ray2, pickResults, false);
if (pickResults.getNumber() != 0) {
final PickData pickData = pickResults.getPickData(0);
final Vector3 p = pickData.getIntersectionRecord().getIntersectionPoint(0);
points.get(0).setZ(p.getZ());
}
}
}
return rack.getNormal();
} else if (container instanceof Roof) {
final Roof roof = (Roof) container;
final int[] editPointToRoofIndex = new int[points.size()];
final PickResults pickResults = new PrimitivePickResults();
for (int i = 0; i < points.size(); i++) {
pickResults.clear();
final Ray3 ray = new Ray3(getAbsPoint(i).multiplyLocal(1, 1, 0), Vector3.UNIT_Z);
for (final Spatial roofPart : roof.getRoofPartsRoot().getChildren()) {
if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
PickingUtil.findPick(((Node) roofPart).getChild(0), ray, pickResults, false);
if (pickResults.getNumber() != 0) {
break;
}
}
}
if (pickResults.getNumber() != 0) {
final PickData pickData = pickResults.getPickData(0);
final Vector3 p = pickData.getIntersectionRecord().getIntersectionPoint(0);
points.get(i).setZ(p.getZ());
final UserData userData = (UserData) ((Spatial) pickData.getTarget()).getUserData();
final int roofPartIndex = userData.getEditPointIndex();
editPointToRoofIndex[i] = roofPartIndex;
}
// find roofPart with most edit points on it
containerRoofIndex = editPointToRoofIndex[0];
if (points.size() > 1) {
containerRoofIndex = 0;
final Map<Integer, Integer> counts = new HashMap<Integer, Integer>(points.size());
for (final int roofIndex : editPointToRoofIndex) {
counts.put(roofIndex, counts.get(roofIndex) == null ? 1 : counts.get(roofIndex) + 1);
}
int highestCount = 0;
for (final int roofIndex : editPointToRoofIndex) {
if (counts.get(roofIndex) > highestCount) {
highestCount = counts.get(roofIndex);
containerRoofIndex = roofIndex;
}
}
}
}
return (ReadOnlyVector3) roof.getRoofPartsRoot().getChild(containerRoofIndex).getUserData();
} else if (container instanceof Foundation) {
final Foundation foundation = (Foundation) container;
final List<Node> nodes = foundation.getImportedNodes();
if (nodes != null) {
final Map<Vector3, ReadOnlyVector3> intersections = new HashMap<Vector3, ReadOnlyVector3>();
final PickResults pickResults = new PrimitivePickResults();
for (final Node n : nodes) {
for (final Spatial s : n.getChildren()) {
if (s instanceof Mesh) {
final Mesh m = (Mesh) s;
pickResults.clear();
PickingUtil.findPick(m, new Ray3(getAbsPoint(0).multiplyLocal(1, 1, 0), Vector3.UNIT_Z), pickResults, false);
if (pickResults.getNumber() > 0) {
intersections.put(pickResults.getPickData(0).getIntersectionRecord().getIntersectionPoint(0), ((UserData) m.getUserData()).getNormal());
}
}
}
}
if (!intersections.isEmpty()) {
double zmax = -Double.MAX_VALUE;
ReadOnlyVector3 normal = null;
for (final Vector3 v : intersections.keySet()) {
if (v.getZ() > zmax) {
zmax = v.getZ();
normal = intersections.get(v);
}
}
if (normal != null) {
pickedNormal = normal;
return normal;
}
}
}
}
return container.getNormal();
}
use of com.ardor3d.scenegraph.Mesh in project energy3d by concord-consortium.
the class MeshLocator method find.
public Mesh find() {
if (foundation.getImportedNodes() == null || foundation.getImportedNodes().isEmpty()) {
return null;
}
Node node = null;
for (final Node n : foundation.getImportedNodes()) {
if (n.getNumberOfChildren() > 0) {
final Spatial s = n.getChild(0);
final Mesh m = (Mesh) s;
final UserData u = (UserData) m.getUserData();
if (u.getNodeIndex() == nodeIndex) {
node = n;
break;
}
}
}
if (node != null) {
for (final Spatial s : node.getChildren()) {
final Mesh m = (Mesh) s;
final UserData u = (UserData) m.getUserData();
if (u.getMeshIndex() == meshIndex) {
return m;
}
}
}
return null;
}
Aggregations