use of com.ardor3d.renderer.state.BlendState in project energy3d by concord-consortium.
the class Human method init.
@Override
protected void init() {
super.init();
final double h;
final double w;
switch(humanType) {
case JANE:
w = 2.5;
h = 8;
break;
case JENI:
w = 3;
h = 9;
break;
case JILL:
w = 3;
h = 8;
break;
case JACK:
w = 2.8;
h = 9;
break;
case JOHN:
w = 4;
h = 10;
break;
case JOSE:
w = 8;
h = 8;
break;
default:
w = 2.5;
h = 8;
}
mesh = new Quad("Human Quad", w, h);
mesh.setModelBound(new BoundingBox());
mesh.updateModelBound();
mesh.setRotation(new Matrix3().fromAngles(Math.PI / 2, 0, 0));
// stand on the ground by default
translate(w, h, feetHeight);
mesh.setUserData(new UserData(this, 0, true));
final BlendState bs = new BlendState();
bs.setEnabled(true);
bs.setBlendEnabled(false);
bs.setTestEnabled(true);
bs.setTestFunction(TestFunction.GreaterThan);
bs.setReference(0.7f);
mesh.setRenderState(bs);
mesh.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
billboard = new BillboardNode("Billboard");
billboard.setAlignment(BillboardAlignment.AxialZ);
billboard.attachChild(mesh);
root.attachChild(billboard);
updateTextureAndColor();
}
use of com.ardor3d.renderer.state.BlendState in project energy3d by concord-consortium.
the class ParabolicTrough 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(troughLength)) {
troughLength = 2 * moduleLength;
}
if (Util.isZero(apertureWidth)) {
apertureWidth = 2;
}
if (Util.isZero(semilatusRectum)) {
semilatusRectum = 2;
}
if (Util.isZero(reflectance)) {
reflectance = 0.9;
}
if (Util.isZero(absorptance)) {
absorptance = 0.95;
}
if (Util.isZero(opticalEfficiency)) {
opticalEfficiency = 0.7;
}
if (Util.isZero(thermalEfficiency)) {
thermalEfficiency = 0.3;
}
if (Util.isZero(nSectionParabola)) {
nSectionParabola = 16;
}
if (Util.isZero(nSectionAxis)) {
nSectionAxis = 32;
}
detailed = Scene.getInstance().countParts(this.getClass()) < 50;
mesh = new ParabolicCylinder("Parabolic Cylinder", nSectionParabola, semilatusRectum, apertureWidth, troughLength);
mesh.setDefaultColor(SKY_BLUE);
mesh.setModelBound(new OrientedBoundingBox());
mesh.setUserData(new UserData(this));
CullState cullState = new CullState();
cullState.setCullFace(Face.Back);
mesh.setRenderState(cullState);
root.attachChild(mesh);
reflector = (ParabolicCylinder) mesh;
reflectorBack = mesh.makeCopy(true);
reflectorBack.clearRenderState(StateType.Texture);
reflectorBack.setDefaultColor(ColorRGBA.WHITE);
cullState = new CullState();
cullState.setCullFace(Face.None);
reflectorBack.setRenderState(cullState);
root.attachChild(reflectorBack);
final ColorRGBA tubeColor = new ColorRGBA(0.8f, 0.8f, 0.8f, 0.8f);
absorber = new Cylinder("Absorber Tube", 2, detailed ? 10 : 4, 0.5, 0, true);
final BlendState blend = new BlendState();
blend.setBlendEnabled(true);
absorber.setRenderState(blend);
absorber.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
absorber.setDefaultColor(tubeColor);
absorber.setModelBound(new OrientedBoundingBox());
root.attachChild(absorber);
absorberEnd1 = new Cylinder("Absorber End Tube 1", 2, detailed ? 10 : 4, 0.5, 0, true);
absorberEnd1.setRenderState(blend);
absorberEnd1.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
absorberEnd1.setDefaultColor(tubeColor);
absorberEnd1.setModelBound(new OrientedBoundingBox());
root.attachChild(absorberEnd1);
absorberEnd2 = new Cylinder("Absorber End Tube 2", 2, detailed ? 10 : 4, 0.5, 0, true);
absorberEnd2.setRenderState(blend);
absorberEnd2.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
absorberEnd2.setDefaultColor(tubeColor);
absorberEnd2.setModelBound(new OrientedBoundingBox());
root.attachChild(absorberEnd2);
if (detailed) {
absorberCore = new Cylinder("Absorber Tube Core", 2, 4, 0.4, 0, true);
absorberCore.setDefaultColor(ColorRGBA.BROWN);
absorberCore.setModelBound(new OrientedBoundingBox());
root.attachChild(absorberCore);
absorberEnd1Core = new Cylinder("Absorber End Tube 1 Core", 2, 4, 0.4, 0, true);
absorberEnd1Core.setDefaultColor(ColorRGBA.BROWN);
absorberEnd1Core.setModelBound(new OrientedBoundingBox());
root.attachChild(absorberEnd1Core);
absorberEnd2Core = new Cylinder("Absorber End Tube 2 Core", 2, 4, 0.4, 0, true);
absorberEnd2Core.setDefaultColor(ColorRGBA.BROWN);
absorberEnd2Core.setModelBound(new OrientedBoundingBox());
root.attachChild(absorberEnd2Core);
}
final int nModules = getNumberOfModules();
outlines = new Line("Parabolic Trough (Outline)");
outlines.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4 + 2 * (reflector.getNumberOfSamples() + 1) * (nModules + 1)));
outlines.setDefaultColor(ColorRGBA.BLACK);
outlines.setModelBound(new OrientedBoundingBox());
outlines.setLineWidth(1f);
outlines.setStipplePattern((short) 0xffff);
Util.disablePickShadowLight(outlines);
root.attachChild(outlines);
steelFrame = new Line("Parabolic Trough Steel Frame");
steelFrame.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
steelFrame.setDefaultColor(ColorRGBA.GRAY);
steelFrame.setModelBound(new OrientedBoundingBox());
steelFrame.setLineWidth(3);
steelFrame.setStipplePattern((short) 0xffff);
root.attachChild(steelFrame);
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()) {
oldTroughCenter = points.get(0).clone();
}
oldTroughLength = troughLength;
oldApertureWidth = apertureWidth;
}
use of com.ardor3d.renderer.state.BlendState in project energy3d by concord-consortium.
the class Tree method init.
@Override
protected void init() {
super.init();
switch(treeType) {
case COTTONWOOD:
treeWidth = 80;
treeHeight = 100;
break;
case LINDEN:
treeWidth = 90;
treeHeight = 120;
break;
case OAK:
treeWidth = 70;
treeHeight = 80;
break;
case ELM:
treeWidth = 60;
treeHeight = 75;
break;
case MAPLE:
treeWidth = 30;
treeHeight = 60;
break;
case PINE:
treeWidth = 30;
treeHeight = 80;
break;
default:
treeWidth = 30;
treeHeight = 40;
}
mesh = new Quad("Tree Quad", treeWidth, treeHeight);
mesh.setModelBound(new BoundingBox());
mesh.updateModelBound();
mesh.setRotation(new Matrix3().fromAngles(Math.PI / 2, 0, 0));
mesh.setTranslation(0, 0, treeHeight / 2.0);
mesh.getSceneHints().setPickingHint(PickingHint.Pickable, false);
final BlendState bs = new BlendState();
bs.setEnabled(true);
bs.setBlendEnabled(false);
bs.setTestEnabled(true);
bs.setTestFunction(TestFunction.GreaterThan);
bs.setReference(0.7f);
mesh.setRenderState(bs);
mesh.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
billboard = new BillboardNode("Billboard");
billboard.setAlignment(BillboardAlignment.AxialZ);
billboard.attachChild(mesh);
root.attachChild(billboard);
switch(treeType) {
case PINE:
// axis samples, radial samples, radius, height, closed
crown = new Cone("Tree Crown", 2, 6, 18, 20, false);
break;
default:
// z samples, radial samples, radius
crown = new Sphere("Tree Crown", 4, 8, 14);
}
crown.setModelBound(new BoundingSphere());
crown.updateModelBound();
final Cylinder trunk = new Cylinder("Tree Trunk", 10, 10, 1, 20);
trunk.setModelBound(new BoundingBox());
trunk.updateModelBound();
switch(treeType) {
case COTTONWOOD:
crown.setScale(3, 3, 3.5);
crown.setTranslation(0, 0, 55);
trunk.setScale(8, 8, 2);
trunk.setTranslation(0, 0, 20);
break;
case LINDEN:
crown.setScale(3.5, 3.5, 4);
crown.setTranslation(0, 0, 65);
trunk.setScale(5, 5, 2);
trunk.setTranslation(0, 0, 20);
break;
case OAK:
crown.setScale(2.5, 2.5, 3);
crown.setTranslation(0, 0, 45);
trunk.setScale(5, 5, 2);
trunk.setTranslation(0, 0, 20);
break;
case ELM:
crown.setScale(2, 2, 2.5);
crown.setTranslation(0, 0, 40);
trunk.setScale(2, 2, 2);
trunk.setTranslation(0, 0, 20);
break;
case MAPLE:
crown.setScale(1, 1, 2.1);
crown.setTranslation(0, 0, 32);
trunk.setTranslation(0, 0, 10);
break;
case PINE:
crown.setScale(1, 1, -4.0);
crown.setTranslation(0, 0, 45);
trunk.setTranslation(0, 0, 10);
break;
default:
crown.setScale(1, 1, 1.2);
crown.setTranslation(0, 0, 24);
trunk.setTranslation(0, 0, 10);
break;
}
collisionRoot = new Node("Tree Collision Root");
collisionRoot.attachChild(crown);
collisionRoot.attachChild(trunk);
if (points.size() > 0) {
collisionRoot.setTranslation(getAbsPoint(0));
}
collisionRoot.updateWorldTransform(true);
collisionRoot.updateWorldBound(true);
collisionRoot.getSceneHints().setCullHint(showPolygons ? CullHint.Never : CullHint.Always);
root.attachChild(collisionRoot);
crown.setUserData(new UserData(this));
trunk.setUserData(new UserData(this));
updateTextureAndColor();
}
use of com.ardor3d.renderer.state.BlendState in project energy3d by concord-consortium.
the class SceneManager method drawGrids.
public Mesh drawGrids(final double gridSize) {
final Mesh gridsMesh = new Line("Ground Grids");
gridsMesh.getSceneHints().setCullHint(CullHint.Always);
gridsMesh.setDefaultColor(new ColorRGBA(0, 0, 1, 1));
final BlendState blendState = new BlendState();
blendState.setBlendEnabled(true);
gridsMesh.setRenderState(blendState);
gridsMesh.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
final ReadOnlyVector3 width = Vector3.UNIT_X.multiply(2000, null);
final ReadOnlyVector3 height = Vector3.UNIT_Y.multiply(2000, null);
final ArrayList<ReadOnlyVector3> points = new ArrayList<ReadOnlyVector3>();
final ReadOnlyVector3 pMiddle = Vector3.ZERO;
final int cols = (int) (width.length() / gridSize);
for (int col = 1; col < cols / 2 + 1; col++) {
for (int neg = -1; neg <= 1; neg += 2) {
final ReadOnlyVector3 lineP1 = width.normalize(null).multiplyLocal(neg * col * gridSize).addLocal(pMiddle).subtractLocal(height.multiply(0.5, null));
points.add(lineP1);
final ReadOnlyVector3 lineP2 = lineP1.add(height, null);
points.add(lineP2);
if (col == 0) {
break;
}
}
}
final int rows = (int) (height.length() / gridSize);
for (int row = 1; row < rows / 2 + 1; row++) {
for (int neg = -1; neg <= 1; neg += 2) {
final ReadOnlyVector3 lineP1 = height.normalize(null).multiplyLocal(neg * row * gridSize).addLocal(pMiddle).subtractLocal(width.multiply(0.5, null));
points.add(lineP1);
final ReadOnlyVector3 lineP2 = lineP1.add(width, null);
points.add(lineP2);
if (row == 0) {
break;
}
}
}
final FloatBuffer buf = BufferUtils.createVector3Buffer(points.size());
for (final ReadOnlyVector3 p : points) {
buf.put(p.getXf()).put(p.getYf()).put(0.01f);
}
gridsMesh.getMeshData().setVertexBuffer(buf);
gridsMesh.getMeshData().updateVertexCount();
Util.disablePickShadowLight(gridsMesh);
gridsMesh.setModelBound(new BoundingBox());
gridsMesh.updateModelBound();
gridsMesh.updateWorldBound(true);
return gridsMesh;
}
use of com.ardor3d.renderer.state.BlendState in project energy3d by concord-consortium.
the class SceneManager method createLand.
private Mesh createLand() {
final Quad land = new Quad("Land", SKY_RADIUS * 2, SKY_RADIUS * 2);
land.setDefaultColor(new ColorRGBA(0, 1.0f, 0.75f, 0.5f));
final OffsetState offsetState = new OffsetState();
offsetState.setTypeEnabled(OffsetType.Fill, true);
offsetState.setFactor(10);
offsetState.setUnits(10);
land.setRenderState(offsetState);
final BlendState blendState = new BlendState();
blendState.setBlendEnabled(true);
land.setRenderState(blendState);
land.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
final MaterialState ms = new MaterialState();
ms.setColorMaterial(ColorMaterial.Diffuse);
land.setRenderState(ms);
land.updateModelBound();
land.updateWorldBound(true);
return land;
}
Aggregations