Search in sources :

Example 66 with InputCapsule

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

the class EffectTrack method read.

/**
     * Internal use only serialization
     *
     * @param im importer
     * @throws IOException Exception
     */
public void read(JmeImporter im) throws IOException {
    InputCapsule in = im.getCapsule(this);
    this.particlesPerSeconds = in.readFloat("particlesPerSeconds", 0);
    //reading the emitter even if the track will then reference its cloned counter part if it's loaded with the assetManager.
    //This also avoid null pointer exception if the model is not loaded via the AssetManager.
    emitter = (ParticleEmitter) in.readSavable("emitter", null);
    emitter.setParticlesPerSec(0);
    //if the emitter was saved with a KillParticleControl we remove it.
    //        Control c = emitter.getControl(KillParticleControl.class);
    //        if(c!=null){
    //            emitter.removeControl(c);
    //        }
    //emitter.removeControl(KillParticleControl.class);
    length = in.readFloat("length", length);
    startOffset = in.readFloat("startOffset", 0);
}
Also used : InputCapsule(com.jme3.export.InputCapsule)

Example 67 with InputCapsule

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

the class AbstractCinematicEvent method read.

/**
     * Used 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);
}
Also used : LoopMode(com.jme3.animation.LoopMode) InputCapsule(com.jme3.export.InputCapsule) PlayState(com.jme3.cinematic.PlayState)

Example 68 with InputCapsule

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

the class ShaderGenerationInfo method read.

@Override
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);
}
Also used : InputCapsule(com.jme3.export.InputCapsule) ArrayList(java.util.ArrayList)

Example 69 with InputCapsule

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

the class Spatial method read.

public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);
    name = ic.readString("name", null);
    worldBound = (BoundingVolume) ic.readSavable("world_bound", null);
    cullHint = ic.readEnum("cull_mode", CullHint.class, CullHint.Inherit);
    batchHint = ic.readEnum("batch_hint", BatchHint.class, BatchHint.Inherit);
    queueBucket = ic.readEnum("queue", RenderQueue.Bucket.class, RenderQueue.Bucket.Inherit);
    shadowMode = ic.readEnum("shadow_mode", ShadowMode.class, ShadowMode.Inherit);
    localTransform = (Transform) ic.readSavable("transform", Transform.IDENTITY);
    localLights = (LightList) ic.readSavable("lights", null);
    localLights.setOwner(this);
    ArrayList<MatParamOverride> localOverridesList = ic.readSavableArrayList("overrides", null);
    if (localOverridesList == null) {
        localOverrides = new SafeArrayList<>(MatParamOverride.class);
    } else {
        localOverrides = new SafeArrayList(MatParamOverride.class, localOverridesList);
    }
    worldOverrides = new SafeArrayList<>(MatParamOverride.class);
    //changed for backward compatibility with j3o files generated before the AnimControl/SkeletonControl split
    //the AnimControl creates the SkeletonControl for old files and add it to the spatial.
    //The SkeletonControl must be the last in the stack so we add the list of all other control before it.
    //When backward compatibility won't be needed anymore this can be replaced by :
    //controls = ic.readSavableArrayList("controlsList", null));
    controls.addAll(0, ic.readSavableArrayList("controlsList", null));
    userData = (HashMap<String, Savable>) ic.readStringSavableMap("user_data", null);
}
Also used : Bucket(com.jme3.renderer.queue.RenderQueue.Bucket) SafeArrayList(com.jme3.util.SafeArrayList) ShadowMode(com.jme3.renderer.queue.RenderQueue.ShadowMode) MatParamOverride(com.jme3.material.MatParamOverride)

Example 70 with InputCapsule

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

the class Geometry method read.

@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    mesh = (Mesh) ic.readSavable("mesh", null);
    material = null;
    String matName = ic.readString("materialName", null);
    if (matName != null) {
        // Attempt to load material via J3M
        try {
            material = im.getAssetManager().loadMaterial(matName);
        } catch (AssetNotFoundException ex) {
            // Cannot find J3M file.
            logger.log(Level.FINE, "Cannot locate {0} for geometry {1}", new Object[] { matName, key });
        }
    }
    // If material is NULL, try to load it from the geometry
    if (material == null) {
        material = (Material) ic.readSavable("material", null);
    }
    ignoreTransform = ic.readBoolean("ignoreTransform", false);
    if (ic.getSavableVersion(Geometry.class) == 0) {
        // Fix shared mesh (if set)
        Mesh sharedMesh = getUserData(UserData.JME_SHAREDMESH);
        if (sharedMesh != null) {
            getMesh().extractVertexData(sharedMesh);
            setUserData(UserData.JME_SHAREDMESH, null);
        }
    }
}
Also used : InputCapsule(com.jme3.export.InputCapsule) AssetNotFoundException(com.jme3.asset.AssetNotFoundException)

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