Search in sources :

Example 91 with Geometry

use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.

the class TestEverything method setupRobotGuy.

//    public void setupTerrain(){
//        Material mat = manager.loadMaterial("Textures/Terrain/Rock/Rock.j3m");
//        mat.getTextureParam("DiffuseMap").getValue().setWrap(WrapMode.Repeat);
//        mat.getTextureParam("NormalMap").getValue().setWrap(WrapMode.Repeat);
//        try{
//            Geomap map = GeomapLoader.fromImage(TestEverything.class.getResource("/textures/heightmap.png"));
//            Mesh m = map.createMesh(new Vector3f(0.35f, 0.0005f, 0.35f), new Vector2f(10, 10), true);
//            Logger.getLogger(TangentBinormalGenerator.class.getName()).setLevel(Level.SEVERE);
//            TangentBinormalGenerator.generate(m);
//            Geometry t = new Geometry("Terrain", m);
//            t.setLocalTranslation(85, -15, 0);
//            t.setMaterial(mat);
//            t.updateModelBound();
//            t.setShadowMode(ShadowMode.Receive);
//            rootNode.attachChild(t);
//        }catch (IOException ex){
//            ex.printStackTrace();
//        }
//
//    }
public void setupRobotGuy() {
    Node model = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Oto/Oto.j3m");
    model.getChild(0).setMaterial(mat);
    //        model.setAnimation("Walk");
    model.setLocalTranslation(30, 10.5f, 30);
    model.setLocalScale(2);
    model.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(model);
}
Also used : Node(com.jme3.scene.Node) Material(com.jme3.material.Material)

Example 92 with Geometry

use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.

the class CubeField method gameReset.

/**
     * Used to reset cubeField 
     */
private void gameReset() {
    Score = 0;
    lowCap = 10;
    colorInt = 0;
    highCap = 40;
    difficulty = highCap;
    for (Geometry cube : cubeField) {
        cube.removeFromParent();
    }
    cubeField.clear();
    if (fcube != null) {
        fcube.removeFromParent();
    }
    fcube = createFirstCube();
    obstacleColors.clear();
    obstacleColors.add(ColorRGBA.Orange);
    obstacleColors.add(ColorRGBA.Red);
    obstacleColors.add(ColorRGBA.Yellow);
    renderer.setBackgroundColor(ColorRGBA.White);
    speed = lowCap / 400f;
    coreTime = 20.0f;
    coreTime2 = 10.0f;
    diffHelp = lowCap;
    player.setLocalTranslation(0, 0, 0);
}
Also used : Geometry(com.jme3.scene.Geometry)

Example 93 with Geometry

use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.

the class TestRagdollCharacter method initWall.

public void initWall(float bLength, float bWidth, float bHeight) {
    Box brick = new Box(bLength, bHeight, bWidth);
    brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
    Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
    key.setGenerateMips(true);
    Texture tex = assetManager.loadTexture(key);
    mat2.setTexture("ColorMap", tex);
    float startpt = bLength / 4;
    float height = -5;
    for (int j = 0; j < 15; j++) {
        for (int i = 0; i < 4; i++) {
            Vector3f ori = new Vector3f(i * bLength * 2 + startpt, bHeight + height, -10);
            Geometry reBoxg = new Geometry("brick", brick);
            reBoxg.setMaterial(mat2);
            reBoxg.setLocalTranslation(ori);
            //for geometry with sphere mesh the physics system automatically uses a sphere collision shape
            reBoxg.addControl(new RigidBodyControl(1.5f));
            reBoxg.setShadowMode(ShadowMode.CastAndReceive);
            reBoxg.getControl(RigidBodyControl.class).setFriction(0.6f);
            this.rootNode.attachChild(reBoxg);
            this.getPhysicsSpace().add(reBoxg);
        }
        startpt = -startpt;
        height += 2 * bHeight;
    }
}
Also used : Geometry(com.jme3.scene.Geometry) TextureKey(com.jme3.asset.TextureKey) Vector2f(com.jme3.math.Vector2f) Vector3f(com.jme3.math.Vector3f) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) Texture(com.jme3.texture.Texture) RigidBodyControl(com.jme3.bullet.control.RigidBodyControl)

