本文整理汇总了Java中javafx.scene.shape.MeshView类的典型用法代码示例。如果您正苦于以下问题:Java MeshView类的具体用法?Java MeshView怎么用?Java MeshView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MeshView类属于javafx.scene.shape包,在下文中一共展示了MeshView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildGroup
import javafx.scene.shape.MeshView; //导入依赖的package包/类
@Override
protected Group buildGroup() {
mb = new MeshBuilder();
triangleMesh = mb.getTriangleMesh();
meshView = new MeshView(triangleMesh);
material = new PhongMaterial();
material.setDiffuseColor(Color.LIGHTGRAY);
material.setSpecularColor(Color.rgb(30, 30, 30));
meshView.setMaterial(material);
//Set Wireframe mode
meshView.setDrawMode(DrawMode.FILL);
meshView.setCullFace(CullFace.BACK);
meshView.setScaleX(SCALE);
meshView.setScaleY(SCALE);
meshView.setScaleZ(SCALE);
grp = new Group(meshView);
return grp;
}
示例2: initScene
import javafx.scene.shape.MeshView; //导入依赖的package包/类
@Override
protected void initScene() {
DefaultMeshBuilder dmb = new DefaultMeshBuilder() {
@Override
protected double function(double fx, double fy) {
return 1;
}
};
MeshView meshView = new MeshView(dmb.getTriangleMesh());
meshView.setScaleX(100);
meshView.setScaleY(100);
meshView.setScaleZ(100);
Sphere s = new Sphere(50);
s.setTranslateX(WIDTH / 2);
s.setTranslateY(HEIGHT / 2);
Group root = new Group(s, meshView);
scene = createScene(root, WIDTH, HEIGHT);
scene.setCamera(new PerspectiveCamera());
}
示例3: updateArrow
import javafx.scene.shape.MeshView; //导入依赖的package包/类
public void updateArrow(String face, boolean hover){
boolean bFaceArrow = !(face.startsWith("X") || face.startsWith("Y") || face.startsWith("Z"));
MeshView arrow = bFaceArrow ? faceArrow : axisArrow;
if (hover && onRotation.get()) {
return;
}
arrow.getTransforms().clear();
if (hover) {
double d0 = arrow.getBoundsInParent().getHeight() / 2d;
Affine aff = Utils.getAffine(dimCube, d0, bFaceArrow, face);
arrow.getTransforms().setAll(aff);
arrow.setMaterial(Utils.getMaterial(face));
if (previewFace.get().isEmpty()) {
previewFace.set(face);
onPreview.set(true);
rotateFace(face, true, false);
}
} else if (previewFace.get().equals(face)) {
rotateFace(Utils.reverseRotation(face), true, true);
} else if (previewFace.get().equals("V")) {
previewFace.set("");
onPreview.set(false);
}
}
示例4: checkMesh
import javafx.scene.shape.MeshView; //导入依赖的package包/类
/**
* Check that the decorator will set the object's material correctly.
*/
@Test @Ignore
public void checkMesh() {
// Create a render object
Shape shape = GeometryFactory.eINSTANCE.createShape();
FXRenderObject object = new FXRenderObject(
GeometryFactory.eINSTANCE.createCube(), new FXMeshCache());
// Create a color decorator for it
FXColorOption decorator = new FXColorOption(object);
// Set the color
object.setProperty(ColorOptionImpl.PROPERTY_NAME_RED, 200);
object.setProperty(ColorOptionImpl.PROPERTY_NAME_GREEN, 100);
object.setProperty(ColorOptionImpl.PROPERTY_NAME_BLUE, 0);
// We cannot test PhongMaterials for equality as JavaFX does not
// overload equals() or provide methods for getting a PhongMaterial's
// attributes, so instead just check that the decorator returned a
// meshview.
assertTrue(object.getMesh().getChildren().get(0) instanceof MeshView);
}
示例5: setMaterial
import javafx.scene.shape.MeshView; //导入依赖的package包/类
/**
* Set all the MeshViews in the group to the given material, as well as the
* children of any child groups.
*
* @param group
* The group whose children will have their material set.
* @param material
* The material to be set to the group's children.
*/
private void setMaterial(Group group, Material material) {
// Handle each of the group's children
for (Node node : group.getChildren()) {
// If the node is a mesh view, set its material
if (node.getClass() == MeshView.class) {
((MeshView) node).setMaterial(material);
}
// Otherwise, recursively handle the child group
else if (node.getClass() == Group.class) {
setMaterial((Group) node, material);
}
}
}
示例6: setMode
import javafx.scene.shape.MeshView; //导入依赖的package包/类
/**
* Set all the MeshViews in the group to the given draw mode, as well as the
* children of any child groups.
*
* @param group
* The group whose children will have their draw modes set.
* @param mode
* The mode to be set to the group's children.
*/
private void setMode(Group group, DrawMode mode) {
// Handle each of the group's children
for (Node node : group.getChildren()) {
// If the node is a mesh view, set its material
if (node.getClass() == MeshView.class) {
((MeshView) node).setDrawMode(mode);
}
// Otherwise, recursively handle the child group
else if (node.getClass() == Group.class) {
setMode((Group) node, mode);
}
}
}
示例7: getAsMeshViews
import javafx.scene.shape.MeshView; //导入依赖的package包/类
public List<MeshView> getAsMeshViews() {
List<MeshView> result = new ArrayList<>(meshes.size());
for (int i = 0; i < meshes.size(); i++) {
Mesh mesh = meshes.get(i);
Material mat = materials.get(i);
MeshView view = new MeshView(mesh);
view.setMaterial(mat);
view.setCullFace(CullFace.NONE);
result.add(view);
}
return result;
}
示例8: updateArrow
import javafx.scene.shape.MeshView; //导入依赖的package包/类
public void updateArrow(String face, boolean hover){
boolean bFaceArrow=!(face.startsWith("X")||face.startsWith("Y")||face.startsWith("Z"));
MeshView arrow=bFaceArrow?faceArrow:axisArrow;
if(hover && onRotation.get()){
return;
}
arrow.getTransforms().clear();
if(hover){
double d0=arrow.getBoundsInParent().getHeight()/2d;
Affine aff=Utils.getAffine(dimCube, d0, bFaceArrow, face);
arrow.getTransforms().setAll(aff);
arrow.setMaterial(Utils.getMaterial(face));
if(previewFace.get().isEmpty()) {
previewFace.set(face);
onPreview.set(true);
rotateFace(face,true,false);
}
} else if(previewFace.get().equals(face)){
rotateFace(Utils.reverseRotation(face),true,true);
} else if(previewFace.get().equals("V")){
previewFace.set("");
onPreview.set(false);
}
}
示例9: setView
import javafx.scene.shape.MeshView; //导入依赖的package包/类
/**
* @param view the view to set
*/
public final void setView(MeshView view) {
this.view = view;
// remove all previously added mesh views
List<Node> nodesToRemove
= getGroup().getChildren().stream().filter(
e -> e instanceof MeshView).
collect(Collectors.toList());
getGroup().getChildren().removeAll(nodesToRemove);
// finally add the new view
getGroup().getChildren().add(view);
}
示例10: addVolumeInteraction
import javafx.scene.shape.MeshView; //导入依赖的package包/类
/**Adds the high resolution volume interaction to a group, that consists of meshView objects.
* Do not use this on the low resolution model.
* @param volumeMeshView the group of meshViews (volumes) that should be selectable
**/
private void addVolumeInteraction(MeshView volumeMeshView) {
volumeMeshView.addEventHandler(MouseEvent.MOUSE_CLICKED, mouseClick -> {
if (mouseClick.getButton().toString().matches("SECONDARY")) {
Node pickedNode = mouseClick.getPickResult().getIntersectedNode();
PickResult res = mouseClick.getPickResult();
if (debugMode) {
System.out.println("Selected node is a volume!");
System.out.println(newFaceMap.get(pickedNode));
}
handleSelection(faceNodeSelection, faceNodeSelectionMaterial, pickedNode, new MeshView());
}
});
}
示例11: load
import javafx.scene.shape.MeshView; //导入依赖的package包/类
/**
* Load a 3D file, always loaded as TriangleMesh.
*
* @param fileUrl the url of the 3D file to load
* @return the loaded Node which could be a MeshView or a Group
* @throws IOException if there is a problem loading the file
*/
public static Group load(final String fileUrl) throws IOException {
final int dot = fileUrl.lastIndexOf('.');
if (dot <= 0) {
throw new IOException("Unknown 3D file format, url missing extension [" + fileUrl + "]");
}
final String extension = fileUrl.substring(dot + 1, fileUrl.length()).toLowerCase();
switch (extension) {
case "3ds":
ModelImporter tdsImporter = new TdsModelImporter();
tdsImporter.read(fileUrl);
final Node[] tdsMesh = (Node[]) tdsImporter.getImport();
tdsImporter.close();
return new Group(tdsMesh);
case "stl":
StlMeshImporter stlImporter = new StlMeshImporter();
stlImporter.read(fileUrl);
// STL includes only geometry data
TriangleMesh cylinderHeadMesh = stlImporter.getImport();
stlImporter.close();
// Create Shape3D
MeshView cylinderHeadMeshView = new MeshView();
cylinderHeadMeshView.setMaterial(new PhongMaterial(Color.GRAY));
cylinderHeadMeshView.setMesh(cylinderHeadMesh);
stlImporter.close();
return new Group(cylinderHeadMeshView);
default:
throw new IOException("Unsupported 3D file format [" + extension + "]");
}
}
示例12: Cone
import javafx.scene.shape.MeshView; //导入依赖的package包/类
public Cone(double rad, double height) {
this.rad = rad;
this.height = height;
mv = new MeshView();
mv.setMesh(dmb.getTriangleMesh());
grp = new Group(mv);
}
示例13: SemiSphere
import javafx.scene.shape.MeshView; //导入依赖的package包/类
public SemiSphere(double rad,int divX,int divY) {
this.rad = rad;
dmb = new SemiSphereBuilder(divX,divY);
mv = new MeshView();
mv.setMesh(dmb.getTriangleMesh());
grp = new Group(mv);
}
示例14: doSequence
import javafx.scene.shape.MeshView; //导入依赖的package包/类
public void doSequence(String list){
onScrambling.set(true);
sequence = Utils.unifyNotation(list);
/*
This is the way to perform several rotations from a list, waiting till each of
them ends properly. A listener is added to onRotation, so only when the last rotation finishes
a new rotation is performed. The end of the list is used to stop the listener, by adding
a new listener to the index property. Note the size+1, to allow for the last rotation to end.
*/
IntegerProperty index = new SimpleIntegerProperty(1);
ChangeListener<Boolean> lis = (ov, b, b1) -> {
if (!b1) {
if (index.get()<sequence.size()) {
rotateFace(sequence.get(index.get()));
} else {
// save transforms
for (Map.Entry<String, MeshView> entry : mapMeshes.entrySet()) {
mapTransformsScramble.put(entry.getKey(), entry.getValue().getTransforms().get(0));
}
orderScramble = new ArrayList<>();
for (Integer i : reorder) {
orderScramble.add(i);
}
}
index.set(index.get()+1);
}
};
index.addListener((ov, v, v1) -> {
if (v1.intValue() == sequence.size()+1) {
onScrambling.set(false);
onRotation.removeListener(lis);
count.set(-1);
}
});
onRotation.addListener(lis);
rotateFace(sequence.get(0));
}
示例15: doReset
import javafx.scene.shape.MeshView; //导入依赖的package包/类
public void doReset(){
// System.out.println("Reset!");
content.resetCam();
for (Map.Entry<String, MeshView> entry : mapMeshes.entrySet()) {
entry.getValue().getTransforms().setAll(mapTransformsOriginal.get(entry.getKey()));
}
order = new ArrayList<>();
for (Integer i : orderOriginal) {
order.add(i);
}
rot.setCube(order);
count.set(-1);
}