use of com.ardor3d.math.Vector3 in project energy3d by concord-consortium.
the class Foundation method drawSolarReceiver.
public void drawSolarReceiver() {
if (solarReceiver == null) {
return;
}
int countHeliostats = 0;
for (final HousePart p : Scene.getInstance().getParts()) {
if (p instanceof Mirror) {
final Mirror m = (Mirror) p;
if (m.getReceiver() == this) {
countHeliostats++;
}
}
}
int countFresnelReflectors = 0;
for (final HousePart p : Scene.getInstance().getParts()) {
if (p instanceof FresnelReflector) {
final FresnelReflector r = (FresnelReflector) p;
if (r.getReceiver() == this) {
countFresnelReflectors++;
}
}
}
solarReceiver.setVisible(countHeliostats > 0 || countFresnelReflectors > 0);
if (solarReceiver.isVisible()) {
if (bloomRenderPass == null) {
bloomRenderPass = new BloomRenderPass(SceneManager.getInstance().getCamera(), 10);
// bloomRenderPass.setNrBlurPasses(1);
SceneManager.getInstance().getPassManager().add(bloomRenderPass);
}
if (!bloomRenderPass.contains(solarReceiver)) {
bloomRenderPass.add(solarReceiver);
}
double rx = 0;
double ry = 0;
final Vector3 center = getAbsCenter();
double xmin = center.getX();
double xmax = center.getX();
double ymin = center.getY();
double ymax = center.getY();
double lmax = -1;
int count = 0;
for (final HousePart p : children) {
if (p instanceof Wall) {
final Wall wall = (Wall) p;
final Vector3 c = p.getAbsCenter();
rx += c.getX();
ry += c.getY();
if (xmin > c.getX()) {
xmin = c.getX();
} else if (xmax < c.getX()) {
xmax = c.getX();
}
if (ymin > c.getY()) {
ymin = c.getY();
} else if (ymax < c.getY()) {
ymax = c.getY();
}
count++;
final double wallLength = wall.getAbsPoint(0).distance(wall.getAbsPoint(2));
if (wallLength > lmax) {
lmax = wallLength;
}
}
}
if (countHeliostats > 0) {
bloomRenderPass.setBlurIntensityMultiplier(Math.min(0.01f * countHeliostats, 0.8f));
solarReceiver.setHeight(getSolarReceiverHeight(0.1) * 0.15);
Vector3 o;
if (count == 0) {
o = getAbsCenter();
o.setZ(getSolarReceiverHeight(0.1) - solarReceiver.getHeight() * 0.5);
solarReceiver.setRadius(10);
} else {
o = new Vector3(rx / count, ry / count, getSolarReceiverHeight(0.1) - solarReceiver.getHeight() * 0.5);
final double r1 = Math.max((xmax - xmin), (ymax - ymin)) / 2;
final double r2 = Math.max(r1 * 0.4, 4);
solarReceiver.setRadius(r1 + r2);
}
solarReceiver.setTranslation(o);
} else if (countFresnelReflectors > 0) {
bloomRenderPass.setBlurIntensityMultiplier(Math.min(0.1f * countFresnelReflectors, 0.8f));
solarReceiver.setRadius(1);
solarReceiver.setHeight(lmax);
final double az = getAzimuth();
final Matrix3 rotateAroundZ = new Matrix3().applyRotationZ(Math.toRadians(-az));
final Matrix3 rotateAroundX = new Matrix3().applyRotationX(Math.PI * 0.5);
solarReceiver.setRotation(rotateAroundZ.multiplyLocal(rotateAroundX));
final Vector3 o = new Vector3((xmin + xmax) * 0.5, (ymin + ymax) * 0.5, getSolarReceiverHeight(solarReceiver.getRadius() * 1.2));
solarReceiver.setTranslation(o);
}
}
}
use of com.ardor3d.math.Vector3 in project energy3d by concord-consortium.
the class Foundation method updateImportedNodePositionsAfterMove.
private void updateImportedNodePositionsAfterMove() {
if (importedNodeStates != null) {
final double az = Math.toRadians(getAzimuth());
final Vector3 ac = getAbsCenter();
if (Util.isZero(az)) {
for (final NodeState ns : importedNodeStates) {
ns.setAbsolutePosition(ac.addLocal(ns.getRelativePosition()));
}
} else {
// why -az?
final Matrix3 matrix = new Matrix3().fromAngles(0, 0, -az);
for (final NodeState ns : importedNodeStates) {
ns.setAbsolutePosition(ac.addLocal(matrix.applyPost(ns.getRelativePosition(), null)));
}
}
}
}
use of com.ardor3d.math.Vector3 in project energy3d by concord-consortium.
the class Foundation method getAbsCenter.
@Override
public Vector3 getAbsCenter() {
double x = 0, y = 0, z = 0;
for (int i = 0; i < 4; i++) {
final Vector3 v = getAbsPoint(i);
x += v.getX();
y += v.getY();
z += v.getZ();
}
return new Vector3(x / 4, y / 4, z / 4);
}
use of com.ardor3d.math.Vector3 in project energy3d by concord-consortium.
the class Foundation method drawOutline.
private void drawOutline(final Mesh mesh, final float height) {
final FloatBuffer buf = mesh.getMeshData().getVertexBuffer();
buf.rewind();
final Vector3 p0 = getAbsPoint(0);
final Vector3 p1 = getAbsPoint(1);
final Vector3 p2 = getAbsPoint(2);
final Vector3 p3 = getAbsPoint(3);
putOutlinePoint(buf, p0);
putOutlinePoint(buf, p2);
putOutlinePoint(buf, p2);
putOutlinePoint(buf, p3);
putOutlinePoint(buf, p3);
putOutlinePoint(buf, p1);
putOutlinePoint(buf, p1);
putOutlinePoint(buf, p0);
putOutlinePoint(buf, p0, height);
putOutlinePoint(buf, p2, height);
putOutlinePoint(buf, p2, height);
putOutlinePoint(buf, p3, height);
putOutlinePoint(buf, p3, height);
putOutlinePoint(buf, p1, height);
putOutlinePoint(buf, p1, height);
putOutlinePoint(buf, p0, height);
putOutlinePoint(buf, p0);
putOutlinePoint(buf, p0, height);
putOutlinePoint(buf, p2);
putOutlinePoint(buf, p2, height);
putOutlinePoint(buf, p3);
putOutlinePoint(buf, p3, height);
putOutlinePoint(buf, p1);
putOutlinePoint(buf, p1, height);
mesh.updateModelBound();
}
use of com.ardor3d.math.Vector3 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