use of com.jme3.math.Transform in project chordatlas by twak.
the class ObjGen method calculate.
@Override
public void calculate() {
tweed.clearCurrentToolState();
gNode.removeFromParent();
Transform oldTransform = null;
for (Spatial s : gNode.getChildren()) {
s.removeFromParent();
oldTransform = s.getLocalTransform();
}
Spatial mesh = tweed.getAssetManager().loadModel(filename);
Material mat = null;
ColorRGBA genCol = new ColorRGBA(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, transparency);
// addLocal( ColorRGBA.Black.mult( 0.5f ) );
genCol.multLocal(0.35f);
if (transparency == 0) {
mat = new Material(tweed.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
ColorRGBA c = Jme3z.toJme(color);
mat.setColor("Diffuse", c);
mat.setColor("Ambient", c);
mat.setBoolean("UseMaterialColors", true);
} else if (transparency == 1)
mat = null;
else {
mat = new Material(tweed.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.getAdditionalRenderState().setBlendMode(BlendMode.PremultAlpha);
mat.setColor("Color", genCol);
}
Mode mode = renderLines ? Mesh.Mode.Lines : Mesh.Mode.Triangles;
if (mesh instanceof Geometry) {
// objs with several objects are a node
geometry = (Geometry) mesh;
setTexture(geometry, mat);
geometry.getMesh().setMode(mode);
} else {
mesh.setUserData(HandleMe.class.getSimpleName(), true);
for (Spatial s : ((Node) mesh).getChildren()) ((Geometry) s).getMesh().setMode(mode);
}
hasTextures = mat == null;
if (mat != null)
mesh.setMaterial(mat);
if (oldTransform != null)
mesh.setLocalTransform(oldTransform);
gNode.setUserData(HandleMe.class.getSimpleName(), true);
gNode.attachChild(mesh);
super.calculate();
}
use of com.jme3.math.Transform in project chordatlas by twak.
the class PanoGen method createPanoGen.
private void createPanoGen(File f, List<Pano> results) {
String name = f.getName().substring(0, f.getName().length() - 4);
try {
String[] sVals = name.split("[_]", 10);
if (sVals.length < 6)
return;
List<Double> pos = Arrays.asList(Arrays.copyOfRange(sVals, 0, 6)).stream().map(z -> Double.parseDouble(z)).collect(Collectors.toList());
double[] trans = new double[] { pos.get(0), pos.get(1), 0 };
double[] north = new double[] { pos.get(0), pos.get(1) + 1e-6, 0 };
// two part transform to align heights - geoid for 4326 is different to 27700
MathTransform latLong2Country = CRS.findMathTransform(CRS.decode(sourceCRS), CRS.decode(TweedSettings.settings.gmlCoordSystem), true);
latLong2Country.transform(trans, 0, trans, 0, 1);
latLong2Country.transform(north, 0, north, 0, 1);
if (TweedSettings.settings.gmlCoordSystem.equals("EPSG:3042")) {
/* madrid?! */
System.out.println("******* dirty hack in place for flipped CS");
double tmp = trans[0];
trans[0] = trans[1];
trans[1] = tmp;
}
MathTransform country2Cartesian = CRS.findMathTransform(CRS.decode(TweedSettings.settings.gmlCoordSystem), DefaultGeocentricCRS.CARTESIAN, true);
country2Cartesian.transform(trans, 0, trans, 0, 1);
country2Cartesian.transform(north, 0, north, 0, 1);
{
Point3d tmp = new Point3d(trans);
TweedSettings.settings.toOrigin.transform(tmp);
tmp.get(trans);
tmp = new Point3d(north);
TweedSettings.settings.toOrigin.transform(tmp);
tmp.get(north);
}
if (TweedSettings.settings.gmlCoordSystem.equals("EPSG:2062")) {
// oviedo :(
trans[2] -= 258;
north[2] -= 258;
trans[0] += 3;
trans[0] += 3;
}
Vector3d location = new Vector3d(trans[0], 2.5f, /* camera height above floor */
trans[2]);
{
Vector3d west = new Vector3d((float) (trans[0] - north[0]), 0f, (float) (north[2] - trans[2]));
west.scale(0.6f / west.length());
location.add(west);
}
System.out.println("pano@ " + location);
results.add(new Pano(name, location, // + 360 - (toNorth * 180 /FastMath.PI ) ) % 360,
(pos.get(3).floatValue() + 180), pos.get(4).floatValue(), pos.get(5).floatValue()));
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
} catch (NoSuchAuthorityCodeException e) {
e.printStackTrace();
} catch (FactoryException e) {
e.printStackTrace();
} catch (TransformException e) {
e.printStackTrace();
}
}
Aggregations