當前位置: 首頁>>代碼示例>>Java>>正文


Java Material類代碼示例

本文整理匯總了Java中com.jme3.material.Material的典型用法代碼示例。如果您正苦於以下問題:Java Material類的具體用法?Java Material怎麽用?Java Material使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Material類屬於com.jme3.material包,在下文中一共展示了Material類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toMaterial

import com.jme3.material.Material; //導入依賴的package包/類
@Override
public MaterialMap toMaterial(AssetManager am, Substance substance, String substance_assets_path) {
	Material mat=new Material(am,"Common/MatDefs/Light/PBRLighting.j3md");
	mat.setName(substance.get("name").toString());
	Map<Object,Object> textures=(Map<Object,Object>)substance.get("textures");
	if(textures!=null){
		for(Entry e:textures.entrySet()){
			String tx=e.getKey().toString();
			if(!e.getValue().toString().isEmpty()){
				tx=tx.substring(tx.lastIndexOf("_")+1);
				String p=substance_assets_path+e.getValue();
				LOGGER.log(Level.FINE,"Set "+tx+"="+p);
				mat.setTexture(tx,am.loadTexture(p));
			}
		}
	}
	MaterialMap map=new MaterialMap();
	map.material=mat;
	map.render_bucket=Bucket.Opaque;
	return map;
}
 
開發者ID:riccardobl,項目名稱:JMELink-SP,代碼行數:22,代碼來源:PBRSubstance.java

示例2: removeSpatial

import com.jme3.material.Material; //導入依賴的package包/類
public void removeSpatial(Spatial s) {
	s.depthFirstTraversal(new SceneGraphVisitor(){
		@Override
		public void visit(Spatial sx) {
			if(sx instanceof Geometry){
				Geometry geo=(Geometry)sx;
				Material mat=geo.getMaterial();
				String mat_name=mat==null?null:mat.getName();
				if(mat_name==null){
					System.err.println("Invalid material or missing name");
				}else{
					Iterator<Entry> e_i=ENTRIES.iterator();
					while(e_i.hasNext()){
						if(e_i.next().geo==geo){
							e_i.remove();
							break;
						}
					}
				}
			}
		}
	});
}
 
開發者ID:riccardobl,項目名稱:JMELink-SP,代碼行數:24,代碼來源:SubstanceLinkAppState.java

示例3: addObject

