本文整理汇总了Java中com.sun.j3d.utils.picking.PickResult类的典型用法代码示例。如果您正苦于以下问题:Java PickResult类的具体用法?Java PickResult怎么用?Java PickResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PickResult类属于com.sun.j3d.utils.picking包,在下文中一共展示了PickResult类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: pickManifestation
import com.sun.j3d.utils.picking.PickResult; //导入依赖的package包/类
@Override
public RenderedManifestation pickManifestation( MouseEvent e )
{
PickResult pickResult = null;
try {
mPickCanvas .setShapeLocation( e );
pickResult = mPickCanvas .pickClosest();
} catch( Throwable t ) {
t .printStackTrace();
}
Node node = pickResult == null? null : pickResult .getObject();
// for scenegraph.Factory approach
// Node node = pickResult == null? null : pickResult .getNode( PickResult.BRANCH_GROUP );
RenderedManifestation picked = node == null? null : (RenderedManifestation) node .getUserData();
return picked;
}
开发者ID:vZome,项目名称:vzome-desktop,代码行数:19,代码来源:Java3dRenderingViewer.java
示例2: pickCube
import com.sun.j3d.utils.picking.PickResult; //导入依赖的package包/类
@Override
public Collection<RenderedManifestation> pickCube()
{
PickResult[] pickResult = null;
try {
mPickCanvas .setShapeBounds( new BoundingBox( new Point3d(0,0,-50), new Point3d(50,50,50) ), new Point3d(1d,1d,1d) );
pickResult = mPickCanvas .pickAll();
} catch( Throwable t ) {
t .printStackTrace();
}
Collection<RenderedManifestation> result = new ArrayList<>();
for ( int i = 0; i < pickResult.length; i++ )
{
Node node = pickResult[ i ] .getObject();
RenderedManifestation picked = (RenderedManifestation) node .getUserData();
result .add( picked );
}
// for scenegraph.Factory approach
// Node node = pickResult == null? null : pickResult .getNode( PickResult.BRANCH_GROUP );
return result;
}
开发者ID:vZome,项目名称:vzome-desktop,代码行数:24,代码来源:Java3dRenderingViewer.java
示例3: setupBehaviour
import com.sun.j3d.utils.picking.PickResult; //导入依赖的package包/类
protected void setupBehaviour(BranchGroup mainScene) {
PickMouseBehavior pickMouseBehavior = new PickMouseBehavior(canvas, mainScene, null) {
@Override
public void updateScene(int x, int y) {
pickCanvas.setShapeLocation(x, y);
PickResult pickInfo = pickCanvas.pickClosest();
if (pickInfo != null) {
Shape3D selected = (Shape3D) pickInfo.getObject();
if (selection.contains(selected)) {
selection.remove(selected);
selected.setAppearance(defaultAppearance);
} else {
selection.add(selected);
selected.setAppearance(selectedAppearance);
}
}
}
};
pickMouseBehavior.setSchedulingBounds(new BoundingSphere(new Point3d(0, 0, 0), Double.MAX_VALUE));
mainScene.addChild(pickMouseBehavior);
}
开发者ID:hlg,项目名称:billie,代码行数:22,代码来源:SimpleViewer.java
示例4: setupBehaviour
import com.sun.j3d.utils.picking.PickResult; //导入依赖的package包/类
public void setupBehaviour(BranchGroup mainScene) {
BranchGroup root = mainScene;
while (root.getAllChildren().hasMoreElements() && !Iterators.any(Iterators.<Node>forEnumeration(root.getAllChildren()), new Predicate<Node>() {
public boolean apply(Node o) {
return o instanceof Shape3D;
}
}))
root = (BranchGroup) Iterators.find(Iterators.<Node>forEnumeration(root.getAllChildren()), new Predicate<Node>() {
public boolean apply(Node node) {
return node instanceof BranchGroup;
}
});
setAllShapesOfTo(root, defaultAppearance, true);
PickMouseBehavior pickMouseBehavior = new PickMouseBehavior(canvas, root, null) {
@Override
public void updateScene(int x, int y) {
pickCanvas.setShapeLocation(x, y);
PickResult pickResult = pickCanvas.pickClosest();
selectedNode = (pickResult != null) ? (Shape3D) pickResult.getObject() : null;
if (selectedNode != null) {
BranchGroup grandParent = (BranchGroup) selectedNode.getParent().getParent();
if (grandParent != null) {
setAllShapesOfTo(grandParent, noAppearance, false);
}
setAllShapesOfTo((BranchGroup) selectedNode.getParent(), contextAppearance, false);
selectedNode.setAppearance(noAppearance);
selectedNode.setPickable(false);
Enumeration<Node> siblings = ((BranchGroup) selectedNode.getParent()).getAllChildren();
while (siblings.hasMoreElements()) {
Node node = siblings.nextElement();
if (node instanceof BranchGroup) setAllShapesOfTo((BranchGroup) node, defaultAppearance, true);
}
}
}
};
pickMouseBehavior.setSchedulingBounds(new BoundingSphere(new Point3d(0, 0, 0), Double.MAX_VALUE));
mainScene.addChild(pickMouseBehavior);
}
开发者ID:hlg,项目名称:billie,代码行数:39,代码来源:SpatialHierarchyViewer.java
示例5: mouseClicked
import com.sun.j3d.utils.picking.PickResult; //导入依赖的package包/类
private void mouseClicked(MouseEvent e) {
lastMouseDragLocation = null;
pickCanvas.setShapeLocation(e);
PickResult[] thePickResult = pickCanvas.pickAllSorted();
if (thePickResult != null) {
for (PickResult theResult : thePickResult) {
if (theResult != null) {
Primitive p = (Primitive) theResult.getNode(PickResult.PRIMITIVE);
if (p != null) {
if (p.getUserData() instanceof UserObjectInfo) {
UserObjectInfo theItem = (UserObjectInfo) p.getUserData();
if (!SwingUtilities.isRightMouseButton(e)) {
if (e.getClickCount() == 2) {
editModelItem(theItem.item);
} else {
OutlineComponent.getDefault().setSelectedItem(theItem.item);
}
// We only handle the first found object
return;
} else {
DefaultPopupMenu theMenu = new DefaultPopupMenu(ResourceHelper
.getResourceHelper(ERDesignerBundle.BUNDLE_NAME));
List<ModelItem> theItems = new ArrayList<>();
theItems.add(theItem.item);
ContextMenuFactory.addActionsToMenu(Java3DEditor.this, theMenu, theItems);
UIInitializer.getInstance().initialize(theMenu);
theMenu.show(mainPanel, e.getX(), e.getY());
// We only handle the first found object
return;
}
}
}
}
}
}
}
开发者ID:mirkosertic,项目名称:ERDesignerNG,代码行数:42,代码来源:Java3DEditor.java
示例6: mouseMoved
import com.sun.j3d.utils.picking.PickResult; //导入依赖的package包/类
private void mouseMoved(MouseEvent e) {
currentElement.setText("");
UserObjectInfo pickedObject = null;
pickCanvas.setShapeLocation(e);
// We have to use pickAll because of transparency
PickResult[] thePickResult = pickCanvas.pickAllSorted();
if (thePickResult != null) {
for (PickResult theResult : thePickResult) {
if (theResult != null) {
Primitive p = (Primitive) theResult.getNode(PickResult.PRIMITIVE);
if (p != null) {
if (p.getUserData() instanceof UserObjectInfo && pickedObject == null) {
UserObjectInfo theItem = (UserObjectInfo) p.getUserData();
pickedObject = theItem;
}
}
}
}
}
if (pickedObject != null) {
currentElement.setText(pickedObject.item.getName());
if (pickedObject != fadingComponent) {
fadingHelper.setComponentToHighlightFadeOut(fadingHelper.getComponentToHighlight() != null);
fadingHelper.setComponentToHighlightNext(getHighlightComponentFor(pickedObject));
}
} else {
fadingHelper.setComponentToHighlightFadeOut(true);
fadingHelper.setComponentToHighlightNext(null);
}
fadingComponent = pickedObject;
fadingHelper.startWaitTimer();
// Repaint triggern
Transform3D theTransform = new Transform3D();
modelGroup.getTransform(theTransform);
modelGroup.setTransform(theTransform);
}
开发者ID:mirkosertic,项目名称:ERDesignerNG,代码行数:42,代码来源:Java3DEditor.java
示例7: mouseClicked
import com.sun.j3d.utils.picking.PickResult; //导入依赖的package包/类
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
pickCanvas.setShapeLocation(e);
PickResult result = pickCanvas.pickClosest();
// If nothing is selected, restore all data points
if (result == null) {
for (int i = 0; i < N; i++) {
spheres[i].getAppearance().getMaterial()
.setDiffuseColor(colors[i]);
TransparencyAttributes t_attr = new TransparencyAttributes(
TransparencyAttributes.NONE, 0.0f);
spheres[i].getAppearance()
.setTransparencyAttributes(t_attr);
}
ScatterPlot3DGUI.detailTextArea.append("Nothing selected.\n\n");
} else {
Primitive p = (Primitive) result.getNode(PickResult.PRIMITIVE);
Shape3D s = (Shape3D) result.getNode(PickResult.SHAPE3D);
if (p != null) {
int index = Integer.parseInt(p.getUserData().toString());
if (index == -1) {
ScatterPlot3DGUI.detailTextArea
.append("Axis selected.\n");
} else {
for (int i = 0; i < totalCol; i++) {
ScatterPlot3DGUI.detailTextArea
.append(ScatterPlot3DGUI.headers[i] + ": "
+ data.data[index][i] + "\n");
}
}
// Adjust label
ScatterPlot3DGUI.detailTextArea.append("\n");
ScatterPlot3DGUI.detailTextArea
.setCaretPosition(ScatterPlot3DGUI.detailTextArea
.getDocument().getLength());
} else if (s != null) {
System.out.print("s: ");
System.out.println(s.getClass().getName());
} else {
System.out.println("null");
}
}
} else if (e.getButton() == MouseEvent.BUTTON3) {
saveMenu.show(e.getComponent(), e.getX(), e.getY());
}
}
开发者ID:airalcorn2,项目名称:ScatterPlot3D,代码行数:75,代码来源:ScatterPlot3D.java
注:本文中的com.sun.j3d.utils.picking.PickResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论