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


Java Geometry.setMaterial方法代码示例

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


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

示例1: addObject

import com.jme3.scene.Geometry; //导入方法依赖的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

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

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

示例4: process

import com.jme3.scene.Geometry; //导入方法依赖的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

示例5: addObject

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
@Override
protected Geometry addObject(Entity e) {
    Geometry geom = new Geometry("ID: "+e.getId(), getMesh(e));
    //geom.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
    Material dummy = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    dummy.setColor("Color", ColorRGBA.White);
    geom.setMaterial(dummy);
    root.attachChild(geom);
    return geom;
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:11,代码来源:ShapeContainer.java

示例6: addObject

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
@Override
protected Spatial addObject(Entity e) {
    PhysicsPosition pos = e.get(PhysicsPosition.class);
    Vector3f size = e.get(BoxComponent.class).getSize();
    Geometry reBoxg = new Geometry("brick", new Box(size.x, size.y, size.z));
    reBoxg.setMaterial(e.get(MaterialComponent.class).getMat());
    reBoxg.setLocalTranslation(pos.getLocation());
    reBoxg.setLocalRotation(pos.getRotation());
    reBoxg.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
    TestBrickWall.this.rootNode.attachChild(reBoxg);
    return reBoxg;
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:13,代码来源:TestBrickWall.java

示例7: calculate

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

	for (Spatial s : gNode.getChildren())
		s.removeFromParent();
	
	Mesh mesh = new Mesh();
	mesh.setMode( Mode.Points );
	
	Vector3f[] verts = new Vector3f[cubes.size()];
	
	for (int i = 0; i < cubes.size(); i++) {
		verts[ i ] = new com.jme3.math.Vector3f( (float)cubes.get( i ).x, (float)cubes.get( i ).y, (float)cubes.get( i ).z );
	}
	
	mesh.setBuffer( VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer( verts ) );
	
	Material mat1 = new Material( tweed.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md" );
	mat1.setBoolean( "VertexColor", true );
	Geometry depth = new Geometry( "depth", mesh );
	depth.setMaterial( mat1 );
	
	depth.updateModelBound();
	depth.updateGeometricState();
	
	gNode.attachChild(depth);
	
	super.calculate();
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:30,代码来源:DebugGen.java

示例8: createPlayer

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
/**
 * Create a new player.
 * @param parentNode Parent of player. Should be root node.
 * @param playerIdx Order of created player starting at 0.
 * @return Spatial of new player.
 */
private Spatial createPlayer(Node parentNode, int playerIdx) {
  // Currently a simple box is used for the player.
  Box box = new Box(1, 1, 1);
  Geometry player = new Geometry("PLAYER" + playerIdx, box);

  Material mat = new Material(application.getAssetManager(),
      "Common/MatDefs/Misc/Unshaded.j3md");
  mat.setColor("Color", ColorRGBA.Blue);
  player.setMaterial(mat);

  // Move player in front of first course point.
  Spatial[] coursePoints = coursePath.getCoursePoints();
  if (coursePoints.length > 0) {
    Spatial startPoint = coursePoints[0];
    Vector3f forward = startPoint.getWorldRotation().mult(Vector3f.UNIT_Z);
    player.move(forward.mult(PLAYER_START_DISTANCE));
  }

  // Attribute that this is a player.
  player.setUserData(IS_PLAYER_ATTR, true);
  // Add physics to player
  CollisionShape shape = CollisionShapeFactory.createBoxShape(player);
  GhostControl playerPhysics = new GhostControl(shape);
  player.addControl(playerPhysics);
  bullet.getPhysicsSpace().add(playerPhysics);

  // Attach to root node and course path.
  parentNode.attachChild(player);
  coursePath.addPlayer(player);
  return player;
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:38,代码来源:PlayerManager.java

示例9: storeMaterials

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
/**
 * Store embedded materials.
 *
 * @param materialsFolder the materials destination folder.
 * @param canOverwrite    can we overwrite exists materials.
 * @param materialName    the material name.
 * @param geometry        the geometry.
 */
private void storeMaterials(@NotNull final Path materialsFolder, final boolean canOverwrite,
                            @NotNull final String materialName, @NotNull final Geometry geometry) {

    final Path resultFile = materialsFolder.resolve(normalizeName(materialName) + "." + FileExtensions.JME_MATERIAL);
    final Path assetFile = getAssetFile(resultFile);

    if (assetFile == null) {
        LOGGER.warning("Can't get asset file for the file " + resultFile);
        return;
    }

    final Material currentMaterial = geometry.getMaterial();

    if (!Files.exists(resultFile) || canOverwrite) {
        try (PrintWriter pout = new PrintWriter(Files.newOutputStream(resultFile, WRITE, TRUNCATE_EXISTING, CREATE))) {
            pout.println(MaterialSerializer.serializeToString(currentMaterial));
        } catch (final IOException e) {
            EditorUtil.handleException(LOGGER, this, e);
        }
    }

    final String assetPath = toAssetPath(assetFile);

    final AssetManager assetManager = EDITOR.getAssetManager();
    geometry.setMaterial(assetManager.loadMaterial(assetPath));
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:35,代码来源:AbstractModelFileConverter.java

示例10: ScaleHandle

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
public ScaleHandle(Tweed tweed, Spatial target) {
		super (tweed);
		
		this.target = target;
		
		
//		dir = rot.getRotationColumn(0);

		Box handleOne = new Box( 0.5f, 0.5f, 0.5f );
		g1 = new Geometry("h1", handleOne);
		g1.setUserData(Tweed.CLICK, this);
		Material mat1 = new Material(tweed.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
		mat1.setColor("Color", ColorRGBA.Magenta);
		g1.setMaterial(mat1);
		
		updateScale();
		
		attachChild(g1);

	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:21,代码来源:ScaleHandle.java

示例11: RotHandle

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
public RotHandle(Tweed tweed, Spatial target) {
	super (tweed);
	this.target = target;
	this.dir = new Vector3f(0,1,0);
	
	
	
	Torus handleOne = new Torus(24, 8, 0.2f, 4f); //Box( 0.1f, 0.1f, 0.1f );
	g1 = new Geometry("h1", handleOne);
	g1.setUserData(Tweed.CLICK, this);
	Material mat1 = new Material(tweed.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
	mat1.setColor( "Color", ColorRGBA.Yellow );
	g1.setMaterial(mat1);
	
	updateScale();
	
	attachChild(g1);

}
 
开发者ID:twak,项目名称:chordatlas,代码行数:20,代码来源:RotHandle.java

示例12: render

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
public Spatial render( Tweed tweed ) {

			
			if (a == null  || b == null)
				return null;
			
			Mesh mesh1 = new Mesh();
			{
				Vector3f[] vertices = new Vector3f[4];
				vertices[ 0 ] = new Vector3f( a.x, heightMin, a.z );
				vertices[ 1 ] = new Vector3f( a.x, heightMax, a.z );
				vertices[ 2 ] = new Vector3f( b.x, heightMin, b.z );
				vertices[ 3 ] = new Vector3f( b.x, heightMax, b.z );

				Vector3f[] texCoord = new Vector3f[4];
				texCoord[ 0 ] = new Vector3f( 0, 0, 0 );
				texCoord[ 1 ] = new Vector3f( 1, 0, 0 );
				texCoord[ 2 ] = new Vector3f( 0, 1, 0 );
				texCoord[ 3 ] = new Vector3f( 1, 1, 0 );

				int[] indexes = { 0, 1, 3, 3, 2, 0, 3, 1, 0, 0, 2, 3 };

				mesh1.setBuffer( VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer( vertices ) );

				mesh1.setBuffer( VertexBuffer.Type.TexCoord, 3, BufferUtils.createFloatBuffer( texCoord ) );
				mesh1.setBuffer( VertexBuffer.Type.Index, 3, BufferUtils.createIntBuffer( indexes ) );
				mesh1.updateBound();
			}
			Material mat = new Material( tweed.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md" );
			mat.getAdditionalRenderState().setBlendMode( BlendMode.Alpha );
			mat.setColor( "Color", new ColorRGBA( color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 0.5f ) );

			//		Material mat = new Material(tweed.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");

			Geometry spat = new Geometry( "Box", mesh1 );
			spat.setMaterial( mat );

			

			return spat;
		}
 
开发者ID:twak,项目名称:chordatlas,代码行数:42,代码来源:PlanesGen.java

示例13: checkAndUpdateVehicle

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
private void checkAndUpdateVehicle() {

        final int numWheels = body.getNumWheels();

        suspensionNode.detachAllChildren();

        for (int i = 0; i < numWheels; 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 Arrow locArrow = new Arrow(location);
            final Arrow axleArrow = new Arrow(axle);
            final Arrow wheelArrow = new Arrow(direction.multLocal(radius));
            final Arrow dirArrow = new Arrow(direction.multLocal(restLength));

            final Geometry locGeom = new Geometry("WheelLocationDebugShape" + i, locArrow);
            final Geometry dirGeom = new Geometry("WheelDirectionDebugShape" + i, dirArrow);
            final Geometry axleGeom = new Geometry("WheelAxleDebugShape" + i, axleArrow);
            final Geometry wheelGeom = new Geometry("WheelRadiusDebugShape" + i, wheelArrow);

            dirGeom.setLocalTranslation(location);
            axleGeom.setLocalTranslation(location.add(direction));
            wheelGeom.setLocalTranslation(location.add(direction));

            locGeom.setMaterial(debugAppState.getDebugMagenta());
            dirGeom.setMaterial(debugAppState.getDebugMagenta());
            axleGeom.setMaterial(debugAppState.getDebugMagenta());
            wheelGeom.setMaterial(debugAppState.getDebugMagenta());

            suspensionNode.attachChild(locGeom);
            suspensionNode.attachChild(dirGeom);
            suspensionNode.attachChild(axleGeom);
            suspensionNode.attachChild(wheelGeom);
        }
    }
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder-extension,代码行数:47,代码来源:BulletVehicleDebugControl.java

示例14: render

import com.jme3.scene.Geometry; //导入方法依赖的package包/类
public void render( Tweed tweed, Node gNode, ColorRGBA color, float width ) {

		Mesh m = new Mesh();

		m.setMode( Mesh.Mode.Lines );

		List<Float> coords = new ArrayList();
		List<Integer> inds = new ArrayList();

		for ( Pair<Point3d, Point3d> p : new ConsecutiveItPairs<>( get3D() ) ) {

			inds.add( inds.size() );
			inds.add( inds.size() );

			coords.add( (float) p.first().x );
			coords.add( (float) p.first().y );
			coords.add( (float) p.first().z );
			coords.add( (float) p.second().x );
			coords.add( (float) p.second().y );
			coords.add( (float) p.second().z );
		}

		m.setBuffer( VertexBuffer.Type.Position, 3, Arrayz.toFloatArray( coords ) );
		m.setBuffer( VertexBuffer.Type.Index, 2, Arrayz.toIntArray( inds ) );

		Geometry geom = new Geometry( "profile", m );

		Material lineMaterial = new Material( tweed.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md" );

		lineMaterial.getAdditionalRenderState().setLineWidth( Math.max (1f, width ) );

		lineMaterial.setColor( "Color", color == null ? ColorRGBA.Blue : color );
		geom.setMaterial( lineMaterial );

		geom.updateGeometricState();
		geom.updateModelBound();
		
		gNode.attachChild( geom );
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:40,代码来源:Prof.java


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