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


Java Sphere.setMaterial方法代码示例

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


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

示例1: buildGroup

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
private static Group buildGroup() {
        Sphere s = new Sphere();
        s.setScaleX(SCALE);
        s.setScaleY(SCALE);
        s.setScaleZ(SCALE);
        PhongMaterial material = new PhongMaterial();
        material.setDiffuseColor(Color.LIGHTGRAY);
        material.setSpecularColor(Color.rgb(30, 30, 30));
        s.setMaterial(material);
//        PointLight pl = new PointLight(Color.AQUA);
//        pl.setTranslateZ(-1000);
        Group group = new Group(/*pl,*/ s);
        group.setTranslateX(SS_WIDTH / 2);
        group.setTranslateY(SS_HEIGHT / 2);
        return group;
    }
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:17,代码来源:SubSceneBasicPropsTestApp.java

示例2: Bone

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
public Bone(double scale, Point3D posJoint) {
    Box origin=new Box(10,10,10);
    origin.setMaterial(new PhongMaterial(Color.ORANGE));
    
    Cylinder bone = new Cylinder(5, posJoint.magnitude()/scale);
    double angle = Math.toDegrees(Math.acos((new Point3D(0,1,0)).dotProduct(posJoint)/posJoint.magnitude()));
    Point3D axis = (new Point3D(0,1,0)).crossProduct(posJoint);
    bone.getTransforms().addAll(new Rotate(angle,0,0,0,axis), new Translate(0,posJoint.magnitude()/2d/scale, 0));
    bone.setMaterial(new PhongMaterial(Color.CADETBLUE));
    
    Sphere end = new Sphere(6);
    end.getTransforms().addAll(new Translate(posJoint.getX()/scale,posJoint.getY()/scale,posJoint.getZ()/scale));
    end.setMaterial(new PhongMaterial(Color.YELLOW));
    
    getChildren().addAll(origin, bone, end);
    getTransforms().add(new Scale(scale, scale, scale));
}
 
开发者ID:jperedadnr,项目名称:RiggedHand,代码行数:18,代码来源:Bone.java

示例3: buildGroup

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
private static Group buildGroup() {
        Group grp = new Group();
        Sphere s = new Sphere();
        Box b = new Box();
        s.setScaleX(SCALE);
        s.setScaleY(SCALE);
        s.setScaleZ(SCALE);
        s.setTranslateX(-130);
        b.setScaleX(SCALE);
        b.setScaleY(SCALE);
        b.setScaleZ(SCALE);
        b.setTranslateX(130);
        PhongMaterial material = new PhongMaterial();
        material.setDiffuseColor(Color.LIGHTGRAY);
        material.setSpecularColor(Color.rgb(30, 30, 30));
        s.setMaterial(material);
        b.setMaterial(material);
        PointLight pl = new PointLight(Color.AQUA);
        pl.setTranslateZ(-1000);
        Sphere lightBalance = new Sphere();
//        lightBalance.setScaleX(0.1);
//        lightBalance.setScaleX(0.1);
//        lightBalance.setScaleX(0.1);
        lightBalance.setTranslateZ(1000);
        grp.getChildren().addAll(s, b,pl,lightBalance);
        return grp;
    }
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:28,代码来源:SubSceneDepthTestApp.java

