Java Code Examples for com.jme3.math.Vector3f#isValidVector()

The following examples show how to use com.jme3.math.Vector3f#isValidVector() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestIssue1138.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleUpdate(float tpf) {
    for (Joint joint : sControl.getArmature().getJointList()) {
        Vector3f translation = joint.getLocalTranslation();
        if (!Vector3f.isValidVector(translation)) {
            String msg = "Invalid translation for joint " + joint.getName();
            throw new IllegalStateException(msg);
        }
    }
}
 
Example 2
Source File: ParticleEmitter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get the normal which particles are facing.
 *
 * @return the normal which particles are facing.
 *
 * @see ParticleEmitter#setFaceNormal(com.jme3.math.Vector3f)
 */
public Vector3f getFaceNormal() {
    if (Vector3f.isValidVector(faceNormal)) {
        return faceNormal;
    } else {
        return null;
    }
}
 
Example 3
Source File: ParticleEmitter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Instantly emits available particles, up to num.
 */
public void emitParticles(int num) {
    // Force world transform to update
    this.getWorldTransform();

    TempVars vars = TempVars.get();

    BoundingBox bbox = (BoundingBox) this.getMesh().getBound();

    Vector3f min = vars.vect1;
    Vector3f max = vars.vect2;

    bbox.getMin(min);
    bbox.getMax(max);

    if (!Vector3f.isValidVector(min)) {
        min.set(Vector3f.POSITIVE_INFINITY);
    }
    if (!Vector3f.isValidVector(max)) {
        max.set(Vector3f.NEGATIVE_INFINITY);
    }

    for(int i=0;i<num;i++) {
        if( emitParticle(min, max) == null ) break;
    }

    bbox.setMinMax(min, max);
    this.setBoundRefresh();

    vars.release();
}
 
Example 4
Source File: MyParticleEmitter.java    From OpenRTS with MIT License 5 votes vote down vote up
/**
 * Get the normal which particles are facing. 
 * 
 * @return the normal which particles are facing. 
 * 
 * @see ParticleEmitter#setFaceNormal(com.jme3.math.Vector3f) 
 */
@Override
public Vector3f getFaceNormal() {
    if (Vector3f.isValidVector(faceNormal)) {
        return faceNormal;
    } else {
        return null;
    }
}
 
Example 5
Source File: MyParticleEmitter.java    From OpenRTS with MIT License 5 votes vote down vote up
/**
 * Instantly emits all the particles possible to be emitted. Any particles
 * which are currently inactive will be spawned immediately.
 */
@Override
public void emitAllParticles() {
    // Force world transform to update
    this.getWorldTransform();

    TempVars vars = TempVars.get();

    BoundingBox bbox = (BoundingBox) this.getMesh().getBound();

    Vector3f min = vars.vect1;
    Vector3f max = vars.vect2;

    bbox.getMin(min);
    bbox.getMax(max);

    if (!Vector3f.isValidVector(min)) {
        min.set(Vector3f.POSITIVE_INFINITY);
    }
    if (!Vector3f.isValidVector(max)) {
        max.set(Vector3f.NEGATIVE_INFINITY);
    }

    while (emitParticle(min, max) != null);

    bbox.setMinMax(min, max);
    this.setBoundRefresh();

    vars.release();
}
 
Example 6
Source File: ParticleEmitter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Get the normal which particles are facing. 
 * 
 * @return the normal which particles are facing. 
 * 
 * @see ParticleEmitter#setFaceNormal(com.jme3.math.Vector3f) 
 */
public Vector3f getFaceNormal() {
    if (Vector3f.isValidVector(faceNormal)) {
        return faceNormal;
    } else {
        return null;
    }
}
 
Example 7
Source File: ParticleEmitter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Instantly emits all the particles possible to be emitted. Any particles
 * which are currently inactive will be spawned immediately.
 */
public void emitAllParticles() {
    // Force world transform to update
    this.getWorldTransform();

    TempVars vars = TempVars.get();

    BoundingBox bbox = (BoundingBox) this.getMesh().getBound();

    Vector3f min = vars.vect1;
    Vector3f max = vars.vect2;

    bbox.getMin(min);
    bbox.getMax(max);

    if (!Vector3f.isValidVector(min)) {
        min.set(Vector3f.POSITIVE_INFINITY);
    }
    if (!Vector3f.isValidVector(max)) {
        max.set(Vector3f.NEGATIVE_INFINITY);
    }

    while (emitParticle(min, max) != null);

    bbox.setMinMax(min, max);
    this.setBoundRefresh();

    vars.release();
}
 
Example 8
Source File: ParticleEmitter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Sets the normal which particles are facing.
 *
 * <p>By default, particles
 * will face the camera, but for some effects (e.g shockwave) it may
 * be necessary to face a specific direction instead. To restore
 * normal functionality, provide <code>null</code> as the argument for
 * <code>faceNormal</code>.
 *
 * @param faceNormal The normals particles should face, or <code>null</code>
 * if particles should face the camera.
 */
public void setFaceNormal(Vector3f faceNormal) {
    if (faceNormal == null || !Vector3f.isValidVector(faceNormal)) {
        this.faceNormal.set(Vector3f.NAN);
    } else {
        this.faceNormal = faceNormal;
    }
}
 
Example 9
Source File: MyParticleEmitter.java    From OpenRTS with MIT License 3 votes vote down vote up
/**
 * Sets the normal which particles are facing. 
 * 
 * <p>By default, particles
 * will face the camera, but for some effects (e.g shockwave) it may
 * be necessary to face a specific direction instead. To restore
 * normal functionality, provide <code>null</code> as the argument for
 * <code>faceNormal</code>.
 *
 * @param faceNormal The normals particles should face, or <code>null</code>
 * if particles should face the camera.
 */
@Override
public void setFaceNormal(Vector3f faceNormal) {
    if (faceNormal == null || !Vector3f.isValidVector(faceNormal)) {
        this.faceNormal.set(Vector3f.NAN);
    } else {
        this.faceNormal = faceNormal;
    }
}
 
Example 10
Source File: ParticleEmitter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 3 votes vote down vote up
/**
 * Sets the normal which particles are facing. 
 * 
 * <p>By default, particles
 * will face the camera, but for some effects (e.g shockwave) it may
 * be necessary to face a specific direction instead. To restore
 * normal functionality, provide <code>null</code> as the argument for
 * <code>faceNormal</code>.
 *
 * @param faceNormal The normals particles should face, or <code>null</code>
 * if particles should face the camera.
 */
public void setFaceNormal(Vector3f faceNormal) {
    if (faceNormal == null || !Vector3f.isValidVector(faceNormal)) {
        this.faceNormal.set(Vector3f.NAN);
    } else {
        this.faceNormal = faceNormal;
    }
}