本文整理汇总了Java中javax.media.j3d.Node类的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Node类属于javax.media.j3d包,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create3D
import javax.media.j3d.Node; //导入依赖的package包/类
/** Create 3D geometry. */
@Override
protected void create3D() {
Appearance appear = new Appearance();
material.setCapability(Material.ALLOW_COMPONENT_WRITE);
material.setDiffuseColor(color);
material.setSpecularColor(black);
appear.setMaterial(material);
int flags = Primitive.GEOMETRY_NOT_SHARED | Primitive.ENABLE_GEOMETRY_PICKING | Primitive.GENERATE_NORMALS;
body = new Sphere(radius, flags, appear);
// we must be able to change the pick flag of the agent
body.setCapability(Node.ALLOW_PICKABLE_READ);
body.setCapability(Node.ALLOW_PICKABLE_WRITE);
body.setPickable(true);
body.setCollidable(true);
addChild(body);
// Add bounds for interactions
Bounds bounds = new BoundingSphere(new Point3d(0, 0, 0), radius);
setBounds(bounds);
}
示例2: Object1d
import javax.media.j3d.Node; //导入依赖的package包/类
/**
* créer la représentation d'un objet avec une géométrie de type linéaire.
* créer le lien entre la représentation et l'objet indispensable pour pouvoir
* effectuer des sélections
*
* @param feat l'entité dont la géométrie servira à créer la représentation et
* à laquelle sera attachée la représentation
* @param isClrd indique si une couleur unique sera appliquée ou non (si false
* une couleur différente par face)
* @param color couleur appliquée si isClrd == true
* @param coefOpacity coefficient d'opacité appliqué à l'objet
* @param isSolid propose un mode de représentation filaire (false) ou
* surfacique (true)
*/
public Object1d(IFeature feat, boolean isClrd, Color color,
double coefOpacity, boolean isSolid) {
super(feat, isClrd, color, coefOpacity, isSolid);
// Génère en fonction du cas la géométrie Java3D
LineStripArray geomInfo = null;
if (isClrd) {
geomInfo = this.geometryWithColor();
} else {
geomInfo = this.geometryWithOutColor();
}
if (geomInfo == null) {
Object1d.logger.warn(Messages.getString("Representation.RepNulle"));
return;
}
// Génère l'apparence et l'applique
Shape3D shapepleine = new Shape3D(geomInfo, this.generateAppearance(isClrd,
color, coefOpacity, isSolid));
// Autorisations sur la Shape3D
shapepleine.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
shapepleine.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
shapepleine.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
shapepleine.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
shapepleine.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ);
shapepleine.setCapability(Node.ALLOW_LOCALE_READ);
shapepleine.setCapability(Node.ALLOW_PICKABLE_READ);
shapepleine.setCapability(Node.ALLOW_PICKABLE_WRITE);
this.bGRep.addChild(shapepleine);
// Optimisation
this.bGRep.compile();
}
示例3: Default3DRep
import javax.media.j3d.Node; //导入依赖的package包/类
/**
* Constructeur par défaut permettant de créer les autorisations nécessaires à
* un BranchGroup attribut (ici BgRep attribut "protected")
*/
public Default3DRep() {
// Association des BranchGroup des
// faces
this.bGRep = new BranchGroup();
// Capacites du BranchGroup de l'objet geographique
this.bGRep.setCapability(Node.ALLOW_PICKABLE_READ);
this.bGRep.setCapability(Node.ALLOW_PICKABLE_WRITE);
this.bGRep.setCapability(Node.ENABLE_PICK_REPORTING);
this.bGRep.setCapability(Group.ALLOW_CHILDREN_READ);
this.bGRep.setCapability(Group.ALLOW_CHILDREN_WRITE);
this.bGRep.setCapability(Group.ALLOW_CHILDREN_EXTEND);
this.bGRep.setCapability(BranchGroup.ALLOW_DETACH);
this.bGRep.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ);
// Passer les informations de l'objet au BG
this.bGRep.setUserData(this);
this.bGRep.setPickable(true);
}
示例4: setVisible
import javax.media.j3d.Node; //导入依赖的package包/类
@Override
public void setVisible(boolean visible) {
BranchGroup branch = this.getBranchGroup();
if (branch == null) {
return;
}
if (visible) {
if (this.parent == null) {
return;
}
if (this.getBranchGroup().getParent() != null) {
return;
}
this.parent.addChild(this.getBranchGroup());
} else {
Node node = branch.getParent();
if (node != null) {
this.parent = (BranchGroup) node;
}
this.getBranchGroup().detach();
}
this.visible = visible;
}
示例5: checkAppearancesName
import javax.media.j3d.Node; //导入依赖的package包/类
/**
* Ensures that all the appearance of the children shapes of the
* given <code>node</code> have a name.
*/
public void checkAppearancesName(Node node)
{
// Search appearances used by node shapes keeping their enumeration order
Set<Appearance> appearances = new LinkedHashSet<Appearance>();
searchMaterials(node, appearances);
int i = 0;
for (Appearance appearance : appearances)
{
try
{
if (appearance.getName() == null)
{
appearance.setName("Texture_" + ++i);
}
}
catch (NoSuchMethodError ex)
{
// Don't support HomeMaterial with Java 3D < 1.4 where appearance name was added
break;
}
}
}
示例6: searchMaterials
import javax.media.j3d.Node; //导入依赖的package包/类
private void searchMaterials(Node node, Set<Appearance> appearances)
{
if (node instanceof Group)
{
// Enumerate children
Enumeration<?> enumeration = ((Group) node).getAllChildren();
while (enumeration.hasMoreElements())
{
searchMaterials((Node) enumeration.nextElement(), appearances);
}
}
else if (node instanceof Link)
{
searchMaterials(((Link) node).getSharedGroup(), appearances);
}
else if (node instanceof Shape3D)
{
Appearance appearance = ((Shape3D) node).getAppearance();
if (appearance != null)
{
appearances.add(appearance);
}
}
}
示例7: startOffscreenImagesCreation
import javax.media.j3d.Node; //导入依赖的package包/类
/**
* Optimizes this component for the creation of a sequence of multiple off screen images.
* Once off screen images are generated with {@link #getOffScreenImage(int, int) getOffScreenImage},
* call {@link #endOffscreenImagesCreation() endOffscreenImagesCreation} method to free resources.
*/
public void startOffscreenImagesCreation()
{
if (this.offscreenUniverse == null)
{
if (this.onscreenUniverse != null)
{
throw new IllegalStateException("Can't listen to home changes offscreen and onscreen at the same time");
}
this.offscreenUniverse = createUniverse(this.displayShadowOnFloor, true, true);
// Replace textures by clones because Java 3D doesn't accept all the time
// to share textures between offscreen and onscreen environments
Map<Texture, Texture> replacedTextures = new HashMap<Texture, Texture>();
for (Enumeration it = this.offscreenUniverse.getLocale().getAllBranchGraphs(); it.hasMoreElements();)
{
cloneTexture((Node) it.nextElement(), replacedTextures);
}
}
}
示例8: createSceneTree
import javax.media.j3d.Node; //导入依赖的package包/类
/**
* Returns a new scene tree root.
*/
private BranchGroup createSceneTree(boolean displayShadowOnFloor, boolean listenToHomeUpdates,
boolean waitForLoading)
{
BranchGroup root = new BranchGroup();
// Build scene tree
root.addChild(createHomeTree(displayShadowOnFloor, listenToHomeUpdates, waitForLoading));
root.addChild(createBackgroundNode(listenToHomeUpdates, waitForLoading));
Node groundNode = createGroundNode(-0.5E7f, -0.5E7f, 1E7f, 1E7f, listenToHomeUpdates, waitForLoading);
root.addChild(groundNode);
this.defaultLights = createLights(groundNode, listenToHomeUpdates);
for (Light light : this.defaultLights)
{
root.addChild(light);
}
return root;
}
示例9: addObject
import javax.media.j3d.Node; //导入依赖的package包/类
/**
* Adds to <code>group</code> a branch matching <code>homeObject</code> at a given <code>index</code>.
* If <code>index</code> is equal to -1, <code>homeObject</code> will be added at the end of the group.
*/
private Node addObject(Group group, Selectable homeObject, int index, boolean listenToHomeUpdates,
boolean waitForLoading)
{
Object3DBranch object3D = createObject3D(homeObject, waitForLoading);
if (listenToHomeUpdates)
{
this.homeObjects.put(homeObject, object3D);
}
if (index == -1)
{
group.addChild(object3D);
}
else
{
group.insertChild(object3D, index);
}
clearPrintedImageCache();
return object3D;
}
示例10: getShapesCount
import javax.media.j3d.Node; //导入依赖的package包/类
private int getShapesCount(Node node) {
if (node instanceof Group) {
int shapesCount = 0;
Enumeration<?> enumeration = ((Group)node).getAllChildren();
while (enumeration.hasMoreElements ()) {
shapesCount += getShapesCount((Node)enumeration.nextElement());
}
return shapesCount;
} else if (node instanceof Link) {
return getShapesCount(((Link)node).getSharedGroup());
} else if (node instanceof Shape3D) {
return 1;
} else {
return 0;
}
}
示例11: create3D
import javax.media.j3d.Node; //导入依赖的package包/类
void create3D(float size) {
super.create3D(true);
// lamp body
onColor = new Color3f(0.1f, 1f, 1f);
offColor = new Color3f(0.3f, 0.3f, 0.3f);
blinkColor = new Color3f(1f, 0.3f, 0.3f);
Appearance appear = new Appearance();
material = new Material();
material.setAmbientColor(offColor);
material.setDiffuseColor(offColor);
material.setCapability(Material.ALLOW_COMPONENT_WRITE);
material.setSpecularColor(offColor);
material.setColorTarget(Material.DIFFUSE);
appear.setMaterial(material);
Node node = new com.sun.j3d.utils.geometry.Cylinder(size, size, appear);
node.setCollidable(false);
node.setPickable(false);
addChild(node);
}
示例12: create3D
import javax.media.j3d.Node; //导入依赖的package包/类
/** Create 3D geometry. */
@Override
protected void create3D() {
Appearance appear = new Appearance();
material.setDiffuseColor(color);
material.setSpecularColor(black);
appear.setMaterial(material);
int flags = Primitive.GEOMETRY_NOT_SHARED | Primitive.ENABLE_GEOMETRY_PICKING | Primitive.GENERATE_NORMALS;
body = new Sphere(radius, flags, appear);
// we must be able to change the pick flag of the agent
body.setCapability(Node.ALLOW_PICKABLE_READ);
body.setCapability(Node.ALLOW_PICKABLE_WRITE);
body.setPickable(true);
body.setCollidable(true);
addChild(body);
// Add bounds for interactions
Bounds bounds = new BoundingSphere(new Point3d(0, 0, 0), radius);
setBounds(bounds);
}
示例13: calcRenderSize
import javax.media.j3d.Node; //导入依赖的package包/类
/**
* Returns the number of pixels drawn in the current display
*/
@Override
public double calcRenderSize(ScreenSizeCalculator screenSize, Canvas3D canvas)
{
int rSize = 0;
double area = 0.0;
Node renderNode = root;
screenSize.setScreenXform(canvas, renderNode);
// TODO: modify ScreenSizeCalculator to take convex poly instead of
// quad
return area;
}
示例14: addNode
import javax.media.j3d.Node; //导入依赖的package包/类
/**
* Fuegt eine Node ein
*
* @param node
* Die Node
* @param x
* X-Koordinate
* @param y
* Y-Koordinate
* @param z
* Z-Achse absolut; positiv ist vom Boden Richtung Bot +
* Betrachter, negativ vom Boden weg vom Betrachter
* @param bg
* BranchGropu, in die das Objekt rein soll
*/
public void addNode(Node node, float x, float y, float z, BranchGroup bg) {
Transform3D translate = new Transform3D();
translate.set(new Vector3d(x, y, z));
TransformGroup tg = new TransformGroup(translate);
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
tg.addChild(node);
TransformGroup tgObject = new TransformGroup();
tgObject.addChild(tg);
tgObject.setCapability(Node.ENABLE_PICK_REPORTING);
tgObject.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
tgObject.setPickable(true);
bg.addChild(tgObject);
}
示例15: setParcours
import javax.media.j3d.Node; //导入依赖的package包/类
/**
* Erzeugt einen Szenegraphen mit Boden und Grenzen der Roboterwelt
* @param parc Der Parcours
*/
private void setParcours(Parcours parc) {
parcours = parc;
// Hindernisse werden an die richtige Position geschoben
// Zuerst werden sie gemeinsam so verschoben, dass ihre Unterkante genau
// buendig mit der Unterkante des Bodens ist:
Transform3D translate = new Transform3D();
translate.set(new Vector3d(0d, 0d, 0.2d - PLAYGROUND_THICKNESS));
TransformGroup obstTG = new TransformGroup(translate);
obstTG.setCapability(Node.ENABLE_PICK_REPORTING);
obstTG.setPickable(true);
obstBG.addChild(obstTG);
obstTG.addChild(parc.getObstBG());
lightBG.addChild(parc.getLightBG());
bpsBG.addChild(parc.getBpsBG());
terrainBG.addChild(parc.getTerrainBG());
obstBG.setCapability(Node.ENABLE_PICK_REPORTING);
obstBG.setCapability(Node.ALLOW_PICKABLE_READ);
}