use of com.ardor3d.scenegraph.Mesh in project energy3d by concord-consortium.
the class FoundationPolygon method setPreviewPoint.
@Override
public void setPreviewPoint(final int x, final int y) {
final PickedHousePart pick = SelectUtil.pickPart(x, y, container);
Vector3 p;
if (pick != null) {
p = pick.getPoint().clone();
p.setZ(container.getHeight());
final Vector3 relativeP = toRelative(p);
final int n = points.size() / 2;
if (editPointIndex < n) {
points.get(editPointIndex).set(relativeP);
} else {
if (SelectUtil.getCurrentEditPointMesh() != null) {
SelectUtil.getCurrentEditPointMesh().setDefaultColor(ColorRGBA.WHITE);
}
editPointIndex -= n;
final Mesh editPointShape = getEditPointShape(editPointIndex);
SelectUtil.setCurrentEditPointMesh(editPointShape);
editPointShape.setDefaultColor(ColorRGBA.RED);
points.add(editPointIndex, relativeP);
points.add(new Vector3());
setEditPointsVisible(true);
}
draw();
}
}
use of com.ardor3d.scenegraph.Mesh in project energy3d by concord-consortium.
the class HousePart method addPrintMesh.
protected void addPrintMesh(final List<Mesh> list, final Mesh mesh) {
if (mesh.getSceneHints().getCullHint() != CullHint.Always) {
final Mesh newMesh = mesh.makeCopy(false);
final MaterialState material = new MaterialState();
material.setDiffuse(mesh.getDefaultColor());
newMesh.setRenderState(material);
newMesh.getMeshData().transformVertices((Transform) mesh.getWorldTransform());
newMesh.getMeshData().transformNormals((Transform) mesh.getWorldTransform(), true);
list.add(newMesh);
}
}
use of com.ardor3d.scenegraph.Mesh 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.scenegraph.Mesh in project energy3d by concord-consortium.
the class Scene method exportObj.
public void exportObj(final File file) throws Exception {
try {
final List<Mesh> objs = new ArrayList<Mesh>();
for (final HousePart part : parts) {
part.addPrintMeshes(objs);
}
final Quaternion rotate = new Quaternion(-1, 0, 0, 1);
for (final Mesh mesh : objs) {
mesh.getMeshData().rotatePoints(rotate);
if (mesh.getMeshData().getNormalBuffer() != null) {
mesh.getMeshData().rotateNormals(rotate);
}
mesh.updateModelBound();
}
final String s = file.toString();
new ObjExporter().save(objs, new File(s), new File(s.substring(0, s.lastIndexOf(".")) + ".mtl"), null);
} catch (final Throwable t) {
BugReporter.report(t);
}
}
use of com.ardor3d.scenegraph.Mesh in project energy3d by concord-consortium.
the class Scene method applyGroundImage.
private void applyGroundImage() {
final Mesh mesh = SceneManager.getInstance().getGroundImageLand();
if (groundImage == null) {
// set a dummy texture in case the mesh holds the original buffered image and causes memory leak
mesh.setRenderState(new TextureState());
mesh.setVisible(false);
setFoundationsVisible(true);
} else {
SceneManager.getInstance().resizeGroundImageLand(groundImageScale);
final Texture2D texture = new Texture2D();
texture.setTextureKey(TextureKey.getRTTKey(MinificationFilter.NearestNeighborNoMipMaps));
texture.setImage(AWTImageLoader.makeArdor3dImage(groundImage, true));
final TextureState textureState = new TextureState();
textureState.setTexture(texture);
mesh.setRenderState(textureState);
mesh.setVisible(!hideGroundImage);
setFoundationsVisible(false);
}
}
Aggregations