当前位置: 首页>>代码示例>>Java>>正文


Java Geometry.getMesh方法代码示例

本文整理汇总了Java中com.jme3.scene.Geometry.getMesh方法的典型用法代码示例。如果您正苦于以下问题:Java Geometry.getMesh方法的具体用法?Java Geometry.getMesh怎么用?Java Geometry.getMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jme3.scene.Geometry的用法示例。


在下文中一共展示了Geometry.getMesh方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: processOk

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
@Override
@FXThread
protected void processOk() {

    final NodeTree<?> nodeTree = getNodeTree();

    final TreeNode<?> node = getNode();
    final Geometry geometry = (Geometry) node.getElement();
    final Mesh newMesh = geometry.getMesh();
    final Mesh oldMesh = newMesh.deepClone();

    final ComboBox<AlgorithmType> algorithmTypeComboBox = getAlgorithmTypeComboBox();
    final AlgorithmType algorithmType = algorithmTypeComboBox.getSelectionModel().getSelectedItem();

    if (algorithmType == AlgorithmType.STANDARD) {
        final CheckBox splitMirroredCheckBox = getSplitMirroredCheckBox();
        TangentGenerator.useStandardGenerator(geometry, splitMirroredCheckBox.isSelected());
    } else {
        TangentGenerator.useMikktspaceGenerator(geometry);
    }

    final ChangeConsumer changeConsumer = notNull(nodeTree.getChangeConsumer());
    changeConsumer.execute(new ChangeMeshOperation(newMesh, oldMesh, geometry));

    super.processOk();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:27,代码来源:GenerateTangentsDialog.java

示例5: getChildren

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
@Override
public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) {
    if (!(nodeTree instanceof ModelNodeTree)) return TreeNode.EMPTY_ARRAY;

    final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class);

    final Geometry geometry = getElement();
    final Mesh mesh = geometry.getMesh();
    final Material material = geometry.getMaterial();

    if (mesh != null) result.add(FACTORY_REGISTRY.createFor(mesh));

    result.add(FACTORY_REGISTRY.createFor(material));
    result.addAll(super.getChildren(nodeTree));

    return result;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:18,代码来源:GeometryTreeNode.java

示例6: processOpen

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
/**
 * The process of opening file.
 *
 * @param file the file
 */
