Search in sources :

Example 91 with Vector3f

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();
}
Also used : MotionPathListener(com.jme3.cinematic.MotionPathListener) BitmapText(com.jme3.font.BitmapText) Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) ChaseCamera(com.jme3.input.ChaseCamera) MotionPath(com.jme3.cinematic.MotionPath) MotionEvent(com.jme3.cinematic.events.MotionEvent)

Example 92 with Vector3f

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());
}
Also used : InputCapsule(com.jme3.export.InputCapsule)

Example 93 with Vector3f

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);
}
Also used : InputCapsule(com.jme3.export.InputCapsule)

Example 94 with Vector3f

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;
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 95 with Vector3f

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);
}
Also used : Vector3f(com.jme3.math.Vector3f) BoundingBox(com.jme3.bounding.BoundingBox)

Aggregations

Vector3f (com.jme3.math.Vector3f)536 Material (com.jme3.material.Material)126 Geometry (com.jme3.scene.Geometry)118 DirectionalLight (com.jme3.light.DirectionalLight)95 Quaternion (com.jme3.math.Quaternion)94 TempVars (com.jme3.util.TempVars)67 ColorRGBA (com.jme3.math.ColorRGBA)64 Node (com.jme3.scene.Node)63 Spatial (com.jme3.scene.Spatial)57 Box (com.jme3.scene.shape.Box)57 Sphere (com.jme3.scene.shape.Sphere)51 Texture (com.jme3.texture.Texture)41 KeyTrigger (com.jme3.input.controls.KeyTrigger)36 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)35 Vector2f (com.jme3.math.Vector2f)35 FilterPostProcessor (com.jme3.post.FilterPostProcessor)34 FloatBuffer (java.nio.FloatBuffer)34 InputCapsule (com.jme3.export.InputCapsule)33 BoundingBox (com.jme3.bounding.BoundingBox)30 AmbientLight (com.jme3.light.AmbientLight)30