Java Code Examples for com.jme3.export.InputCapsule#readFloat()

The following examples show how to use com.jme3.export.InputCapsule#readFloat() . 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: HingeJoint.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule capsule = im.getCapsule(this);
    this.axisA = (Vector3f) capsule.readSavable("axisA", new Vector3f());
    this.axisB = (Vector3f) capsule.readSavable("axisB", new Vector3f());

    this.angularOnly = capsule.readBoolean("angularOnly", false);
    float lowerLimit = capsule.readFloat("lowerLimit", 1e30f);
    float upperLimit = capsule.readFloat("upperLimit", -1e30f);

    this.biasFactor = capsule.readFloat("biasFactor", 0.3f);
    this.relaxationFactor = capsule.readFloat("relaxationFactor", 1f);
    this.limitSoftness = capsule.readFloat("limitSoftness", 0.9f);

    boolean enableAngularMotor=capsule.readBoolean("enableAngularMotor", false);
    float targetVelocity=capsule.readFloat("targetVelocity", 0.0f);
    float maxMotorImpulse=capsule.readFloat("maxMotorImpulse", 0.0f);

    createJoint();
    enableMotor(enableAngularMotor, targetVelocity, maxMotorImpulse);
    ((HingeConstraint) constraint).setLimit(lowerLimit, upperLimit, limitSoftness, biasFactor, relaxationFactor);
}
 
Example 2
Source File: VehicleWheel.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void read(JmeImporter im) throws IOException {
    InputCapsule capsule = im.getCapsule(this);
    wheelSpatial = (Spatial) capsule.readSavable("wheelSpatial", null);
    frontWheel = capsule.readBoolean("frontWheel", false);
    location = (Vector3f) capsule.readSavable("wheelLocation", new Vector3f());
    direction = (Vector3f) capsule.readSavable("wheelDirection", new Vector3f());
    axle = (Vector3f) capsule.readSavable("wheelAxle", new Vector3f());
    suspensionStiffness = capsule.readFloat("suspensionStiffness", 20.0f);
    wheelsDampingRelaxation = capsule.readFloat("wheelsDampingRelaxation", 2.3f);
    wheelsDampingCompression = capsule.readFloat("wheelsDampingCompression", 4.4f);
    frictionSlip = capsule.readFloat("frictionSlip", 10.5f);
    rollInfluence = capsule.readFloat("rollInfluence", 1.0f);
    maxSuspensionTravelCm = capsule.readFloat("maxSuspensionTravelCm", 500f);
    maxSuspensionForce = capsule.readFloat("maxSuspensionForce", 6000f);
    radius = capsule.readFloat("wheelRadius", 0.5f);
    restLength = capsule.readFloat("restLength", 1f);
}
 
Example 3
Source File: UserData.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);
    type = ic.readByte("type", (byte) 0);

    switch (type) {
        case 0:
            value = ic.readInt("intVal", 0);
            break;
        case 1:
            value = ic.readFloat("floatVal", 0f);
            break;
        case 2:
            value = ic.readBoolean("boolVal", false);
            break;
        case 3:
            value = ic.readString("strVal", null);
            break;
        case 4:
            value = ic.readLong("longVal", 0l);
            break;
        default:
            throw new UnsupportedOperationException();
    }
}
 
Example 4
Source File: PhysicsRigidBody.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void read(JmeImporter e) throws IOException {
    super.read(e);

    InputCapsule capsule = e.getCapsule(this);
    float mass = capsule.readFloat("mass", 1.0f);
    this.mass = mass;
    rebuildRigidBody();
    setGravity((Vector3f) capsule.readSavable("gravity", Vector3f.ZERO.clone()));
    setFriction(capsule.readFloat("friction", 0.5f));
    setKinematic(capsule.readBoolean("kinematic", false));

    setRestitution(capsule.readFloat("restitution", 0));
    setAngularFactor(capsule.readFloat("angularFactor", 1));
    setDamping(capsule.readFloat("linearDamping", 0), capsule.readFloat("angularDamping", 0));
    setSleepingThresholds(capsule.readFloat("linearSleepingThreshold", 0.8f), capsule.readFloat("angularSleepingThreshold", 1.0f));
    setCcdMotionThreshold(capsule.readFloat("ccdMotionThreshold", 0));
    setCcdSweptSphereRadius(capsule.readFloat("ccdSweptSphereRadius", 0));

    setPhysicsLocation((Vector3f) capsule.readSavable("physicsLocation", new Vector3f()));
    setPhysicsRotation((Matrix3f) capsule.readSavable("physicsRotation", new Matrix3f()));

    joints = capsule.readSavableArrayList("joints", null);
}
 
