com.jme3.material.Material Java Examples
The following examples show how to use
com.jme3.material.Material.
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: MaterialFileEditor.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * Reload the material. */ @FxThread private void reload(@NotNull final Material material) { setCurrentMaterial(material); setIgnoreListeners(true); try { final MaterialEditor3DPart editor3DState = getEditor3DPart(); editor3DState.updateMaterial(material); getSettingsTree().fill(new RootMaterialSettings(material)); final ComboBox<String> materialDefinitionBox = getMaterialDefinitionBox(); final ObservableList<String> items = materialDefinitionBox.getItems(); items.clear(); items.addAll(RESOURCE_MANAGER.getAvailableResources(FileExtensions.JME_MATERIAL_DEFINITION)); final MaterialDef materialDef = material.getMaterialDef(); materialDefinitionBox.getSelectionModel().select(materialDef.getAssetName()); } finally { setIgnoreListeners(false); } }
Example #2
Source File: TestTransparentCartoonEdge.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public void makeToonish(Spatial spatial){ if (spatial instanceof Node){ Node n = (Node) spatial; for (Spatial child : n.getChildren()) makeToonish(child); }else if (spatial instanceof Geometry){ Geometry g = (Geometry) spatial; Material m = g.getMaterial(); if (m.getMaterialDef().getName().equals("Phong Lighting")){ Texture t = assetManager.loadTexture("Textures/ColorRamp/toon.png"); // t.setMinFilter(Texture.MinFilter.NearestNoMipMaps); // t.setMagFilter(Texture.MagFilter.Nearest); m.setTexture("ColorRamp", t); m.setBoolean("UseMaterialColors", true); m.setColor("Specular", ColorRGBA.Black); m.setColor("Diffuse", ColorRGBA.White); m.setBoolean("VertexLighting", true); } } }
Example #3
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 #4
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 #5
Source File: TestTransparentCartoonEdge.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void makeToonish(Spatial spatial){ if (spatial instanceof Node){ Node n = (Node) spatial; for (Spatial child : n.getChildren()) makeToonish(child); }else if (spatial instanceof Geometry){ Geometry g = (Geometry) spatial; Material m = g.getMaterial(); if (m.getMaterialDef().getName().equals("Phong Lighting")){ Texture t = assetManager.loadTexture("Textures/ColorRamp/toon.png"); // t.setMinFilter(Texture.MinFilter.NearestNoMipMaps); // t.setMagFilter(Texture.MagFilter.Nearest); m.setTexture("ColorRamp", t); m.setBoolean("UseMaterialColors", true); m.setColor("Specular", ColorRGBA.Black); m.setColor("Diffuse", ColorRGBA.White); m.setBoolean("VertexLighting", true); } } }
Example #6
Source File: HelloPhysics.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
/** Initialize the materials used in this scene. */ public void initMaterials() { wall_mat = 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); wall_mat.setTexture("ColorMap", tex); stone_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG"); key2.setGenerateMips(true); Texture tex2 = assetManager.loadTexture(key2); stone_mat.setTexture("ColorMap", tex2); floor_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg"); key3.setGenerateMips(true); Texture tex3 = assetManager.loadTexture(key3); tex3.setWrap(WrapMode.Repeat); floor_mat.setTexture("ColorMap", tex3); }
Example #7
Source File: MaterialContext.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
/** * Sets the texture to the given material. * * @param material * the material that we add texture to * @param mapTo * the texture mapping type * @param texture * the added texture */ private void setTexture(Material material, int mapTo, Texture texture) { switch (mapTo) { case MTEX_COL: material.setTexture(shadeless ? MaterialHelper.TEXTURE_TYPE_COLOR : MaterialHelper.TEXTURE_TYPE_DIFFUSE, texture); break; case MTEX_NOR: material.setTexture(MaterialHelper.TEXTURE_TYPE_NORMAL, texture); break; case MTEX_SPEC: material.setTexture(MaterialHelper.TEXTURE_TYPE_SPECULAR, texture); break; case MTEX_EMIT: material.setTexture(MaterialHelper.TEXTURE_TYPE_GLOW, texture); break; case MTEX_ALPHA: if (!shadeless) { material.setTexture(MaterialHelper.TEXTURE_TYPE_ALPHA, texture); } else { LOGGER.warning("JME does not support alpha map on unshaded material. Material name is " + name); } break; default: LOGGER.severe("Unknown mapping type: " + mapTo); } }
Example #8
Source File: EditableMaterialFile.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
/** * Creates the data from a material * @param mat */ public void setAsMaterial(Material mat) throws IOException { assert (mat.getMaterialDef().getAssetName() != null); setName("MyMaterial"); setMatDefName(mat.getMaterialDef().getAssetName()); createBaseMaterialFile(); materialParameters.clear(); Collection<MatParam> params = mat.getParams(); for (Iterator<MatParam> it = params.iterator(); it.hasNext();) { MatParam matParam = it.next(); materialParameters.put(matParam.getName(), new MaterialProperty(matParam)); } additionalRenderStates.put("Wireframe", new MaterialProperty("OnOff", "Wireframe", mat.getAdditionalRenderState().isWireframe() ? "On" : "Off")); additionalRenderStates.put("DepthWrite", new MaterialProperty("OnOff", "DepthWrite", mat.getAdditionalRenderState().isDepthWrite() ? "On" : "Off")); additionalRenderStates.put("DepthTest", new MaterialProperty("OnOff", "DepthTest", mat.getAdditionalRenderState().isDepthTest() ? "On" : "Off")); additionalRenderStates.put("ColorWrite", new MaterialProperty("OnOff", "ColorWrite", mat.getAdditionalRenderState().isColorWrite() ? "On" : "Off")); additionalRenderStates.put("PointSprite", new MaterialProperty("OnOff", "PointSprite", mat.getAdditionalRenderState().isPointSprite() ? "On" : "Off")); additionalRenderStates.put("FaceCull", new MaterialProperty("FaceCullMode", "FaceCull", mat.getAdditionalRenderState().getFaceCullMode().name())); additionalRenderStates.put("Blend", new MaterialProperty("BlendMode", "Blend", mat.getAdditionalRenderState().getBlendMode().name())); additionalRenderStates.put("AlphaTestFalloff", new MaterialProperty("Float", "AlphaTestFalloff", mat.getAdditionalRenderState().getAlphaFallOff() + "")); additionalRenderStates.put("PolyOffset", new MaterialProperty("Float,Float", "PolyOffset", mat.getAdditionalRenderState().getPolyOffsetUnits() + " " + mat.getAdditionalRenderState().getPolyOffsetFactor())); checkWithMatDef(); setAsText(getUpdatedContent()); }
Example #9
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 #10
Source File: HDRRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void renderProcessing(Renderer r, FrameBuffer dst, Material mat){ if (dst == null){ fsQuad.setWidth(mainSceneFB.getWidth()); fsQuad.setHeight(mainSceneFB.getHeight()); fbCam.resize(mainSceneFB.getWidth(), mainSceneFB.getHeight(), true); }else{ fsQuad.setWidth(dst.getWidth()); fsQuad.setHeight(dst.getHeight()); fbCam.resize(dst.getWidth(), dst.getHeight(), true); } fsQuad.setMaterial(mat); fsQuad.updateGeometricState(); renderManager.setCamera(fbCam, true); r.setFrameBuffer(dst); r.clearBuffers(true, true, true); renderManager.renderGeometry(fsQuad); }
Example #11
Source File: TestResizableApp.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { flyCam.setDragToRotate(true); Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); geom.setMaterial(mat); rootNode.attachChild(geom); txt = new BitmapText(loadGuiFont(), false); txt.setText("Drag the corners of the application to resize it.\n" + "Current Size: " + settings.getWidth() + "x" + settings.getHeight()); txt.setLocalTranslation(0, settings.getHeight(), 0); guiNode.attachChild(txt); }
Example #12
Source File: MaterialUtils.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * Check a material on containing a texture. * * @param material the material. * @param assetPath the path of the texture. * @return true if the material definition contains the texture. */ @FromAnyThread private static boolean containsTexture(@NotNull Material material, @NotNull String assetPath) { var materialParams = material.getParams(); for (var materialParam : materialParams) { if (materialParam.getVarType() != VarType.Texture2D) { continue; } var value = (Texture) materialParam.getValue(); var textureKey = value == null ? null : (TextureKey) value.getKey(); if (textureKey != null && StringUtils.equals(textureKey.getName(), assetPath)) { return true; } } return false; }
Example #13
Source File: TestExplosionEffect.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void createRoundSpark(){ roundspark = new ParticleEmitter("RoundSpark", EMITTER_TYPE, 20 * COUNT_FACTOR); roundspark.setStartColor(new ColorRGBA(1f, 0.29f, 0.34f, (float) (1.0 / COUNT_FACTOR_F))); roundspark.setEndColor(new ColorRGBA(0, 0, 0, 0.5f / COUNT_FACTOR_F)); roundspark.setStartSize(1.2f); roundspark.setEndSize(1.8f); roundspark.setShape(new EmitterSphereShape(Vector3f.ZERO, 2f)); roundspark.setParticlesPerSec(0); roundspark.setGravity(0, -.5f, 0); roundspark.setLowLife(1.8f); roundspark.setHighLife(2f); roundspark.getParticleInfluencer() .setInitialVelocity(new Vector3f(0, 3, 0)); roundspark.getParticleInfluencer().setVelocityVariation(.5f); roundspark.setImagesX(1); roundspark.setImagesY(1); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/roundspark.png")); mat.setBoolean("PointSprite", POINT_SPRITE); roundspark.setMaterial(mat); explosionEffect.attachChild(roundspark); }
Example #14
Source File: TestBatchNodeTower.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void initMaterial() { mat = 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); mat.setTexture("ColorMap", tex); mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG"); key2.setGenerateMips(true); Texture tex2 = assetManager.loadTexture(key2); mat2.setTexture("ColorMap", tex2); mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg"); key3.setGenerateMips(true); Texture tex3 = assetManager.loadTexture(key3); tex3.setWrap(WrapMode.Repeat); mat3.setTexture("ColorMap", tex3); }
Example #15
Source File: OpaqueComparator.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public int compare(Geometry o1, Geometry o2) { Material m1 = o1.getMaterial(); Material m2 = o2.getMaterial(); int sortId = m1.compareTo(m2); if (sortId == 0){ // use the same shader. // sort front-to-back then. float d1 = distanceToCam(o1); float d2 = distanceToCam(o2); if (d1 == d2) return 0; else if (d1 < d2) return -1; else return 1; }else{ return sortId; } }
Example #16
Source File: TestAwtPanels.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { flyCam.setDragToRotate(true); Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); geom.setMaterial(mat); rootNode.attachChild(geom); /* * Wait until both AWT panels are ready. */ try { panelsAreReady.await(); } catch (InterruptedException exception) { throw new RuntimeException("Interrupted while waiting for panels", exception); } panel.attachTo(true, viewPort); guiViewPort.setClearFlags(true, true, true); panel2.attachTo(false, guiViewPort); }
Example #17
Source File: MaterialFileEditor.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread protected void handleExternalChanges() { super.handleExternalChanges(); final Path assetFile = notNull(getAssetFile(getEditFile())); final MaterialKey materialKey = new MaterialKey(toAssetPath(assetFile)); final AssetManager assetManager = EditorUtil.getAssetManager(); final Material material = assetManager.loadAsset(materialKey); reload(material); final EditorOperationControl operationControl = getOperationControl(); operationControl.clear(); }
Example #18
Source File: BasicShadowRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
/** * Creates a BasicShadowRenderer * @param manager the asset manager * @param size the size of the shadow map (the map is square) */ public BasicShadowRenderer(AssetManager manager, int size) { shadowFB = new FrameBuffer(size, size, 1); shadowMap = new Texture2D(size, size, Format.Depth); shadowFB.setDepthTexture(shadowMap); shadowCam = new Camera(size, size); preshadowMat = new Material(manager, "Common/MatDefs/Shadow/PreShadow.j3md"); postshadowMat = new Material(manager, "Common/MatDefs/Shadow/PostShadow.j3md"); postshadowMat.setTexture("ShadowMap", shadowMap); dispPic.setTexture(manager, shadowMap, false); for (int i = 0; i < points.length; i++) { points[i] = new Vector3f(); } }
Example #19
Source File: TestBumpModel.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void simpleInitApp() { Spatial signpost = (Spatial) assetManager.loadAsset(new OgreMeshKey("Models/Sign Post/Sign Post.mesh.xml")); signpost.setMaterial( (Material) assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m")); TangentBinormalGenerator.generate(signpost); rootNode.attachChild(signpost); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial( (Material) assetManager.loadMaterial("Common/Materials/RedColor.j3m")); rootNode.attachChild(lightMdl); // flourescent main light pl = new PointLight(); pl.setColor(new ColorRGBA(0.88f, 0.92f, 0.95f, 1.0f)); 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 #20
Source File: TestInstanceNodeWithLight.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { InstancedNode instancedNode = new InstancedNode("testInstancedNode"); rootNode.attachChild(instancedNode); box = new Geometry("Box", new Box(0.5f, 0.5f, 0.5f)); Material material = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); material.setBoolean("UseInstancing", true); material.setColor("Diffuse", ColorRGBA.Red); material.setBoolean("UseMaterialColors", true); box.setMaterial(material); instancedNode.attachChild(box); instancedNode.instance(); pointLight = new PointLight(); pointLight.setColor(ColorRGBA.White); pointLight.setRadius(10f); rootNode.addLight(pointLight); box.setLocalTranslation(new Vector3f(offset, 0, 0)); pointLight.setPosition(new Vector3f(offset - 3f, 0, 0)); cam.setLocation(new Vector3f(offset - 5f, 0, 0)); cam.lookAtDirection(Vector3f.UNIT_X, Vector3f.UNIT_Y); }
Example #21
Source File: TestBrickTower.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public void initMaterial() { mat = 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); mat.setTexture("ColorMap", tex); mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG"); key2.setGenerateMips(true); Texture tex2 = assetManager.loadTexture(key2); mat2.setTexture("ColorMap", tex2); mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg"); key3.setGenerateMips(true); Texture tex3 = assetManager.loadTexture(key3); tex3.setWrap(WrapMode.Repeat); mat3.setTexture("ColorMap", tex3); }
Example #22
Source File: HelloAudio.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { flyCam.setMoveSpeed(40); /** just a blue box floating in space */ Box box1 = new Box(1, 1, 1); player = new Geometry("Player", box1); Material mat1 = new Material(assetManager,"Common/MatDefs/Misc/Unshaded.j3md"); mat1.setColor("Color", ColorRGBA.Blue); player.setMaterial(mat1); rootNode.attachChild(player); /** custom init methods, see below */ initKeys(); initAudio(); }
Example #23
Source File: TestSpotLight.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void setupFloor(){ Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat); mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat); // mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat); mat.setFloat("Shininess",3); // mat.setBoolean("VertexLighting", true); Box floor = new Box(50, 1f, 50); TangentBinormalGenerator.generate(floor); floor.scaleTextureCoordinates(new Vector2f(5, 5)); Geometry floorGeom = new Geometry("Floor", floor); floorGeom.setMaterial(mat); floorGeom.setShadowMode(ShadowMode.Receive); rootNode.attachChild(floorGeom); }
Example #24
Source File: GeometryTreeNode.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override public void accept(@NotNull final ChangeConsumer changeConsumer, @NotNull final Object object, final boolean isCopy) { final Geometry geometry = getElement(); if (object instanceof Material) { final Material material = (Material) object; if (isCopy) { final Material clone = material.clone(); final PropertyOperation<ChangeConsumer, Geometry, Material> operation = new PropertyOperation<>(geometry, "Material", clone, geometry.getMaterial()); operation.setApplyHandler(Geometry::setMaterial); changeConsumer.execute(operation); } } super.accept(changeConsumer, object, isCopy); }
Example #25
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 #26
Source File: TestSplitScreen.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void simpleInitApp() { flyCam.setEnabled(false); Geometry blueBox = new Geometry("blue box", mesh); Material blueMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); blueMat.setColor("Color", ColorRGBA.Blue); blueBox.setMaterial(blueMat); rootNode.attachChild(blueBox); rightCam = cam.clone(); rightCam.setViewPort(0.5f, 1f, 0f, 1f); rightView = renderManager.createMainView("right", rightCam); rightView.setClearFlags(true, true, true); rightView.setEnabled(false); rightView.attachScene(rootNode); Geometry redBox = new Geometry("red box", mesh); Material redMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); redMat.setColor("Color", ColorRGBA.Red); redBox.setMaterial(redMat); leftScene.attachChild(redBox); leftCam = cam.clone(); leftCam.setViewPort(0f, 0.5f, 0f, 1f); leftView = renderManager.createMainView("left", leftCam); leftView.setClearFlags(true, true, true); leftView.setEnabled(false); leftView.attachScene(leftScene); inputManager.addMapping("lmb", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); inputManager.addListener(this, "lmb"); }
Example #27
Source File: CollideIgnoreTransformTest.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Attach a red square in the XY plane with its lower left corner at (0, 0, * 0). It is composed of 2 triangles. */ void createRedSquare() { Mesh quadMesh = new Quad(1f, 1f); Geometry redSquare = new Geometry("red square", quadMesh); Material red = assetManager.loadMaterial("Common/Materials/RedColor.j3m"); redSquare.setMaterial(red); rootNode.attachChild(redSquare); redSquare.setLocalTranslation(0f, 3f, 0f); redSquare.setIgnoreTransform(true); }
Example #28
Source File: PhysicsCollisionObject.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
protected Spatial attachDebugShape(Material material) { debugMaterialBlue = material; debugMaterialGreen = material; debugMaterialRed = material; debugMaterialYellow = material; debugArrow = new Arrow(Vector3f.UNIT_XYZ); debugArrowGeom = new Geometry("DebugArrow", debugArrow); debugArrowGeom.setMaterial(debugMaterialGreen); return attachDebugShape(); }
Example #29
Source File: CartoonSSAO.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { this.renderManager = renderManager; this.viewPort = vp; int screenWidth = Math.round(w / downsample); int screenHeight = Math.round(h / downsample); normalPass = new Pass(); normalPass.init(renderManager.getRenderer(), screenWidth, screenHeight, Format.RGBA8, Format.Depth); frustumNearFar = new Vector2f(); float farY = (vp.getCamera().getFrustumTop() / vp.getCamera().getFrustumNear()) * vp.getCamera().getFrustumFar(); float farX = farY * (screenWidth / (float) screenHeight); frustumCorner = new Vector3f(farX, farY, vp.getCamera().getFrustumFar()); frustumNearFar.x = vp.getCamera().getFrustumNear(); frustumNearFar.y = vp.getCamera().getFrustumFar(); //ssao Pass material = new Material(manager, "Common/MatDefs/VR/CartoonSSAO.j3md"); material.setTexture("Normals", normalPass.getRenderedTexture()); material.setVector3("FrustumCorner", frustumCorner); material.setVector2("FrustumNearFar", frustumNearFar); material.setFloat("Distance", applyDistance); if( useOutline == false ) material.setBoolean("disableOutline", true); if( instancedRendering ) material.setBoolean("useInstancing", true); }
Example #30
Source File: TestEverything.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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); }