use of com.ardor3d.scenegraph.Spatial in project energy3d by concord-consortium.
the class SceneManager method initMouse.
private void initMouse() {
logicalLayer.registerTrigger(new InputTrigger(new MouseButtonPressedCondition(MouseButton.LEFT), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
((Component) canvas).requestFocusInWindow();
if (Config.isMac()) {
// control-click is mouse right-click on the Mac, skip
final KeyboardState ks = inputStates.getCurrent().getKeyboardState();
if (ks.isDown(Key.LCONTROL) || ks.isDown(Key.RCONTROL)) {
return;
}
}
if (firstClickState == null) {
firstClickState = inputStates;
mousePressed(inputStates.getCurrent().getMouseState(), inputStates.getCurrent().getKeyboardState());
} else {
firstClickState = null;
mouseReleased(inputStates.getCurrent().getMouseState());
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new MouseButtonReleasedCondition(MouseButton.LEFT), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (Config.isMac()) {
// control-click is mouse right-click on the Mac, skip
final KeyboardState ks = inputStates.getCurrent().getKeyboardState();
if (ks.isDown(Key.LCONTROL) || ks.isDown(Key.RCONTROL)) {
return;
}
}
// if editing object using select or resize then only mouse drag is allowed
if (operation == Operation.SELECT || operation == Operation.RESIZE) {
firstClickState = null;
mouseReleased(inputStates.getCurrent().getMouseState());
} else if (firstClickState != null) {
final MouseState mouseState = inputStates.getCurrent().getMouseState();
final MouseState prevMouseState = firstClickState.getCurrent().getMouseState();
final ReadOnlyVector2 p1 = new Vector2(prevMouseState.getX(), prevMouseState.getY());
final ReadOnlyVector2 p2 = new Vector2(mouseState.getX(), mouseState.getY());
if (!(selectedPart instanceof Foundation || selectedPart instanceof Wall || selectedPart instanceof Window || selectedPart instanceof Door) || p1.distance(p2) > 10) {
firstClickState = null;
mouseReleased(inputStates.getCurrent().getMouseState());
}
}
}
}));
((Component) canvas).addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
if (Util.isRightClick(e)) {
mouseRightClicked(e);
}
}
@Override
public void mouseReleased(final MouseEvent e) {
if (Util.isRightClick(e)) {
if (cameraChanged) {
TimeSeriesLogger.getInstance().logCamera("Pan");
cameraChanged = false;
}
}
}
});
((Component) canvas).addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(final MouseEvent e) {
EnergyPanel.getInstance().update();
cameraChanged = true;
}
});
((Component) canvas).addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(final MouseWheelEvent e) {
TimeSeriesLogger.getInstance().logCamera("Zoom");
}
});
logicalLayer.registerTrigger(new InputTrigger(new MouseMovedCondition(), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
refresh = true;
mouseState = inputStates.getCurrent().getMouseState();
}
}));
logicalLayer.registerTrigger(new InputTrigger(new MouseButtonClickedCondition(MouseButton.LEFT), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (Config.isMac()) {
// control-click is mouse right-click on the Mac, skip
final KeyboardState ks = inputStates.getCurrent().getKeyboardState();
if (ks.isDown(Key.LCONTROL) || ks.isDown(Key.RCONTROL)) {
return;
}
}
if (!isTopView() && inputStates.getCurrent().getMouseState().getClickCount(MouseButton.LEFT) == 2) {
if (PrintController.getInstance().isPrintPreview()) {
final MouseState mouse = inputStates.getCurrent().getMouseState();
final Ray3 pickRay = Camera.getCurrentCamera().getPickRay(new Vector2(mouse.getX(), mouse.getY()), false, null);
final PickResults pickResults = new PrimitivePickResults();
PickingUtil.findPick(PrintController.getInstance().getPagesRoot(), pickRay, pickResults, false);
if (pickResults.getNumber() > 0) {
cameraControl.zoomAtPoint(pickResults.getPickData(0).getIntersectionRecord().getIntersectionPoint(0));
}
} else {
final PickedHousePart pickedHousePart = SelectUtil.pickPart(inputStates.getCurrent().getMouseState().getX(), inputStates.getCurrent().getMouseState().getY());
if (pickedHousePart != null) {
cameraControl.zoomAtPoint(pickedHousePart.getPoint());
}
}
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.LSHIFT), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
// SelectUtil.setPickLayer(0);
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.LSHIFT), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
// SelectUtil.setPickLayer(-1);
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.DELETE), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
deleteCurrentSelection();
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.BACK), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
deleteCurrentSelection();
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyHeldCondition(Key.ESCAPE), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
hideAllEditPoints();
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
final KeyboardState ks = inputStates.getCurrent().getKeyboardState();
if (Config.isMac()) {
if (ks.isDown(Key.LMETA) || ks.isDown(Key.RMETA)) {
resetCamera();
}
} else {
if (ks.isDown(Key.LCONTROL) || ks.isDown(Key.RCONTROL)) {
resetCamera();
}
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.I), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
System.out.println("---- Parts: ------------------------");
System.out.println("size = " + Scene.getInstance().getParts().size());
for (final HousePart part : Scene.getInstance().getParts()) {
System.out.println(part);
}
System.out.println("---- Scene: ------------------------");
System.out.println("size = " + Scene.getOriginalHouseRoot().getNumberOfChildren());
for (final Spatial mesh : Scene.getOriginalHouseRoot().getChildren()) {
System.out.println(mesh);
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
Scene.getInstance().redrawAll(true);
}
}));
// Run/pause model replay
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (PlayControl.active) {
PlayControl.replaying = !PlayControl.replaying;
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.LEFT), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (PlayControl.active) {
PlayControl.replaying = false;
PlayControl.backward = true;
}
if (isTopView()) {
if (tooManyPartsToMove()) {
moveWithKey(inputStates.getCurrent().getKeyboardState(), new Vector3(-1, 0, 0));
} else {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
arrowKeyHolderTask = new KeyHolderTask(inputStates.getCurrent().getKeyboardState(), new Vector3(-1, 0, 0));
keyHolder.scheduleAtFixedRate(arrowKeyHolderTask, 0, keyHolderInterval);
}
} else {
if (selectedPart instanceof Window) {
final Vector3 v = selectedPart.getNormal().clone();
v.crossLocal(Vector3.UNIT_Z);
moveWithKey(inputStates.getCurrent().getKeyboardState(), v);
Scene.getInstance().redrawAll();
}
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.LEFT), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.UP), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (PlayControl.active) {
PlayControl.replaying = false;
PlayControl.backward = true;
}
if (isTopView()) {
if (tooManyPartsToMove()) {
moveWithKey(inputStates.getCurrent().getKeyboardState(), new Vector3(0, 1, 0));
} else {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
arrowKeyHolderTask = new KeyHolderTask(inputStates.getCurrent().getKeyboardState(), new Vector3(0, 1, 0));
keyHolder.scheduleAtFixedRate(arrowKeyHolderTask, 0, keyHolderInterval);
}
} else {
if (selectedPart instanceof Window) {
final Vector3 n = selectedPart.getNormal().clone();
final Vector3 v = n.cross(Vector3.UNIT_Z, null);
moveWithKey(inputStates.getCurrent().getKeyboardState(), v.crossLocal(n));
Scene.getInstance().redrawAll();
}
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.UP), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.RIGHT), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (PlayControl.active) {
PlayControl.replaying = false;
PlayControl.forward = true;
}
if (isTopView()) {
if (tooManyPartsToMove()) {
moveWithKey(inputStates.getCurrent().getKeyboardState(), new Vector3(1, 0, 0));
} else {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
arrowKeyHolderTask = new KeyHolderTask(inputStates.getCurrent().getKeyboardState(), new Vector3(1, 0, 0));
keyHolder.scheduleAtFixedRate(arrowKeyHolderTask, 0, keyHolderInterval);
}
} else {
if (selectedPart instanceof Window) {
final Vector3 v = selectedPart.getNormal().clone();
v.crossLocal(Vector3.UNIT_Z).negateLocal();
moveWithKey(inputStates.getCurrent().getKeyboardState(), v);
Scene.getInstance().redrawAll();
}
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.RIGHT), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.DOWN), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (PlayControl.active) {
PlayControl.replaying = false;
PlayControl.forward = true;
}
if (isTopView()) {
if (tooManyPartsToMove()) {
moveWithKey(inputStates.getCurrent().getKeyboardState(), new Vector3(0, -1, 0));
} else {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
arrowKeyHolderTask = new KeyHolderTask(inputStates.getCurrent().getKeyboardState(), new Vector3(0, -1, 0));
keyHolder.scheduleAtFixedRate(arrowKeyHolderTask, 0, keyHolderInterval);
}
} else {
if (selectedPart instanceof Window) {
final Vector3 n = selectedPart.getNormal().clone();
final Vector3 v = n.cross(Vector3.UNIT_Z, null).negateLocal();
moveWithKey(inputStates.getCurrent().getKeyboardState(), v.crossLocal(n));
Scene.getInstance().redrawAll();
}
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.DOWN), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ESCAPE), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
PlayControl.active = false;
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.W), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (tooManyPartsToMove()) {
moveWithKey(inputStates.getCurrent().getKeyboardState(), new Vector3(-1, 0, 0));
} else {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
arrowKeyHolderTask = new KeyHolderTask(inputStates.getCurrent().getKeyboardState(), new Vector3(-1, 0, 0));
keyHolder.scheduleAtFixedRate(arrowKeyHolderTask, 0, keyHolderInterval);
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.W), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.E), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (tooManyPartsToMove()) {
moveWithKey(inputStates.getCurrent().getKeyboardState(), new Vector3(1, 0, 0));
} else {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
arrowKeyHolderTask = new KeyHolderTask(inputStates.getCurrent().getKeyboardState(), new Vector3(1, 0, 0));
keyHolder.scheduleAtFixedRate(arrowKeyHolderTask, 0, keyHolderInterval);
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.E), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.S), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (tooManyPartsToMove()) {
moveWithKey(inputStates.getCurrent().getKeyboardState(), new Vector3(0, -1, 0));
} else {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
arrowKeyHolderTask = new KeyHolderTask(inputStates.getCurrent().getKeyboardState(), new Vector3(0, -1, 0));
keyHolder.scheduleAtFixedRate(arrowKeyHolderTask, 0, keyHolderInterval);
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.S), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.N), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (tooManyPartsToMove()) {
moveWithKey(inputStates.getCurrent().getKeyboardState(), new Vector3(0, 1, 0));
} else {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
arrowKeyHolderTask = new KeyHolderTask(inputStates.getCurrent().getKeyboardState(), new Vector3(0, 1, 0));
keyHolder.scheduleAtFixedRate(arrowKeyHolderTask, 0, keyHolderInterval);
}
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.N), new TriggerAction() {
@Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (arrowKeyHolderTask != null) {
arrowKeyHolderTask.cancel();
}
}
}));
}
use of com.ardor3d.scenegraph.Spatial in project energy3d by concord-consortium.
the class Roof method drawOutline.
protected void drawOutline() {
if (container == null) {
return;
}
for (final Spatial roofPart : roofPartsRoot.getChildren()) {
if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
final Node roofPartNode = (Node) roofPart;
final Mesh outlineMesh = (Mesh) roofPartNode.getChild(4);
final Mesh mesh = (Mesh) roofPartNode.getChild(0);
final ArrayList<ReadOnlyVector3> outlinePoints = MeshLib.computeOutline(mesh.getMeshData().getVertexBuffer());
int totalVertices = outlinePoints.size();
for (final HousePart part : children) {
if (part instanceof Window) {
totalVertices += 8;
}
}
final FloatBuffer buf;
if (outlineMesh.getMeshData().getVertexBuffer().capacity() >= totalVertices * 2 * 3) {
buf = outlineMesh.getMeshData().getVertexBuffer();
buf.limit(buf.capacity());
buf.rewind();
} else {
buf = BufferUtils.createVector3Buffer(totalVertices * 2);
outlineMesh.getMeshData().setVertexBuffer(buf);
}
// draw roof outline
for (int i = 0; i < outlinePoints.size(); i++) {
final ReadOnlyVector3 p1 = outlinePoints.get(i);
final ReadOnlyVector3 p2 = outlinePoints.get((i + 1) % outlinePoints.size());
buf.put(p1.getXf()).put(p1.getYf()).put(p1.getZf());
buf.put(p2.getXf()).put(p2.getYf()).put(p2.getZf());
}
// draw skylights outline
final int[] windowIndices = new int[] { 0, 2, 3, 1 };
for (final HousePart part : children) {
if (part instanceof Window && part.isDrawable() && ((Window) part).getRoofIndex() == ((UserData) mesh.getUserData()).getEditPointIndex()) {
for (int i = 0; i < part.getPoints().size(); i++) {
final ReadOnlyVector3 p1 = part.getAbsPoint(windowIndices[i]);
final ReadOnlyVector3 p2 = part.getAbsPoint(windowIndices[(i + 1) % part.getPoints().size()]);
buf.put(p1.getXf()).put(p1.getYf()).put(p1.getZf());
buf.put(p2.getXf()).put(p2.getYf()).put(p2.getZf());
}
}
}
buf.limit(buf.position());
outlineMesh.getMeshData().updateVertexCount();
outlineMesh.updateModelBound();
}
}
}
use of com.ardor3d.scenegraph.Spatial in project energy3d by concord-consortium.
the class Roof method fits.
@Override
protected boolean fits(final HousePart window) {
for (final Spatial roofPart : roofPartsRoot.getChildren()) {
if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
final Mesh mesh = (Mesh) ((Node) roofPart).getChild(0);
final ArrayList<ReadOnlyVector3> outlinePoints = MeshLib.computeOutline(mesh.getMeshData().getVertexBuffer());
boolean allInside = true;
boolean allOutside = true;
for (int i = 0; i < window.getPoints().size(); i++) {
final Vector3 p = window.getAbsPoint(i);
roofPart.getWorldTransform().applyInverse(p);
if (Util.insidePolygon(p, outlinePoints)) {
allOutside = false;
} else {
allInside = false;
}
}
if (!allInside && !allOutside) {
return false;
}
}
}
return true;
}
use of com.ardor3d.scenegraph.Spatial in project energy3d by concord-consortium.
the class Roof method drawMesh.
@Override
protected void drawMesh() {
// undo the effect of wall stretch on all walls if roof is moved to new walls
if (previousContainer != container) {
previousContainer = container;
for (final Wall wall : walls) {
wall.setRoof(null);
wall.draw();
}
}
dashPointsCache.clear();
if (wallUpperPoints == null) {
wallUpperPoints = new ArrayList<ReadOnlyVector3>();
} else {
wallUpperPoints.clear();
}
if (container != null) {
initWallUpperPoints((Wall) container, walls, wallUpperPoints, wallNormals);
}
if (!isDrawable()) {
roofPartsRoot.getSceneHints().setCullHint(CullHint.Always);
setEditPointsVisible(false);
return;
}
roofPartsRoot.getSceneHints().setCullHint(CullHint.Inherit);
final ArrayList<Vector3> orgPoints = new ArrayList<Vector3>(points.size());
for (final ReadOnlyVector3 p : points) {
orgPoints.add(p.clone());
}
wallUpperPointsWithoutOverhang = new ArrayList<ReadOnlyVector3>(wallUpperPoints);
drawRoof();
switch(type) {
case TRANSPARENT:
for (final Spatial child : roofPartsRoot.getChildren()) {
((Mesh) ((Node) child).getChild(0)).getSceneHints().setCullHint(CullHint.Always);
((Mesh) ((Node) child).getChild(REAL_MESH_INDEX)).getSceneHints().setCullHint(CullHint.Always);
}
break;
default:
for (final Spatial child : roofPartsRoot.getChildren()) {
((Mesh) ((Node) child).getChild(0)).getSceneHints().setCullHint(CullHint.Inherit);
((Mesh) ((Node) child).getChild(REAL_MESH_INDEX)).getSceneHints().setCullHint(CullHint.Inherit);
}
}
roofPartsRoot.updateWorldBound(true);
drawOutline();
if (Scene.getInstance().areDashedLinesOnRoofShown()) {
drawDashLines();
} else {
for (final Spatial roofPart : roofPartsRoot.getChildren()) {
if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
final Mesh dashLinesMesh = (Mesh) ((Node) roofPart).getChild(5);
dashLinesMesh.setVisible(false);
}
}
}
}
use of com.ardor3d.scenegraph.Spatial in project energy3d by concord-consortium.
the class Roof method drawHeatFlux.
@Override
public void drawHeatFlux() {
FloatBuffer arrowsVertices = heatFlux.getMeshData().getVertexBuffer();
final Foundation foundation = getTopContainer();
final int cols = (int) Math.max(2, foundation.getAbsPoint(0).distance(foundation.getAbsPoint(2)) / Scene.getInstance().getHeatVectorGridSize());
final int rows = (int) Math.max(2, foundation.getAbsPoint(0).distance(foundation.getAbsPoint(1)) / Scene.getInstance().getHeatVectorGridSize());
arrowsVertices = BufferUtils.createVector3Buffer(rows * cols * 6);
heatFlux.getMeshData().setVertexBuffer(arrowsVertices);
final ReadOnlyVector3 o = foundation.getAbsPoint(0);
final ReadOnlyVector3 u = foundation.getAbsPoint(2).subtract(o, null);
final ReadOnlyVector3 v = foundation.getAbsPoint(1).subtract(o, null);
final Vector3 a = new Vector3();
double g, h;
boolean init = true;
for (int j = 0; j < cols; j++) {
h = j + 0.5;
for (int i = 0; i < rows; i++) {
g = i + 0.5;
a.setX(o.getX() + g * v.getX() / rows + h * u.getX() / cols);
a.setY(o.getY() + g * v.getY() / rows + h * u.getY() / cols);
a.setZ(o.getZ());
if (insideWalls(a.getX(), a.getY(), init)) {
ReadOnlyVector3 b = null;
Node node = null;
Mesh mesh = null;
for (final Spatial child : roofPartsRoot.getChildren()) {
if (child.getSceneHints().getCullHint() != CullHint.Always) {
node = (Node) child;
mesh = (Mesh) node.getChild(REAL_MESH_INDEX);
b = findRoofIntersection(mesh, a);
if (b != null) {
break;
}
}
}
if (b != null) {
final ReadOnlyVector3 normal = (ReadOnlyVector3) node.getUserData();
final double heat = calculateHeatVector(mesh);
drawArrow(b, normal, arrowsVertices, heat);
}
}
if (init) {
init = false;
}
}
heatFlux.getMeshData().updateVertexCount();
heatFlux.updateModelBound();
}
updateHeatFluxVisibility();
}
Aggregations