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

The following examples show how to use com.jme3.export.InputCapsule#readSavableArrayList() . 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: PhysicsVehicle.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * De-serialize this vehicle, 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 {
    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 2
Source File: PhysicsLink.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * De-serialize this link, 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 {
    InputCapsule ic = im.getCapsule(this);

    children = ic.readSavableArrayList("children", new ArrayList(1));
    bone = (Joint) ic.readSavable("bone", null);
    control = (DacLinks) ic.readSavable("control", null);
    blendInterval = ic.readFloat("blendInterval", 1f);
    kinematicWeight = ic.readFloat("kinematicWeight", 1f);
    joint = (PhysicsJoint) ic.readSavable("joint", null);
    parent = (PhysicsLink) ic.readSavable("parent", null);
    rigidBody = (PhysicsRigidBody) ic.readSavable("rigidBody", null);
    kpTransform
            = (Transform) ic.readSavable("kpTransform", new Transform());
    kpVelocity = (Vector3f) ic.readSavable("kpVelocity", new Vector3f());
    localOffset = (Vector3f) ic.readSavable("offset", new Vector3f());
}
 
Example 3
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 4
Source File: ShaderNodeDefinition.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * jme serialization (not used)
 *
 * @param im the importer
 * @throws IOException
 */
@Override
@SuppressWarnings("unchecked")
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);
    name = ic.readString("name", "");

    String[] str = ic.readStringArray("shadersLanguage", null);
    if (str != null) {
        shadersLanguage = Arrays.asList(str);
    } else {
        shadersLanguage = new ArrayList<String>();
    }

    str = ic.readStringArray("shadersPath", null);
    if (str != null) {
        shadersPath = Arrays.asList(str);
    } else {
        shadersPath = new ArrayList<String>();
    }

    type = ic.readEnum("type", Shader.ShaderType.class, null);
    inputs = ic.readSavableArrayList("inputs", new ArrayList<>());
    outputs = ic.readSavableArrayList("outputs", new ArrayList<>());
}
 
Example 5
Source File: AssetLinkNode.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 {
    super.read(e);

    final InputCapsule capsule = e.getCapsule(this);
    final AssetManager assetManager = e.getAssetManager();

    assetLoaderKeys = capsule.readSavableArrayList("assetLoaderKeyList", new ArrayList<>());

    for (final Iterator<ModelKey> iterator = assetLoaderKeys.iterator(); iterator.hasNext(); ) {

        final ModelKey modelKey = iterator.next();
        final Spatial child = assetManager.loadAsset(modelKey);

        if (child != null) {
            child.parent = this;
            children.add(child);
            assetChildren.put(modelKey, child);
        } else {
            Logger.getLogger(this.getClass().getName()).log(Level.WARNING,
                    "Cannot locate {0} for asset link node {1}", new Object[]{modelKey, key});
        }
    }
}
 
Example 6
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 7
Source File: ShaderGenerationInfo.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);
    attributes = ic.readSavableArrayList("attributes", new ArrayList<ShaderNodeVariable>());
    vertexUniforms = ic.readSavableArrayList("vertexUniforms", new ArrayList<ShaderNodeVariable>());
    varyings = ic.readSavableArrayList("varyings", new ArrayList<ShaderNodeVariable>());
    fragmentUniforms = ic.readSavableArrayList("fragmentUniforms", new ArrayList<ShaderNodeVariable>());
    fragmentGlobals = ic.readSavableArrayList("fragmentGlobals", new ArrayList<ShaderNodeVariable>());
    vertexGlobal = (ShaderNodeVariable) ic.readSavable("vertexGlobal", null);

}
 
Example 8
Source File: Shader.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void read(JmeImporter im) throws IOException{
    InputCapsule ic = im.getCapsule(this);
    language = ic.readString("language", null);
    shaderList = ic.readSavableArrayList("shaderList", null);
    attribs = (IntMap<Attribute>) ic.readIntSavableMap("attribs", null);

    HashMap<String, Uniform> uniMap = (HashMap<String, Uniform>) ic.readStringSavableMap("uniforms", null);
    uniforms = new ListMap<String, Uniform>(uniMap);
}
 
Example 9
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 10
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 11
Source File: Technique.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);
    def = (TechniqueDef) ic.readSavable("def", null);
    worldBindUniforms = ic.readSavableArrayList("worldBindUniforms", null);
    defines = (DefineList) ic.readSavable("defines", null);
    shader = (Shader) ic.readSavable("shader", null);
    //if (shader != null)
    //    owner.updateUniformLinks();
}
 
Example 12
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 13
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 14
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>());
    setScale(scale);
    setMargin(margin);
    loadChildren();
}
 
Example 15
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 16
Source File: EmitterMeshVertexShape.java    From MikuMikuStudio with BSD 2-Clause "Simplified" 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 17
Source File: PhysicsVehicle.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 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 18
Source File: TimeLine.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);
    ArrayList list = ic.readSavableArrayList("keyFrames", null);
    for (Iterator it = list.iterator(); it.hasNext();) {
        KeyFrame keyFrame = (KeyFrame) it.next();
        addKeyFrameAtIndex(keyFrame.getIndex(), keyFrame);
    }
}
 
Example 19
Source File: CompoundCollisionShape.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 {
    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 20
Source File: KeyFrame.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);
    cinematicEvents = ic.readSavableArrayList("cinematicEvents", null);
    index=ic.readInt("index", 0);
}