use of com.ardor3d.scenegraph.Line in project energy3d by concord-consortium.
the class Wall method setOriginal.
@Override
public void setOriginal(final HousePart original) {
final Wall originalWall = (Wall) original;
this.thicknessNormal = originalWall.getThicknessNormal();
root.detachChild(invisibleMesh);
root.detachChild(backMesh);
root.detachChild(surroundMesh);
root.detachChild(windowsSurroundMesh);
root.detachChild(outlineMesh);
backMesh = originalWall.backMesh.makeCopy(true);
surroundMesh = originalWall.surroundMesh.makeCopy(true);
windowsSurroundMesh = originalWall.windowsSurroundMesh.makeCopy(true);
outlineMesh = originalWall.outlineMesh.makeCopy(true);
((Line) outlineMesh).setLineWidth(printOutlineThickness);
root.attachChild(backMesh);
root.attachChild(surroundMesh);
root.attachChild(windowsSurroundMesh);
root.attachChild(outlineMesh);
final Mesh orgInvisibleMesh = originalWall.invisibleMesh;
invisibleMesh = orgInvisibleMesh.makeCopy(true);
invisibleMesh.setUserData(new UserData(this, ((UserData) orgInvisibleMesh.getUserData()).getEditPointIndex(), false));
root.attachChild(invisibleMesh);
wallAndWindowsPoints = originalWall.wallAndWindowsPoints;
super.setOriginal(original);
}
use of com.ardor3d.scenegraph.Line in project energy3d by concord-consortium.
the class MeshLib method createMeshes.
public static void createMeshes(final Node root, final ArrayList<GroupData> groups) {
if (groups.size() != root.getNumberOfChildren()) {
root.detachAllChildren();
}
int meshIndex = 0;
for (final GroupData group : groups) {
final Node node;
final Mesh mesh;
final Mesh meshWithHoles;
final BMText label;
if (meshIndex < root.getNumberOfChildren()) {
node = (Node) root.getChild(meshIndex);
mesh = (Mesh) node.getChild(0);
label = (BMText) node.getChild(3);
meshWithHoles = (Mesh) node.getChild(6);
node.getSceneHints().setAllPickingHints(true);
} else {
node = new Node("Roof Part #" + meshIndex);
mesh = new Mesh("Roof Mesh #" + meshIndex);
meshWithHoles = new Mesh("Roof Mesh with Holes #" + meshIndex);
mesh.setVisible(false);
mesh.setModelBound(new BoundingBox());
meshWithHoles.setModelBound(new BoundingBox());
meshWithHoles.setRenderState(HousePart.offsetState);
label = new BMText("Label Text", "", FontManager.getInstance().getPartNumberFont(), Align.South, Justify.Center);
Util.initHousePartLabel(label);
final Mesh wireframeMesh = new Line("Roof (wireframe)");
wireframeMesh.setDefaultColor(ColorRGBA.BLACK);
wireframeMesh.setModelBound(new BoundingBox());
wireframeMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(10));
// offset to avoid z-fighting
wireframeMesh.setTranslation(group.key.multiply(0.001, null));
final Line dashLineMesh = new Line("Roof (dash line)");
dashLineMesh.setStipplePattern((short) 0xFF00);
dashLineMesh.setVisible(false);
dashLineMesh.setModelBound(new BoundingBox());
final Node sizeAnnotation = new Node("Roof Size Annot");
final Node angleAnnotation = new Node("Roof Angle Annot");
// disable picking for all except mesh
Util.disablePickShadowLight(sizeAnnotation);
Util.disablePickShadowLight(angleAnnotation);
Util.disablePickShadowLight(wireframeMesh);
Util.disablePickShadowLight(dashLineMesh);
// meshWithHoles.getSceneHints().setAllPickingHints(false);
node.attachChild(mesh);
node.attachChild(sizeAnnotation);
node.attachChild(angleAnnotation);
node.attachChild(label);
node.attachChild(wireframeMesh);
node.attachChild(dashLineMesh);
node.attachChild(meshWithHoles);
root.attachChild(node);
}
node.getSceneHints().setCullHint(CullHint.Never);
CollisionTreeManager.getInstance().removeCollisionTree(mesh);
CollisionTreeManager.getInstance().removeCollisionTree(meshWithHoles);
final Vector3 normal = group.key;
node.setUserData(normal);
final FloatBuffer buf = BufferUtils.createVector3Buffer(group.vertices.size());
mesh.getMeshData().setVertexBuffer(buf);
final Vector3 center = new Vector3();
for (final ReadOnlyVector3 v : group.vertices) {
buf.put(v.getXf()).put(v.getYf()).put(v.getZf());
center.addLocal(v);
}
center.multiplyLocal(1.0 / group.vertices.size());
label.setTranslation(center.add(normal.multiply(0.1, null), null));
mesh.updateModelBound();
meshIndex++;
}
}
use of com.ardor3d.scenegraph.Line 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.scenegraph.Line in project energy3d by concord-consortium.
the class Window method init.
@Override
protected void init() {
label1 = Annotation.makeNewLabel(1);
super.init();
if (Util.isZero(uValue)) {
uValue = 2;
}
if (Util.isZero(solarHeatGainCoefficient)) {
solarHeatGainCoefficient = 0.5;
} else if (solarHeatGainCoefficient > 1) {
solarHeatGainCoefficient *= 0.01;
}
if (Util.isZero(volumetricHeatCapacity)) {
volumetricHeatCapacity = 0.5;
}
if (Util.isZero(shutterLength)) {
shutterLength = 0.5;
}
if (glassColor == null) {
setColor(new ColorRGBA(0.3f, 0.3f, 0.5f, 0.5f));
}
if (shutterColor == null) {
shutterColor = ColorRGBA.DARK_GRAY;
}
mesh = new Mesh("Window");
mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
mesh.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(6));
mesh.setModelBound(new BoundingBox());
mesh.getSceneHints().setAllPickingHints(false);
if (glassColor == null) {
glassColor = new ColorRGBA(0.3f, 0.3f, 0.5f, 0.5f);
}
mesh.setDefaultColor(glassColor);
final BlendState blend = new BlendState();
blend.setBlendEnabled(true);
// blend.setTestEnabled(true);
mesh.setRenderState(blend);
mesh.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
final MaterialState ms = new MaterialState();
ms.setColorMaterial(ColorMaterial.Diffuse);
mesh.setRenderState(ms);
root.attachChild(mesh);
collisionMesh = new Mesh("Window Collision");
collisionMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
collisionMesh.setVisible(false);
collisionMesh.setUserData(new UserData(this));
collisionMesh.setModelBound(new BoundingBox());
root.attachChild(collisionMesh);
label1.setAlign(Align.SouthWest);
root.attachChild(label1);
bars = new Line("Window (bars)");
bars.setLineWidth(3);
bars.setModelBound(new BoundingBox());
Util.disablePickShadowLight(bars);
bars.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8));
root.attachChild(bars);
leftShutter = new Mesh("Left Shutter");
leftShutter.getMeshData().setIndexMode(IndexMode.Quads);
leftShutter.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
leftShutter.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(4));
leftShutter.setRenderState(ms);
leftShutter.setModelBound(new BoundingBox());
root.attachChild(leftShutter);
rightShutter = new Mesh("Right Shutter");
rightShutter.getMeshData().setIndexMode(IndexMode.Quads);
rightShutter.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
rightShutter.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(4));
rightShutter.setRenderState(ms);
rightShutter.setModelBound(new BoundingBox());
root.attachChild(rightShutter);
leftShutterOutline = new Line("Left Shutter (Outline)");
leftShutterOutline.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(12));
leftShutterOutline.setDefaultColor(ColorRGBA.BLACK);
leftShutterOutline.setModelBound(new BoundingBox());
root.attachChild(leftShutterOutline);
rightShutterOutline = new Line("Right Shutter (Outline)");
rightShutterOutline.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(12));
rightShutterOutline.setDefaultColor(ColorRGBA.BLACK);
rightShutterOutline.setModelBound(new BoundingBox());
root.attachChild(rightShutterOutline);
}
use of com.ardor3d.scenegraph.Line in project energy3d by concord-consortium.
the class Foundation method updateTextureAndColor.
@Override
public void updateTextureAndColor() {
for (final Mesh mesh : sideMesh) {
mesh.setDefaultColor(Scene.getInstance().getTextureMode() == TextureMode.Full ? ColorRGBA.GRAY : (getColor() == null ? Scene.getInstance().getFoundationColor() : getColor()));
updateTextureAndColor(mesh, getColor() == null ? Scene.getInstance().getFoundationColor() : getColor());
}
updateTextureAndColor(mesh, getColor() == null ? Scene.getInstance().getFoundationColor() : getColor());
if (!SceneManager.getInstance().getSolarHeatMap() && importedNodes != null) {
final int n = importedNodes.size();
if (n > 0) {
Node ni;
for (int i = 0; i < n; i++) {
ni = importedNodes.get(i);
if (root.getChildren().contains(ni)) {
for (final Spatial s : ni.getChildren()) {
if (s instanceof Mesh) {
if (s instanceof Line) {
continue;
}
final Mesh m = (Mesh) s;
final UserData ud = (UserData) m.getUserData();
final TextureState ts = (TextureState) m.getLocalRenderState(StateType.Texture);
if (ts == null || ts.getTexture() == null) {
m.clearRenderState(StateType.Texture);
// m.setDefaultColor(nis.getDefaultColor());
} else {
if (ud.getTextureBuffer() == null || Util.isZero(ud.getTextureBuffer())) {
m.clearRenderState(StateType.Texture);
// m.setDefaultColor(nis.getDefaultColor());
} else {
m.getMeshData().setTextureBuffer(ud.getTextureBuffer(), 0);
m.setRenderState(ud.getRenderState());
}
}
}
}
}
}
}
}
}
Aggregations