use of com.ardor3d.renderer.state.OffsetState in project energy3d by concord-consortium.
the class HousePart method setHighlight.
public void setHighlight(final boolean highlight) {
if (highlight) {
final OffsetState offset = new OffsetState();
offset.setFactor(-1);
offset.setUnits(-1);
mesh.setRenderState(offset);
mesh.setDefaultColor(ColorRGBA.RED);
} else {
mesh.clearRenderState(StateType.Offset);
mesh.setDefaultColor(getColor());
}
}
use of com.ardor3d.renderer.state.OffsetState in project energy3d by concord-consortium.
the class FresnelReflector method init.
@Override
protected void init() {
super.init();
if (Util.isZero(copyLayoutGap)) {
// FIXME: Why is a transient member evaluated to zero?
copyLayoutGap = 0.2;
}
if (Util.isZero(moduleLength)) {
moduleLength = 3;
}
if (Util.isZero(length)) {
length = 2 * moduleLength;
}
if (Util.isZero(moduleWidth)) {
moduleWidth = 2;
}
if (Util.isZero(reflectance)) {
reflectance = 0.9;
}
if (Util.isZero(opticalEfficiency)) {
opticalEfficiency = 0.99;
}
if (Util.isZero(nSectionLength)) {
nSectionLength = 16;
}
if (Util.isZero(nSectionWidth)) {
nSectionWidth = 4;
}
detailed = Scene.getInstance().countParts(this.getClass()) < 50;
if (absorber != null) {
// FIXME: Somehow the absorber foundation, when copied, doesn't point to the right object. This is not a prefect solution, but it fixes the problem.
absorber = (Foundation) Scene.getInstance().getPart(absorber.getId());
}
mesh = new Mesh("Fresnel Reflector Face");
mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
mesh.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(6), 0);
mesh.setDefaultColor(SKY_BLUE);
mesh.setModelBound(new OrientedBoundingBox());
mesh.setUserData(new UserData(this));
root.attachChild(mesh);
reflector = new Box("Fresnel Reflector Box");
reflector.setModelBound(new OrientedBoundingBox());
final OffsetState offset = new OffsetState();
offset.setFactor(1);
offset.setUnits(1);
reflector.setRenderState(offset);
root.attachChild(reflector);
final int nModules = Math.max(1, getNumberOfModules());
outlines = new Line("Fresnel Reflector (Outline)");
outlines.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8 + (nModules - 1) * 2));
outlines.setDefaultColor(ColorRGBA.BLACK);
outlines.setModelBound(new OrientedBoundingBox());
outlines.setLineWidth(1f);
outlines.setStipplePattern((short) 0xffff);
Util.disablePickShadowLight(outlines);
root.attachChild(outlines);
lightBeams = new Line("Light Beams");
lightBeams.setLineWidth(1f);
lightBeams.setStipplePattern((short) 0xffff);
lightBeams.setModelBound(null);
Util.disablePickShadowLight(lightBeams);
lightBeams.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
lightBeams.setDefaultColor(new ColorRGBA(1f, 1f, 1f, 1f));
root.attachChild(lightBeams);
label = new BMText("Label", "#" + id, FontManager.getInstance().getPartNumberFont(), Align.Center, Justify.Center);
Util.initHousePartLabel(label);
label.setFontScale(0.5);
label.setVisible(false);
root.attachChild(label);
modulesRoot = new Node("Modules Root");
root.attachChild(modulesRoot);
updateTextureAndColor();
if (!points.isEmpty()) {
oldReflectorCenter = points.get(0).clone();
}
oldLength = length;
oldModuleWidth = moduleWidth;
}
use of com.ardor3d.renderer.state.OffsetState in project energy3d by concord-consortium.
the class Rack method init.
@Override
protected void init() {
super.init();
if (Util.isZero(copyLayoutGap)) {
// FIXME: Why is a transient member evaluated to zero?
copyLayoutGap = 1;
}
if (Util.isZero(rackWidth)) {
rackWidth = 4.95;
}
if (Util.isZero(rackHeight)) {
rackHeight = 1.65;
}
if (monthlyTiltAngles == null) {
monthlyTiltAngles = new double[12];
Arrays.fill(monthlyTiltAngles, tiltAngle);
}
mesh = new Mesh("Rack");
mesh.setDefaultColor(ColorRGBA.LIGHT_GRAY);
mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
mesh.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(6), 0);
mesh.setModelBound(new OrientedBoundingBox());
mesh.setUserData(new UserData(this));
root.attachChild(mesh);
surround = new Box("Rack (Surround)");
surround.setDefaultColor(ColorRGBA.LIGHT_GRAY);
surround.setModelBound(new OrientedBoundingBox());
final OffsetState offset = new OffsetState();
// set a smaller value than solar panel so that the texture doesn't show up on the underside
offset.setFactor(0.2f);
offset.setUnits(1);
surround.setRenderState(offset);
root.attachChild(surround);
outlineMesh = new Line("Rack (Outline)");
outlineMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8));
outlineMesh.setDefaultColor(ColorRGBA.BLACK);
outlineMesh.setModelBound(new OrientedBoundingBox());
root.attachChild(outlineMesh);
sunBeam = new Line("Sun Beam");
sunBeam.setLineWidth(1f);
sunBeam.setStipplePattern((short) 0xffff);
sunBeam.setModelBound(null);
Util.disablePickShadowLight(sunBeam);
sunBeam.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
sunBeam.setDefaultColor(new ColorRGBA(1f, 1f, 1f, 1f));
root.attachChild(sunBeam);
normalVector = new Line("Normal Vector");
normalVector.setLineWidth(1f);
normalVector.setStipplePattern((short) 0xffff);
normalVector.setModelBound(null);
Util.disablePickShadowLight(normalVector);
normalVector.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
normalVector.setDefaultColor(new ColorRGBA(1f, 1f, 0f, 1f));
root.attachChild(normalVector);
angles = new Node("Angles");
angles.getSceneHints().setAllPickingHints(false);
Util.disablePickShadowLight(angles);
root.attachChild(angles);
// the angle between the sun beam and the normal vector
sunAngle = new AngleAnnotation();
sunAngle.setColor(ColorRGBA.WHITE);
sunAngle.setLineWidth(1);
sunAngle.setFontSize(1);
sunAngle.setCustomRadius(normalVectorLength * 0.8);
angles.attachChild(sunAngle);
solarPanelOutlines = new Line("Solar Panel Outlines");
solarPanelOutlines.setLineWidth(1f);
solarPanelOutlines.setStipplePattern((short) 0xffff);
solarPanelOutlines.setModelBound(null);
Util.disablePickShadowLight(solarPanelOutlines);
solarPanelOutlines.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1));
solarPanelOutlines.setDefaultColor(new ColorRGBA(0f, 0f, 0f, 1f));
root.attachChild(solarPanelOutlines);
label = new BMText("Label", "#" + id, FontManager.getInstance().getPartNumberFont(), Align.Center, Justify.Center);
Util.initHousePartLabel(label);
label.setFontScale(0.5);
label.setVisible(false);
root.attachChild(label);
polesRoot = new Node("Poles Root");
root.attachChild(polesRoot);
updateTextureAndColor();
if (sampleSolarPanel == null) {
sampleSolarPanel = new SolarPanel();
}
// ugly fixes for zero initial values when sampleSolarPanel is previously serialized without new variables
if (sampleSolarPanel.getPvModuleSpecs() == null) {
sampleSolarPanel.setPvModuleSpecs(new PvModuleSpecs());
}
if (Util.isZero(sampleSolarPanel.getNominalOperatingCellTemperature())) {
sampleSolarPanel.setNominalOperatingCellTemperature(48);
}
if (!points.isEmpty()) {
oldRackCenter = points.get(0).clone();
}
oldRackWidth = rackWidth;
oldRackHeight = rackHeight;
}
use of com.ardor3d.renderer.state.OffsetState in project energy3d by concord-consortium.
the class Sensor method init.
@Override
protected void init() {
super.init();
mesh = new Mesh("Sensor");
mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
mesh.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(6), 0);
mesh.setModelBound(new OrientedBoundingBox());
mesh.setUserData(new UserData(this));
root.attachChild(mesh);
surround = new Box("Sensor (Surround)");
surround.setModelBound(new OrientedBoundingBox());
final OffsetState offset = new OffsetState();
offset.setFactor(1);
offset.setUnits(1);
surround.setRenderState(offset);
root.attachChild(surround);
outlineMesh = new Line("Sensor (Outline)");
outlineMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8));
outlineMesh.setDefaultColor(ColorRGBA.BLACK);
outlineMesh.setModelBound(new OrientedBoundingBox());
root.attachChild(outlineMesh);
label = new BMText("" + getId(), "0", FontManager.getInstance().getPartNumberFont(), Align.Center, Justify.Center);
Util.initHousePartLabel(label);
label.setFontScale(0.6);
label.setVisible(true);
root.attachChild(label);
updateTextureAndColor();
}
use of com.ardor3d.renderer.state.OffsetState in project energy3d by concord-consortium.
the class Mirror method init.
@Override
protected void init() {
super.init();
if (Util.isZero(mirrorWidth)) {
mirrorWidth = 5;
}
if (Util.isZero(mirrorHeight)) {
mirrorHeight = 3;
}
if (Util.isZero(reflectance)) {
reflectance = 0.9;
}
if (Util.isZero(opticalEfficiency)) {
opticalEfficiency = 1;
}
if (Util.isZero(baseHeight)) {
baseHeight = 10;
}
if (heliostatTarget != null) {
// FIXME: Somehow the target, when copied, doesn't point to the right object. This is not a prefect solution, but it fixes the problem.
final HousePart hp = Scene.getInstance().getPart(heliostatTarget.getId());
if (hp instanceof Foundation) {
heliostatTarget = (Foundation) hp;
} else {
heliostatTarget = null;
}
}
mesh = new Mesh("Reflecting Mirror");
mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
mesh.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(6), 0);
mesh.setModelBound(new OrientedBoundingBox());
mesh.setUserData(new UserData(this));
root.attachChild(mesh);
surround = new Box("Mirror (Surround)");
surround.setModelBound(new OrientedBoundingBox());
final OffsetState offset = new OffsetState();
offset.setFactor(1);
offset.setUnits(1);
surround.setRenderState(offset);
root.attachChild(surround);
outlineMesh = new Line("Mirror (Outline)");
outlineMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8));
outlineMesh.setDefaultColor(ColorRGBA.BLACK);
outlineMesh.setModelBound(new OrientedBoundingBox());
root.attachChild(outlineMesh);
// if there are many mirrors, reduce the solution of post
post = new Cylinder("Post Cylinder", 2, Scene.getInstance().getAllHeliostats().size() < 200 ? 10 : 2, 10, 0);
post.setRadius(0.6);
post.setDefaultColor(ColorRGBA.WHITE);
post.setRenderState(offsetState);
post.setModelBound(new BoundingBox());
post.updateModelBound();
root.attachChild(post);
lightBeams = new Line("Light Beams");
lightBeams.setLineWidth(1f);
lightBeams.setStipplePattern((short) 0xffff);
lightBeams.setModelBound(null);
// final BlendState blendState = new BlendState();
// blendState.setBlendEnabled(true);
// lightBeams.setRenderState(blendState);
// lightBeams.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
Util.disablePickShadowLight(lightBeams);
lightBeams.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
lightBeams.setDefaultColor(new ColorRGBA(1f, 1f, 1f, 1f));
root.attachChild(lightBeams);
label = new BMText("Label", "# " + id, FontManager.getInstance().getPartNumberFont(), Align.Center, Justify.Center);
Util.initHousePartLabel(label);
label.setFontScale(0.5);
label.setVisible(false);
root.attachChild(label);
updateTextureAndColor();
}
Aggregations