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

The following examples show how to use com.jme3.export.InputCapsule#readSavable() . 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: TerrainPatch.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);
    size = ic.readInt("size", 16);
    totalSize = ic.readInt("totalSize", 16);
    quadrant = ic.readShort("quadrant", (short)0);
    stepScale = (Vector3f) ic.readSavable("stepScale", Vector3f.UNIT_XYZ);
    offset = (Vector2f) ic.readSavable("offset", Vector3f.UNIT_XYZ);
    offsetAmount = ic.readFloat("offsetAmount", 0);
    //lodCalculator = (LodCalculator) ic.readSavable("lodCalculator", new DistanceLodCalculator());
    //lodCalculator.setTerrainPatch(this);
    //lodCalculatorFactory = (LodCalculatorFactory) ic.readSavable("lodCalculatorFactory", null);
    lodEntropy = ic.readFloatArray("lodEntropy", null);
    geomap = (LODGeomap) ic.readSavable("geomap", null);

    Mesh regen = geomap.createMesh(stepScale, new Vector2f(1,1), offset, offsetAmount, totalSize, false);
    setMesh(regen);
    //TangentBinormalGenerator.generate(this); // note that this will be removed
    ensurePositiveVolumeBBox();
}
 
Example 2
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 3
Source File: ConeJoint.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);
    this.rotA = (Matrix3f) capsule.readSavable("rotA", new Matrix3f());
    this.rotB = (Matrix3f) capsule.readSavable("rotB", new Matrix3f());

    this.angularOnly = capsule.readBoolean("angularOnly", false);
    this.swingSpan1 = capsule.readFloat("swingSpan1", 1e30f);
    this.swingSpan2 = capsule.readFloat("swingSpan2", 1e30f);
    this.twistSpan = capsule.readFloat("twistSpan", 1e30f);
    createJoint();
}
 
Example 4
Source File: BIHTree.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);
    mesh = (Mesh) ic.readSavable("mesh", null);
    root = (BIHNode) ic.readSavable("root", null);
    maxTrisPerNode = ic.readInt("tris_per_node", 0);
    pointData = ic.readFloatArray("points", null);
    triIndices = ic.readIntArray("indices", null);
}
 
Example 5
Source File: RotationTrack.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);
    spatialName = ic.readString("spatialName", "");
    endRotation = (Quaternion) ic.readSavable("endRotation", null);
}
 
Example 6
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 7
Source File: Dome.java    From MikuMikuStudio with BSD 2-Clause "Simplified" 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 8
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 9
Source File: BIHTree.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 {
    InputCapsule ic = im.getCapsule(this);
    mesh = (Mesh) ic.readSavable("mesh", null);
    root = (BIHNode) ic.readSavable("root", null);
    maxTrisPerNode = ic.readInt("tris_per_node", 0);
    pointData = ic.readFloatArray("points", null);
    triIndices = ic.readIntArray("indices", null);
}
 
Example 10
Source File: VehicleControl.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);
    enabled = ic.readBoolean("enabled", true);
    spatial = (Spatial) ic.readSavable("spatial", null);
    motionState.setApplyPhysicsLocal(ic.readBoolean("applyLocalPhysics", false));
    setUserObject(spatial);
}
 
Example 11
Source File: GhostControl.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);
    enabled = ic.readBoolean("enabled", true);
    spatial = (Spatial) ic.readSavable("spatial", null);
    applyLocal = ic.readBoolean("applyLocalPhysics", false);
    setUserObject(spatial);
}
 
Example 12
Source File: SpotLight.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);
    spotInnerAngle = ic.readFloat("spotInnerAngle", FastMath.QUARTER_PI / 8);
    spotOuterAngle = ic.readFloat("spotOuterAngle", FastMath.QUARTER_PI / 6);
    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;
    }
}
 
Example 13
Source File: ConeJoint.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);
    this.rotA = (Matrix3f) capsule.readSavable("rotA", new Matrix3f());
    this.rotB = (Matrix3f) capsule.readSavable("rotB", new Matrix3f());

    this.angularOnly = capsule.readBoolean("angularOnly", false);
    this.swingSpan1 = capsule.readFloat("swingSpan1", 1e30f);
    this.swingSpan2 = capsule.readFloat("swingSpan2", 1e30f);
    this.twistSpan = capsule.readFloat("twistSpan", 1e30f);
    createJoint();
}
 
Example 14
Source File: PositionTrack.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);
    spatialName = ic.readString("spatialName", "");
    endPosition = (Vector3f) ic.readSavable("endPosition", null);
}
 
Example 15
Source File: SimplexCollisionShape.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);
    vector1 = (Vector3f) capsule.readSavable("simplexPoint1", null);
    vector2 = (Vector3f) capsule.readSavable("simplexPoint2", null);
    vector3 = (Vector3f) capsule.readSavable("simplexPoint3", null);
    vector4 = (Vector3f) capsule.readSavable("simplexPoint4", null);
    createShape();
}
 
