Java Code Examples for com.jme3.scene.Spatial#setLocalScale()

The following examples show how to use com.jme3.scene.Spatial#setLocalScale() . 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: RollingTheMonkey.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void reset() {
    // Reset the pickups
    for(Spatial pickUp : pickUps.getChildren()) {
        GhostControl pickUpControl = pickUp.getControl(GhostControl.class);
        if(pickUpControl != null) {
            pickUpControl.setEnabled(true);
        }
        pickUp.setLocalScale(1.0f);
    }
    // Reset the player
    player.setPhysicsLocation(PLAYER_START.clone());
    player.setAngularVelocity(Vector3f.ZERO.clone());
    player.setLinearVelocity(Vector3f.ZERO.clone());
    // Reset the score
    score = 0;
    // Reset the message
    messageText.setLocalScale(0.0f);
}
 
Example 2
Source File: TestSimpleWater.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void simpleInitApp() {
    initInput();
    initScene();

    //create processor
    waterProcessor = new SimpleWaterProcessor(assetManager);
    waterProcessor.setReflectionScene(sceneNode);
    waterProcessor.setDebug(true);
    viewPort.addProcessor(waterProcessor);

    waterProcessor.setLightPosition(lightPos);

    //create water quad
    //waterPlane = waterProcessor.createWaterGeometry(100, 100);
    waterPlane=(Spatial)  assetManager.loadAsset("Models/WaterTest/WaterTest.mesh.xml");
    waterPlane.setMaterial(waterProcessor.getMaterial());
    waterPlane.setLocalScale(40);
    waterPlane.setLocalTranslation(-5, 0, 5);

    rootNode.attachChild(waterPlane);
}
 
Example 3
Source File: TestHWSkinningOld.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    flyCam.setMoveSpeed(10f);
    flyCam.setDragToRotate(true);
    setPauseOnLostFocus(false);
    cam.setLocation(new Vector3f(24.746134f, 13.081396f, 32.72753f));
    cam.setRotation(new Quaternion(-0.06867662f, 0.92435044f, -0.19981281f, -0.31770203f));
    makeHudText();

    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal());
    dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
    rootNode.addLight(dl);

    for (int i = 0; i < SIZE; i++) {
        for (int j = 0; j < SIZE; j++) {
            Spatial model = assetManager.loadModel("Models/Oto/OtoOldAnim.j3o");
            model.setLocalScale(0.1f);
            model.setLocalTranslation(i - SIZE / 2, 0, j - SIZE / 2);
            control = model.getControl(AnimControl.class);

            channel = control.createChannel();
            channel.setAnim(animNames[(i + j) % 4]);
            SkeletonControl skeletonControl = model.getControl(SkeletonControl.class);
            skeletonControl.setHardwareSkinningPreferred(hwSkinningEnable);
            skControls.add(skeletonControl);
            rootNode.attachChild(model);
        }
    }

    inputManager.addListener(this, "toggleHWS");
    inputManager.addMapping("toggleHWS", new KeyTrigger(KeyInput.KEY_SPACE));
}
 
