Search in sources :

Example 71 with Sphere

use of com.jme3.scene.shape.Sphere in project jmonkeyengine by jMonkeyEngine.

the class TestOgreLoading method simpleInitApp.

public void simpleInitApp() {
    //        PointLight pl = new PointLight();
    //        pl.setPosition(new Vector3f(10, 10, -10));
    //        rootNode.addLight(pl);
    flyCam.setMoveSpeed(10f);
    // sunset light
    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);
    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    rootNode.attachChild(lightMdl);
    lightMd2 = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMd2.setMaterial(assetManager.loadMaterial("Common/Materials/WhiteColor.j3m"));
    rootNode.attachChild(lightMd2);
    pl = new PointLight();
    pl.setColor(new ColorRGBA(1, 0.9f, 0.9f, 0));
    pl.setPosition(new Vector3f(0f, 0f, 4f));
    rootNode.addLight(pl);
    p2 = new PointLight();
    p2.setColor(new ColorRGBA(0.9f, 1, 0.9f, 0));
    p2.setPosition(new Vector3f(0f, 0f, 3f));
    rootNode.addLight(p2);
    // create the geometry and attach it
    Spatial elephant = (Spatial) assetManager.loadModel("Models/Elephant/Elephant.mesh.xml");
    float scale = 0.05f;
    elephant.scale(scale, scale, scale);
    rootNode.attachChild(elephant);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) ColorRGBA(com.jme3.math.ColorRGBA) Spatial(com.jme3.scene.Spatial) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) PointLight(com.jme3.light.PointLight)

Example 72 with Sphere

use of com.jme3.scene.shape.Sphere in project jmonkeyengine by jMonkeyEngine.

the class TerrainTestModifyHeight method createMarker.

private void createMarker() {
    // collision marker
    Sphere sphere = new Sphere(8, 8, 0.5f);
    marker = new Geometry("Marker");
    marker.setMesh(sphere);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", new ColorRGBA(251f / 255f, 130f / 255f, 0f, 0.6f));
    mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
    marker.setMaterial(mat);
    rootNode.attachChild(marker);
    // surface normal marker
    Arrow arrow = new Arrow(new Vector3f(0, 1, 0));
    markerNormal = new Geometry("MarkerNormal");
    markerNormal.setMesh(arrow);
    markerNormal.setMaterial(mat);
    rootNode.attachChild(markerNormal);
}
Also used : Sphere(com.jme3.scene.shape.Sphere) Geometry(com.jme3.scene.Geometry) Arrow(com.jme3.scene.debug.Arrow) ColorRGBA(com.jme3.math.ColorRGBA) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material)

Example 73 with Sphere

use of com.jme3.scene.shape.Sphere in project jmonkeyengine by jMonkeyEngine.

the class TestInstanceNode method simpleInitApp.

@Override
public void simpleInitApp() {
    mesh1 = new Sphere(13, 13, 0.4f, true, false);
    mesh2 = new Box(0.4f, 0.4f, 0.4f);
    materials[0] = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    materials[0].setBoolean("UseInstancing", INSTANCING);
    materials[0].setColor("Color", ColorRGBA.Red);
    materials[1] = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    materials[1].setBoolean("UseInstancing", INSTANCING);
    materials[1].setColor("Color", ColorRGBA.Green);
    materials[2] = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    materials[2].setBoolean("UseInstancing", INSTANCING);
    materials[2].setColor("Color", ColorRGBA.Blue);
    materials[3] = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    materials[3].setBoolean("UseInstancing", INSTANCING);
    materials[3].setColor("Color", ColorRGBA.Cyan);
    materials[4] = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    materials[4].setBoolean("UseInstancing", INSTANCING);
    materials[4].setColor("Color", ColorRGBA.Magenta);
    materials[5] = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    materials[5].setBoolean("UseInstancing", INSTANCING);
    materials[5].setColor("Color", ColorRGBA.Yellow);
    instancedNode = new InstancedNode("instanced_node");
    rootNode.attachChild(instancedNode);
    int extent = 30;
    for (int y = -extent; y < extent; y++) {
        for (int x = -extent; x < extent; x++) {
            Geometry instance = createInstance(x, y);
            float height = (smoothstep(0, 1, FastMath.nextRandomFloat()) * 2.5f) - 1.25f;
            instance.setUserData("height", height);
            instance.setUserData("dir", 1f);
            instancedNode.attachChild(instance);
        }
    }
    if (INSTANCING) {
        ((InstancedNode) instancedNode).instance();
    }
    //instancedNode = (InstancedNode) instancedNode.clone();
    //instancedNode.move(0, 5, 0);
    //rootNode.attachChild(instancedNode);
    cam.setLocation(new Vector3f(38.373516f, 6.689055f, 38.482082f));
    cam.setRotation(new Quaternion(-0.04004206f, 0.918326f, -0.096310444f, -0.38183528f));
    flyCam.setMoveSpeed(15);
    flyCam.setEnabled(false);
}
Also used : Sphere(com.jme3.scene.shape.Sphere) InstancedGeometry(com.jme3.scene.instancing.InstancedGeometry) Geometry(com.jme3.scene.Geometry) Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) InstancedNode(com.jme3.scene.instancing.InstancedNode)