Example 5
Source File: TerrainQuad.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void read(JmeImporter e) throws IOException {
    super.read(e);
    InputCapsule c = e.getCapsule(this);
    size = c.readInt("size", 0);
    stepScale = (Vector3f) c.readSavable("stepScale", null);
    offset = (Vector2f) c.readSavable("offset", new Vector2f(0,0));
    offsetAmount = c.readFloat("offsetAmount", 0);
    quadrant = c.readInt("quadrant", 0);
    totalSize = c.readInt("totalSize", 0);
    //lodCalculator = (LodCalculator) c.readSavable("lodCalculator", createDefaultLodCalculator());
    //lodCalculatorFactory = (LodCalculatorFactory) c.readSavable("lodCalculatorFactory", null);
    
    if ( !(getParent() instanceof TerrainQuad) ) {
        BoundingBox all = new BoundingBox(getWorldTranslation(), totalSize, totalSize, totalSize);
        affectedAreaBBox = all;
        updateNormals();
    }
}
 
Example 6
Source File: Torus.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void read(JmeImporter e) throws IOException {
    super.read(e);
    InputCapsule capsule = e.getCapsule(this);
    circleSamples = capsule.readInt("circleSamples", 0);
    radialSamples = capsule.readInt("radialSamples", 0);
    innerRadius = capsule.readFloat("innerRadius", 0);
    outerRadius = capsule.readFloat("outerRaidus", 0);
}
 
Example 7
Source File: Cylinder.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void read(JmeImporter e) throws IOException {
    super.read(e);
    InputCapsule capsule = e.getCapsule(this);
    axisSamples = capsule.readInt("axisSamples", 0);
    radialSamples = capsule.readInt("radialSamples", 0);
    radius = capsule.readFloat("radius", 0);
    radius2 = capsule.readFloat("radius2", 0);
    height = capsule.readFloat("height", 0);
    closed = capsule.readBoolean("closed", false);
    inverted = capsule.readBoolean("inverted", false);
}
 
Example 8
Source File: Torus.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void read(JmeImporter e) throws IOException {
    super.read(e);
    InputCapsule capsule = e.getCapsule(this);
    circleSamples = capsule.readInt("circleSamples", 0);
    radialSamples = capsule.readInt("radialSamples", 0);
    innerRadius = capsule.readFloat("innerRadius", 0);
    outerRadius = capsule.readFloat("outerRaidus", 0);
}
 
Example 9
Source File: BetterCharacterControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * De-serialize this control, for example when loading from a J3O file.
 *
 * @param im importer (not null)
 * @throws IOException from importer
 */
@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule in = im.getCapsule(this);
    this.radius = in.readFloat("radius", 1);
    this.height = in.readFloat("height", 2);
    this.mass = in.readFloat("mass", 80);
    this.physicsDamping = in.readFloat("physicsDamping", 0.9f);
    this.jumpForce.set((Vector3f) in.readSavable("jumpForce", new Vector3f(0, mass * 5, 0)));
    rigidBody = new PhysicsRigidBody(getShape(), mass);
    jumpForce.set(new Vector3f(0, mass * 5, 0));
    rigidBody.setAngularFactor(0);
}
 
Example 10
Source File: LowPassFilter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void read(JmeImporter im) throws IOException{
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    volume = ic.readFloat("volume", 0);
    highFreqVolume = ic.readFloat("hf_volume", 0);
}
 
Example 11
Source File: LightScatteringFilter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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);
}
 