示例4: buildAxes

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
private void buildAxes() {
    double length = 2d * dimModel;
    double width = dimModel / 100d;
    double radius = 2d * dimModel / 100d;
    final PhongMaterial redMaterial = new PhongMaterial();
    redMaterial.setDiffuseColor(Color.DARKRED);
    redMaterial.setSpecularColor(Color.RED);
    final PhongMaterial greenMaterial = new PhongMaterial();
    greenMaterial.setDiffuseColor(Color.DARKGREEN);
    greenMaterial.setSpecularColor(Color.GREEN);
    final PhongMaterial blueMaterial = new PhongMaterial();
    blueMaterial.setDiffuseColor(Color.DARKBLUE);
    blueMaterial.setSpecularColor(Color.BLUE);
    
    Sphere xSphere = new Sphere(radius);
    Sphere ySphere = new Sphere(radius);
    Sphere zSphere = new Sphere(radius);
    xSphere.setMaterial(redMaterial);
    ySphere.setMaterial(greenMaterial);
    zSphere.setMaterial(blueMaterial);
    
    xSphere.setTranslateX(dimModel);
    ySphere.setTranslateY(dimModel);
    zSphere.setTranslateZ(dimModel);
    
    Box xAxis = new Box(length, width, width);
    Box yAxis = new Box(width, length, width);
    Box zAxis = new Box(width, width, length);
    xAxis.setMaterial(redMaterial);
    yAxis.setMaterial(greenMaterial);
    zAxis.setMaterial(blueMaterial);
    
    autoScalingGroup.getChildren().addAll(xAxis, yAxis, zAxis);
    autoScalingGroup.getChildren().addAll(xSphere, ySphere, zSphere);
}
 
开发者ID:gluonhq,项目名称:gluon-samples,代码行数:36,代码来源:ContentModel.java

