pickinghelper.java
来自「Java mulitplayer strategy game. Adaptati」· Java 代码 · 共 82 行
JAVA
82 行
/*
* Created on 2005-10-10
* $Id: PickingHelper.java,v 1.1 2005/11/10 13:45:47 macx2k Exp $
*/
package net.sf.jawp.j3d.picking;
import java.util.Enumeration;
import javax.media.j3d.Geometry;
import javax.media.j3d.Group;
import javax.media.j3d.Node;
import javax.media.j3d.Shape3D;
import com.sun.j3d.utils.picking.PickTool;
/**
* Helper class for Java3D picking operations.
*
* @author Maciej Malecki
* @version $Revision: 1.1 $
*/
public final class PickingHelper
{
private PickingHelper()
{
}
/**
* Enables picking for specified complex object.
*
* @param node
* object to be picking enabled
*/
public static void enablePicking(final Node node)
{
node.setPickable(true);
node.setCapability(Node.ENABLE_PICK_REPORTING);
if (node instanceof Group)
{
final Group group = (Group) node;
for (final Enumeration children = group.getAllChildren(); children
.hasMoreElements();)
{
final Node child = (Node) children.nextElement();
enablePicking(child);
}
}
if (node instanceof Shape3D)
{
allowIntersect(node);
}
}
public static void allowIntersect(final Node node)
{
if (node instanceof Group)
{
final Group group = (Group) node;
for (final Enumeration children = group.getAllChildren(); children
.hasMoreElements();)
{
final Node child = (Node) children.nextElement();
allowIntersect(child);
}
}
if (node instanceof Shape3D)
{
final Shape3D shape = (Shape3D) node;
PickTool.setCapabilities(shape, PickTool.INTERSECT_FULL);
for (final Enumeration groups = shape.getAllGeometries(); groups
.hasMoreElements();)
{
final Geometry geometry = (Geometry) groups.nextElement();
geometry.setCapability(Geometry.ALLOW_INTERSECT);
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?