Example 12
Source File: HeightfieldCollisionShape.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule capsule = im.getCapsule(this);
    heightStickWidth = capsule.readInt("heightStickWidth", 0);
    heightStickLength = capsule.readInt("heightStickLength", 0);
    heightScale = capsule.readFloat("heightScale", 0);
    minHeight = capsule.readFloat("minHeight", 0);
    maxHeight = capsule.readFloat("maxHeight", 0);
    upAxis = capsule.readInt("upAxis", 1);
    heightfieldData = capsule.readFloatArray("heightfieldData", new float[0]);
    flipQuadEdges = capsule.readBoolean("flipQuadEdges", false);
    createShape();
}
 
Example 13
Source File: HeightfieldCollisionShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule capsule = im.getCapsule(this);
    heightStickWidth = capsule.readInt("heightStickWidth", 0);
    heightStickLength = capsule.readInt("heightStickLength", 0);
    heightScale = capsule.readFloat("heightScale", 0);
    minHeight = capsule.readFloat("minHeight", 0);
    maxHeight = capsule.readFloat("maxHeight", 0);
    upAxis = capsule.readInt("upAxis", 1);
    heightfieldData = capsule.readFloatArray("heightfieldData", new float[0]);
    flipQuadEdges = capsule.readBoolean("flipQuadEdges", false);
    createShape();
}
 
Example 14
Source File: HeightfieldCollisionShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * De-serialize this shape, for example when loading from a J3O file.
 *
 * @param im importer (not null)
 * @throws IOException from importer
 */
@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule capsule = im.getCapsule(this);
    heightStickWidth = capsule.readInt("heightStickWidth", 0);
    heightStickLength = capsule.readInt("heightStickLength", 0);
    heightScale = capsule.readFloat("heightScale", 0);
    minHeight = capsule.readFloat("minHeight", 0);
    maxHeight = capsule.readFloat("maxHeight", 0);
    upAxis = capsule.readInt("upAxis", 1);
    heightfieldData = capsule.readFloatArray("heightfieldData", new float[0]);
    flipQuadEdges = capsule.readBoolean("flipQuadEdges", false);
    createShape();
}
 
Example 15
Source File: FogFilter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    fogColor = (ColorRGBA) ic.readSavable("fogColor", ColorRGBA.White.clone());
    fogDensity = ic.readFloat("fogDensity", 0.7f);
    fogDistance = ic.readFloat("fogDistance", 1000);
}
 
Example 16
Source File: DepthOfFieldFilter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    blurScale = ic.readFloat("blurScale", 1f);
    focusDistance = ic.readFloat("focusDistance", 50f);
    focusRange = ic.readFloat("focusRange", 10f);
}
 
Example 17
Source File: AudioTrack.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Internal use only serialization
 *
 * @param im importer
 * @throws IOException Exception
 */
public void read(JmeImporter im) throws IOException {
    InputCapsule in = im.getCapsule(this);
    audio = (AudioNode) in.readSavable("audio", null);
    length = in.readFloat("length", length);
    startOffset = in.readFloat("startOffset", 0);
}
 