Example 16
Source File: PointLight.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);
    position = (Vector3f) ic.readSavable("position", null);
    radius = ic.readFloat("radius", 0f);
    if(radius!=0){
        this.invRadius = 1 / radius;
    }else{
        this.invRadius = 0;
    }
}
 
Example 17
Source File: DirectionalLightShadowFilter.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 = (DirectionalLightShadowRenderer) ic.readSavable("shadowRenderer", null);
}
 
Example 18
Source File: WaterFilter.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);
    speed = ic.readFloat("speed", 1f);
    lightDirection = (Vector3f) ic.readSavable("lightDirection", new Vector3f(0, -1, 0));
    lightColor = (ColorRGBA) ic.readSavable("lightColor", ColorRGBA.White);
    waterHeight = ic.readFloat("waterHeight", 0.0f);
    waterColor = (ColorRGBA) ic.readSavable("waterColor", new ColorRGBA(0.0078f, 0.3176f, 0.5f, 1.0f));
    deepWaterColor = (ColorRGBA) ic.readSavable("deepWaterColor", new ColorRGBA(0.0039f, 0.00196f, 0.145f, 1.0f));

    colorExtinction = (Vector3f) ic.readSavable("colorExtinction", new Vector3f(5.0f, 20.0f, 30.0f));
    waterTransparency = ic.readFloat("waterTransparency", 0.1f);
    maxAmplitude = ic.readFloat("maxAmplitude", 1.5f);
    shoreHardness = ic.readFloat("shoreHardness", 0.1f);
    useFoam = ic.readBoolean("useFoam", true);

    foamIntensity = ic.readFloat("foamIntensity", 0.5f);
    foamHardness = ic.readFloat("foamHardness", 1.0f);

    foamExistence = (Vector3f) ic.readSavable("foamExistence", new Vector3f(0.45f, 4.35f, 1.5f));
    waveScale = ic.readFloat("waveScale", 0.005f);

    sunScale = ic.readFloat("sunScale", 3.0f);
    shininess = ic.readFloat("shininess", 0.7f);
    windDirection = (Vector2f) ic.readSavable("windDirection", new Vector2f(0.0f, -1.0f));
    reflectionMapSize = ic.readInt("reflectionMapSize", 512);
    useRipples = ic.readBoolean("useRipples", true);

    normalScale = ic.readFloat("normalScale", 3.0f);
    useHQShoreline = ic.readBoolean("useHQShoreline", true);

    useSpecular = ic.readBoolean("useSpecular", true);

    useRefraction = ic.readBoolean("useRefraction", true);
    refractionStrength = ic.readFloat("refractionStrength", 0.0f);
    refractionConstant = ic.readFloat("refractionConstant", 0.5f);
    reflectionDisplace = ic.readFloat("reflectionDisplace", 30f);
    underWaterFogDistance = ic.readFloat("underWaterFogDistance", 120f);
    causticsIntensity = ic.readFloat("causticsIntensity", 0.5f);

    useCaustics = ic.readBoolean("useCaustics", true);

    final TextureKey causticsTextureKey = (TextureKey) ic.readSavable("causticsTexture", null);
    final TextureKey heightTextureKey = (TextureKey) ic.readSavable("heightTexture", null);
    final TextureKey normalTextureKey = (TextureKey) ic.readSavable("normalTexture", null);
    final TextureKey foamTextureKey = (TextureKey) ic.readSavable("foamTexture", null);

    needSaveReflectionScene = ic.readBoolean("needSaveReflectionScene", false);
    reflectionScene = (Spatial) ic.readSavable("reflectionScene", null);

    final AssetManager assetManager = im.getAssetManager();

    if (causticsTextureKey != null) {
        setCausticsTexture((Texture2D) assetManager.loadTexture(causticsTextureKey));
    }
    if (heightTextureKey != null) {
        setHeightTexture((Texture2D) assetManager.loadTexture(heightTextureKey));
    }
    if (normalTextureKey != null) {
        setNormalTexture((Texture2D) assetManager.loadTexture(normalTextureKey));
    }
    if (foamTextureKey != null) {
        setFoamTexture((Texture2D) assetManager.loadTexture(foamTextureKey));
    }

    //positional attributes
    center = (Vector3f) ic.readSavable("center", null);
    radius = ic.readFloat("radius", 0f);
    int shapeType = ic.readInt("shapeType", AreaShape.Circular.ordinal());
    this.shapeType = AreaShape.values()[shapeType];
}
 
Example 19
Source File: CollisionShape.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void read(JmeImporter im) throws IOException {
    InputCapsule capsule = im.getCapsule(this);
    this.scale = (Vector3f) capsule.readSavable("scale", new Vector3f(1, 1, 1));
    this.margin = capsule.readFloat("margin", 0.0f);
}
 
Example 20
Source File: NormalRecalcControl.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);
    terrain = (TerrainQuad) ic.readSavable("terrain", null);
}