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);
}
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);
}
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);
}
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);
}
}
}
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);
}
Aggregations