use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class CustomRoof method processRoofEditPoints.
@Override
protected void processRoofEditPoints(final List<? extends ReadOnlyVector3> wallUpperPoints) {
if (recalculateEditPoints) {
recalculateEditPoints = false;
points.clear();
points.add(toRelative(getCenter()));
// add or update edit points
final int n = wallUpperPoints.size();
for (int i = 0; i < n; i++) {
final ReadOnlyVector3 p1 = wallUpperPoints.get(i);
final ReadOnlyVector3 p2 = wallUpperPoints.get((i + 1) % n);
// middle of wall = (p1 + p2) / 2
final Vector3 v = new Vector3(p1.getX() + p2.getX(), p1.getY() + p2.getY(), 0).multiplyLocal(0.5);
// add -normal*0.2 to middle point of wall
final HousePart wall = findGableWall(p1, p2);
if (wall != null) {
final ReadOnlyVector3 normal = wall.getNormal();
v.addLocal(normal.multiply(0.2, null).negateLocal());
}
v.set(toRelative(v));
points.add(v);
}
computeHeight(wallUpperPoints);
applyHeight();
} else {
applyHeight();
}
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Floor method setPreviewPoint.
@Override
public void setPreviewPoint(final int x, final int y) {
final Foundation foundation = getTopContainer();
if (foundation != null && foundation.getLockEdit()) {
return;
}
pickContainer(x, y, Wall.class);
if (container != null) {
final ReadOnlyVector3 base = getCenter();
final Vector3 p = Util.closestPoint(base, Vector3.UNIT_Z, x, y);
if (p == null) {
return;
}
snapToGrid(p, base, getGridSize());
final double zMin = container.getAbsPoint(0).getZ() + 0.5;
final double zmax = container.getAbsPoint(1).getZ();
height = Math.min(zmax, Math.max(zMin, p.getZ()));
}
draw();
setEditPointsVisible(container != null);
final Foundation f = getTopContainer();
if (f != null) {
f.draw();
// need to redraw the walls when the floor is part of a balcony
f.drawChildren();
}
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Foundation method drawSideMesh.
private void drawSideMesh() {
final FloatBuffer vertexBuffer0 = sideMesh[0].getMeshData().getVertexBuffer();
final FloatBuffer vertexBuffer1 = sideMesh[1].getMeshData().getVertexBuffer();
final FloatBuffer vertexBuffer2 = sideMesh[2].getMeshData().getVertexBuffer();
final FloatBuffer vertexBuffer3 = sideMesh[3].getMeshData().getVertexBuffer();
vertexBuffer0.rewind();
vertexBuffer1.rewind();
vertexBuffer2.rewind();
vertexBuffer3.rewind();
final Vector3 p0 = getAbsPoint(0);
final Vector3 p1 = getAbsPoint(1);
final Vector3 p2 = getAbsPoint(2);
final Vector3 p3 = getAbsPoint(3);
vertexBuffer0.put(p0.getXf()).put(p0.getYf()).put((float) height);
vertexBuffer0.put(p0.getXf()).put(p0.getYf()).put(0f);
vertexBuffer0.put(p2.getXf()).put(p2.getYf()).put(0f);
vertexBuffer0.put(p2.getXf()).put(p2.getYf()).put(0f);
vertexBuffer0.put(p2.getXf()).put(p2.getYf()).put((float) height);
vertexBuffer0.put(p0.getXf()).put(p0.getYf()).put((float) height);
vertexBuffer1.put(p2.getXf()).put(p2.getYf()).put((float) height);
vertexBuffer1.put(p2.getXf()).put(p2.getYf()).put(0f);
vertexBuffer1.put(p3.getXf()).put(p3.getYf()).put(0f);
vertexBuffer1.put(p3.getXf()).put(p3.getYf()).put(0f);
vertexBuffer1.put(p3.getXf()).put(p3.getYf()).put((float) height);
vertexBuffer1.put(p2.getXf()).put(p2.getYf()).put((float) height);
vertexBuffer2.put(p3.getXf()).put(p3.getYf()).put((float) height);
vertexBuffer2.put(p3.getXf()).put(p3.getYf()).put(0f);
vertexBuffer2.put(p1.getXf()).put(p1.getYf()).put(0f);
vertexBuffer2.put(p1.getXf()).put(p1.getYf()).put(0f);
vertexBuffer2.put(p1.getXf()).put(p1.getYf()).put((float) height);
vertexBuffer2.put(p3.getXf()).put(p3.getYf()).put((float) height);
vertexBuffer3.put(p1.getXf()).put(p1.getYf()).put((float) height);
vertexBuffer3.put(p1.getXf()).put(p1.getYf()).put(0f);
vertexBuffer3.put(p0.getXf()).put(p0.getYf()).put(0f);
vertexBuffer3.put(p0.getXf()).put(p0.getYf()).put(0f);
vertexBuffer3.put(p0.getXf()).put(p0.getYf()).put((float) height);
vertexBuffer3.put(p1.getXf()).put(p1.getYf()).put((float) height);
final FloatBuffer normalBuffer0 = sideMesh[0].getMeshData().getNormalBuffer();
final FloatBuffer normalBuffer1 = sideMesh[1].getMeshData().getNormalBuffer();
final FloatBuffer normalBuffer2 = sideMesh[2].getMeshData().getNormalBuffer();
final FloatBuffer normalBuffer3 = sideMesh[3].getMeshData().getNormalBuffer();
normalBuffer0.rewind();
normalBuffer1.rewind();
normalBuffer2.rewind();
normalBuffer3.rewind();
final ReadOnlyVector3 n1 = p0.subtract(p1, null).normalizeLocal();
final ReadOnlyVector3 n2 = p2.subtract(p0, null).normalizeLocal();
ReadOnlyVector3 normal = n1;
((UserData) sideMesh[0].getUserData()).setNormal(normal);
for (int i = 0; i < 6; i++) {
normalBuffer0.put(normal.getXf()).put(normal.getYf()).put(normal.getZf());
}
normal = n2;
((UserData) sideMesh[1].getUserData()).setNormal(normal);
for (int i = 0; i < 6; i++) {
normalBuffer1.put(normal.getXf()).put(normal.getYf()).put(normal.getZf());
}
normal = n1.negate(null);
((UserData) sideMesh[2].getUserData()).setNormal(normal);
for (int i = 0; i < 6; i++) {
normalBuffer2.put(normal.getXf()).put(normal.getYf()).put(normal.getZf());
}
normal = n2.negate(null);
((UserData) sideMesh[3].getUserData()).setNormal(normal);
for (int i = 0; i < 6; i++) {
normalBuffer3.put(normal.getXf()).put(normal.getYf()).put(normal.getZf());
}
for (int i = 0; i < 4; i++) {
sideMesh[i].updateModelBound();
CollisionTreeManager.INSTANCE.removeCollisionTree(sideMesh[i]);
}
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Foundation method updateLabel.
@Override
public void updateLabel() {
String text = "";
if (labelCustom && labelCustomText != null) {
text += labelCustomText;
}
if (labelId) {
text += (text.equals("") ? "" : "\n") + "#" + id;
}
if (labelPowerTowerHeight) {
text += (text.equals("") ? "" : "\n") + EnergyPanel.NO_DECIMAL.format(getSolarReceiverHeight(0) * Scene.getInstance().getAnnotationScale()) + " m";
}
if (labelPowerTowerOutput) {
final double output = getPowerTowerOutputToday();
text += (text.equals("") ? "" : "\n") + (Util.isZero(output) ? "Output" : EnergyPanel.NO_DECIMAL.format(output) + " kWh");
}
if (labelNumberOfMirrors) {
final int n = getNumberOfTargetingHeliostats();
text += n == 0 ? "" : "\n" + n + " Heliostats";
}
if (labelNumberOfFresnelReflectors) {
final int n = getNumberOfTargetingFresnelReflectors();
text += n == 0 ? "" : "\n" + n + " Fresnel Reflectors";
}
if (labelFresnelReflectorOutput) {
final double output = getFresnelAbsorberOutputToday();
text += (text.equals("") ? "" : "\n") + (Util.isZero(output) ? "Output" : EnergyPanel.NO_DECIMAL.format(output) + " kWh");
}
if (labelBuildingEnergy) {
final String s = totalEnergyToday > 100 ? EnergyPanel.NO_DECIMAL.format(totalEnergyToday) : EnergyPanel.ONE_DECIMAL.format(totalEnergyToday);
text += (text.equals("") ? "" : "\n") + (Util.isZero(totalEnergyToday) ? "Building Energy" : s + " kWh");
}
if (labelNumberOfSolarPanels) {
final int n = getNumberOfSolarPanels();
text += n == 0 ? "" : "\n" + n + " Solar Panels";
}
if (labelPvEnergy) {
final String s = photovoltaicToday > 100 ? EnergyPanel.NO_DECIMAL.format(photovoltaicToday) : EnergyPanel.ONE_DECIMAL.format(photovoltaicToday);
text += (text.equals("") ? "" : "\n") + (Util.isZero(photovoltaicToday) ? "PV Output" : s + " kWh");
}
if (labelSolarPotential) {
final String s = solarPotentialToday > 100 ? EnergyPanel.NO_DECIMAL.format(solarPotentialToday) : EnergyPanel.ONE_DECIMAL.format(solarPotentialToday);
text += (text.equals("") ? "" : "\n") + (Util.isZero(solarPotentialToday) ? "Solar Potential" : s + " kWh");
}
if (!text.equals("")) {
label.setText(text);
final ReadOnlyVector3 center = getCenter();
label.setTranslation(center.getX(), center.getY(), boundingHeight + height + 10);
label.setVisible(true);
} else {
label.setVisible(false);
}
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Foundation method drawHeatFlux.
/**
* Draw the heat flux through the floor area on the foundation
*/
@Override
public void drawHeatFlux() {
FloatBuffer arrowsVertices = heatFlux.getMeshData().getVertexBuffer();
final int cols = (int) Math.max(2, getAbsPoint(0).distance(getAbsPoint(2)) / Scene.getInstance().getHeatVectorGridSize());
final int rows = (int) Math.max(2, getAbsPoint(0).distance(getAbsPoint(1)) / Scene.getInstance().getHeatVectorGridSize());
arrowsVertices = BufferUtils.createVector3Buffer(rows * cols * 6);
heatFlux.getMeshData().setVertexBuffer(arrowsVertices);
final double heat = calculateHeatVector();
if (heat != 0) {
final ReadOnlyVector3 o = getAbsPoint(0);
final ReadOnlyVector3 u = getAbsPoint(2).subtract(o, null);
final ReadOnlyVector3 v = getAbsPoint(1).subtract(o, null);
final ReadOnlyVector3 normal = getNormal().negate(null);
final Vector3 a = new Vector3();
double g, h;
boolean init = true;
final Building building = new Building(this);
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);
if (building.contains(a.getX(), a.getY(), init)) {
a.setZ(o.getZ());
drawArrow(a, normal, arrowsVertices, heat);
}
if (init) {
init = false;
}
}
}
heatFlux.getMeshData().updateVertexCount();
heatFlux.updateModelBound();
}
updateHeatFluxVisibility();
}
Aggregations