com.jme3.export.JmeImporter Java Examples

The following examples show how to use com.jme3.export.JmeImporter. 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: Node.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void read(JmeImporter e) throws IOException {
    // XXX: Load children before loading itself!!
    // This prevents empty children list if controls query
    // it in Control.setSpatial().
    children = new SafeArrayList(Spatial.class,
            e.getCapsule(this).readSavableArrayList("children", null));

    // go through children and set parent to this node
    if (children != null) {
        for (Spatial child : children.getArray()) {
            child.parent = this;
        }
    }
    super.read(e);
}
 
Example #2
Source File: HingeJoint.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
    setLimit(lowerLimit, upperLimit, limitSoftness, biasFactor, relaxationFactor);
}
 
Example #3
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 #4
Source File: Image.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void read(JmeImporter e) throws IOException {
    InputCapsule capsule = e.getCapsule(this);
    format = capsule.readEnum("format", Format.class, Format.RGBA8);
    width = capsule.readInt("width", 0);
    height = capsule.readInt("height", 0);
    depth = capsule.readInt("depth", 0);
    mipMapSizes = capsule.readIntArray("mipMapSizes", null);
    multiSamples = capsule.readInt("multiSamples", 1);
    data = capsule.readByteBufferArrayList("data", null);
    colorSpace = capsule.readEnum("colorSpace", ColorSpace.class, null);

    if (mipMapSizes != null) {
        needGeneratedMips = false;
        mipsWereGenerated = true;
    }
}
 
Example #5
Source File: HullCollisionShape.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
    public void read(JmeImporter im) throws IOException {
        super.read(im);
        InputCapsule capsule = im.getCapsule(this);

        // for backwards compatability
        Mesh mesh = (Mesh) capsule.readSavable("hullMesh", null);
        if (mesh != null) {
            this.points = getPoints(mesh);
        } else {
            this.points = capsule.readFloatArray("points", null);

        }
//        fbuf = ByteBuffer.allocateDirect(points.length * 4).asFloatBuffer();
//        fbuf.put(points);
//        fbuf = FloatBuffer.wrap(points).order(ByteOrder.nativeOrder()).asFloatBuffer();
        createShape();
    }
 
Example #6
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 #7
Source File: DacLinks.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 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
@SuppressWarnings("unchecked")
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);

    boneLinkList
            = ic.readSavableArrayList("boneLinkList", null);
    for (BoneLink link : boneLinkList) {
        String name = link.boneName();
        boneLinks.put(name, link);
    }

    skeleton = (Armature) ic.readSavable("skeleton", null);
    transformer = (Spatial) ic.readSavable("transformer", null);
    torsoLink = (TorsoLink) ic.readSavable("torsoLink", null);
}
 
Example #8
Source File: BlenderKey.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 ic = e.getCapsule(this);
    fps = ic.readInt("fps", DEFAULT_FPS);
    featuresToLoad = ic.readInt("features-to-load", FeaturesToLoad.ALL);
    loadUnlinkedAssets = ic.readBoolean("load-unlinked-assets", false);
    assetRootPath = ic.readString("asset-root-path", null);
    fixUpAxis = ic.readBoolean("fix-up-axis", true);
    generatedTexturePPU = ic.readInt("generated-texture-ppu", 128);
    usedWorld = ic.readString("used-world", null);
    defaultMaterial = (Material) ic.readSavable("default-material", null);
    faceCullMode = ic.readEnum("face-cull-mode", FaceCullMode.class, FaceCullMode.Off);
    layersToLoad = ic.readInt("layers-to=load", -1);
    mipmapGenerationMethod = ic.readEnum("mipmap-generation-method", MipmapGenerationMethod.class, MipmapGenerationMethod.GENERATE_WHEN_NEEDED);
}
 
Example #9
Source File: HullCollisionShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 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);

        // for backwards compatability
        Mesh mesh = (Mesh) capsule.readSavable("hullMesh", null);
        if (mesh != null) {
            this.points = getPoints(mesh);
        } else {
            this.points = capsule.readFloatArray("points", null);

        }
//        fbuf = ByteBuffer.allocateDirect(points.length * 4).asFloatBuffer();
//        fbuf.put(points);
//        fbuf = FloatBuffer.wrap(points).order(ByteOrder.nativeOrder()).asFloatBuffer();
        createShape();
    }
 
