com.jme3.scene.shape.Sphere Java Examples
The following examples show how to use
com.jme3.scene.shape.Sphere.
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: TestSimpleBumps.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { Quad quadMesh = new Quad(1, 1); Geometry sphere = new Geometry("Rock Ball", quadMesh); Material mat = assetManager.loadMaterial("Textures/BumpMapTest/SimpleBump.j3m"); sphere.setMaterial(mat); TangentBinormalGenerator.generate(sphere); rootNode.attachChild(sphere); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); rootNode.attachChild(lightMdl); pl = new PointLight(); pl.setColor(ColorRGBA.White); pl.setPosition(new Vector3f(0f, 0f, 4f)); rootNode.addLight(pl); // DirectionalLight dl = new DirectionalLight(); // dl.setDirection(new Vector3f(1, -1, -1).normalizeLocal()); // dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f)); // rootNode.addLight(dl); }
Example #2
Source File: TestUnshadedModel.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void simpleInitApp() { Sphere sphMesh = new Sphere(32, 32, 1); sphMesh.setTextureMode(Sphere.TextureMode.Projected); sphMesh.updateGeometry(32, 32, 1, false, false); TangentBinormalGenerator.generate(sphMesh); Geometry sphere = new Geometry("Rock Ball", sphMesh); Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); mat.setColor("Ambient", ColorRGBA.DarkGray); mat.setColor("Diffuse", ColorRGBA.White); mat.setBoolean("UseMaterialColors", true); sphere.setMaterial(mat); rootNode.attachChild(sphere); PointLight pl = new PointLight(); pl.setColor(ColorRGBA.White); pl.setPosition(new Vector3f(4f, 0f, 0f)); rootNode.addLight(pl); AmbientLight al = new AmbientLight(); al.setColor(ColorRGBA.White); rootNode.addLight(al); }
Example #3
Source File: TestSimpleWater.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void initScene() { //init cam location cam.setLocation(new Vector3f(0, 10, 10)); cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y); //init scene sceneNode = new Node("Scene"); mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); geom.setMaterial(mat); sceneNode.attachChild(geom); // load sky sceneNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false)); rootNode.attachChild(sceneNode); //add lightPos Geometry Sphere lite=new Sphere(8, 8, 3.0f); lightSphere=new Geometry("lightsphere", lite); lightSphere.setMaterial(mat); lightSphere.setLocalTranslation(lightPos); rootNode.attachChild(lightSphere); }
Example #4
Source File: MaterialPreviewWidget.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void initWidget() { SceneApplication.getApplication().addSceneListener(this); Sphere sphMesh = new Sphere(32, 32, 2.5f); sphMesh.setTextureMode(Sphere.TextureMode.Projected); sphMesh.updateGeometry(32, 32, 2.5f, false, false); TangentBinormalGenerator.generate(sphMesh); sphere = new Geometry("previewSphere", sphMesh); sphere.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_X)); Box boxMesh = new Box(new Vector3f(0, 0, 0), 1.75f, 1.75f, 1.75f); TangentBinormalGenerator.generate(boxMesh); box = new Geometry("previewBox", boxMesh); box.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.DEG_TO_RAD * 30, Vector3f.UNIT_X).multLocal(new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_Y))); Quad quadMesh = new Quad(4.5f, 4.5f); TangentBinormalGenerator.generate(quadMesh); quad = new Geometry("previewQuad", quadMesh); quad.setLocalTranslation(new Vector3f(-2.25f, -2.25f, 0)); currentGeom = sphere; sphereButton.setSelected(true); init=true; }
Example #5
Source File: TestSphere.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void simpleInitApp() { Sphere sphMesh = new Sphere(14, 14, 1); Material solidColor = assetManager.loadMaterial("Common/Materials/RedColor.j3m"); for (int y = -5; y < 5; y++){ for (int x = -5; x < 5; x++){ Geometry sphere = new Geometry("sphere", sphMesh); sphere.setMaterial(solidColor); sphere.setLocalTranslation(x * 2, 0, y * 2); rootNode.attachChild(sphere); } } cam.setLocation(new Vector3f(0, 5, 0)); cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y); }
Example #6
Source File: TestBrickTower.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL); // bulletAppState.setEnabled(false); stateManager.attach(bulletAppState); bullet = new Sphere(32, 32, 0.4f, true, false); bullet.setTextureMode(TextureMode.Projected); bulletCollisionShape = new SphereCollisionShape(0.4f); brick = new Box(brickWidth, brickHeight, brickDepth); brick.scaleTextureCoordinates(new Vector2f(1f, .5f)); //bulletAppState.getPhysicsSpace().enableDebug(assetManager); initMaterial(); initTower(); initFloor(); initCrossHairs(); this.cam.setLocation(new Vector3f(0, 25f, 8f)); cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0)); cam.setFrustumFar(80); inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); inputManager.addListener(actionListener, "shoot"); rootNode.setShadowMode(ShadowMode.Off); }
Example #7
Source File: TerrainTestModifyHeight.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
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); }
Example #8
Source File: TestSimpleWater.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void initScene() { //init cam location cam.setLocation(new Vector3f(0, 10, 10)); cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y); //init scene sceneNode = new Node("Scene"); mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); geom.setMaterial(mat); sceneNode.attachChild(geom); // load sky sceneNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", SkyFactory.EnvMapType.CubeMap)); rootNode.attachChild(sceneNode); //add lightPos Geometry Sphere lite=new Sphere(8, 8, 3.0f); lightSphere=new Geometry("lightsphere", lite); lightSphere.setMaterial(mat); lightSphere.setLocalTranslation(lightPos); rootNode.attachChild(lightSphere); }
Example #9
Source File: TestTangentGen.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { flyCam.setMoveSpeed(20); Sphere sphereMesh = new Sphere(32, 32, 1); sphereMesh.setTextureMode(Sphere.TextureMode.Projected); sphereMesh.updateGeometry(32, 32, 1, false, false); addMesh("Sphere", sphereMesh, new Vector3f(-1, 0, 0)); Quad quadMesh = new Quad(1, 1); quadMesh.updateGeometry(1, 1); addMesh("Quad", quadMesh, new Vector3f(1, 0, 0)); Mesh strip = createTriangleStripMesh(); addMesh("strip", strip, new Vector3f(0, -3, 0)); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(1, -1, -1).normalizeLocal()); dl.setColor(ColorRGBA.White); rootNode.addLight(dl); }
Example #10
Source File: TestGeometryShader.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { Mesh mesh = new Mesh(); mesh.setBuffer(VertexBuffer.Type.Index, 1, BufferUtils.createIntBuffer(new int[]{1})); mesh.setBuffer(VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer(new float[]{0, 0, 0})); mesh.setMode(Mesh.Mode.Points); mesh.setBound(new BoundingBox(new Vector3f(0, 0, 0), 10, 10, 10)); mesh.updateCounts(); Geometry geometry = new Geometry("Test", mesh); geometry.updateGeometricState(); geometry.setMaterial(new Material(assetManager, "Materials/Geom/SimpleGeom.j3md")); //geometry.getMaterial().getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off); //geometry.setMaterial(assetManager.loadMaterial("Materials/Geom/SimpleTess.j3md")); rootNode.attachChild(geometry); Geometry geometry1 = new Geometry("T1", new Sphere(10, 10, 1)); geometry1.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md")); rootNode.attachChild(geometry1); }
Example #11
Source File: TestSimpleBumps.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void simpleInitApp() { Quad quadMesh = new Quad(1, 1); Geometry sphere = new Geometry("Rock Ball", quadMesh); Material mat = assetManager.loadMaterial("Textures/BumpMapTest/SimpleBump.j3m"); sphere.setMaterial(mat); TangentBinormalGenerator.generate(sphere); rootNode.attachChild(sphere); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); rootNode.attachChild(lightMdl); pl = new PointLight(); pl.setColor(ColorRGBA.White); pl.setPosition(new Vector3f(0f, 0f, 4f)); rootNode.addLight(pl); // DirectionalLight dl = new DirectionalLight(); // dl.setDirection(new Vector3f(1, -1, -1).normalizeLocal()); // dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f)); // rootNode.addLight(dl); }
Example #12
Source File: TerrainTestModifyHeight.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
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); }
Example #13
Source File: TestNormalMapping.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { Sphere sphMesh = new Sphere(32, 32, 1); sphMesh.setTextureMode(Sphere.TextureMode.Projected); sphMesh.updateGeometry(32, 32, 1, false, false); TangentBinormalGenerator.generate(sphMesh); Geometry sphere = new Geometry("Rock Ball", sphMesh); Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); sphere.setMaterial(mat); rootNode.attachChild(sphere); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); rootNode.attachChild(lightMdl); pl = new PointLight(); pl.setColor(ColorRGBA.White); pl.setPosition(new Vector3f(0f, 0f, 4f)); rootNode.addLight(pl); // DirectionalLight dl = new DirectionalLight(); // dl.setDirection(new Vector3f(1,-1,1).normalizeLocal()); // dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f)); // rootNode.addLight(dl); }
Example #14
Source File: WorldOfInception.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { //set far frustum only so we see the outer world longer cam.setFrustumFar(10000); cam.setLocation(Vector3f.ZERO); debugTools = new DebugTools(assetManager); rootNode.attachChild(debugTools.debugNode); poiMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); poiMaterial.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); poiMesh = new Sphere(16, 16, 1f); ballMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); ballMaterial.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); ballMaterial.setColor("Color", ColorRGBA.Red); ballMesh = new Sphere(16, 16, 1.0f); poiHorizonCollisionShape = new MeshCollisionShape(new Sphere(128, 128, poiRadius)); poiCollisionShape = new SphereCollisionShape(1f); ballCollisionShape = new SphereCollisionShape(1f); setupKeys(); setupDisplay(); setupFog(); }
Example #15
Source File: TestDoppler.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { flyCam.setMoveSpeed(10); Torus torus = new Torus(10, 6, 1, 3); Geometry g = new Geometry("Torus Geom", torus); g.rotate(-FastMath.HALF_PI, 0, 0); g.center(); g.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); // rootNode.attachChild(g); ufoNode = new AudioNode(assetManager, "Sound/Effects/Beep.ogg", AudioData.DataType.Buffer); ufoNode.setLooping(true); ufoNode.setPitch(0.5f); ufoNode.setRefDistance(1); ufoNode.setMaxDistance(100000000); ufoNode.setVelocityFromTranslation(true); ufoNode.play(); Geometry ball = new Geometry("Beeper", new Sphere(10, 10, 0.1f)); ball.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); ufoNode.attachChild(ball); rootNode.attachChild(ufoNode); }
Example #16
Source File: AbstractSceneEditor3DPart.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@JmeThread protected @NotNull Geometry createGeometry(@NotNull final ScenePresentable.PresentationType presentationType) { final Material material = new Material(EditorUtil.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); material.setColor("Color", ColorRGBA.Yellow); material.getAdditionalRenderState().setWireframe(true); Geometry geometry; switch (presentationType) { case SPHERE: { geometry = new Geometry("Sphere", new Sphere(8, 8, 1)); break; } default: { geometry = new Geometry("Box", new Box(1, 1, 1)); } } geometry.setMaterial(material); return geometry; }
Example #17
Source File: TestNormalMapping.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void simpleInitApp() { Sphere sphMesh = new Sphere(32, 32, 1); sphMesh.setTextureMode(Sphere.TextureMode.Projected); sphMesh.updateGeometry(32, 32, 1, false, false); TangentBinormalGenerator.generate(sphMesh); Geometry sphere = new Geometry("Rock Ball", sphMesh); Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); sphere.setMaterial(mat); rootNode.attachChild(sphere); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); rootNode.attachChild(lightMdl); pl = new PointLight(); pl.setColor(ColorRGBA.White); pl.setPosition(new Vector3f(0f, 0f, 4f)); rootNode.addLight(pl); // DirectionalLight dl = new DirectionalLight(); // dl.setDirection(new Vector3f(1,-1,1).normalizeLocal()); // dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f)); // rootNode.addLight(dl); }
Example #18
Source File: TestUnshadedModel.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void simpleInitApp() { Sphere sphMesh = new Sphere(32, 32, 1); sphMesh.setTextureMode(Sphere.TextureMode.Projected); sphMesh.updateGeometry(32, 32, 1, false, false); TangentBinormalGenerator.generate(sphMesh); Geometry sphere = new Geometry("Rock Ball", sphMesh); Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); mat.setColor("Ambient", ColorRGBA.DarkGray); mat.setColor("Diffuse", ColorRGBA.White); mat.setBoolean("UseMaterialColors", true); sphere.setMaterial(mat); rootNode.attachChild(sphere); PointLight pl = new PointLight(); pl.setColor(ColorRGBA.White); pl.setPosition(new Vector3f(4f, 0f, 0f)); rootNode.addLight(pl); AmbientLight al = new AmbientLight(); al.setColor(ColorRGBA.White); rootNode.addLight(al); }
Example #19
Source File: LightsDebugState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void initialize(Application app) { debugNode = new Node("Environment debug Node"); Sphere s = new Sphere(16, 16, 0.15f); debugGeom = new Geometry("debugEnvProbe", s); debugMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/reflect.j3md"); debugGeom.setMaterial(debugMaterial); debugBounds = BoundingSphereDebug.createDebugSphere(app.getAssetManager()); if (scene == null) { scene = app.getViewPort().getScenes().get(0); } }
Example #20
Source File: TestNormalMapping.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void simpleInitApp() { Sphere sphMesh = new Sphere(32, 32, 1); sphMesh.setTextureMode(Sphere.TextureMode.Projected); sphMesh.updateGeometry(32, 32, 1, false, false); TangentBinormalGenerator.generate(sphMesh); Geometry sphere = new Geometry("Rock Ball", sphMesh); Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); sphere.setMaterial(mat); rootNode.attachChild(sphere); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); rootNode.attachChild(lightMdl); pl = new PointLight(); pl.setColor(ColorRGBA.White); pl.setPosition(new Vector3f(0f, 0f, 4f)); rootNode.addLight(pl); AmbientLight al = new AmbientLight(); al.setColor(new ColorRGBA(0.44f, 0.40f, 0.20f, 1.0f)); rootNode.addLight(al); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(1,-1,-1).normalizeLocal()); dl.setColor(new ColorRGBA(0.92f, 0.85f, 0.8f, 1.0f)); rootNode.addLight(dl); }
Example #21
Source File: PhysicsTestHelper.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * creates a sphere geometry with a RigidBodyControl * * @param assetManager for loading assets * @return a new Geometry */ public static Geometry createPhysicsTestSphere(AssetManager assetManager) { Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); Sphere sphere = new Sphere(8, 8, 0.25f); Geometry boxGeometry = new Geometry("Sphere", sphere); boxGeometry.setMaterial(material); //RigidBodyControl automatically uses sphere collision shapes when attached to single geometry with sphere mesh boxGeometry.addControl(new RigidBodyControl(2)); return boxGeometry; }
Example #22
Source File: TestLeakingGL.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example #23
Source File: PhysicsTestHelper.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * creates the necessary inputlistener and action to shoot balls from the camera * * @param app the application that's running * @param rootNode where ball geometries should be added * @param space where collision objects should be added */ public static void createBallShooter(final Application app, final Node rootNode, final PhysicsSpace space) { ActionListener actionListener = new ActionListener() { @Override public void onAction(String name, boolean keyPressed, float tpf) { Sphere bullet = new Sphere(32, 32, 0.4f, true, false); bullet.setTextureMode(TextureMode.Projected); Material mat2 = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG"); key2.setGenerateMips(true); Texture tex2 = app.getAssetManager().loadTexture(key2); mat2.setTexture("ColorMap", tex2); if (name.equals("shoot") && !keyPressed) { Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(mat2); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setLocalTranslation(app.getCamera().getLocation()); RigidBodyControl bulletControl = new RigidBodyControl(10); bulletg.addControl(bulletControl); bulletControl.setLinearVelocity(app.getCamera().getDirection().mult(25)); bulletg.addControl(bulletControl); rootNode.attachChild(bulletg); space.add(bulletControl); } } }; app.getInputManager().addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); app.getInputManager().addListener(actionListener, "shoot"); }
Example #24
Source File: TestBetterCharacter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void setupPlanet() { Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); //immovable sphere with mesh collision shape Sphere sphere = new Sphere(64, 64, 20); planet = new Geometry("Sphere", sphere); planet.setMaterial(material); planet.setLocalTranslation(30, -15, 30); planet.addControl(new RigidBodyControl(new MeshCollisionShape(sphere), 0)); rootNode.attachChild(planet); getPhysicsSpace().add(planet); }
Example #25
Source File: PhysicsTestHelper.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * creates a sphere geometry with a RigidBodyControl * @param assetManager * @return */ public static Geometry createPhysicsTestSphere(AssetManager assetManager) { Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); Sphere sphere = new Sphere(8, 8, 0.25f); Geometry boxGeometry = new Geometry("Sphere", sphere); boxGeometry.setMaterial(material); //RigidBodyControl automatically uses sphere collision shapes when attached to single geometry with sphere mesh boxGeometry.addControl(new RigidBodyControl(2)); return boxGeometry; }
Example #26
Source File: TerrainTestCollision.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private void createCollisionMarker() { Sphere s = new Sphere(6, 6, 1); collisionMarker = new Geometry("collisionMarker"); collisionMarker.setMesh(s); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Orange); collisionMarker.setMaterial(mat); rootNode.attachChild(collisionMarker); }
Example #27
Source File: TestWalkingChar.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void prepareBullet() { bullet = new Sphere(32, 32, 0.4f, true, false); bullet.setTextureMode(TextureMode.Projected); bulletCollisionShape = new SphereCollisionShape(0.4f); matBullet = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); matBullet.setColor("Color", ColorRGBA.Green); matBullet.setColor("GlowColor", ColorRGBA.Green); getPhysicsSpace().addCollisionListener(this); }
Example #28
Source File: TestCollisionGroups.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.setDebugEnabled(true); // Add a physics sphere to the world Node physicsSphere = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1); physicsSphere.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3, 6, 0)); rootNode.attachChild(physicsSphere); getPhysicsSpace().add(physicsSphere); // Add a physics sphere to the world Node physicsSphere2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1); physicsSphere2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(4, 8, 0)); physicsSphere2.getControl(RigidBodyControl.class).addCollideWithGroup(PhysicsCollisionObject.COLLISION_GROUP_02); rootNode.attachChild(physicsSphere2); getPhysicsSpace().add(physicsSphere2); // an obstacle mesh, does not move (mass=0) Node node2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new MeshCollisionShape(new Sphere(16, 16, 1.2f)), 0); node2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2.5f, -4, 0f)); node2.getControl(RigidBodyControl.class).setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_02); node2.getControl(RigidBodyControl.class).setCollideWithGroups(PhysicsCollisionObject.COLLISION_GROUP_02); rootNode.attachChild(node2); getPhysicsSpace().add(node2); // the floor, does not move (mass=0) Node node3 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new MeshCollisionShape(new Box(100f, 0.2f, 100f)), 0); node3.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, -6, 0f)); rootNode.attachChild(node3); getPhysicsSpace().add(node3); }
Example #29
Source File: HelloPicking.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** A red ball that marks the last spot that was "hit" by the "shot". */ protected void initMark() { Sphere sphere = new Sphere(30, 30, 0.2f); mark = new Geometry("BOOM!", sphere); Material mark_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mark_mat.setColor("Color", ColorRGBA.Red); mark.setMaterial(mark_mat); }
Example #30
Source File: TestCcd.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.getPhysicsSpace().enableDebug(assetManager); bullet = new Sphere(32, 32, 0.4f, true, false); bullet.setTextureMode(TextureMode.Projected); bulletCollisionShape = new SphereCollisionShape(0.1f); setupKeys(); mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.getAdditionalRenderState().setWireframe(true); mat.setColor("Color", ColorRGBA.Green); mat2 = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat2.getAdditionalRenderState().setWireframe(true); mat2.setColor("Color", ColorRGBA.Red); // An obstacle mesh, does not move (mass=0) Node node2 = new Node(); node2.setName("mesh"); node2.setLocalTranslation(new Vector3f(2.5f, 0, 0f)); node2.addControl(new RigidBodyControl(new MeshCollisionShape(new Box(Vector3f.ZERO, 4, 4, 0.1f)), 0)); rootNode.attachChild(node2); getPhysicsSpace().add(node2); // The floor, does not move (mass=0) Node node3 = new Node(); node3.setLocalTranslation(new Vector3f(0f, -6, 0f)); node3.addControl(new RigidBodyControl(new BoxCollisionShape(new Vector3f(100, 1, 100)), 0)); rootNode.attachChild(node3); getPhysicsSpace().add(node3); }