use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.
the class TestMotionPath method simpleInitApp.
@Override
public void simpleInitApp() {
createScene();
cam.setLocation(new Vector3f(8.4399185f, 11.189463f, 14.267577f));
path = new MotionPath();
path.addWayPoint(new Vector3f(10, 3, 0));
path.addWayPoint(new Vector3f(10, 3, 10));
path.addWayPoint(new Vector3f(-40, 3, 10));
path.addWayPoint(new Vector3f(-40, 3, 0));
path.addWayPoint(new Vector3f(-40, 8, 0));
path.addWayPoint(new Vector3f(10, 8, 0));
path.addWayPoint(new Vector3f(10, 8, 10));
path.addWayPoint(new Vector3f(15, 8, 10));
path.enableDebugShape(assetManager, rootNode);
motionControl = new MotionEvent(teapot, path);
motionControl.setDirectionType(MotionEvent.Direction.PathAndRotation);
motionControl.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y));
motionControl.setInitialDuration(10f);
motionControl.setSpeed(2f);
guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
final BitmapText wayPointsText = new BitmapText(guiFont, false);
wayPointsText.setSize(guiFont.getCharSet().getRenderedSize());
guiNode.attachChild(wayPointsText);
path.addListener(new MotionPathListener() {
public void onWayPointReach(MotionEvent control, int wayPointIndex) {
if (path.getNbWayPoints() == wayPointIndex + 1) {
wayPointsText.setText(control.getSpatial().getName() + "Finished!!! ");
} else {
wayPointsText.setText(control.getSpatial().getName() + " Reached way point " + wayPointIndex);
}
wayPointsText.setLocalTranslation((cam.getWidth() - wayPointsText.getLineWidth()) / 2, cam.getHeight(), 0);
}
});
flyCam.setEnabled(false);
ChaseCamera chaser = new ChaseCamera(cam, teapot);
// motionControl.setSpeed(-3f);
// motionControl.setLoopMode(LoopMode.Loop);
// path.setCycle(true);
// chaser.setEnabled(false);
chaser.registerWithInput(inputManager);
initInputs();
}
use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.
the class ToneMapFilter method read.
@Override
public void read(JmeImporter im) throws IOException {
super.read(im);
InputCapsule ic = im.getCapsule(this);
whitePoint = (Vector3f) ic.readSavable("whitePoint", DEFAULT_WHITEPOINT.clone());
}
use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.
the class LightScatteringFilter method read.
@Override
public void read(JmeImporter im) throws IOException {
super.read(im);
InputCapsule ic = im.getCapsule(this);
lightPosition = (Vector3f) ic.readSavable("lightPosition", Vector3f.ZERO);
nbSamples = ic.readInt("nbSamples", 50);
blurStart = ic.readFloat("blurStart", 0.02f);
blurWidth = ic.readFloat("blurWidth", 0.9f);
lightDensity = ic.readFloat("lightDensity", 1.4f);
adaptative = ic.readBoolean("adaptative", true);
}
use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.
the class MapModel3D method toPosition.
/**
* Converts a world position into a Mercator position.
*
* @param posVec <code>Vector</code> containing the world unit
* coordinates that are to be converted into
* longitude / latitude coordinates.
* @return The resulting <code>Position</code> in degrees of
* latitude and longitude.
* @since 1.0
*/
public Position toPosition(Vector3f posVec) {
double lat, lon;
Position pos = null;
try {
Vector3f worldCentre = toWorldUnit(new Position(0, 0));
// Get the difference between position and the centre
double xDistance = difference(xCentre, posVec.getX());
double yDistance = difference(worldCentre.getZ(), posVec.getZ());
double lonDistanceInDegrees = (xDistance * minutesPerWorldUnit) / 60;
double mp = (yDistance * minutesPerWorldUnit);
// Otherwise use binary search
if (getMinutesPerWu() < 0.05) {
lat = findLat(mp, getCentre().getLatitude());
if (lat == -1000) {
System.out.println("lat: " + lat);
}
} else {
lat = findLat(mp, 0.0, 85.0);
}
lon = (posVec.getX() < xCentre ? centre.getLongitude() - lonDistanceInDegrees : centre.getLongitude() + lonDistanceInDegrees);
if (posVec.getZ() > worldCentre.getZ()) {
lat = -1 * lat;
}
if (lat == -1000 || lon == -1000) {
return pos;
}
pos = new Position(lat, lon);
} catch (InvalidPositionException ipe) {
ipe.printStackTrace();
}
return pos;
}
use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.
the class ShadowUtil method computeBoundForPoints.
/**
* Compute bounds from an array of points
*
* @param pts
* @param transform
* @return
*/
public static BoundingBox computeBoundForPoints(Vector3f[] pts, Transform transform) {
Vector3f min = new Vector3f(Vector3f.POSITIVE_INFINITY);
Vector3f max = new Vector3f(Vector3f.NEGATIVE_INFINITY);
Vector3f temp = new Vector3f();
for (int i = 0; i < pts.length; i++) {
transform.transformVector(pts[i], temp);
min.minLocal(temp);
max.maxLocal(temp);
}
Vector3f center = min.add(max).multLocal(0.5f);
Vector3f extent = max.subtract(min).multLocal(0.5f);
return new BoundingBox(center, extent.x, extent.y, extent.z);
}
Aggregations