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

The following examples show how to use com.jme3.export.InputCapsule#readEnum() . 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: BoneLink.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
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);

    Savable[] tmp = ic.readSavableArray("managedBones", null);
    if (tmp == null) {
        managedBones = null;
    } else {
        managedBones = new Joint[tmp.length];
        for (int i = 0; i < tmp.length; ++i) {
            managedBones[i] = (Joint) tmp[i];
        }
    }

    submode = ic.readEnum("submode", KinematicSubmode.class,
            KinematicSubmode.Animated);
    prevBoneTransforms = RagUtils.readTransformArray(ic,
            "prevBoneTransforms");
    startBoneTransforms = RagUtils.readTransformArray(ic,
            "startBoneTransforms");
}
 
Example 2
Source File: TextureKey.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);
    flipY = ic.readBoolean("flip_y", false);
    generateMips = ic.readBoolean("generate_mips", false);
    anisotropy = ic.readInt("anisotropy", 0);
    boolean asCube = ic.readBoolean("as_cubemap", false);
    
    if (asCube) {
        // Backwards compat
        textureTypeHint = Type.CubeMap;
    } else {
        textureTypeHint = ic.readEnum("tex_type", Texture.Type.class, Type.TwoDimensional);
    }
}
 
Example 3
Source File: Image.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void read(JmeImporter e) throws IOException {
    InputCapsule capsule = e.getCapsule(this);
    format = capsule.readEnum("format", Format.class, Format.RGBA8);
    width = capsule.readInt("width", 0);
    height = capsule.readInt("height", 0);
    depth = capsule.readInt("depth", 0);
    mipMapSizes = capsule.readIntArray("mipMapSizes", null);
    multiSamples = capsule.readInt("multiSamples", 1);
    data = capsule.readByteBufferArrayList("data", null);
    colorSpace = capsule.readEnum("colorSpace", ColorSpace.class, null);

    if (mipMapSizes != null) {
        needGeneratedMips = false;
        mipsWereGenerated = true;
    }
}
 
Example 4
Source File: Image.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
public void read(JmeImporter e) throws IOException {
    InputCapsule capsule = e.getCapsule(this);
    format = capsule.readEnum("format", Format.class, Format.RGBA8);
    width = capsule.readInt("width", 0);
    height = capsule.readInt("height", 0);
    depth = capsule.readInt("depth", 0);
    mipMapSizes = capsule.readIntArray("mipMapSizes", null);
    multiSamples = capsule.readInt("multiSamples", 1);
    data = (ArrayList<ByteBuffer>) capsule.readByteBufferArrayList("data", null);
    colorSpace = capsule.readEnum("colorSpace", ColorSpace.class, null);

    if (mipMapSizes != null) {
        needGeneratedMips = false;
        mipsWereGenerated = true;
    }
}
 
Example 5
Source File: Sphere.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void read(JmeImporter e) throws IOException {
    super.read(e);
    InputCapsule capsule = e.getCapsule(this);
    zSamples = capsule.readInt("zSamples", 0);
    radialSamples = capsule.readInt("radialSamples", 0);
    radius = capsule.readFloat("radius", 0);
    useEvenSlices = capsule.readBoolean("useEvenSlices", false);
    textureMode = capsule.readEnum("textureMode", TextureMode.class, TextureMode.Original);
    interior = capsule.readBoolean("interior", false);
}
 
Example 6
Source File: VertexBuffer.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);
    components = ic.readInt("components", 0);
    usage = ic.readEnum("usage", Usage.class, Usage.Dynamic);
    bufType = ic.readEnum("buffer_type", Type.class, null);
    format = ic.readEnum("format", Format.class, Format.Float);
    normalized = ic.readBoolean("normalized", false);
    offset = ic.readInt("offset", 0);
    stride = ic.readInt("stride", 0);
    componentsLength = components * format.getComponentSize();

    String dataName = "data" + format.name();
    switch (format){
        case Float:
            data = ic.readFloatBuffer(dataName, null);
            break;
        case Short:
        case UnsignedShort:
            data = ic.readShortBuffer(dataName, null);
            break;
        case UnsignedByte:
        case Byte:
        case Half:
            data = ic.readByteBuffer(dataName, null);
            break;
        case Int:
        case UnsignedInt:
            data = ic.readIntBuffer(dataName, null);
            break;
        default:
            throw new IOException("Unsupported import buffer format: "+format);
    }
}
 
Example 7
Source File: MotionTrack.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 in = im.getCapsule(this);
    lookAt = (Vector3f) in.readSavable("lookAt", Vector3f.ZERO);
    upVector = (Vector3f) in.readSavable("upVector", Vector3f.UNIT_Y);
    rotation = (Quaternion) in.readSavable("rotation", Quaternion.IDENTITY);
    directionType = in.readEnum("directionType", Direction.class, Direction.None);
    path = (MotionPath) in.readSavable("path", null);
}
 
Example 8
Source File: BloomFilter.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);
    glowMode = ic.readEnum("glowMode", GlowMode.class, GlowMode.Scene);
    blurScale = ic.readFloat("blurScale", 1.5f);
    exposurePower = ic.readFloat("exposurePower", 5.0f);
    exposureCutOff = ic.readFloat("exposureCutOff", 0.0f);
    bloomIntensity = ic.readFloat("bloomIntensity", 2.0f);
    downSamplingFactor = ic.readFloat("downSamplingFactor", 1);
}
 
