Search in sources :

Example 16 with Mode

use of com.jme3.scene.Mesh.Mode in project jmonkeyengine by jMonkeyEngine.

the class LandscapeHelper method toFog.

/**
     * The method loads fog for the scene.
     * NOTICE! Remember to manually set the distance and density of the fog.
     * Unfortunately blender's fog parameters in no way fit to the JME.
     * @param worldStructure
     *            the world's structure
     * @return fog filter or null if scene does not define it
     */
public FogFilter toFog(Structure worldStructure) {
    FogFilter result = null;
    int mode = ((Number) worldStructure.getFieldValue("mode")).intValue();
    if ((mode & MODE_MIST) != 0) {
        LOGGER.fine("Loading fog.");
        result = new FogFilter();
        result.setName("FIfog");
        result.setFogColor(this.toBackgroundColor(worldStructure));
    }
    return result;
}
Also used : FogFilter(com.jme3.post.filters.FogFilter)

Example 17 with Mode

use of com.jme3.scene.Mesh.Mode in project jmonkeyengine by jMonkeyEngine.

the class BlenderKey method read.

@Override
public void read(JmeImporter e) throws IOException {
    super.read(e);
    InputCapsule ic = e.getCapsule(this);
    fps = ic.readInt("fps", DEFAULT_FPS);
    featuresToLoad = ic.readInt("features-to-load", FeaturesToLoad.ALL);
    loadUnlinkedAssets = ic.readBoolean("load-unlinked-assets", false);
    assetRootPath = ic.readString("asset-root-path", null);
    fixUpAxis = ic.readBoolean("fix-up-axis", true);
    generatedTexturePPU = ic.readInt("generated-texture-ppu", 128);
    usedWorld = ic.readString("used-world", null);
    defaultMaterial = (Material) ic.readSavable("default-material", null);
    faceCullMode = ic.readEnum("face-cull-mode", FaceCullMode.class, FaceCullMode.Off);
    layersToLoad = ic.readInt("layers-to=load", -1);
    mipmapGenerationMethod = ic.readEnum("mipmap-generation-method", MipmapGenerationMethod.class, MipmapGenerationMethod.GENERATE_WHEN_NEEDED);
    skyGeneratedTextureSize = ic.readInt("sky-generated-texture-size", 1000);
    skyGeneratedTextureRadius = ic.readFloat("sky-generated-texture-radius", 1f);
    skyGeneratedTextureShape = ic.readEnum("sky-generated-texture-shape", SkyGeneratedTextureShape.class, SkyGeneratedTextureShape.SPHERE);
    optimiseTextures = ic.readBoolean("optimise-textures", false);
    animationMatchMethod = ic.readEnum("animation-match-method", AnimationMatchMethod.class, AnimationMatchMethod.AT_LEAST_ONE_NAME_MATCH);
    pointsSize = ic.readFloat("points-size", 1);
    linesWidth = ic.readFloat("lines-width", 1);
}
Also used : InputCapsule(com.jme3.export.InputCapsule) FaceCullMode(com.jme3.material.RenderState.FaceCullMode)

Example 18 with Mode

use of com.jme3.scene.Mesh.Mode in project jmonkeyengine by jMonkeyEngine.

the class BlenderKey method write.

@Override
public void write(JmeExporter e) throws IOException {
    super.write(e);
    OutputCapsule oc = e.getCapsule(this);
    oc.write(fps, "fps", DEFAULT_FPS);
    oc.write(featuresToLoad, "features-to-load", FeaturesToLoad.ALL);
    oc.write(loadUnlinkedAssets, "load-unlinked-assets", false);
    oc.write(assetRootPath, "asset-root-path", null);
    oc.write(fixUpAxis, "fix-up-axis", true);
    oc.write(generatedTexturePPU, "generated-texture-ppu", 128);
    oc.write(usedWorld, "used-world", null);
    oc.write(defaultMaterial, "default-material", null);
    oc.write(faceCullMode, "face-cull-mode", FaceCullMode.Off);
    oc.write(layersToLoad, "layers-to-load", -1);
    oc.write(mipmapGenerationMethod, "mipmap-generation-method", MipmapGenerationMethod.GENERATE_WHEN_NEEDED);
    oc.write(skyGeneratedTextureSize, "sky-generated-texture-size", 1000);
    oc.write(skyGeneratedTextureRadius, "sky-generated-texture-radius", 1f);
    oc.write(skyGeneratedTextureShape, "sky-generated-texture-shape", SkyGeneratedTextureShape.SPHERE);
    oc.write(optimiseTextures, "optimise-textures", false);
    oc.write(animationMatchMethod, "animation-match-method", AnimationMatchMethod.AT_LEAST_ONE_NAME_MATCH);
    oc.write(pointsSize, "points-size", 1);
    oc.write(linesWidth, "lines-width", 1);
}
Also used : OutputCapsule(com.jme3.export.OutputCapsule)