Example #10
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 #11
Source File: TextureKey.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 ic = im.getCapsule(this);
    flipY = ic.readBoolean("flip_y", false);
    generateMips = ic.readBoolean("generate_mips", false);
    anisotropy = ic.readInt("anisotropy", 0);
    boolean asCube = ic.readBoolean("as_cubemap", false);
    
    if (asCube) {
        // Backwards compat
        textureTypeHint = Type.CubeMap;
    } else {
        textureTypeHint = ic.readEnum("tex_type", Texture.Type.class, Type.TwoDimensional);
    }
}
 
Example #12
Source File: PhysicsCharacter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * De-serialize this character from the specified importer, for example when
 * loading from a J3O file.
 *
 * @param e importer (not null)
 * @throws IOException from importer
 */
@Override
public void read(JmeImporter e) throws IOException {
    super.read(e);
    InputCapsule capsule = e.getCapsule(this);
    stepHeight = capsule.readFloat("stepHeight", 1.0f);
    buildObject();
    setGravity(capsule.readFloat("gravity", 9.8f * 3));
    setMaxSlope(capsule.readFloat("maxSlope", 1.0f));
    setFallSpeed(capsule.readFloat("fallSpeed", 55.0f));
    setJumpSpeed(capsule.readFloat("jumpSpeed", 10.0f));
    setUpAxis(capsule.readInt("upAxis", 1));
    setCcdMotionThreshold(capsule.readFloat("ccdMotionThreshold", 0));
    setCcdSweptSphereRadius(capsule.readFloat("ccdSweptSphereRadius", 0));
    setPhysicsLocation((Vector3f) capsule.readSavable("physicsLocation", new Vector3f()));
}
 
Example #13
Source File: RangeOfMotion.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * De-serialize this preset, 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 {
    InputCapsule capsule = im.getCapsule(this);
    maxX = capsule.readFloat("maxX", 0f);
    minX = capsule.readFloat("minX", 0f);
    maxY = capsule.readFloat("maxY", 0f);
    minY = capsule.readFloat("minY", 0f);
    maxZ = capsule.readFloat("maxZ", 0f);
    minZ = capsule.readFloat("minZ", 0f);
}
 
Example #14
Source File: DynamicAnimControl.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 the importer (not null)
 * @throws IOException from the importer
 */
@Override
@SuppressWarnings("unchecked")
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);

    // isReady and collisionListeners not read
    ragdollMass = ic.readFloat("ragdollMass", 1f);
    centerLocation
            = (Vector3f) ic.readSavable("centerLocation", new Vector3f());
    centerVelocity
            = (Vector3f) ic.readSavable("centerVelocity", new Vector3f());
}
 
Example #15
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 #16
Source File: PhysicsGhostObject.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);
    buildObject();
    setPhysicsLocation((Vector3f) capsule.readSavable("physicsLocation", new Vector3f()));
    setPhysicsRotation(((Matrix3f) capsule.readSavable("physicsRotation", new Matrix3f())));
    setCcdMotionThreshold(capsule.readFloat("ccdMotionThreshold", 0));
    setCcdSweptSphereRadius(capsule.readFloat("ccdSweptSphereRadius", 0));
}
 
