use of com.ardor3d.scenegraph.Node in project energy3d by concord-consortium.
the class Foundation method pickMesh.
public void pickMesh(final int x, final int y) {
selectedMesh = null;
if (importedNodes != null) {
final PickResults pickResults = new PrimitivePickResults();
pickResults.setCheckDistance(true);
final Ray3 pickRay = SceneManager.getInstance().getCamera().getPickRay(new Vector2(x, y), false, null);
for (final Node node : importedNodes) {
for (final Spatial s : node.getChildren()) {
if (s instanceof Mesh) {
PickingUtil.findPick(s, pickRay, pickResults, false);
}
}
}
if (pickResults.getNumber() > 0) {
final Pickable pickable = pickResults.getPickData(0).getTarget();
if (pickable instanceof Mesh) {
selectedMesh = (Mesh) pickable;
drawMeshSelection(selectedMesh);
}
} else {
setMeshSelectionVisible(false);
}
}
}
use of com.ardor3d.scenegraph.Node in project energy3d by concord-consortium.
the class Foundation method processImportedMeshes.
// imported nodes often have a twin of meshes with identical vertex coordinates but opposite normal vectors, find these and offset them
public void processImportedMeshes() {
// this could be a very compute-intensive task
SceneManager.getInstance().cursorWait(true);
for (final Node node : importedNodes) {
NodeWorker.reach(node);
}
clearSelectedMesh();
SceneManager.getInstance().cursorWait(false);
}
use of com.ardor3d.scenegraph.Node in project energy3d by concord-consortium.
the class Foundation method drawImportedNodes.
public void drawImportedNodes() {
if (importedNodes != null) {
final int n = importedNodes.size();
if (n > 0) {
Node ni;
final Vector3 c = getAbsCenter();
// the absolute center is lifted to the center of the bounding box that includes walls when there are
c.setZ(height);
// FIXME: Why negate?
final Matrix3 matrix = new Matrix3().fromAngles(0, 0, -Math.toRadians(getAzimuth()));
for (int i = 0; i < n; i++) {
ni = importedNodes.get(i);
if (root.getChildren().contains(ni)) {
final Vector3 relativePosition = importedNodeStates.get(i).getRelativePosition();
if (relativePosition != null) {
final Vector3 vi = matrix.applyPost(relativePosition, null);
ni.setTranslation(c.add(vi, null));
ni.setRotation(matrix);
for (final Spatial s : ni.getChildren()) {
if (s instanceof Mesh) {
final Mesh m = (Mesh) s;
m.updateModelBound();
}
}
}
}
}
}
}
}
use of com.ardor3d.scenegraph.Node in project energy3d by concord-consortium.
the class Foundation method scanChildrenHeight.
public void scanChildrenHeight() {
if (!isFirstPointInserted()) {
return;
}
boundingHeight = scanChildrenHeight(this) - height;
for (int i = 4; i < Math.min(8, points.size()); i++) {
points.get(i).setZ(boundingHeight + height);
}
if (importedNodes != null) {
boolean taller = false;
for (final Node n : importedNodes) {
final OrientedBoundingBox b = Util.getOrientedBoundingBox(n);
final double bh = b.getCenter().getZ() + b.getExtent().getZ();
if (bh > boundingHeight) {
boundingHeight = bh;
taller = true;
}
}
if (taller) {
// subtract as bounding box height includes the foundation height
boundingHeight -= height;
}
}
newBoundingHeight = boundingHeight;
syncUpperPoints();
updateEditShapes();
}
use of com.ardor3d.scenegraph.Node 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;
}
Aggregations