Example 19 with Mode

use of com.jme3.scene.Mesh.Mode in project jmonkeyengine by jMonkeyEngine.

the class ConstraintDefinitionDistLimit method bake.

@Override
public void bake(Space ownerSpace, Space targetSpace, Transform targetTransform, float influence) {
    if (this.getOwner() instanceof Bone && ((Bone) this.getOwner()).getParent() != null && blenderContext.getBoneContext(ownerOMA).is(BoneContext.CONNECTED_TO_PARENT)) {
        // distance limit does not work on bones who are connected to their parent
        return;
    }
    if (influence == 0 || targetTransform == null) {
        // no need to do anything
        return;
    }
    Transform ownerTransform = this.getOwnerTransform(ownerSpace);
    Vector3f v = ownerTransform.getTranslation().subtract(targetTransform.getTranslation());
    float currentDistance = v.length();
    switch(mode) {
        case LIMITDIST_INSIDE:
            if (currentDistance >= dist) {
                v.normalizeLocal();
                v.multLocal(dist + (currentDistance - dist) * (1.0f - influence));
                ownerTransform.getTranslation().set(v.addLocal(targetTransform.getTranslation()));
            }
            break;
        case LIMITDIST_ONSURFACE:
            if (currentDistance > dist) {
                v.normalizeLocal();
                v.multLocal(dist + (currentDistance - dist) * (1.0f - influence));
                ownerTransform.getTranslation().set(v.addLocal(targetTransform.getTranslation()));
            } else if (currentDistance < dist) {
                v.normalizeLocal().multLocal(dist * influence);
                ownerTransform.getTranslation().set(targetTransform.getTranslation().add(v));
            }
            break;
        case LIMITDIST_OUTSIDE:
            if (currentDistance <= dist) {
                v = targetTransform.getTranslation().subtract(ownerTransform.getTranslation()).normalizeLocal().multLocal(dist * influence);
                ownerTransform.getTranslation().set(targetTransform.getTranslation().add(v));
            }
            break;
        default:
            throw new IllegalStateException("Unknown distance limit constraint mode: " + mode);
    }
    this.applyOwnerTransform(ownerTransform, ownerSpace);
}
Also used : Vector3f(com.jme3.math.Vector3f) Bone(com.jme3.animation.Bone) Transform(com.jme3.math.Transform)

Example 20 with Mode

use of com.jme3.scene.Mesh.Mode in project jmonkeyengine by jMonkeyEngine.

the class KinematicRagdollControl method setMode.

/**
     * Enable or disable the ragdoll behaviour. if ragdollEnabled is true, the
     * character motion will only be powerd by physics else, the characted will
     * be animated by the keyframe animation, but will be able to physically
     * interact with its physic environnement
     *
     * @param ragdollEnabled
     */
protected void setMode(Mode mode) {
    this.mode = mode;
    AnimControl animControl = targetModel.getControl(AnimControl.class);
    animControl.setEnabled(mode == Mode.Kinematic);
    baseRigidBody.setKinematic(mode == Mode.Kinematic);
    if (mode != Mode.IK) {
        TempVars vars = TempVars.get();
        for (PhysicsBoneLink link : boneLinks.values()) {
            link.rigidBody.setKinematic(mode == Mode.Kinematic);
            if (mode == Mode.Ragdoll) {
                Quaternion tmpRot1 = vars.quat1;
                Vector3f position = vars.vect1;
                //making sure that the ragdoll is at the correct place.
                matchPhysicObjectToBone(link, position, tmpRot1);
            }
        }
        vars.release();
    }
    if (mode != Mode.IK) {
        for (Bone bone : skeleton.getRoots()) {
            RagdollUtils.setUserControl(bone, mode == Mode.Ragdoll);
        }
    }
}
Also used : Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) TempVars(com.jme3.util.TempVars) Bone(com.jme3.animation.Bone) AnimControl(com.jme3.animation.AnimControl)

Aggregations

Vector3f (com.jme3.math.Vector3f)6 Texture2D (com.jme3.texture.Texture2D)6 Bone (com.jme3.animation.Bone)5 Quaternion (com.jme3.math.Quaternion)4 AppSettings (com.jme3.system.AppSettings)3 AnimControl (com.jme3.animation.AnimControl)2 InputCapsule (com.jme3.export.InputCapsule)2 OutputCapsule (com.jme3.export.OutputCapsule)2 Material (com.jme3.material.Material)2 Spatial (com.jme3.scene.Spatial)2 IndexBuffer (com.jme3.scene.mesh.IndexBuffer)2 Texture (com.jme3.texture.Texture)2 TempVars (com.jme3.util.TempVars)2 GraphicsDevice (java.awt.GraphicsDevice)2 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2 FileReader (java.io.FileReader)2 IOException (java.io.IOException)2 Buffer (java.nio.Buffer)2 FloatBuffer (java.nio.FloatBuffer)2