Example 9
Source File: TextureCubeMap.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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);
    wrapR = capsule.readEnum("wrapR", WrapMode.class, WrapMode.EdgeClamp);
}
 
Example 10
Source File: LightControl.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.SpatialToLight);
    light = (Light)ic.readSavable(LIGHT_NAME, null);
}
 
Example 11
Source File: Texture2D.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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);
}
 
Example 12
Source File: TechniqueDef.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);
    name = ic.readString("name", null);
    vertName = ic.readString("vertName", null);
    fragName = ic.readString("fragName", null);
    shaderLang = ic.readString("shaderLang", null);
    presetDefines = (DefineList) ic.readSavable("presetDefines", null);
    lightMode = ic.readEnum("lightMode", LightMode.class, LightMode.Disable);
    shadowMode = ic.readEnum("shadowMode", ShadowMode.class, ShadowMode.Disable);
    renderState = (RenderState) ic.readSavable("renderState", null);
    usesShaders = ic.readBoolean("usesShaders", false);
}
 
Example 13
Source File: LightControl.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);
    controlDir = ic.readEnum(CONTROL_DIR_NAME, ControlDirection.class, ControlDirection.SpatialToLight);
    light = (Light) ic.readSavable(LIGHT_NAME, null);
}
 
Example 14
Source File: AbstractCinematicEvent.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 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);
}
 
Example 15
Source File: CameraControl.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);
    controlDir = ic.readEnum(CONTROL_DIR_NAME, ControlDirection.class, ControlDirection.SpatialToCamera);
    camera = (Camera)ic.readSavable(CAMERA_NAME, null);
}
 
Example 16
Source File: MotionEvent.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 in = im.getCapsule(this);
    lookAt = (Vector3f) in.readSavable("lookAt", null);
    upVector = (Vector3f) in.readSavable("upVector", Vector3f.UNIT_Y);
    rotation = (Quaternion) in.readSavable("rotation", null);
    directionType = in.readEnum("directionType", Direction.class, Direction.None);
    path = (MotionPath) in.readSavable("path", null);
    spatial = (Spatial) in.readSavable("spatial", null);
}
 
Example 17
Source File: Texture.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void read(JmeImporter e) throws IOException {
    InputCapsule capsule = e.getCapsule(this);
    name = capsule.readString("name", null);
    key = (TextureKey) capsule.readSavable("key", null);
    
    // load texture from key, if available
    if (key != null) {
        // key is available, so try the texture from there.
        Texture loadedTex = e.getAssetManager().loadTexture(key);
        if (loadedTex == null) {
            Logger.getLogger(Texture.class.getName()).log(Level.SEVERE, "Could not load texture: {0}", key.toString());
        } else {
            image = loadedTex.getImage();
        }
    }else{
        // no key is set on the texture. Attempt to load an embedded image
        image = (Image) capsule.readSavable("image", null);
        if (image == null){
            // TODO: what to print out here? the texture has no key or data, there's no useful information .. 
            // assume texture.name is set even though the key is null
            Logger.getLogger(Texture.class.getName()).log(Level.SEVERE, "Could not load embedded image: {0}", toString() );
        }
    }

    anisotropicFilter = capsule.readInt("anisotropicFilter", 1);
    minificationFilter = capsule.readEnum("minificationFilter",
            MinFilter.class,
            MinFilter.BilinearNoMipMaps);
    magnificationFilter = capsule.readEnum("magnificationFilter",
            MagFilter.class, MagFilter.Bilinear);
}
 
Example 18
Source File: Image.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void read(JmeImporter e) throws IOException {
    InputCapsule capsule = e.getCapsule(this);
    format = capsule.readEnum("format", Format.class, Format.RGBA8);
    width = capsule.readInt("width", 0);
    height = capsule.readInt("height", 0);
    depth = capsule.readInt("depth", 0);
    mipMapSizes = capsule.readIntArray("mipMapSizes", null);
    multiSamples = capsule.readInt("multiSamples", 1);
    data = (ArrayList<ByteBuffer>) capsule.readByteBufferArrayList("data", null);
}
 
Example 19
Source File: BloomFilter.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);
    glowMode = ic.readEnum("glowMode", GlowMode.class, GlowMode.Scene);
    blurScale = ic.readFloat("blurScale", 1.5f);
    exposurePower = ic.readFloat("exposurePower", 5.0f);
    exposureCutOff = ic.readFloat("exposureCutOff", 0.0f);
    bloomIntensity = ic.readFloat("bloomIntensity", 2.0f);
    downSamplingFactor = ic.readFloat("downSamplingFactor", 1);
}
 
Example 20
Source File: TorsoLink.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 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
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);

    Savable[] tmp = ic.readSavableArray("managedBones", null);
    if (tmp == null) {
        managedBones = null;
    } else {
        managedBones = new Joint[tmp.length];
        for (int i = 0; i < tmp.length; ++i) {
            managedBones[i] = (Joint) tmp[i];
        }
    }

    submode = ic.readEnum("submode", KinematicSubmode.class,
            KinematicSubmode.Animated);
    endModelTransform = (Transform) ic.readSavable("endModelTransform",
            new Transform());
    meshToModel
            = (Transform) ic.readSavable("meshToModel", new Transform());
    startModelTransform = (Transform) ic.readSavable("startModelTransform",
            new Transform());
    prevBoneTransforms = RagUtils.readTransformArray(ic,
            "prevBoneTransforms");
    startBoneTransforms = RagUtils.readTransformArray(ic,
            "startBoneTransforms");
}