Search in sources :

Example 1 with InputCapsule

use of com.jme3.export.InputCapsule in project jmonkeyengine by jMonkeyEngine.

the class KinematicRagdollControl method read.

/**
     * de-serialize this control
     *
     * @param im
     * @throws IOException
     */
@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    String[] loadedBoneList = ic.readStringArray("boneList", new String[0]);
    boneList.addAll(Arrays.asList(loadedBoneList));
    PhysicsBoneLink[] loadedBoneLinks = (PhysicsBoneLink[]) ic.readSavableArray("boneList", new PhysicsBoneLink[0]);
    for (PhysicsBoneLink physicsBoneLink : loadedBoneLinks) {
        boneLinks.put(physicsBoneLink.bone.getName(), physicsBoneLink);
    }
    modelPosition.set((Vector3f) ic.readSavable("modelPosition", new Vector3f()));
    modelRotation.set((Quaternion) ic.readSavable("modelRotation", new Quaternion()));
    targetModel = (Spatial) ic.readSavable("targetModel", null);
    skeleton = (Skeleton) ic.readSavable("skeleton", null);
    //        preset //TODO
    initScale = (Vector3f) ic.readSavable("initScale", null);
    mode = ic.readEnum("mode", Mode.class, Mode.Kinematic);
    blendedControl = ic.readBoolean("blendedControl", false);
    weightThreshold = ic.readFloat("weightThreshold", -1.0f);
    blendStart = ic.readFloat("blendStart", 0.0f);
    blendTime = ic.readFloat("blendTime", 1.0f);
    eventDispatchImpulseThreshold = ic.readFloat("eventDispatchImpulseThreshold", 10);
    rootMass = ic.readFloat("rootMass", 15);
    totalMass = ic.readFloat("totalMass", 0);
}
Also used : Quaternion(com.jme3.math.Quaternion) InputCapsule(com.jme3.export.InputCapsule) Vector3f(com.jme3.math.Vector3f)

Example 2 with InputCapsule

use of com.jme3.export.InputCapsule in project jmonkeyengine by jMonkeyEngine.

the class Texture2D method read.

@Override
public void read(JmeImporter e) throws IOException {
    super.read(e);
    InputCapsule capsule = e.getCapsule(this);
    wrapS = capsule.readEnum("wrapS", WrapMode.class, WrapMode.EdgeClamp);
    wrapT = capsule.readEnum("wrapT", WrapMode.class, WrapMode.EdgeClamp);
}
Also used : InputCapsule(com.jme3.export.InputCapsule)

Example 3 with InputCapsule

use of com.jme3.export.InputCapsule in project jmonkeyengine by jMonkeyEngine.

the class SpotLight method read.

@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    spotInnerAngle = ic.readFloat("spotInnerAngle", FastMath.QUARTER_PI / 8);
    spotOuterAngle = ic.readFloat("spotOuterAngle", FastMath.QUARTER_PI / 6);
    computeAngleParameters();
    direction = (Vector3f) ic.readSavable("direction", new Vector3f());
    position = (Vector3f) ic.readSavable("position", new Vector3f());
    spotRange = ic.readFloat("spotRange", 100);
    if (spotRange != 0) {
        this.invSpotRange = 1 / spotRange;
    } else {
        this.invSpotRange = 0;
    }
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 4 with InputCapsule

use of com.jme3.export.InputCapsule in project jmonkeyengine by jMonkeyEngine.

the class ParticleEmitter method read.