import com.jme3.material.Material; //導入依賴的package包/類
@Override
protected Spatial addObject(Entity e) {
    Vector3f loc = e.get(PhysicsPosition.class).getLocation();
    Mesh mesh = MeshFactory.createSphere(0.25f);
    Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    material.setColor("Color", ColorRGBA.Orange);
    TextureKey key = new TextureKey("Interface/grid-shaded.png");
    key.setGenerateMips(true);
    Texture texture = assetManager.loadTexture(key);
    texture.setWrap(Texture.WrapMode.Repeat);
    material.setTexture("ColorMap", texture);
    Geometry geometry = new Geometry("PhysicsPosition: "+e.getId(), mesh);
    geometry.setMaterial(material);
    geometry.setLocalTranslation(loc);
    rootNode.attachChild(geometry);
    return geometry;
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:18,代碼來源:ESDebugViewState.java

示例4: reload

import com.jme3.material.Material; //導入依賴的package包/類
/**
 * Reload the material.
 */
@FXThread
private void reload(@NotNull final Material material) {
    setCurrentMaterial(material);
    setIgnoreListeners(true);
    try {

        final MaterialEditor3DState editor3DState = getEditor3DState();
        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);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:27,代碼來源:MaterialFileEditor.java

示例5: render

import com.jme3.material.Material; //導入依賴的package包/類
public void render( List<Prof> ofs, Tweed tweed, ColorRGBA col, Node n ) {

//		Random randy = new Random(ofs.hashCode());
		
		Material mat = new Material( tweed.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md" );
		
//		ColorRGBA col = new ColorRGBA(
//				randy.nextFloat(), 
//				0.2f+ 0.5f * randy.nextFloat(), 
//				0.5f+ 0.5f * randy.nextFloat(), 1);
		
		mat.setColor( "Diffuse", col );
		mat.setColor( "Ambient", col.mult( 0.1f ) );
		mat.setBoolean( "UseMaterialColors", true );
		
		for (Prof p : ofs) {
			Geometry g = new Geometry();
			g.setMesh( p.renderStrip(  TweedSettings.settings.profileHSampleDist/2, null ) );
			g.setMaterial( mat );
			n.attachChild( g );
		}
	}
 
開發者ID:twak,項目名稱:chordatlas,代碼行數:23,代碼來源:ProfileGen.java

示例6: generateNames

import com.jme3.material.Material; //導入依賴的package包/類
/**
 * Generate names for materials.
 */
private void generateNames(@NotNull final ObjectDictionary<String, Geometry> mapping,
                           @NotNull final Geometry geometry) {

    final Material material = geometry.getMaterial();
    final String originalName = material.getName();
    final String name = StringUtils.isEmpty(geometry.getName()) ? "geom" : geometry.getName();

    String resultName = StringUtils.isEmpty(originalName) ? "embedded-mat-" + name : originalName;

    if (!mapping.containsKey(resultName)) {
        mapping.put(resultName, geometry);
    } else {
        for (int i = 1; mapping.containsKey(resultName); i++) {
            resultName = (StringUtils.isEmpty(originalName) ? "embedded-mat-" : originalName) + name + "_" + i;
        }
        mapping.put(resultName, geometry);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:22,代碼來源:AbstractModelFileConverter.java

示例7: updateMaterialImpl

import com.jme3.material.Material; //導入依賴的package包/類
/**
 * Update the {@link Material} in the {@link EditorThread}.
 *
 * @param material the new material.
 */
@JMEThread
protected void updateMaterialImpl(@NotNull final Material material) {

    final Geometry testBox = getTestBox();
    testBox.setMaterial(material);

    final Geometry testQuad = getTestQuad();
    testQuad.setMaterial(material);

    final Geometry testSphere = getTestSphere();
    testSphere.setMaterial(material);

    final RenderManager renderManager = EDITOR.getRenderManager();
    try {
        renderManager.preloadScene(testBox);
    } catch (final RendererException | AssetNotFoundException | UnsupportedOperationException e) {
        handleMaterialException(e);
        testBox.setMaterial(EDITOR.getDefaultMaterial());
        testQuad.setMaterial(EDITOR.getDefaultMaterial());
        testSphere.setMaterial(EDITOR.getDefaultMaterial());
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:28,代碼來源:BaseMaterialEditor3DState.java

示例8: createCollisionPlane

import com.jme3.material.Material; //導入依賴的package包/類
/**
 * Create collision plane.
 */
@FromAnyThread
private void createCollisionPlane() {

    final AssetManager assetManager = EDITOR.getAssetManager();

    final Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    final RenderState renderState = material.getAdditionalRenderState();
    renderState.setFaceCullMode(RenderState.FaceCullMode.Off);
    renderState.setWireframe(true);

    final float size = 20000;

    final Geometry geometry = new Geometry("plane", new Quad(size, size));
    geometry.setMaterial(material);
    geometry.setLocalTranslation(-size / 2, -size / 2, 0);

    collisionPlane = new Node();
    collisionPlane.attachChild(geometry);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:23,代碼來源:AbstractSceneEditor3DState.java

示例9: createGeometry

import com.jme3.material.Material; //導入依賴的package包/類
protected @NotNull Geometry createGeometry(@NotNull final ScenePresentable.PresentationType presentationType) {

        final Material material = new Material(EDITOR.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;
    }
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:22,代碼來源:AbstractSceneEditor3DState.java

示例10: processOpen

import com.jme3.material.Material; //導入依賴的package包/類
@Override
@FXThread
protected void processOpen(@NotNull final ResourceElement element) {
    super.processOpen(element);

    final ComboBox<String> textureParamNameBox = getTextureParamNameComboBox();
    final SingleSelectionModel<String> selectionModel = textureParamNameBox.getSelectionModel();
    final String textureParamName = selectionModel.getSelectedItem();

    final CheckBox transformBox = getApplyLightingTransformCheckBox();

    final AssetManager assetManager = EDITOR.getAssetManager();

    final Path file = element.getFile();
    final Path assetFile = getAssetFile(file);

    if (assetFile == null) {
        throw new RuntimeException("AssetFile can't be null.");
    }

    final Material material = assetManager.loadAsset(new MaterialKey(toAssetPath(assetFile)));

    final Consumer<ParticlesMaterial> consumer = getConsumer();
    consumer.accept(new ParticlesMaterial(material, textureParamName, transformBox.isSelected()));
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:26,代碼來源:ParticlesAssetEditorDialog.java

示例11: processEdit

import com.jme3.material.Material; //導入依賴的package包/類
@FXThread
@Override
protected void processEdit() {

    final ParticlesMaterial element = getPropertyValue();
    if (element == null) return;

    final Material material = element.getMaterial();
    final AssetKey<?> key = material.getKey();
    if (key == null) return;

    final Path assetFile = Paths.get(key.getName());
    final Path realFile = getRealFile(assetFile);
    if (realFile == null || !Files.exists(realFile)) return;

    final RequestedOpenFileEvent event = new RequestedOpenFileEvent();
    event.setFile(realFile);

    FX_EVENT_MANAGER.notify(event);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:21,代碼來源:MaterialEmitterPropertyControl.java

示例12: createMaterialFileIfNeed

import com.jme3.material.Material; //導入依賴的package包/類
/**
 * Create a material of the geometry as a file if need.
 *
 * @param geometry the sky geometry.
 */
@BackgroundThread
private @NotNull Material createMaterialFileIfNeed(@NotNull final Geometry geometry) {

    final TextField materialNameField = getMaterialNameField();
    final ChooseFolderControl materialFolderControl = getMaterialFolderControl();

    final Material material = geometry.getMaterial();
    final String content = MaterialSerializer.serializeToString(material);

    final Path folder = materialFolderControl.getFolder();
    final Path materialFile = folder.resolve(materialNameField.getText() + "." + FileExtensions.JME_MATERIAL);

    try {
        Files.write(materialFile, content.getBytes("UTF-8"), WRITE, TRUNCATE_EXISTING, CREATE);
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }

    final Path assetFile = EditorUtil.getAssetFile(materialFile);
    final String assetPath = EditorUtil.toAssetPath(assetFile);
    final AssetManager assetManager = EDITOR.getAssetManager();

    return assetManager.loadMaterial(assetPath);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:30,代碼來源:CreateSkyDialog.java

示例13: process

import com.jme3.material.Material; //導入依賴的package包/類
@Override
@FXThread
protected void process() {
    super.process();

    final NodeTree<ModelChangeConsumer> nodeTree = getNodeTree();
    final ModelChangeConsumer consumer = notNull(nodeTree.getChangeConsumer());
    final SceneLayer defaultLayer = getDefaultLayer(consumer);

    final AssetManager assetManager = EDITOR.getAssetManager();

    final Geometry geometry = createGeometry();
    geometry.setMaterial(new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"));

    final TreeNode<?> treeNode = getNode();
    final Node parent = (Node) treeNode.getElement();

    if (defaultLayer != null) {
        SceneLayer.setLayer(defaultLayer, geometry);
    }

    consumer.execute(new AddChildOperation(geometry, parent));
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:24,代碼來源:AbstractCreateGeometryAction.java

示例14: processSave

import com.jme3.material.Material; //導入依賴的package包/類
/**
 * The process of saving the file.
 *
 * @param file the file to save
 */
@FXThread
private void processSave(@NotNull final Path file) {

    final TreeNode<?> node = getNode();
    final Material material = (Material) node.getElement();
    final String materialContent = MaterialSerializer.serializeToString(material);

    try (final PrintWriter out = new PrintWriter(Files.newOutputStream(file, WRITE, TRUNCATE_EXISTING, CREATE))) {
        out.print(materialContent);
    } catch (final IOException e) {
        EditorUtil.handleException(LOGGER, this, e);
        return;
    }

    final Path assetFile = notNull(getAssetFile(file));
    final AssetManager assetManager = EDITOR.getAssetManager();
    final Material savedMaterial = assetManager.loadMaterial(notNull(toAssetPath(assetFile)));

    final PropertyOperation<ChangeConsumer, Material, AssetKey> operation =
            new PropertyOperation<>(material, "AssetKey", savedMaterial.getKey(), null);
    operation.setApplyHandler(Material::setKey);

    final ChangeConsumer changeConsumer = notNull(getNodeTree().getChangeConsumer());
    changeConsumer.execute(operation);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:31,代碼來源:SaveAsMaterialAction.java

示例15: fillContextMenu

import com.jme3.material.Material; //導入依賴的package包/類
@Override
@FXThread
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree, @NotNull final ObservableList<MenuItem> items) {
    super.fillContextMenu(nodeTree, items);

    final Material material = getElement();
    final TreeNode<?> parent = notNull(getParent());
    final Object parentElement = parent.getElement();
    final Object linkNode = parentElement instanceof Spatial ?
            NodeUtils.findParent((Spatial) parentElement, AssetLinkNode.class::isInstance) : null;

    if (linkNode == null) {
        items.add(new SaveAsMaterialAction(nodeTree, this));
    }

    if (material.getKey() != null) {
        items.add(new MakeAsEmbeddedMaterialAction(nodeTree, this));
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:20,代碼來源:MaterialTreeNode.java


注:本文中的com.jme3.material.Material類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。