protected void processOpen(@NotNull final Path file) {

    final NodeTree<ModelChangeConsumer> nodeTree = getNodeTree();
    final ModelChangeConsumer changeConsumer = notNull(nodeTree.getChangeConsumer());

    final Path assetFile = notNull(getAssetFile(file), "Not found asset file for " + file);
    final String assetPath = EditorUtil.toAssetPath(assetFile);

    final ModelKey modelKey = new ModelKey(assetPath);

    final AssetManager assetManager = EDITOR.getAssetManager();
    final Spatial loadedModel = assetManager.loadModel(modelKey);
    final Geometry geometry = NodeUtils.findGeometry(loadedModel);

    if (geometry == null) {
        LOGGER.warning(this, "not found a geometry in the model " + assetPath);
        return;
    }

    final TreeNode<?> treeNode = getNode();
    final ParticleEmitterNode emitterNode = (ParticleEmitterNode) treeNode.getElement();
    final ParticleGeometry particleGeometry = emitterNode.getParticleGeometry();
    final ParticleDataMeshInfo meshInfo = new ParticleDataMeshInfo(ParticleDataTemplateMesh.class, geometry.getMesh());

    changeConsumer.execute(new ChangeParticleMeshOperation(meshInfo, particleGeometry));
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:32,代码来源:LoadModelParticlesMeshAction.java

示例7: controlUpdate

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
@Override
protected void controlUpdate(final float tpf) {
    super.controlUpdate(tpf);

    final Geometry baseMarker = getBaseMarker();
    final Geometry targetMarker = getTargetMarker();
    final Geometry line = getLine();

    final Vector3f firstPoint = baseMarker.getLocalTranslation();
    final Vector3f secondPoint = targetMarker.getLocalTranslation();

    final Line mesh = (Line) line.getMesh();
    mesh.updatePoints(firstPoint, secondPoint);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:15,代码来源:SlopeTerrainToolControl.java

示例8: isContains

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
/**
 * Check that a point is contains in a geometry.
 *
 * @param geometry the geometry.
 * @param x        the X coord.
 * @param y        the Y coord.
 * @return true of the mesh contains the point.
 */
public static boolean isContains(@NotNull final Geometry geometry, final float x, final float y) {

    final Mesh mesh = geometry.getMesh();
    final Vector3f localScale = geometry.getLocalScale();

    if (mesh instanceof Sphere) {
        final float radius = ((Sphere) mesh).getRadius() * localScale.getX();
        final Vector2f point = new Vector2f(x, y);
        // return true if the distance is less than equal to the radius
        return Math.abs(point.length()) <= radius;
    }

    return false;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:23,代码来源:EditingUtils.java

示例9: getColor

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
public static ColorRGBA getColor( Geometry geom, Vector3f pt, int index, Tweed tweed ) {
		
		MatParam param = geom.getMaterial().getParam( "DiffuseMap" );
		
		ImageRaster ir = ImageRaster.create( tweed.getAssetManager().loadTexture( ((Texture2D)param.getValue()).getName() ).getImage() );
    	
		Mesh mesh = geom.getMesh();
//		geom.getMaterial().getMaterialDef().
		
        VertexBuffer pb = mesh.getBuffer(Type.Position);
        VertexBuffer tb = mesh.getBuffer( Type.TexCoord );
        
        IndexBuffer  ib = mesh.getIndicesAsList();
        
        Vector2f uva = new Vector2f(), uvb = new Vector2f(), uvc = new Vector2f();
        Vector3f la  = new Vector3f(), lb  = new Vector3f(), lc  = new Vector3f();
        
        if (pb != null && pb.getFormat() == Format.Float && pb.getNumComponents() == 3) {
        	
            FloatBuffer fpb = (FloatBuffer) pb.getData();
            FloatBuffer ftb = (FloatBuffer) tb.getData();

            // aquire triangle's vertex indices
            int vertIndex = index * 3;
            
            int va = ib.get(vertIndex);
            int vb = ib.get(vertIndex+1);
            int vc = ib.get(vertIndex+2);
            
            BufferUtils.populateFromBuffer( la, fpb, va );
            BufferUtils.populateFromBuffer( lb, fpb, vb );
            BufferUtils.populateFromBuffer( lc, fpb, vc );
            
            BufferUtils.populateFromBuffer( uva, ftb, va );
            BufferUtils.populateFromBuffer( uvb, ftb, vb );
            BufferUtils.populateFromBuffer( uvc, ftb, vc );
            
//            PaintThing.debug.put(1, new Line ( la.x, la.z, lb.x, lb.z) );
//            PaintThing.debug.put(2, new Line ( lb.x, lb.z, lc.x, lc.z) );
//            PaintThing.debug.put(3, new Line ( lc.x, lc.z, la.x, la.z) );
            
            float[] bary = barycentric( pt, la, lb, lc );
            
            int x = (int)( ( uva.x * bary[0] + uvb.x * bary[1] + uvc.x * bary[2] ) * ir.getWidth ()) ,
            	y = (int)( ( uva.y * bary[0] + uvb.y * bary[1] + uvc.y * bary[2] ) * ir.getHeight()) ;
            
            ColorRGBA out = ir.getPixel( x, y );//ir.getHeight() - y -1 );

//            for (Pair<Vector3f, Vector2f> pair : new Pair[]{ new Pair( la, uva), new Pair (lb, uvb), new Pair (lc, uvc)}) {
//            	
//            	int xx = (int)(pair.second().x * ir.getWidth () ),
//            	    yy = (int)(pair.second().y * ir.getHeight() );
//            	
//            	System.out.println("xx "+xx+" yy "+ yy );
//            	
//            	ColorRGBA o = ir.getPixel( 
//            			xx,
//            			yy );
//            	
//            	PaintThing.debug.put(1, new ColPt( pair.first().x, pair.first().z, o.r, o.g, o.b ));
//            }
            
//            System.out.println("<< "+ ((Texture2D)param.getValue()).getName());
//			System.out.println( x + " " + y + " :: " + bary[ 0 ] + " " + bary[ 1 ] + " " + bary[ 2 ] + 
//					" --> " + out.r + "," + out.g + "," + out.b );
            
            return out;
            
        }else{
        	
            throw new UnsupportedOperationException("Position buffer not set or has incompatible format");
        }
    }
 
开发者ID:twak,项目名称:chordatlas,代码行数:74,代码来源:SkelFootprint.java

示例10: controlUpdate

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
@Override
protected void controlUpdate(final float tpf) {
    checkAndUpdateVehicle();

    for (int i = 0; i < body.getNumWheels(); i++) {

        final VehicleWheel physicsVehicleWheel = body.getWheel(i);

        final Vector3f location = new Vector3f(physicsVehicleWheel.getLocation());
        final Vector3f direction = new Vector3f(physicsVehicleWheel.getDirection());
        direction.normalizeLocal();

        final Vector3f axle = new Vector3f(physicsVehicleWheel.getAxle());
        axle.normalizeLocal();
        axle.multLocal(0.3f);

        final float restLength = physicsVehicleWheel.getRestLength();
        final float radius = physicsVehicleWheel.getRadius();

        final Geometry locGeom = (Geometry) suspensionNode.getChild("WheelLocationDebugShape" + i);
        final Geometry dirGeom = (Geometry) suspensionNode.getChild("WheelDirectionDebugShape" + i);
        final Geometry axleGeom = (Geometry) suspensionNode.getChild("WheelAxleDebugShape" + i);
        final Geometry wheelGeom = (Geometry) suspensionNode.getChild("WheelRadiusDebugShape" + i);

        final Arrow locArrow = (Arrow) locGeom.getMesh();
        locArrow.setArrowExtent(location);

        final Arrow axleArrow = (Arrow) axleGeom.getMesh();
        axleArrow.setArrowExtent(axle);

        final Arrow wheelArrow = (Arrow) wheelGeom.getMesh();
        wheelArrow.setArrowExtent(direction.multLocal(radius));

        final Arrow dirArrow = (Arrow) dirGeom.getMesh();
        dirArrow.setArrowExtent(direction.multLocal(restLength));

        dirGeom.setLocalTranslation(location);
        axleGeom.setLocalTranslation(location.addLocal(direction));
        wheelGeom.setLocalTranslation(location);
    }

    final Vector3f physicsLocation = body.getPhysicsLocation(physicalLocation);
    final Quaternion physicsRotation = body.getPhysicsRotation(physicalRotation);

    applyPhysicsTransform(physicsLocation, physicsRotation);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder-extension,代码行数:47,代码来源:BulletVehicleDebugControl.java

示例11: GenerateLodLevelsDialog

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
public GenerateLodLevelsDialog(@NotNull final NodeTree<?> nodeTree, final @NotNull Geometry geometry) {
    this.nodeTree = nodeTree;
    this.geometry = geometry;
    this.mesh = geometry.getMesh();
    updateButtonOk();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:7,代码来源:GenerateLodLevelsDialog.java


注:本文中的com.jme3.scene.Geometry.getMesh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。