Example 18
Source File: SliderJoint.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule capsule = im.getCapsule(this);
    float dampingDirAng = capsule.readFloat("dampingDirAng", 0f);
    float dampingDirLin = capsule.readFloat("dampingDirLin", 0f);
    float dampingLimAng = capsule.readFloat("dampingLimAng", 0f);
    float dampingLimLin = capsule.readFloat("dampingLimLin", 0f);
    float dampingOrthoAng = capsule.readFloat("dampingOrthoAng", 0f);
    float dampingOrthoLin = capsule.readFloat("dampingOrthoLin", 0f);
    float lowerAngLimit = capsule.readFloat("lowerAngLimit", 0f);
    float lowerLinLimit = capsule.readFloat("lowerLinLimit", 0f);
    float maxAngMotorForce = capsule.readFloat("maxAngMotorForce", 0f);
    float maxLinMotorForce = capsule.readFloat("maxLinMotorForce", 0f);
    boolean poweredAngMotor = capsule.readBoolean("poweredAngMotor", false);
    boolean poweredLinMotor = capsule.readBoolean("poweredLinMotor", false);
    float restitutionDirAng = capsule.readFloat("restitutionDirAng", 0f);
    float restitutionDirLin = capsule.readFloat("restitutionDirLin", 0f);
    float restitutionLimAng = capsule.readFloat("restitutionLimAng", 0f);
    float restitutionLimLin = capsule.readFloat("restitutionLimLin", 0f);
    float restitutionOrthoAng = capsule.readFloat("restitutionOrthoAng", 0f);
    float restitutionOrthoLin = capsule.readFloat("restitutionOrthoLin", 0f);

    float softnessDirAng = capsule.readFloat("softnessDirAng", 0f);
    float softnessDirLin = capsule.readFloat("softnessDirLin", 0f);
    float softnessLimAng = capsule.readFloat("softnessLimAng", 0f);
    float softnessLimLin = capsule.readFloat("softnessLimLin", 0f);
    float softnessOrthoAng = capsule.readFloat("softnessOrthoAng", 0f);
    float softnessOrthoLin = capsule.readFloat("softnessOrthoLin", 0f);

    float targetAngMotorVelicoty = capsule.readFloat("targetAngMotorVelicoty", 0f);
    float targetLinMotorVelicoty = capsule.readFloat("targetLinMotorVelicoty", 0f);

    float upperAngLimit = capsule.readFloat("upperAngLimit", 0f);
    float upperLinLimit = capsule.readFloat("upperLinLimit", 0f);

    useLinearReferenceFrameA = capsule.readBoolean("useLinearReferenceFrameA", false);

    createJoint();

    ((SliderConstraint)constraint).setDampingDirAng(dampingDirAng);
    ((SliderConstraint)constraint).setDampingDirLin(dampingDirLin);
    ((SliderConstraint)constraint).setDampingLimAng(dampingLimAng);
    ((SliderConstraint)constraint).setDampingLimLin(dampingLimLin);
    ((SliderConstraint)constraint).setDampingOrthoAng(dampingOrthoAng);
    ((SliderConstraint)constraint).setDampingOrthoLin(dampingOrthoLin);
    ((SliderConstraint)constraint).setLowerAngLimit(lowerAngLimit);
    ((SliderConstraint)constraint).setLowerLinLimit(lowerLinLimit);
    ((SliderConstraint)constraint).setMaxAngMotorForce(maxAngMotorForce);
    ((SliderConstraint)constraint).setMaxLinMotorForce(maxLinMotorForce);
    ((SliderConstraint)constraint).setPoweredAngMotor(poweredAngMotor);
    ((SliderConstraint)constraint).setPoweredLinMotor(poweredLinMotor);
    ((SliderConstraint)constraint).setRestitutionDirAng(restitutionDirAng);
    ((SliderConstraint)constraint).setRestitutionDirLin(restitutionDirLin);
    ((SliderConstraint)constraint).setRestitutionLimAng(restitutionLimAng);
    ((SliderConstraint)constraint).setRestitutionLimLin(restitutionLimLin);
    ((SliderConstraint)constraint).setRestitutionOrthoAng(restitutionOrthoAng);
    ((SliderConstraint)constraint).setRestitutionOrthoLin(restitutionOrthoLin);

    ((SliderConstraint)constraint).setSoftnessDirAng(softnessDirAng);
    ((SliderConstraint)constraint).setSoftnessDirLin(softnessDirLin);
    ((SliderConstraint)constraint).setSoftnessLimAng(softnessLimAng);
    ((SliderConstraint)constraint).setSoftnessLimLin(softnessLimLin);
    ((SliderConstraint)constraint).setSoftnessOrthoAng(softnessOrthoAng);
    ((SliderConstraint)constraint).setSoftnessOrthoLin(softnessOrthoLin);

    ((SliderConstraint)constraint).setTargetAngMotorVelocity(targetAngMotorVelicoty);
    ((SliderConstraint)constraint).setTargetLinMotorVelocity(targetLinMotorVelicoty);

    ((SliderConstraint)constraint).setUpperAngLimit(upperAngLimit);
    ((SliderConstraint)constraint).setUpperLinLimit(upperLinLimit);
}
 
Example 19
Source File: FadeFilter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    duration = ic.readFloat("duration", 1);
}
 
Example 20
Source File: EmitterSphereShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);
    center = (Vector3f) ic.readSavable("center", null);
    radius = ic.readFloat("radius", 0);
}