Example #17
Source File: SixDofJoint.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);

    Transform transA = new Transform(Converter.convert(new Matrix3f()));
    Converter.convert(pivotA, transA.origin);

    Transform transB = new Transform(Converter.convert(new Matrix3f()));
    Converter.convert(pivotB, transB.origin);
    constraint = new Generic6DofConstraint(nodeA.getObjectId(), nodeB.getObjectId(), transA, transB, useLinearReferenceFrameA);
    gatherMotors();

    setAngularUpperLimit((Vector3f) capsule.readSavable("angularUpperLimit", new Vector3f(Vector3f.POSITIVE_INFINITY)));
    setAngularLowerLimit((Vector3f) capsule.readSavable("angularLowerLimit", new Vector3f(Vector3f.NEGATIVE_INFINITY)));
    setLinearUpperLimit((Vector3f) capsule.readSavable("linearUpperLimit", new Vector3f(Vector3f.POSITIVE_INFINITY)));
    setLinearLowerLimit((Vector3f) capsule.readSavable("linearLowerLimit", new Vector3f(Vector3f.NEGATIVE_INFINITY)));

    for (int i = 0; i < 3; i++) {
        RotationalLimitMotor rotationalLimitMotor = getRotationalLimitMotor(i);
        rotationalLimitMotor.setBounce(capsule.readFloat("rotMotor" + i + "_Bounce", 0.0f));
        rotationalLimitMotor.setDamping(capsule.readFloat("rotMotor" + i + "_Damping", 1.0f));
        rotationalLimitMotor.setERP(capsule.readFloat("rotMotor" + i + "_ERP", 0.5f));
        rotationalLimitMotor.setHiLimit(capsule.readFloat("rotMotor" + i + "_HiLimit", Float.POSITIVE_INFINITY));
        rotationalLimitMotor.setLimitSoftness(capsule.readFloat("rotMotor" + i + "_LimitSoftness", 0.5f));
        rotationalLimitMotor.setLoLimit(capsule.readFloat("rotMotor" + i + "_LoLimit", Float.NEGATIVE_INFINITY));
        rotationalLimitMotor.setMaxLimitForce(capsule.readFloat("rotMotor" + i + "_MaxLimitForce", 300.0f));
        rotationalLimitMotor.setMaxMotorForce(capsule.readFloat("rotMotor" + i + "_MaxMotorForce", 0.1f));
        rotationalLimitMotor.setTargetVelocity(capsule.readFloat("rotMotor" + i + "_TargetVelocity", 0));
        rotationalLimitMotor.setEnableMotor(capsule.readBoolean("rotMotor" + i + "_EnableMotor", false));
    }
    getTranslationalLimitMotor().setAccumulatedImpulse((Vector3f) capsule.readSavable("transMotor_AccumulatedImpulse", Vector3f.ZERO));
    getTranslationalLimitMotor().setDamping(capsule.readFloat("transMotor_Damping", 1.0f));
    getTranslationalLimitMotor().setLimitSoftness(capsule.readFloat("transMotor_LimitSoftness", 0.7f));
    getTranslationalLimitMotor().setLowerLimit((Vector3f) capsule.readSavable("transMotor_LowerLimit", Vector3f.ZERO));
    getTranslationalLimitMotor().setRestitution(capsule.readFloat("transMotor_Restitution", 0.5f));
    getTranslationalLimitMotor().setUpperLimit((Vector3f) capsule.readSavable("transMotor_UpperLimit", Vector3f.ZERO));
}
 
Example #18
Source File: Dome.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);
    planes = capsule.readInt("planes", 0);
    radialSamples = capsule.readInt("radialSamples", 0);
    radius = capsule.readFloat("radius", 0);
    center = (Vector3f) capsule.readSavable("center", Vector3f.ZERO.clone());
}
 
Example #19
Source File: BoundingBox.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);
    xExtent = capsule.readFloat("xExtent", 0);
    yExtent = capsule.readFloat("yExtent", 0);
    zExtent = capsule.readFloat("zExtent", 0);
}
 
Example #20
Source File: SpatialTrack.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);
    translations = (CompactVector3Array) ic.readSavable("translations", null);
    rotations = (CompactQuaternionArray) ic.readSavable("rotations", null);
    times = ic.readFloatArray("times", null);
    scales = (CompactVector3Array) ic.readSavable("scales", null);
}
 
Example #21
Source File: LightControl.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);
    controlDir = ic.readEnum(CONTROL_DIR_NAME, ControlDirection.class, ControlDirection.SpatialToLight);
    light = (Light)ic.readSavable(LIGHT_NAME, null);
}
 