@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    shape = (EmitterShape) ic.readSavable("shape", DEFAULT_SHAPE);
    if (shape == DEFAULT_SHAPE) {
        // Prevent reference to static
        shape = shape.deepClone();
    }
    meshType = ic.readEnum("meshType", ParticleMesh.Type.class, ParticleMesh.Type.Triangle);
    int numParticles = ic.readInt("numParticles", 0);
    enabled = ic.readBoolean("enabled", true);
    particlesPerSec = ic.readFloat("particlesPerSec", 0);
    lowLife = ic.readFloat("lowLife", 0);
    highLife = ic.readFloat("highLife", 0);
    gravity = (Vector3f) ic.readSavable("gravity", null);
    imagesX = ic.readInt("imagesX", 1);
    imagesY = ic.readInt("imagesY", 1);
    startColor = (ColorRGBA) ic.readSavable("startColor", null);
    endColor = (ColorRGBA) ic.readSavable("endColor", null);
    startSize = ic.readFloat("startSize", 0);
    endSize = ic.readFloat("endSize", 0);
    worldSpace = ic.readBoolean("worldSpace", false);
    this.setIgnoreTransform(worldSpace);
    facingVelocity = ic.readBoolean("facingVelocity", false);
    faceNormal = (Vector3f) ic.readSavable("faceNormal", new Vector3f(Vector3f.NAN));
    selectRandomImage = ic.readBoolean("selectRandomImage", false);
    randomAngle = ic.readBoolean("randomAngle", false);
    rotateSpeed = ic.readFloat("rotateSpeed", 0);
    switch(meshType) {
        case Point:
            particleMesh = new ParticlePointMesh();
            this.setMesh(particleMesh);
            break;
        case Triangle:
            particleMesh = new ParticleTriMesh();
            this.setMesh(particleMesh);
            break;
        default:
            throw new IllegalStateException("Unrecognized particle type: " + meshType);
    }
    this.setNumParticles(numParticles);
    //        particleMesh.initParticleData(this, particles.length);
    //        particleMesh.setImagesXY(imagesX, imagesY);
    particleInfluencer = (ParticleInfluencer) ic.readSavable("influencer", DEFAULT_INFLUENCER);
    if (particleInfluencer == DEFAULT_INFLUENCER) {
        particleInfluencer = particleInfluencer.clone();
    }
    if (im.getFormatVersion() == 0) {
        // find it in the controls and take it out, then add the proper one in
        for (int i = 0; i < controls.size(); i++) {
            Object obj = controls.get(i);
            if (obj instanceof ParticleEmitter) {
                controls.remove(i);
                // now add the proper one in
                controls.add(new ParticleEmitterControl(this));
                break;
            }
        }
        // compatability before gravity was not a vector but a float
        if (gravity == null) {
            gravity = new Vector3f();
            gravity.y = ic.readFloat("gravity", 0);
        }
    } else {
        // since the parentEmitter is not loaded, it must be
        // loaded separately
        control = getControl(ParticleEmitterControl.class);
        control.parentEmitter = this;
    }
}
Also used : Type(com.jme3.effect.ParticleMesh.Type) InputCapsule(com.jme3.export.InputCapsule) Vector3f(com.jme3.math.Vector3f)

Example 5 with InputCapsule

use of com.jme3.export.InputCapsule in project jmonkeyengine by jMonkeyEngine.

the class ChaseCamera method read.

/**
     * Read the camera
     * @param im
     * @throws IOException
     */
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);
    maxDistance = ic.readFloat("maxDistance", 40);
    minDistance = ic.readFloat("minDistance", 1);
}
Also used : InputCapsule(com.jme3.export.InputCapsule)

Aggregations

InputCapsule (com.jme3.export.InputCapsule)123 Vector3f (com.jme3.math.Vector3f)18 Matrix3f (com.jme3.math.Matrix3f)5 ArrayList (java.util.ArrayList)5 AssetNotFoundException (com.jme3.asset.AssetNotFoundException)2 PhysicsRigidBody (com.jme3.bullet.objects.PhysicsRigidBody)2 Mesh (com.jme3.scene.Mesh)2 ShadowCompareMode (com.jme3.texture.Texture.ShadowCompareMode)2 ConvexShape (com.bulletphysics.collision.shapes.ConvexShape)1 KinematicCharacterController (com.bulletphysics.dynamics.character.KinematicCharacterController)1 Generic6DofConstraint (com.bulletphysics.dynamics.constraintsolver.Generic6DofConstraint)1 HingeConstraint (com.bulletphysics.dynamics.constraintsolver.HingeConstraint)1 SliderConstraint (com.bulletphysics.dynamics.constraintsolver.SliderConstraint)1 Transform (com.bulletphysics.linearmath.Transform)1 LinkerMsg (com.cas.circuit.msg.LinkerMsg)1 LoopMode (com.jme3.animation.LoopMode)1 AssetInfo (com.jme3.asset.AssetInfo)1 AssetKey (com.jme3.asset.AssetKey)1 AssetManager (com.jme3.asset.AssetManager)1 ModelKey (com.jme3.asset.ModelKey)1