示例5: addAtom

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
private void addAtom(LeafSubstructure<?> origin, Atom atom) {
    Sphere atomShape = new Sphere(1.0);
    atomShape.setMaterial(getMaterial(origin, atom));
    atomShape.setTranslateX(atom.getPosition().getX());
    atomShape.setTranslateY(atom.getPosition().getY());
    atomShape.setTranslateZ(atom.getPosition().getZ());

    // add tooltip
    Tooltip tooltip = new Tooltip(atom.getElement().getName() + " (" + (atom.getAtomName()) + ":" +
            atom.getAtomIdentifier() + ") of " + origin.getFamily().getThreeLetterCode() + ":" + origin.getIdentifier());
    Tooltip.install(atomShape, tooltip);

    moleculeGroup.getChildren().add(atomShape);
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:15,代码来源:StructureViewer.java

示例6: buildScene

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
private Group buildScene() {
	    Sphere mars = new Sphere(MARS_RADIUS);
	    mars.setTranslateX(VIEWPORT_SIZE / 2d);
	    mars.setTranslateY(VIEWPORT_SIZE / 2d);

	    PhongMaterial material = new PhongMaterial();
	    material.setDiffuseMap(
	      new Image(this.getClass().getResource(DIFFUSE_MAP).toExternalForm(),
	        MAP_WIDTH,
	        MAP_HEIGHT,
	        true,
	        true
	      )
	    );

	    material.setBumpMap(
	      new Image(this.getClass().getResource(NORMAL_MAP).toExternalForm(),
	        MAP_WIDTH,
	        MAP_HEIGHT,
	        true,
	        true
	      )
	    );
/*
	    material.setSpecularMap(
	      new Image(this.getClass().getResource(SPECULAR_MAP).toExternalForm(),
	        MAP_WIDTH,
	        MAP_HEIGHT,
	        true,
	        true
	      )
	    );
*/
	    mars.setMaterial(
	        material
	    );

	    return new Group(mars);
	}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:40,代码来源:MarsViewer.java

示例7: buildScene

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
private Group buildScene() {
  Sphere earth = new Sphere(EARTH_RADIUS);
  earth.setTranslateX(VIEWPORT_SIZE / 2d);
  earth.setTranslateY(VIEWPORT_SIZE / 2d);

  PhongMaterial earthMaterial = new PhongMaterial();
  earthMaterial.setDiffuseMap(
    new Image(
      DIFFUSE_MAP,
      MAP_WIDTH,
      MAP_HEIGHT,
      true,
      true
    )
  );
  earthMaterial.setBumpMap(
    new Image(
      NORMAL_MAP,
      MAP_WIDTH,
      MAP_HEIGHT,
      true,
      true
    )
  );
  earthMaterial.setSpecularMap(
    new Image(
      SPECULAR_MAP,
      MAP_WIDTH,
      MAP_HEIGHT,
      true,
      true
    )
  );

  earth.setMaterial(
      earthMaterial
  );

  return new Group(earth);
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:41,代码来源:EarthViewer.java

示例8: FXVertexView

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
/**
 * The default constructor.
 * 
 * @param model
 *            The model which this view will display
 */
public FXVertexView(Vertex model) {
	this();

	// Set the node's name
	node.setId(model.getProperty(MeshProperty.NAME));

	// Get the model's transformation
	Transformation localTransform = model.getTransformation();

	// Flatten the sphere into a circle
	localTransform.setScale(1, 1, 0.75);

	// Set the node's transformation
	node.getTransforms().setAll(Util.convertTransformation(localTransform));

	// Create a Shape3D for the model
	mesh = new Sphere(1);

	// Set the sphere to the correct wireframe and opacity states
	if (transparent) {
		mesh.setOpacity(0d);
	}
	if (wireframe) {
		mesh.setDrawMode(DrawMode.LINE);
	}

	// Set the sphere to be the constructing material by default
	mesh.setMaterial(constructingMaterial);
	node.getChildren().add(mesh);
}
 
开发者ID:eclipse,项目名称:eavp,代码行数:37,代码来源:FXVertexView.java

示例9: Axis3D

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
public Axis3D() {
	super();
       
       final PhongMaterial redMaterial = new PhongMaterial();
       redMaterial.setDiffuseColor(Color.DARKRED);
       redMaterial.setSpecularColor(Color.RED);
       final PhongMaterial greenMaterial = new PhongMaterial();
       greenMaterial.setDiffuseColor(Color.DARKGREEN);
       greenMaterial.setSpecularColor(Color.GREEN);
       final PhongMaterial blueMaterial = new PhongMaterial();
       blueMaterial.setDiffuseColor(Color.DARKBLUE);
       blueMaterial.setSpecularColor(Color.BLUE);
       final Sphere red = new Sphere(50);
       red.setMaterial(redMaterial);
       final Sphere blue = new Sphere(50);
       blue.setMaterial(blueMaterial);

       
       xAxis = new Box(24.0, 0.05, 0.05);
       yAxis = new Box(0.05, 24.0, 0.05);
       zAxis = new Box(0.05, 0.05, 24.0);
       xAxis.setMaterial(redMaterial);
       yAxis.setMaterial(greenMaterial);
       zAxis.setMaterial(blueMaterial);

       getChildren().addAll(xAxis,yAxis,zAxis);
}
 
开发者ID:sanke69,项目名称:fr.xs.jtk,代码行数:28,代码来源:Axis3D.java

示例10: addSphere

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
public void addSphere(double x, double y, double z, Material material) {
    Sphere sphere = new Sphere(RADIUS);
    sphere.setTranslateX(x * SCALE_FACTOR);
    sphere.setTranslateY(y * SCALE_FACTOR);
    sphere.setTranslateZ(z * SCALE_FACTOR);
    sphere.setMaterial(material);
    getChildren().add(sphere);
}
 
开发者ID:kcoolsae,项目名称:Equi,代码行数:9,代码来源:Node3D.java

示例11: createSphere

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
private Sphere createSphere(Physical ball) {
    Sphere sphere = new Sphere(this.radius);
    
    ViewPoint location = ViewPoint.of(ball.getLocation());
    sphere.setTranslateX(location.x);
    sphere.setTranslateY(location.y);
    sphere.setTranslateZ(location.z);
    
    Material material = new PhongMaterial(this.color);
    sphere.setMaterial(material);
    
    return sphere;
}
 
开发者ID:opengl-8080,项目名称:classical-physics,代码行数:14,代码来源:BallLocus.java

示例12: buildAxes

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
private void buildAxes() {
    double length = 2d*dimModel;
    double width = dimModel/100d;
    double radius = 2d*dimModel/100d;
    final PhongMaterial redMaterial = new PhongMaterial();
    redMaterial.setDiffuseColor(Color.DARKRED);
    redMaterial.setSpecularColor(Color.RED);
    final PhongMaterial greenMaterial = new PhongMaterial();
    greenMaterial.setDiffuseColor(Color.DARKGREEN);
    greenMaterial.setSpecularColor(Color.GREEN);
    final PhongMaterial blueMaterial = new PhongMaterial();
    blueMaterial.setDiffuseColor(Color.DARKBLUE);
    blueMaterial.setSpecularColor(Color.BLUE);
    
    Sphere xSphere = new Sphere(radius);
    Sphere ySphere = new Sphere(radius);
    Sphere zSphere = new Sphere(radius);
    xSphere.setMaterial(redMaterial);
    ySphere.setMaterial(greenMaterial);
    zSphere.setMaterial(blueMaterial);
    
    xSphere.setTranslateX(dimModel);
    ySphere.setTranslateY(dimModel);
    zSphere.setTranslateZ(dimModel);
    
    Box xAxis = new Box(length, width, width);
    Box yAxis = new Box(width, length, width);
    Box zAxis = new Box(width, width, length);
    xAxis.setMaterial(redMaterial);
    yAxis.setMaterial(greenMaterial);
    zAxis.setMaterial(blueMaterial);
    
    autoScalingGroup.getChildren().addAll(xAxis, yAxis, zAxis);
    autoScalingGroup.getChildren().addAll(xSphere, ySphere, zSphere);
}
 
开发者ID:jperedadnr,项目名称:RubikFX,代码行数:36,代码来源:ContentModel.java

示例13: createContent

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
public Parent createContent() throws Exception {

        Image dImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-d.jpg").toExternalForm());
        Image nImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-n.jpg").toExternalForm());
        Image sImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-s.jpg").toExternalForm());
        Image siImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-l.jpg").toExternalForm());

        material = new PhongMaterial();
        material.setDiffuseColor(Color.WHITE);
        material.diffuseMapProperty().bind(
                Bindings.when(diffuseMap).then(dImage).otherwise((Image) null));
        material.setSpecularColor(Color.TRANSPARENT);
        material.specularMapProperty().bind(
                Bindings.when(specularMap).then(sImage).otherwise((Image) null));
        material.bumpMapProperty().bind(
                Bindings.when(bumpMap).then(nImage).otherwise((Image) null));
        material.selfIlluminationMapProperty().bind(
                Bindings.when(selfIlluminationMap).then(siImage).otherwise((Image) null));

        earth = new Sphere(5);
        earth.setMaterial(material);
        earth.setRotationAxis(Rotate.Y_AXIS);


        // Create and position camera
        PerspectiveCamera camera = new PerspectiveCamera(true);
        camera.getTransforms().addAll(
                new Rotate(-20, Rotate.Y_AXIS),
                new Rotate(-20, Rotate.X_AXIS),
                new Translate(0, 0, -20));

        sun = new PointLight(Color.rgb(255, 243, 234));
        sun.translateXProperty().bind(sunDistance.multiply(-0.82));
        sun.translateYProperty().bind(sunDistance.multiply(-0.41));
        sun.translateZProperty().bind(sunDistance.multiply(-0.41));
        sun.lightOnProperty().bind(sunLight);

        AmbientLight ambient = new AmbientLight(Color.rgb(1, 1, 1));

        // Build the Scene Graph
        Group root = new Group();
        root.getChildren().add(camera);
        root.getChildren().add(earth);
        root.getChildren().add(sun);
        root.getChildren().add(ambient);

        RotateTransition rt = new RotateTransition(Duration.seconds(24), earth);
        rt.setByAngle(360);
        rt.setInterpolator(Interpolator.LINEAR);
        rt.setCycleCount(Animation.INDEFINITE);
        rt.play();

        // Use a SubScene
        SubScene subScene = new SubScene(root, 400, 300, true, SceneAntialiasing.BALANCED);
        subScene.setFill(Color.TRANSPARENT);
        subScene.setCamera(camera);

        return new Group(subScene);
    }
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:60,代码来源:Simple3DSphereApp.java

示例14: populate

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
public Group populate() {
		Group g = new Group();

		double size = 100000D;
//		Skybox skyBox = new Skybox( top, bottom, left, right, front, back, size, camera );

		CubeWorld cubeWorld = new CubeWorld(5000, 500, true);
		CubeViewer cubeViewer = new CubeViewer(5000, 500, true);
		

		final PhongMaterial redMaterial = new PhongMaterial();
		redMaterial.setDiffuseColor(Color.DARKRED);
		redMaterial.setSpecularColor(Color.RED);
		final PhongMaterial greenMaterial = new PhongMaterial();
		greenMaterial.setDiffuseColor(Color.DARKGREEN);
		greenMaterial.setSpecularColor(Color.GREEN);
		final PhongMaterial blueMaterial = new PhongMaterial();
		blueMaterial.setDiffuseColor(Color.DARKBLUE);
		blueMaterial.setSpecularColor(Color.BLUE);

		final Sphere red = new Sphere(10);
		red.setMaterial(redMaterial);
		final Sphere green = new Sphere(20);
		green.setMaterial(greenMaterial);
		final Sphere blue = new Sphere(30);
		blue.setMaterial(blueMaterial);

		g.getChildren().add(aBunchOfCapsules());
		g.getChildren().add(aBunchOfCones());
		g.getChildren().add(aBunchOfOctahedron());
		g.getChildren().add(aBunchOfSphereSegment());
		g.getChildren().add(aBunchOfSpheroid());
		g.getChildren().add(aBunchOfTorus());
		g.getChildren().add(aBunchOfTrapezoid());

//		g.getChildren().add(skyBox);
		g.getChildren().add(cubeWorld);
		g.getChildren().add(cubeViewer);
		g.getChildren().add(new Axis3D());
		g.getChildren().addAll(red, green, blue);

		return g;
	}
 
开发者ID:sanke69,项目名称:fr.xs.jtk,代码行数:44,代码来源:ABunchOfMeshTest.java

示例15: testObject3D

import javafx.scene.shape.Sphere; //导入方法依赖的package包/类
@Override
public Group testObject3D() {
	root.getChildren().add(new AmbientLight(Color.color(0.1, 0.1, 0.1)));

	buildAxes(axis);
	Pivot p1 = new Pivot(-AXIS_LENGTH / 2, 0, -AXIS_LENGTH / 2);
	buildAxes(p1);
	Pivot p2 = new Pivot(AXIS_LENGTH / 2, 0, -AXIS_LENGTH / 2);
	buildAxes(p2);
	Pivot p3 = new Pivot(-AXIS_LENGTH / 2, 0, AXIS_LENGTH / 2);
	buildAxes(p3);
	Pivot p4 = new Pivot(AXIS_LENGTH / 2, 0, AXIS_LENGTH / 2);
	buildAxes(p4);

	Sphere s = new Sphere(100);
	s.setMaterial(PhongPhactory.fromImage("data/ball.jpg"));
	earth.getChildren().add(s);
	root.getChildren().add(earth);

	camera.getChildren().add(cam);

	PointLight l = new PointLight(Color.WHITE);
	light.getChildren().add(l);
	light.setPosition(300, -200, -300);
	buildAxes(light); // adding the axis will add light pivot to scene

	PointLight rl = new PointLight(Color.DARKRED);
	redLight.getChildren().add(rl);
	redLight.setPosition(-300, -200, 300);
	buildAxes(redLight);

	Box b = new Box(1200, 600, 1200);
	box.getChildren().add(b);
	box.setPosition(0, 0, 0);
	b.setCullFace(CullFace.FRONT);
	b.setMaterial(PhongPhactory.fromImage("/data/crate.jpg"));
	root.getChildren().add(box);

	Timeline t = new Timeline(new KeyFrame(Duration.millis(20), e -> {
		a = a + 0.02;

		earth.setEularRotation(a, -a * 4, -a);

		axis.setPosition(Math.cos(a) * (AXIS_LENGTH / 2), 0, Math.sin(a) * (AXIS_LENGTH / 2));
		camera.setPosition(Math.cos(-a / 4) * (AXIS_LENGTH * 4), -AXIS_LENGTH, Math.sin(-a / 4) * (AXIS_LENGTH * 4));
		camera.lookAt(axis.getPosition(), up);

	}));
	t.setCycleCount(Timeline.INDEFINITE);
	t.play();

	return root;
}
 
开发者ID:sanke69,项目名称:fr.xs.jtk,代码行数:54,代码来源:PivotTest.java


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