Example #22
Source File: SixDofJoint.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 capsule = im.getCapsule(this);

    Transform transA = new Transform(Converter.convert(new Matrix3f()));
    Converter.convert(pivotA, transA.origin);

    Transform transB = new Transform(Converter.convert(new Matrix3f()));
    Converter.convert(pivotB, transB.origin);
    constraint = new Generic6DofConstraint(nodeA.getObjectId(), nodeB.getObjectId(), transA, transB, useLinearReferenceFrameA);
    gatherMotors();

    setAngularUpperLimit((Vector3f) capsule.readSavable("angularUpperLimit", new Vector3f(Vector3f.POSITIVE_INFINITY)));
    setAngularLowerLimit((Vector3f) capsule.readSavable("angularLowerLimit", new Vector3f(Vector3f.NEGATIVE_INFINITY)));
    setLinearUpperLimit((Vector3f) capsule.readSavable("linearUpperLimit", new Vector3f(Vector3f.POSITIVE_INFINITY)));
    setLinearLowerLimit((Vector3f) capsule.readSavable("linearLowerLimit", new Vector3f(Vector3f.NEGATIVE_INFINITY)));

    for (int i = 0; i < 3; i++) {
        RotationalLimitMotor rotationalLimitMotor = getRotationalLimitMotor(i);
        rotationalLimitMotor.setBounce(capsule.readFloat("rotMotor" + i + "_Bounce", 0.0f));
        rotationalLimitMotor.setDamping(capsule.readFloat("rotMotor" + i + "_Damping", 1.0f));
        rotationalLimitMotor.setERP(capsule.readFloat("rotMotor" + i + "_ERP", 0.5f));
        rotationalLimitMotor.setHiLimit(capsule.readFloat("rotMotor" + i + "_HiLimit", Float.POSITIVE_INFINITY));
        rotationalLimitMotor.setLimitSoftness(capsule.readFloat("rotMotor" + i + "_LimitSoftness", 0.5f));
        rotationalLimitMotor.setLoLimit(capsule.readFloat("rotMotor" + i + "_LoLimit", Float.NEGATIVE_INFINITY));
        rotationalLimitMotor.setMaxLimitForce(capsule.readFloat("rotMotor" + i + "_MaxLimitForce", 300.0f));
        rotationalLimitMotor.setMaxMotorForce(capsule.readFloat("rotMotor" + i + "_MaxMotorForce", 0.1f));
        rotationalLimitMotor.setTargetVelocity(capsule.readFloat("rotMotor" + i + "_TargetVelocity", 0));
        rotationalLimitMotor.setEnableMotor(capsule.readBoolean("rotMotor" + i + "_EnableMotor", false));
    }
    getTranslationalLimitMotor().setAccumulatedImpulse((Vector3f) capsule.readSavable("transMotor_AccumulatedImpulse", Vector3f.ZERO));
    getTranslationalLimitMotor().setDamping(capsule.readFloat("transMotor_Damping", 1.0f));
    getTranslationalLimitMotor().setLimitSoftness(capsule.readFloat("transMotor_LimitSoftness", 0.7f));
    getTranslationalLimitMotor().setLowerLimit((Vector3f) capsule.readSavable("transMotor_LowerLimit", Vector3f.ZERO));
    getTranslationalLimitMotor().setRestitution(capsule.readFloat("transMotor_Restitution", 0.5f));
    getTranslationalLimitMotor().setUpperLimit((Vector3f) capsule.readSavable("transMotor_UpperLimit", Vector3f.ZERO));
}
 
Example #23
Source File: PhysicsVehicle.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void read(JmeImporter im) throws IOException {
    InputCapsule capsule = im.getCapsule(this);
    tuning = new VehicleTuning();
    tuning.frictionSlip = capsule.readFloat("frictionSlip", 10.5f);
    tuning.maxSuspensionTravelCm = capsule.readFloat("maxSuspensionTravelCm", 500f);
    tuning.maxSuspensionForce = capsule.readFloat("maxSuspensionForce", 6000f);
    tuning.suspensionCompression = capsule.readFloat("suspensionCompression", 0.83f);
    tuning.suspensionDamping = capsule.readFloat("suspensionDamping", 0.88f);
    tuning.suspensionStiffness = capsule.readFloat("suspensionStiffness", 5.88f);
    wheels = capsule.readSavableArrayList("wheelsList", new ArrayList<VehicleWheel>());
    motionState.setVehicle(this);
    super.read(im);
}
 
