Java Code Examples for com.jme3.export.JmeImporter#getCapsule()

The following examples show how to use com.jme3.export.JmeImporter#getCapsule() . 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: LightList.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);
//        owner = (Spatial) ic.readSavable("owner", null);

        List<Light> lights = ic.readSavableArrayList("lights", null);
        listSize = lights.size();
        
        // NOTE: make sure the array has a length of at least 1
        int arraySize = Math.max(DEFAULT_SIZE, listSize);
        list = new Light[arraySize];
        distToOwner = new float[arraySize];

        for (int i = 0; i < listSize; i++){
            list[i] = lights.get(i);
        }
        
        Arrays.fill(distToOwner, Float.NEGATIVE_INFINITY);
    }
 
Example 2
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 3
Source File: CylinderCollisionShape.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);
    halfExtents = (Vector3f) capsule.readSavable("halfExtents", new Vector3f(0.5f, 0.5f, 0.5f));
    axis = capsule.readInt("axis", 1);
    createShape();
}
 
Example 4
Source File: PhysicsRigidBody.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * De-serialize this body, for example when loading from a J3O file.
 *
 * @param e importer (not null)
 * @throws IOException from importer
 */
@Override
@SuppressWarnings("unchecked")
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()));
    setContactResponse(capsule.readBoolean("contactResponse", true));
    setFriction(capsule.readFloat("friction", 0.5f));
    setKinematic(capsule.readBoolean("kinematic", false));

    setRestitution(capsule.readFloat("restitution", 0));
    Vector3f angularFactor = (Vector3f) capsule.readSavable("angularFactor", null);
    if(angularFactor == null) {
        setAngularFactor(capsule.readFloat("angularFactor", 1));
    } else {
        setAngularFactor(angularFactor);
        setLinearFactor((Vector3f) capsule.readSavable("linearFactor", Vector3f.UNIT_XYZ.clone()));
    }
    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()));
    setLinearVelocity((Vector3f) capsule.readSavable("linearVelocity", new Vector3f()));
    setAngularVelocity((Vector3f) capsule.readSavable("angularVelocity", new Vector3f()));

    joints = capsule.readSavableArrayList("joints", null);
}
 
Example 5
Source File: Point2PointJoint.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);
    createJoint();
    InputCapsule cap = im.getCapsule(this);
    setDamping(cap.readFloat("damping", 1.0f));
    setDamping(cap.readFloat("tau", 0.3f));
    setDamping(cap.readFloat("impulseClamp", 0f));
}
 
Example 6
Source File: CameraControl.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.SpatialToCamera);
    camera = (Camera)ic.readSavable(CAMERA_NAME, null);
}
 
Example 7
Source File: EmitterMeshVertexShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);
    this.vertices = ic.readSavableArrayList("vertices", null);

    List<List<Vector3f>> tmpNormals = ic.readSavableArrayList("normals", null);
    if (tmpNormals != null){
        this.normals = tmpNormals;
    }
}
 
Example 8
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 9
Source File: TextureKey.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);
    flipY = ic.readBoolean("flip_y", false);
    generateMips = ic.readBoolean("generate_mips", false);
    asCube = ic.readBoolean("as_cubemap", false);
    anisotropy = ic.readInt("anisotropy", 0);
}
 
Example 10
Source File: DirectionalLightShadowRendererVR.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);
    lambda = ic.readFloat("lambda", 0.65f);
    zFarOverride = ic.readInt("zFarOverride", 0);
    light = (DirectionalLight) ic.readSavable("light", null);
    fadeInfo = (Vector2f) ic.readSavable("fadeInfo", null);
    fadeLength = ic.readFloat("fadeLength", 0f);
    init(nbShadowMaps, (int) shadowMapSize);
}
 
Example 11
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 12
Source File: MeshCollisionShape.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);
    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]));
    createShape();
}
 
Example 13
Source File: PhysicsJoint.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void read(JmeImporter im) throws IOException {
    InputCapsule capsule = im.getCapsule(this);
    this.nodeA = ((PhysicsRigidBody) capsule.readSavable("nodeA", new PhysicsRigidBody()));
    this.nodeB = (PhysicsRigidBody) capsule.readSavable("nodeB", new PhysicsRigidBody());
    this.pivotA = (Vector3f) capsule.readSavable("pivotA", new Vector3f());
    this.pivotB = (Vector3f) capsule.readSavable("pivotB", new Vector3f());
}
 
Example 14
Source File: VehicleControl.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 ic = im.getCapsule(this);
    enabled = ic.readBoolean("enabled", true);
    spatial = (Spatial) ic.readSavable("spatial", null);
    motionState.setApplyPhysicsLocal(ic.readBoolean("applyLocalPhysics", false));
    setUserObject(spatial);
}
 
Example 15
Source File: PhysicsRigidBody.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * De-serialize this body, for example when loading from a J3O file.
 *
 * @param e importer (not null)
 * @throws IOException from importer
 */
@Override
@SuppressWarnings("unchecked")
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()));
    setContactResponse(capsule.readBoolean("contactResponse", true));
    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()));
    setLinearVelocity((Vector3f) capsule.readSavable("linearVelocity", new Vector3f()));
    setAngularVelocity((Vector3f) capsule.readSavable("angularVelocity", new Vector3f()));

    joints = capsule.readSavableArrayList("joints", null);
}
 
Example 16
Source File: BoxCollisionShape.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);
    Vector3f halfExtents = (Vector3f) capsule.readSavable("halfExtents", new Vector3f(1, 1, 1));
    this.halfExtents = halfExtents;
    createShape();
}
 
Example 17
Source File: DirectionalLightShadowFilterVR.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 ic = im.getCapsule(this);
    shadowRenderer = (DirectionalLightShadowRendererVR) ic.readSavable("shadowRenderer", null);
}
 
Example 18
Source File: EditorCamera.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
/**
 * Read the camera
 */
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);
    maxDistance = ic.readFloat("maxDistance", 40);
    minDistance = ic.readFloat("minDistance", 1);
}
 
Example 19
Source File: ComposeFilter.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 ic = im.getCapsule(this);
}
 
Example 20
Source File: NormalRecalcControl.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);
    terrain = (TerrainQuad) ic.readSavable("terrain", null);
}