Example 74 with Sphere

use of com.jme3.scene.shape.Sphere in project jmonkeyengine by jMonkeyEngine.

the class TestLeakingGL method simpleUpdate.

@Override
public void simpleUpdate(float tpf) {
    rootNode.detachAllChildren();
    for (int y = -15; y < 15; y++) {
        for (int x = -15; x < 15; x++) {
            Mesh sphMesh = original.deepClone();
            Geometry sphere = new Geometry("sphere", sphMesh);
            sphere.setMaterial(solidColor);
            sphere.setLocalTranslation(x * 1.5f, 0, y * 1.5f);
            rootNode.attachChild(sphere);
        }
    }
}
Also used : Geometry(com.jme3.scene.Geometry) Mesh(com.jme3.scene.Mesh) CullHint(com.jme3.scene.Spatial.CullHint)

Example 75 with Sphere

use of com.jme3.scene.shape.Sphere in project jmonkeyengine by jMonkeyEngine.

the class TestLeakingGL method simpleInitApp.

public void simpleInitApp() {
    original = new Sphere(4, 4, 1);
    original.setStatic();
    //original.setInterleaved();
    // this will make sure all spheres are rendered always
    rootNode.setCullHint(CullHint.Never);
    solidColor = assetManager.loadMaterial("Common/Materials/RedColor.j3m");
    cam.setLocation(new Vector3f(0, 5, 0));
    cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
    Logger.getLogger(Node.class.getName()).setLevel(Level.WARNING);
    Logger.getLogger(NativeObjectManager.class.getName()).setLevel(Level.WARNING);
}
Also used : Sphere(com.jme3.scene.shape.Sphere) Vector3f(com.jme3.math.Vector3f)

Aggregations

Sphere (com.jme3.scene.shape.Sphere)63 Geometry (com.jme3.scene.Geometry)58 Vector3f (com.jme3.math.Vector3f)57 Material (com.jme3.material.Material)46 DirectionalLight (com.jme3.light.DirectionalLight)23 Box (com.jme3.scene.shape.Box)22 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)17 Node (com.jme3.scene.Node)17 PointLight (com.jme3.light.PointLight)15 BulletAppState (com.jme3.bullet.BulletAppState)13 SphereCollisionShape (com.jme3.bullet.collision.shapes.SphereCollisionShape)13 BoundingSphere (com.jme3.bounding.BoundingSphere)12 AmbientLight (com.jme3.light.AmbientLight)12 Quaternion (com.jme3.math.Quaternion)11 ColorRGBA (com.jme3.math.ColorRGBA)10 Spatial (com.jme3.scene.Spatial)9 TempVars (com.jme3.util.TempVars)9 KeyTrigger (com.jme3.input.controls.KeyTrigger)8 Vector2f (com.jme3.math.Vector2f)8 MeshCollisionShape (com.jme3.bullet.collision.shapes.MeshCollisionShape)7