Example 4
Source File: TestEverything.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupSignpost(){
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
Example 5
Source File: TestParallaxPBR.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupSignpost() {
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    TangentBinormalGenerator.generate(signpost);
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 23.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
Example 6
Source File: TestEverything.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setupSignpost(){
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
Example 7
Source File: TestPostFilters.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setupSignpost() {
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
Example 8
Source File: TestHWSkinning.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Spatial loadModel(int i) {
    Spatial model = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    model.setLocalScale(0.1f);
    AnimComposer composer = model.getControl(AnimComposer.class);

    composer.setCurrentAction(animNames[i]);
    SkinningControl skinningControl = model.getControl(SkinningControl.class);
    skinningControl.setHardwareSkinningPreferred(hwSkinningEnable);
    skControls.add(skinningControl);
    rootNode.attachChild(model);
    return model;
}
 
Example 9
Source File: TestParallax.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setupSignpost() {
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    TangentBinormalGenerator.generate(signpost);
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 23.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
Example 10
Source File: TestSpotLight.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setupSignpost(){
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
  //   mat.setBoolean("VertexLighting", true);
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    TangentBinormalGenerator.generate(signpost);
    rootNode.attachChild(signpost);
}
 
Example 11
Source File: TestSpotLightShadows.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupSignpost() {
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    //   mat.setBoolean("VertexLighting", true);
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    TangentBinormalGenerator.generate(signpost);
    rootNode.attachChild(signpost);
}
 
Example 12
Source File: TestPostFilters.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupSignpost() {
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
Example 13
Source File: TestDirectionalLightShadow.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void loadScene() {
    obj = new Spatial[2];
    // Setup first view


    mat = new Material[2];
    mat[0] = assetManager.loadMaterial("Common/Materials/RedColor.j3m");
    mat[1] = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat[1].setBoolean("UseMaterialColors", true);
    mat[1].setColor("Ambient", ColorRGBA.White);
    mat[1].setColor("Diffuse", ColorRGBA.White.clone());


    obj[0] = new Geometry("sphere", new Sphere(30, 30, 2));
    obj[0].setShadowMode(ShadowMode.CastAndReceive);
    obj[1] = new Geometry("cube", new Box(1.0f, 1.0f, 1.0f));
    obj[1].setShadowMode(ShadowMode.CastAndReceive);
    TangentBinormalGenerator.generate(obj[1]);
    TangentBinormalGenerator.generate(obj[0]);

    Spatial t = obj[0].clone(false);
    t.setLocalScale(10f);
    t.setMaterial(mat[1]);
    rootNode.attachChild(t);
    t.setLocalTranslation(0, 25, 0);

    for (int i = 0; i < 60; i++) {
        t = obj[FastMath.nextRandomInt(0, obj.length - 1)].clone(false);
        t.setLocalScale(FastMath.nextRandomFloat() * 10f);
        t.setMaterial(mat[FastMath.nextRandomInt(0, mat.length - 1)]);
        rootNode.attachChild(t);
        t.setLocalTranslation(FastMath.nextRandomFloat() * 200f, FastMath.nextRandomFloat() * 30f + 20, 30f * (i + 2f));
    }

    Box b = new Box(1000, 2, 1000);
    b.scaleTextureCoordinates(new Vector2f(10, 10));
    ground = new Geometry("soil", b);
    ground.setLocalTranslation(0, 10, 550);
    matGroundU = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    matGroundU.setColor("Color", ColorRGBA.Green);


    matGroundL = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
    grass.setWrap(WrapMode.Repeat);
    matGroundL.setTexture("DiffuseMap", grass);

    ground.setMaterial(matGroundL);

    ground.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(ground);

    l = new DirectionalLight();
    //l.setDirection(new Vector3f(0.5973172f, -0.16583486f, 0.7846725f).normalizeLocal());
    l.setDirection(new Vector3f(-1, -1, -1));
    rootNode.addLight(l);


    al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(0.02f));
    rootNode.addLight(al);

    Spatial sky = SkyFactory.createSky(assetManager,
            "Scenes/Beach/FullskiesSunset0068.dds", EnvMapType.CubeMap);
    sky.setLocalScale(350);

    rootNode.attachChild(sky);
}
 
Example 14
Source File: TestAnimMorphSerialization.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
    setTimer(new EraseTimer());
    //cam.setFrustumPerspective(90f, (float) cam.getWidth() / cam.getHeight(), 0.01f, 10f);
    viewPort.setBackgroundColor(ColorRGBA.DarkGray);
    //rootNode.addLight(new DirectionalLight(new Vector3f(-1, -1, -1).normalizeLocal()));
    //rootNode.addLight(new AmbientLight(ColorRGBA.DarkGray));
    Node probeNode = (Node) assetManager.loadModel("Scenes/defaultProbe.j3o");
    rootNode.attachChild(probeNode);
    Spatial model = assetManager.loadModel("Models/gltf/zophrac/scene.gltf");

    File storageFolder = JmeSystem.getStorageFolder();
    file = new File(storageFolder.getPath() + File.separator + "zophrac.j3o");
    BinaryExporter be = new BinaryExporter();
    try {
        be.save(model, file);
    } catch (IOException e) {
        e.printStackTrace();
    }

    assetManager.registerLocator(storageFolder.getPath(), FileLocator.class);
    Spatial model2 = assetManager.loadModel("zophrac.j3o");
    model2.setLocalScale(0.1f);
    probeNode.attachChild(model2);

    debugAppState = new ArmatureDebugAppState();
    stateManager.attach(debugAppState);

    setupModel(model2);

    flyCam.setEnabled(false);

    Node target = new Node("CamTarget");
    //target.setLocalTransform(model.getLocalTransform());
    target.move(0, 0, 0);
    ChaseCameraAppState chaseCam = new ChaseCameraAppState();
    chaseCam.setTarget(target);
    getStateManager().attach(chaseCam);
    chaseCam.setInvertHorizontalAxis(true);
    chaseCam.setInvertVerticalAxis(true);
    chaseCam.setZoomSpeed(0.5f);
    chaseCam.setMinVerticalRotation(-FastMath.HALF_PI);
    chaseCam.setRotationSpeed(3);
    chaseCam.setDefaultDistance(3);
    chaseCam.setMinDistance(0.01f);
    chaseCam.setZoomSpeed(0.01f);
    chaseCam.setDefaultVerticalRotation(0.3f);

    initInputs();
}
 
Example 15
Source File: KinematicRagdollControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Create spatial-dependent data. Invoked when this control is added to a
 * scene.
 *
 * @param model the controlled spatial (not null)
 */
@Override
protected void createSpatialData(Spatial model) {
    targetModel = model;
    Node parent = model.getParent();


    Vector3f initPosition = model.getLocalTranslation().clone();
    Quaternion initRotation = model.getLocalRotation().clone();
    initScale = model.getLocalScale().clone();

    model.removeFromParent();
    model.setLocalTranslation(Vector3f.ZERO);
    model.setLocalRotation(Quaternion.IDENTITY);
    model.setLocalScale(1);
    //HACK ALERT change this
    //I remove the skeletonControl and readd it to the spatial to make sure it's after the ragdollControl in the stack
    //Find a proper way to order the controls.
    SkeletonControl sc = model.getControl(SkeletonControl.class);
    if(sc == null){
        throw new IllegalArgumentException("The root node of the model should have a SkeletonControl. Make sure the control is there and that it's not on a sub node.");
    }
    model.removeControl(sc);
    model.addControl(sc);

    if (boneList.isEmpty()) {
        // add all bones to the list
        skeleton = sc.getSkeleton();
        for (int boneI = 0; boneI < skeleton.getBoneCount(); boneI++) {
            String boneName = skeleton.getBone(boneI).getName();
            boneList.add(boneName);
        }
    }
    // filter out bones without vertices
    filterBoneList(sc);

    if (boneList.isEmpty()) {
        throw new IllegalArgumentException(
                "No suitable bones were found in the model's skeleton.");
    }

    // put into bind pose and compute bone transforms in model space
    // maybe don't reset to ragdoll out of animations?
    scanSpatial(model);


    if (parent != null) {
        parent.attachChild(model);

    }
    model.setLocalTranslation(initPosition);
    model.setLocalRotation(initRotation);
    model.setLocalScale(initScale);

    if (added) {
        addPhysics(space);
    }
    logger.log(Level.FINE, "Created physics ragdoll for skeleton {0}", skeleton);
}
 
Example 16
Source File: TestCollisionShapeFactory.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void randomizeTransform(Spatial spat){
    spat.setLocalTranslation((float) Math.random() * 10, (float) Math.random() * 10, (float) Math.random() * 10);
    spat.setLocalTranslation((float) Math.random() * 10, (float) Math.random() * 10, (float) Math.random() * 10);
    spat.setLocalScale((float) Math.random() * 2, (float) Math.random() * 2, (float) Math.random() * 2);
}
 
Example 17
Source File: TestMultiPostWater.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
    public void simpleInitApp() {

//      setDisplayFps(false);
//      setDisplayStatView(false);

        Node mainScene = new Node("Main Scene");
        rootNode.attachChild(mainScene);

        createTerrain(mainScene);
        DirectionalLight sun = new DirectionalLight();
        sun.setDirection(lightDir);
        sun.setColor(ColorRGBA.White.clone().multLocal(1.7f));
        mainScene.addLight(sun);

        flyCam.setMoveSpeed(100);

        //cam.setLocation(new Vector3f(-700, 100, 300));
        //cam.setRotation(new Quaternion().fromAngleAxis(0.5f, Vector3f.UNIT_Z));
        cam.setLocation(new Vector3f(-327.21957f, 251.6459f, 126.884346f));
        cam.setRotation(new Quaternion().fromAngles(new float[]{FastMath.PI * 0.06f, FastMath.PI * 0.65f, 0}));


        Spatial sky = SkyFactory.createSky(assetManager, 
                "Scenes/Beach/FullskiesSunset0068.dds", EnvMapType.CubeMap);
        sky.setLocalScale(350);

        mainScene.attachChild(sky);
        cam.setFrustumFar(4000);



        FilterPostProcessor fpp = new FilterPostProcessor(assetManager);

        water = new WaterFilter(rootNode, lightDir);
        water.setCenter(new Vector3f(9.628218f, -15.830074f, 199.23595f));
        water.setRadius(260);
        water.setWaveScale(0.003f);
        water.setMaxAmplitude(2f);
        water.setFoamExistence(new Vector3f(1f, 4, 0.5f));
        water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
        water.setRefractionStrength(0.2f);
        water.setWaterHeight(WATER_HEIGHT);
        fpp.addFilter(water);

        WaterFilter water2 = new WaterFilter(rootNode, lightDir);
        water2.setCenter(new Vector3f(-280.46027f, -24.971727f, -271.71976f));
        water2.setRadius(260);
        water2.setWaterHeight(WATER_HEIGHT);
        water2.setUseFoam(false);
        water2.setUseRipples(false);
        water2.setDeepWaterColor(ColorRGBA.Brown);
        water2.setWaterColor(ColorRGBA.Brown.mult(2.0f));
        water2.setWaterTransparency(0.2f);
        water2.setMaxAmplitude(0.3f);
        water2.setWaveScale(0.008f);
        water2.setSpeed(0.7f);
        water2.setShoreHardness(1.0f);
        water2.setRefractionConstant(0.2f);
        water2.setShininess(0.3f);
        water2.setSunScale(1.0f);
        water2.setColorExtinction(new Vector3f(10.0f, 20.0f, 30.0f));
        fpp.addFilter(water2);


        WaterFilter water3 = new WaterFilter(rootNode, lightDir);
        water3.setCenter(new Vector3f(319.6663f, -18.367947f, -236.67674f));
        water3.setRadius(260);
        water3.setWaterHeight(WATER_HEIGHT);
        water3.setWaveScale(0.003f);
        water3.setMaxAmplitude(2f);
        water3.setFoamExistence(new Vector3f(1f, 4, 0.5f));
        water3.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
        water3.setRefractionStrength(0.2f);
        water3.setDeepWaterColor(ColorRGBA.Red);
        water3.setWaterColor(ColorRGBA.Red.mult(2.0f));
        water3.setLightColor(ColorRGBA.Red);
        fpp.addFilter(water3);

        viewPort.addProcessor(fpp);

        //fpp.setNumSamples(4);
    }
 
Example 18
Source File: TestTangentGenBadUV.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
    Spatial teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    if (teapot instanceof Geometry){
        Geometry g = (Geometry) teapot;
        TangentBinormalGenerator.generate(g.getMesh());
    }else{
        throw new RuntimeException();
    }
    teapot.setLocalScale(2f);
    Material mat = assetManager.loadMaterial("Textures/BumpMapTest/Tangent.j3m");
    teapot.setMaterial(mat);
    rootNode.attachChild(teapot);

    Geometry debug = new Geometry(
            "Debug Teapot",
            TangentBinormalGenerator.genTbnLines(((Geometry) teapot).getMesh(), 0.03f)
    );
    Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m");
    debug.setMaterial(debugMat);
    debug.setCullHint(Spatial.CullHint.Never);
    debug.getLocalTranslation().set(teapot.getLocalTranslation());
    debug.getLocalScale().set(teapot.getLocalScale());
    rootNode.attachChild(debug);


    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(1,-1,-1).normalizeLocal());
    dl.setColor(ColorRGBA.White);
    rootNode.addLight(dl);

    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    lightMdl.getMesh().setStatic();
    rootNode.attachChild(lightMdl);

    pl = new PointLight();
    pl.setColor(ColorRGBA.White);
    //pl.setRadius(3f);
    rootNode.addLight(pl);
}
 
Example 19
Source File: TestLightScattering.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
    public void simpleInitApp() {
        // put the camera in a bad position
        cam.setLocation(new Vector3f(55.35316f, -0.27061665f, 27.092093f));
        cam.setRotation(new Quaternion(0.010414706f, 0.9874893f, 0.13880467f, -0.07409228f));
//        cam.setDirection(new Vector3f(0,-0.5f,1.0f));
//        cam.setLocation(new Vector3f(0, 300, -500));
        //cam.setFrustumFar(1000);
        flyCam.setMoveSpeed(10);
        Material mat = assetManager.loadMaterial("Textures/Terrain/Rocky/Rocky.j3m");
        Spatial scene = assetManager.loadModel("Models/Terrain/Terrain.mesh.xml");
        TangentBinormalGenerator.generate(((Geometry)((Node)scene).getChild(0)).getMesh());
        scene.setMaterial(mat);
        scene.setShadowMode(ShadowMode.CastAndReceive);
        scene.setLocalScale(400);
        scene.setLocalTranslation(0, -10, -120);

        rootNode.attachChild(scene);

        // load sky
        rootNode.attachChild(SkyFactory.createSky(assetManager,
                "Textures/Sky/Bright/FullskiesBlueClear03.dds", 
                SkyFactory.EnvMapType.CubeMap));

        DirectionalLight sun = new DirectionalLight();
        Vector3f lightDir = new Vector3f(-0.12f, -0.3729129f, 0.74847335f);
        sun.setDirection(lightDir);
        sun.setColor(ColorRGBA.White.clone().multLocal(2));
        scene.addLight(sun);


        FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
        int numSamples = getContext().getSettings().getSamples();
        if (numSamples > 0) {
            fpp.setNumSamples(numSamples);
        }
        Vector3f lightPos = lightDir.multLocal(-3000);
        LightScatteringFilter filter = new LightScatteringFilter(lightPos);
        LightScatteringUI ui = new LightScatteringUI(inputManager, filter);
        fpp.addFilter(filter);
        viewPort.addProcessor(fpp);
    }
 
Example 20
Source File: KinematicRagdollControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setSpatial(Spatial model) {
    if (model == null) {
        removeFromPhysicsSpace();
        clearData();
        return;
    }
    targetModel = model;
    Node parent = model.getParent();


    Vector3f initPosition = model.getLocalTranslation().clone();
    Quaternion initRotation = model.getLocalRotation().clone();
    initScale = model.getLocalScale().clone();

    model.removeFromParent();
    model.setLocalTranslation(Vector3f.ZERO);
    model.setLocalRotation(Quaternion.IDENTITY);
    model.setLocalScale(1);
    //HACK ALERT change this
    //I remove the skeletonControl and readd it to the spatial to make sure it's after the ragdollControl in the stack
    //Find a proper way to order the controls.
    SkeletonControl sc = model.getControl(SkeletonControl.class);
    model.removeControl(sc);
    model.addControl(sc);
    //---- 

    removeFromPhysicsSpace();
    clearData();
    // put into bind pose and compute bone transforms in model space
    // maybe dont reset to ragdoll out of animations?
    scanSpatial(model);


    if (parent != null) {
        parent.attachChild(model);

    }
    model.setLocalTranslation(initPosition);
    model.setLocalRotation(initRotation);
    model.setLocalScale(initScale);

    logger.log(Level.INFO, "Created physics ragdoll for skeleton {0}", skeleton);
}