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


Java Geometry類代碼示例

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


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

示例1: handleRemovedObject

import com.jme3.scene.Geometry; //導入依賴的package包/類
@Override
@FXThread
protected void handleRemovedObject(@NotNull final Spatial model) {
    super.handleRemovedObject(model);

    final ModelEditor3DState editor3DState = getEditor3DState();
    final Array<Geometry> geometries = ArrayFactory.newArray(Geometry.class);

    NodeUtils.addGeometry(model, geometries);

    if (!geometries.isEmpty()) {
        geometries.forEach(geometry -> {
            if (geometry.getQueueBucket() == RenderQueue.Bucket.Sky) {
                editor3DState.removeCustomSky(geometry);
            }
        });
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:19,代碼來源:ModelFileEditor.java

示例2: removeSpatial

import com.jme3.scene.Geometry; //導入依賴的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: generateNames

import com.jme3.scene.Geometry; //導入依賴的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

示例4: addObject

import com.jme3.scene.Geometry; //導入依賴的package包/類
@Override
protected Spatial addObject(Entity e) {
    Mesh mesh = factory.getMesh(e.get(componentType));
    if(mesh == null){
        LOGGER.info("Factory doesn't provide mesh for "+componentType+" "+e.getId());
        return new Node("Empty mesh ("+componentType+") "+e.getId());
    }
    Geometry geom = new Geometry(componentType.getName()+" "+ e.getId(), mesh);
    RigidBody body = e.get(RigidBody.class);
    if(body.isKinematic()){
        geom.setMaterial(createMaterial(ColorRGBA.Green));
    }else {
        if(body.getMass() == 0) {
            geom.setMaterial(createMaterial(ColorRGBA.Cyan.mult(ColorRGBA.DarkGray)));
        }else {
            geom.setMaterial(createMaterial(ColorRGBA.Red));
        }
    }
    rootNode.attachChild(geom);
    return geom;
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:22,代碼來源:ESDebugViewState.java

示例5: updateObject

import com.jme3.scene.Geometry; //導入依賴的package包/類
@Override
protected void updateObject(Spatial geom, Entity e) {
    if(geom instanceof Node){
        LOGGER.info("Can't update mesh for "+e.getId()+" recreate it!");
        return;
    }
    Mesh mesh = factory.getMesh(e.get(componentType));
    ((Geometry)geom).setMesh(mesh);
    geom.updateModelBound();
    RigidBody body = e.get(RigidBody.class);
    if(body.isKinematic()){
        geom.setMaterial(createMaterial(ColorRGBA.Green));
    }else {
        if(body.getMass() == 0) {
            geom.setMaterial(createMaterial(ColorRGBA.Cyan.mult(ColorRGBA.DarkGray)));
        }else {
            geom.setMaterial(createMaterial(ColorRGBA.Red));
        }
    }
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:21,代碼來源:ESDebugViewState.java

示例6: findGeometry

import com.jme3.scene.Geometry; //導入依賴的package包/類
/**
 * Find a first geometry in the {@link Spatial}.
 *
 * @param spatial the spatial
 * @param name    the name
 * @return the geometry
 */
public static @Nullable Geometry findGeometry(@NotNull final Spatial spatial, @NotNull final String name) {
    if (!(spatial instanceof Node)) return null;

    final Node node = (Node) spatial;

    for (final Spatial children : node.getChildren()) {
        final Geometry geometry = findGeometry(children, name);
        if (geometry != null) return geometry;
        if (children instanceof Geometry && StringUtils.equals(children.getName(), name)) {
            return (Geometry) children;
        }
    }

    return null;
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:23,代碼來源:NodeUtils.java

示例7: render

import com.jme3.scene.Geometry; //導入依賴的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

示例8: setSpatial

import com.jme3.scene.Geometry; //導入依賴的package包/類
@Override
public void setSpatial(Spatial spatial) {
    if (!(spatial instanceof Geometry)) {
        throw new IllegalArgumentException("LodControl can only be attached to Geometry!");
    }

    super.setSpatial(spatial);
    Geometry geom = (Geometry) spatial;
    Mesh mesh = geom.getMesh();
    numLevels = mesh.getNumLodLevels();
    
    for (int i = 0; i < numLevels; i++)
    	if (mesh.getLodLevel( i ) == null)
    		numLevels--;
    
    numTris = new int[numLevels];
    for (int i = numLevels - 1; i >= 0; i--) {
        numTris[i] = mesh.getTriangleCount(i);
    }
}
 
開發者ID:twak,項目名稱:chordatlas,代碼行數:21,代碼來源:GISLodControl.java

示例9: getIndex

import com.jme3.scene.Geometry; //導入依賴的package包/類
/**
 * Get the index of the object in the model.
 */
private static boolean getIndex(@NotNull final Object model, @NotNull final Object object,
                                @NotNull final AtomicInteger counter) {
    counter.incrementAndGet();

    if (Objects.equals(model, object)) {
        return true;
    } else if (model instanceof Geometry) {
        return getIndex(((Geometry) model).getMesh(), object, counter);
    } else if (!(model instanceof Node)) {
        return false;
    }

    final Node node = (Node) model;
    final List<Spatial> children = node.getChildren();

    for (final Spatial child : children) {
        if (getIndex(child, object, counter)) {
            return true;
        }
    }

    return false;
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:27,代碼來源:GeomUtils.java

示例10: BaseMaterialEditor3DState

import com.jme3.scene.Geometry; //導入依賴的package包/類
public BaseMaterialEditor3DState(@NotNull final T fileEditor) {
    super(fileEditor);
    this.testBox = new Geometry("Box", new Box(2, 2, 2));
    this.testSphere = new Geometry("Sphere", new Sphere(30, 30, 2));
    this.testQuad = new Geometry("Quad", new Quad(4, 4));
    this.testQuad.setLocalTranslation(QUAD_OFFSET);
    this.lightEnabled = MaterialFileEditor.DEFAULT_LIGHT_ENABLED;

    TangentGenerator.useMikktspaceGenerator(testBox);
    TangentGenerator.useMikktspaceGenerator(testSphere);
    TangentGenerator.useMikktspaceGenerator(testQuad);

    final DirectionalLight light = notNull(getLightForCamera());
    light.setDirection(LIGHT_DIRECTION);

    final EditorCamera editorCamera = notNull(getEditorCamera());
    editorCamera.setDefaultHorizontalRotation(H_ROTATION);
    editorCamera.setDefaultVerticalRotation(V_ROTATION);

    getModelNode().attachChild(getNodeForCamera());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:22,代碼來源:BaseMaterialEditor3DState.java

示例11: addGeometry

import com.jme3.scene.Geometry; //導入依賴的package包/類
/**
 * Collect all geometries.
 *
 * @param spatial   the spatial
 * @param container the container
 */
public static void addGeometry(@NotNull final Spatial spatial, @NotNull final Array<Geometry> container) {

    if (spatial instanceof Geometry) {
        container.add((Geometry) spatial);
        return;
    } else if (!(spatial instanceof Node)) {
        return;
    }

    final Node node = (Node) spatial;

    for (final Spatial children : node.getChildren()) {
        addGeometry(children, container);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:22,代碼來源:NodeUtils.java

示例12: updateMaterialImpl

import com.jme3.scene.Geometry; //導入依賴的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

示例13: updateModel

import com.jme3.scene.Geometry; //導入依賴的package包/類
/**
 * Update position and rotation of a model.
 */
@JMEThread
public void updateModel() {

    final ScenePresentable object = getObject();
    final Geometry model = getModel();
    if (model == null || object == null) return;

    // TODO implement getting parent
    /*final Node parent = object.getParent();

    if (parent != null) {
        setLocalTranslation(parent.getWorldTranslation());
        setLocalRotation(parent.getWorldRotation());
        setLocalScale(parent.getWorldScale());
    }*/

    final Node editedNode = getEditedNode();
    model.setLocalTranslation(editedNode.getWorldTranslation());
    model.setLocalRotation(editedNode.getWorldRotation());
    model.setLocalScale(editedNode.getWorldScale());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:25,代碼來源:EditorPresentableNode.java

示例14: updateItem

import com.jme3.scene.Geometry; //導入依賴的package包/類
@Override
protected void updateItem(@Nullable final Integer level, final boolean empty) {
    super.updateItem(level, empty);

    final Geometry geometry = getEditObject();
    final Mesh mesh = geometry.getMesh();

    if (level == null || mesh == null) {
        setText("None");
        return;
    }

    int elements;

    if (level < mesh.getNumLodLevels()) {
        final VertexBuffer lodLevel = mesh.getLodLevel(level);
        elements = lodLevel.getNumElements();
    } else {
        elements = mesh.getTriangleCount();
    }

    setText(Messages.MODEL_PROPERTY_LEVEL + ": " + level + " (" + elements + " " +
            Messages.MODEL_PROPERTY_TRIANGLE_COUNT + ")");
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:25,代碼來源:LodLevelPropertyControl.java

示例15: reload

import com.jme3.scene.Geometry; //導入依賴的package包/類
@Override
@FXThread
protected void reload() {
    if (!hasEditObject()) return;

    final Geometry geometry = getEditObject();
    final Mesh mesh = geometry.getMesh();
    if (mesh == null) return;

    final Integer element = getPropertyValue();
    final ComboBox<Integer> levelComboBox = getLevelComboBox();
    final ObservableList<Integer> items = levelComboBox.getItems();
    items.clear();

    final int numLodLevels = mesh.getNumLodLevels();

    for (int i = 0; i < numLodLevels; i++) {
        items.add(i);
    }

    if (items.isEmpty()) {
        items.add(0);
    }

    levelComboBox.getSelectionModel().select(element);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:27,代碼來源:LodLevelPropertyControl.java


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