Example #24
Source File: SixDofJoint.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * De-serialize this joint, 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);

    objectId = createJoint(nodeA.getObjectId(), nodeB.getObjectId(), pivotA, rotA, pivotB, rotB, useLinearReferenceFrameA);
    Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created Joint {0}", Long.toHexString(objectId));
    gatherMotors();

    setAngularUpperLimit((Vector3f) capsule.readSavable("angularUpperLimit", new Vector3f(Vector3f.POSITIVE_INFINITY)));
    setAngularLowerLimit((Vector3f) capsule.readSavable("angularLowerLimit", new Vector3f(Vector3f.NEGATIVE_INFINITY)));
    setLinearUpperLimit((Vector3f) capsule.readSavable("linearUpperLimit", new Vector3f(Vector3f.POSITIVE_INFINITY)));
    setLinearLowerLimit((Vector3f) capsule.readSavable("linearLowerLimit", new Vector3f(Vector3f.NEGATIVE_INFINITY)));

    for (int i = 0; i < 3; i++) {
        RotationalLimitMotor rotationalLimitMotor = getRotationalLimitMotor(i);
        rotationalLimitMotor.setBounce(capsule.readFloat("rotMotor" + i + "_Bounce", 0.0f));
        rotationalLimitMotor.setDamping(capsule.readFloat("rotMotor" + i + "_Damping", 1.0f));
        rotationalLimitMotor.setERP(capsule.readFloat("rotMotor" + i + "_ERP", 0.5f));
        rotationalLimitMotor.setHiLimit(capsule.readFloat("rotMotor" + i + "_HiLimit", Float.POSITIVE_INFINITY));
        rotationalLimitMotor.setLimitSoftness(capsule.readFloat("rotMotor" + i + "_LimitSoftness", 0.5f));
        rotationalLimitMotor.setLoLimit(capsule.readFloat("rotMotor" + i + "_LoLimit", Float.NEGATIVE_INFINITY));
        rotationalLimitMotor.setMaxLimitForce(capsule.readFloat("rotMotor" + i + "_MaxLimitForce", 300.0f));
        rotationalLimitMotor.setMaxMotorForce(capsule.readFloat("rotMotor" + i + "_MaxMotorForce", 0.1f));
        rotationalLimitMotor.setTargetVelocity(capsule.readFloat("rotMotor" + i + "_TargetVelocity", 0));
        rotationalLimitMotor.setEnableMotor(capsule.readBoolean("rotMotor" + i + "_EnableMotor", false));
    }
    getTranslationalLimitMotor().setAccumulatedImpulse((Vector3f) capsule.readSavable("transMotor_AccumulatedImpulse", Vector3f.ZERO));
    getTranslationalLimitMotor().setDamping(capsule.readFloat("transMotor_Damping", 1.0f));
    getTranslationalLimitMotor().setLimitSoftness(capsule.readFloat("transMotor_LimitSoftness", 0.7f));
    getTranslationalLimitMotor().setLowerLimit((Vector3f) capsule.readSavable("transMotor_LowerLimit", Vector3f.ZERO));
    getTranslationalLimitMotor().setRestitution(capsule.readFloat("transMotor_Restitution", 0.5f));
    getTranslationalLimitMotor().setUpperLimit((Vector3f) capsule.readSavable("transMotor_UpperLimit", Vector3f.ZERO));

    for (int axisIndex = 0; axisIndex < 3; ++axisIndex) {
        translationalMotor.setEnabled(axisIndex, capsule.readBoolean(
                "transMotor_Enable" + axisIndex, false));
    }
}
 
Example #25
Source File: Cinematic.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);

    cinematicEvents = ic.readSavableArrayList("cinematicEvents", null);
    cameras = (Map<String, CameraNode>) ic.readStringSavableMap("cameras", null);
    timeLine = (TimeLine) ic.readSavable("timeLine", null);
    niftyXmlPath = ic.readString("niftyXmlPath", null);

}
 
Example #26
Source File: MeshCollisionShape.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);
    numVertices = capsule.readInt("numVertices", 0);
    numTriangles = capsule.readInt("numTriangles", 0);
    vertexStride = capsule.readInt("vertexStride", 0);
    triangleIndexStride = capsule.readInt("triangleIndexStride", 0);

    triangleIndexBase = ByteBuffer.wrap(capsule.readByteArray("triangleIndexBase", new byte[0]));
    vertexBase = ByteBuffer.wrap(capsule.readByteArray("vertexBase", new byte[0])).order(ByteOrder.nativeOrder());
    createShape();
}
 
Example #27
Source File: AbstractCinematicEvent.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * for serialization only
 * @param im importer
 * @throws IOException 
 */
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);
    playState = ic.readEnum("playState", PlayState.class, PlayState.Stopped);
    speed = ic.readFloat("speed", 1);
    initialDuration = ic.readFloat("initalDuration", 10);
    loopMode = ic.readEnum("loopMode", LoopMode.class, LoopMode.DontLoop);
}
 
Example #28
Source File: Line.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 in = im.getCapsule(this);

    start = (Vector3f) in.readSavable("startVertex", null);
    end = (Vector3f) in.readSavable("endVertex", null);
}
 
Example #29
Source File: CompoundCollisionShape.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);
    children = capsule.readSavableArrayList("children", new ArrayList<ChildCollisionShape>());
    cShape.setLocalScaling(Converter.convert(getScale()));
    cShape.setMargin(margin);
    loadChildren();
}
 
Example #30
Source File: MatParamTexture.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);
    texture = (Texture) value;
    colorSpace = ic.readEnum("colorSpace", ColorSpace.class, null);
}