use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Wall method computeWallAndWindowPolygon.
public List<List<Vector3>> computeWallAndWindowPolygon(final boolean backMesh) {
final List<List<Vector3>> polygonPoints = new ArrayList<List<Vector3>>();
final ReadOnlyVector3 trans = backMesh ? getThicknessNormal() : Vector3.ZERO;
// Start the polygon with (1) then 0, 2, 3, [roof points] so that roof points are appended to the end of vertex list
final ArrayList<Vector3> wallPoints = new ArrayList<Vector3>(4);
addPolygonPoint(wallPoints, this, 1, trans);
addPolygonPoint(wallPoints, this, 0, trans);
addPolygonPoint(wallPoints, this, 2, trans);
addPolygonPoint(wallPoints, this, 3, trans);
polygonPoints.add(wallPoints);
// Add window holes
for (final HousePart child : children) {
if (child instanceof Window && includeWindow(child)) {
polygonPoints.add(computeWindowHole(child, trans));
}
}
return polygonPoints;
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Window method drawAnnotations.
@Override
public void drawAnnotations() {
if (points.size() < 4) {
return;
}
int annotCounter = 0;
Vector3 p0 = getAbsPoint(0);
Vector3 p1 = getAbsPoint(1);
Vector3 p2 = getAbsPoint(2);
Vector3 p3 = getAbsPoint(3);
final int vIndex = getNormal().equals(Vector3.UNIT_Z) ? 1 : 2;
if (!Util.isEqual(p0.getValue(vIndex), p2.getValue(vIndex))) {
final Vector3 tmp = p0;
p0 = p2;
p2 = p3;
p3 = p1;
p1 = tmp;
}
if (p0.getValue(vIndex) > p1.getValue(vIndex)) {
swap(p0, p1);
swap(p2, p3);
}
final Vector3 p01 = p1.subtract(p0, null).normalizeLocal();
if (p2.subtract(p0, null).normalizeLocal().dot(p01.cross(getNormal(), null)) < 0) {
swap(p0, p2);
swap(p1, p3);
}
final Vector3 cornerXY = p0.subtract(container.getAbsPoint(0), null);
cornerXY.setZ(0);
final ReadOnlyVector3 faceDirection = getNormal();
if (container instanceof Wall) {
final ReadOnlyVector3 v02 = container.getAbsPoint(2).subtract(container.getAbsPoint(0), null);
final boolean reversedFace = v02.normalize(null).crossLocal(container.getNormal()).dot(Vector3.NEG_UNIT_Z) < 0.0;
double xy = cornerXY.length();
if (reversedFace) {
xy = v02.length() - xy;
}
label1.setText("(" + Math.round(Scene.getInstance().getAnnotationScale() * 10 * xy) / 10.0 + ", " + Math.round(Scene.getInstance().getAnnotationScale() * 10.0 * (p0.getZ() - container.getAbsPoint(0).getZ())) / 10.0 + ")");
label1.setTranslation(p0);
label1.setRotation(new Matrix3().fromAngles(0, 0, -Util.angleBetween(v02.normalize(null).multiplyLocal(reversedFace ? -1 : 1), Vector3.UNIT_X, Vector3.UNIT_Z)));
}
final ReadOnlyVector3 center = getCenter();
final float lineWidth = original == null ? 1f : 2f;
SizeAnnotation annot = fetchSizeAnnot(annotCounter++);
annot.setRange(p0, p1, center, faceDirection, false, Align.Center, true, true, false);
annot.setLineWidth(lineWidth);
annot = fetchSizeAnnot(annotCounter++);
annot.setRange(p0, p2, center, faceDirection, false, Align.Center, true, false, false);
annot.setLineWidth(lineWidth);
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class CameraControl method animate.
public void animate() {
final double currentTime = SceneManager.getInstance().getTimer().getTimeInSeconds();
final double t = currentTime - animationTime;
final double animationDuration = 1.0;
final ReadOnlyVector3 currentDirection = orgCameraDirection.multiply(animationDuration - t, null).addLocal(newCameraDirection.multiply(t, null)).normalizeLocal();
final ReadOnlyVector3 currentLocation = orgCameraLocation.multiply(animationDuration - t, null).addLocal(newCameraLocation.multiply(t, null));
Camera.getCurrentCamera().setLocation(currentLocation);
Camera.getCurrentCamera().lookAt(currentLocation.add(currentDirection, null), Vector3.UNIT_Z);
SceneManager.getInstance().getCameraNode().updateFromCamera();
Scene.getInstance().updateEditShapes();
if (t > animationDuration) {
animationTime = -1;
}
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class CameraControl method zoomAtPoint.
public void zoomAtPoint(final ReadOnlyVector3 clickedPoint) {
final boolean isPrintPreview = PrintController.getInstance().isPrintPreview();
final double zoomInDistance = isPrintPreview ? 50 : 20;
final double zoomDistance;
final boolean zoomOut = Camera.getCurrentCamera().getLocation().distance(clickedPoint) < zoomInDistance + 1;
if (zoomOut) {
zoomDistance = 100.0;
} else {
zoomDistance = zoomInDistance;
}
orgCameraDirection = new Vector3(Camera.getCurrentCamera().getDirection());
orgCameraLocation = new Vector3(Camera.getCurrentCamera().getLocation());
if (isPrintPreview) {
newCameraDirection = Vector3.UNIT_Y;
} else {
newCameraDirection = clickedPoint.subtract(Camera.getCurrentCamera().getLocation(), null).normalizeLocal();
}
if (isPrintPreview && zoomOut) {
newCameraLocation = PrintController.getInstance().getZoomAllCameraLocation();
} else {
newCameraLocation = clickedPoint.subtract(newCameraDirection.multiply(zoomDistance, null), null);
}
animationTime = SceneManager.getInstance().getTimer().getTimeInSeconds();
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class TriangleMeshLib method createMeshes.
private static List<Mesh> createMeshes(final ArrayList<GroupData> groups) {
final List<Mesh> results = new ArrayList<Mesh>();
for (final GroupData group : groups) {
final Mesh mesh = new Mesh();
mesh.setUserData(group.key);
mesh.setModelBound(new BoundingBox());
results.add(mesh);
final FloatBuffer vertexBuffer = BufferUtils.createVector3Buffer(group.vertices.size());
mesh.getMeshData().setVertexBuffer(vertexBuffer);
for (final ReadOnlyVector3 v : group.vertices) {
vertexBuffer.put(v.getXf()).put(v.getYf()).put(v.getZf());
}
final FloatBuffer normalBuffer = BufferUtils.createFloatBuffer(vertexBuffer.limit());
mesh.getMeshData().setNormalBuffer(normalBuffer);
for (final ReadOnlyVector3 v : group.normals) {
normalBuffer.put(v.getXf()).put(v.getYf()).put(v.getZf());
}
if (!group.textures.isEmpty()) {
final FloatBuffer textureBuffer = BufferUtils.createVector2Buffer(group.textures.size());
mesh.getMeshData().setTextureBuffer(textureBuffer, 0);
for (final ReadOnlyVector2 v : group.textures) {
textureBuffer.put(v.getXf()).put(v.getYf());
}
if (group.textureImage != null) {
final Texture texture = TextureManager.loadFromImage(group.textureImage, Texture.MinificationFilter.Trilinear, TextureStoreFormat.GuessNoCompressedFormat);
final TextureState ts = new TextureState();
ts.setTexture(texture);
mesh.setRenderState(ts);
}
}
mesh.updateModelBound();
}
return results;
}
Aggregations