Example 94 with Geometry

use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.

the class TestQ3 method simpleInitApp.

public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    flyCam.setMoveSpeed(100);
    setupKeys();
    this.cam.setFrustumFar(2000);
    DirectionalLight dl = new DirectionalLight();
    dl.setColor(ColorRGBA.White.clone().multLocal(2));
    dl.setDirection(new Vector3f(-1, -1, -1).normalize());
    rootNode.addLight(dl);
    AmbientLight am = new AmbientLight();
    am.setColor(ColorRGBA.White.mult(2));
    rootNode.addLight(am);
    // load the level from zip or http zip
    if (useHttp) {
        assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/quake3level.zip", HttpZipLocator.class);
    } else {
        assetManager.registerLocator("quake3level.zip", ZipLocator.class);
    }
    // create the geometry and attach it
    MaterialList matList = (MaterialList) assetManager.loadAsset("Scene.material");
    OgreMeshKey key = new OgreMeshKey("main.meshxml", matList);
    gameLevel = (Node) assetManager.loadAsset(key);
    gameLevel.setLocalScale(0.1f);
    // add a physics control, it will generate a MeshCollisionShape based on the gameLevel
    gameLevel.addControl(new RigidBodyControl(0));
    player = new PhysicsCharacter(new SphereCollisionShape(5), .01f);
    player.setJumpSpeed(20);
    player.setFallSpeed(30);
    player.setGravity(30);
    player.setPhysicsLocation(new Vector3f(60, 10, -60));
    rootNode.attachChild(gameLevel);
    getPhysicsSpace().addAll(gameLevel);
    getPhysicsSpace().add(player);
}
Also used : PhysicsCharacter(com.jme3.bullet.objects.PhysicsCharacter) SphereCollisionShape(com.jme3.bullet.collision.shapes.SphereCollisionShape) BulletAppState(com.jme3.bullet.BulletAppState) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) MaterialList(com.jme3.material.MaterialList) OgreMeshKey(com.jme3.scene.plugins.ogre.OgreMeshKey) RigidBodyControl(com.jme3.bullet.control.RigidBodyControl) AmbientLight(com.jme3.light.AmbientLight)

Example 95 with Geometry

use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.

the class TestOrtho method simpleInitApp.

public void simpleInitApp() {
    Picture p = new Picture("Picture");
    // make it appear behind stats view
    p.move(0, 0, -1);
    p.setPosition(0, 0);
    p.setWidth(settings.getWidth());
    p.setHeight(settings.getHeight());
    p.setImage(assetManager, "Interface/Logo/Monkey.png", false);
    // attach geometry to orthoNode
    guiNode.attachChild(p);
}
Also used : Picture(com.jme3.ui.Picture)

Aggregations

Geometry (com.jme3.scene.Geometry)246 Material (com.jme3.material.Material)175 Vector3f (com.jme3.math.Vector3f)116 Box (com.jme3.scene.shape.Box)92 DirectionalLight (com.jme3.light.DirectionalLight)56 Node (com.jme3.scene.Node)54 Sphere (com.jme3.scene.shape.Sphere)49 Spatial (com.jme3.scene.Spatial)41 Quaternion (com.jme3.math.Quaternion)39 Quad (com.jme3.scene.shape.Quad)33 Texture (com.jme3.texture.Texture)30 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)26 Mesh (com.jme3.scene.Mesh)25 KeyTrigger (com.jme3.input.controls.KeyTrigger)24 AmbientLight (com.jme3.light.AmbientLight)24 ColorRGBA (com.jme3.math.ColorRGBA)21 FilterPostProcessor (com.jme3.post.FilterPostProcessor)21 PointLight (com.jme3.light.PointLight)20 Vector2f (com.jme3.math.Vector2f)17 FloatBuffer (java.nio.FloatBuffer)17