| /******************************************************************************* |
| * Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Pierre Allard, |
| * Regent L'Archeveque, |
| * Sebastien Gemme - initial API and implementation |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.common.topology.addons.primitives.impl; |
| |
| import javax.vecmath.Point3d; |
| import javax.vecmath.Vector3d; |
| |
| import org.eclipse.apogy.common.math.ApogyCommonMathFacade; |
| import org.eclipse.apogy.common.math.Tuple3d; |
| import org.eclipse.apogy.common.topology.addons.primitives.AmbientLight; |
| import org.eclipse.apogy.common.topology.addons.primitives.ApogyCommonTopologyAddonsPrimitivesFactory; |
| import org.eclipse.apogy.common.topology.addons.primitives.DirectionalLight; |
| import org.eclipse.apogy.common.topology.addons.primitives.Plane; |
| import org.eclipse.apogy.common.topology.addons.primitives.PointLight; |
| import org.eclipse.apogy.common.topology.addons.primitives.SpotLight; |
| import org.eclipse.apogy.common.topology.addons.primitives.Vector; |
| |
| public class ApogyCommonTopologyAddonsPrimitivesFacadeCustomImpl extends ApogyCommonTopologyAddonsPrimitivesFacadeImpl { |
| |
| @Override |
| public Vector createVector(Vector vector) { |
| Vector result = ApogyCommonTopologyAddonsPrimitivesFactory.eINSTANCE.createVector(); |
| |
| result.setCoordinates(ApogyCommonMathFacade.INSTANCE.createTuple3d(vector.getCoordinates().asTuple3d())); |
| |
| return result; |
| } |
| |
| @Override |
| public Vector createVector(Point3d p0, Point3d p1) { |
| Vector result = ApogyCommonTopologyAddonsPrimitivesFactory.eINSTANCE.createVector(); |
| |
| double length = p0.distance(p1); |
| result.setLength(length); |
| |
| if (length != 0) { |
| Point3d diff = new Point3d(); |
| diff.sub(p1, p0); |
| |
| result.setCoordinates(ApogyCommonMathFacade.INSTANCE.createTuple3d(diff)); |
| } |
| |
| return result; |
| } |
| |
| public Vector createVector(double x, double y, double z) { |
| Vector result = ApogyCommonTopologyAddonsPrimitivesFactory.eINSTANCE.createVector(); |
| |
| result.setCoordinates(ApogyCommonMathFacade.INSTANCE.createTuple3d(x, y, z)); |
| |
| return result; |
| } |
| |
| @Override |
| public Plane createPlane(Vector3d v0, Vector3d v1, double width, double height) { |
| |
| Tuple3d v0Tuple = ApogyCommonMathFacade.INSTANCE.createTuple3d(v0); |
| Tuple3d v1Tuple = ApogyCommonMathFacade.INSTANCE.createTuple3d(v1); |
| |
| Plane plane = ApogyCommonTopologyAddonsPrimitivesFactory.eINSTANCE.createPlane(); |
| plane.setV0(v0Tuple); |
| plane.setV1(v1Tuple); |
| plane.setWidth(width); |
| plane.setHeight(height); |
| |
| return plane; |
| } |
| |
| @Override |
| public AmbientLight createAmbientLight(Tuple3d color) { |
| AmbientLight light = ApogyCommonTopologyAddonsPrimitivesFactory.eINSTANCE.createAmbientLight(); |
| light.setColor(color); |
| |
| return light; |
| } |
| |
| @Override |
| public AmbientLight createAmbientLight(boolean lightOn, Tuple3d color) { |
| AmbientLight light = ApogyCommonTopologyAddonsPrimitivesFactory.eINSTANCE.createAmbientLight(); |
| |
| light.setEnabled(lightOn); |
| light.setColor(color); |
| |
| return light; |
| } |
| |
| @Override |
| public DirectionalLight createDirectionalLight(boolean lightOn, Tuple3d color, Tuple3d direction) { |
| DirectionalLight light = ApogyCommonTopologyAddonsPrimitivesFactory.eINSTANCE.createDirectionalLight(); |
| |
| light.setEnabled(lightOn); |
| light.setDirection(direction); |
| light.setColor(color); |
| |
| return light; |
| } |
| |
| @Override |
| public PointLight createPointLight(Tuple3d color, float radius) { |
| PointLight light = ApogyCommonTopologyAddonsPrimitivesFactory.eINSTANCE.createPointLight(); |
| light.setColor(color); |
| light.setRadius(radius); |
| |
| return light; |
| } |
| |
| public SpotLight createSpotLight(Tuple3d color, float spreadAngle, float spotRange) { |
| SpotLight light = ApogyCommonTopologyAddonsPrimitivesFactory.eINSTANCE.createSpotLight(); |
| |
| light.setColor(color); |
| light.setSpreadAngle(spreadAngle); |
| light.setSpotRange(spotRange); |
| |
| return light; |
| } |
| |
| @Override |
| public DirectionalLight createDirectionalLight(Tuple3d color, Tuple3d direction) { |
| DirectionalLight light = ApogyCommonTopologyAddonsPrimitivesFactory.eINSTANCE.createDirectionalLight(); |
| light.setColor(color); |
| light.setDirection(direction); |
| |
| return light; |
| } |
| |
| public PointLight createPointLight(Tuple3d color) { |
| PointLight light = ApogyCommonTopologyAddonsPrimitivesFactory.eINSTANCE.createPointLight(); |
| light.setColor(color); |
| return light; |
| } |
| |
| } // ApogyCommonTopologyAddonsPrimitivesFacadeImpl |