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


Java SceneGraphVisitor类代码示例

本文整理汇总了Java中com.jme3.scene.SceneGraphVisitor的典型用法代码示例。如果您正苦于以下问题:Java SceneGraphVisitor类的具体用法?Java SceneGraphVisitor怎么用?Java SceneGraphVisitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: removeSpatial

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
public void removeSpatial(Spatial s) {
	s.depthFirstTraversal(new SceneGraphVisitor(){
		@Override
		public void visit(Spatial sx) {
			if(sx instanceof Geometry){
				Geometry geo=(Geometry)sx;
				Material mat=geo.getMaterial();
				String mat_name=mat==null?null:mat.getName();
				if(mat_name==null){
					System.err.println("Invalid material or missing name");
				}else{
					Iterator<Entry> e_i=ENTRIES.iterator();
					while(e_i.hasNext()){
						if(e_i.next().geo==geo){
							e_i.remove();
							break;
						}
					}
				}
			}
		}
	});
}
 
开发者ID:riccardobl,项目名称:JMELink-SP,代码行数:24,代码来源:SubstanceLinkAppState.java

示例2: findSpatial

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
/**
 * Finds a spatial in the given Spatial tree with the specified name and
 * path, the path and name are constructed from the given (sub-)spatial(s)
 * and is not read from the UserData of the objects. This is mainly used to
 * check if the original spatial still exists in the original file.
 *
 * @param root
 * @param name
 * @param path
 */
public static Spatial findSpatial(final Spatial root, final String name, final String path) {
    if (name == null || path == null) {
        logger.log(Level.WARNING, "Trying to find Spatial with null name spatial for {0}.", root);
        return null;
    }
    if (name.equals(root.getName()) && path.equals(getSpatialPath(root))) {
        return root;
    }
    final SpatialHolder holder = new SpatialHolder();
    root.depthFirstTraversal(new SceneGraphVisitor() {
        @Override
        public void visit(Spatial spatial) {
            if (name.equals(spatial.getName()) && path.equals(getSpatialPath(spatial))) {
                if (holder.spatial == null) {
                    holder.spatial = spatial;
                } else {
                    logger.log(Level.WARNING, "Found Spatial {0} twice in {1}", new Object[]{path, root});
                }
            }
        }
    });
    return holder.spatial;
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:34,代码来源:SpatialUtil.java

示例3: removeBondPointsForItem

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
protected void removeBondPointsForItem(Spatial item) {
    item.depthFirstTraversal(new SceneGraphVisitor() {
        @Override
        public void visit(Spatial spatial) {
            if (spatial instanceof Node) {
                Node bondPoint = (Node) spatial;
                ObjectBond bond = bondForPoint.get(bondPoint);
                if (bond != null) {
                    inventory.removeJoint(bond.hostItem, bond.guestItem, MySixDofJoint.class);
                    removeBond(bond);
                }
                String role = spatial.getUserData("bondPoint");
                if ("host".equals(role)) {
                    hostBondPoints.remove(bondPoint.getName());
                } else if ("guest".equals(role)) {
                    guestBondPoints.remove(bondPoint.getName());
                }
            }
        }
    });
    guestBondPointsByItem.remove(item);
}
 
开发者ID:dwhuang,项目名称:SMILE,代码行数:23,代码来源:ObjectBondTracker.java

示例4: createInitBonds

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
public void createInitBonds() {
    for (Spatial item : items) {
        item.depthFirstTraversal(new SceneGraphVisitor() {
            @Override
            public void visit(Spatial spatial) {
                if (spatial instanceof Node) {
                    Node node = (Node) spatial;
                    String hostId = node.getUserData("initBondHostId");
                    if (hostId != null) {
                        objectBondTracker.createInitBond(node, hostId,
                                (Integer) node.getUserData("initBondTightness"));
                    }
                }
            }
        });
    }
}
 
开发者ID:dwhuang,项目名称:SMILE,代码行数:18,代码来源:Inventory.java

示例5: makeWireFrame

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
public static void makeWireFrame(Spatial spatial) {
    SceneGraphVisitor sgv = new SceneGraphVisitor() {
        @Override
        public void visit(Spatial spa) {
            if (spa instanceof Geometry) {
                Geometry geo = (Geometry) spa;
                Material mat = geo.getMaterial();
                if (mat == null) {
                    mat = new Material(LuoYing.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
                }
                mat.getAdditionalRenderState().setWireframe(true);
                geo.setMaterial(mat);
                geo.setCullHint(Spatial.CullHint.Never);
            }
        }
    };
    spatial.depthFirstTraversal(sgv);
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:19,代码来源:DebugUtils.java

示例6: initialize

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
@Override
public void initialize() {
    super.initialize();
    entity.getSpatial().depthFirstTraversal(new SceneGraphVisitor() {
        @Override
        public void visit(Spatial spatial) {
            if (spatial instanceof Geometry) {
                if (spatial.getControl(LodControl.class) == null) {
                    LodControl lod = new MyLodControl();
                    lod.setDistTolerance(distTolerance);
                    lod.setTrisPerPixel(trisPerPixel);
                    lod.setEnabled(enabled);
                    spatial.addControl(lod);
                    lcs.add(lod);
                }
            }
        }
    });
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:20,代码来源:LodModule.java

示例7: onActivate

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
@Override
protected void onActivate() {
	if(owner != null) owner.setInvisible(true);

	SceneGraphVisitor visitor = new SceneGraphVisitor() {
		@Override
		public void visit(Spatial spatial) {
			Entity e = spatial.getUserData("entity");
			if (e == null) return;
			if (!(e instanceof Mob)) System.out.println("non-Mob encountered in the Mob node");

			Mob mob = (Mob) e;
			if (mob.getTarget() == owner) mob.setTarget(null);
		}
	};

	world.getMobNode().depthFirstTraversal(visitor);
}
 
开发者ID:GSam,项目名称:Game-Project,代码行数:19,代码来源:StealthField.java

示例8: makeMesh

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
@Override
protected void makeMesh(AssetManager assetManager){
    geometry = assetManager.loadModel(meshfile);
    geometry.setLocalScale(scale);
    geometry.getLocalRotation().multLocal(new Quaternion().fromAngleNormalAxis(angle, Vector3f.UNIT_Y));
    
    deleteSpecialNodes();

    ((Node)geometry).depthFirstTraversal(new SceneGraphVisitor() {
        @Override
        public void visit(Spatial spatial) {
            if(spatial instanceof LightNode)
                spatial.getParent().detachChild(spatial);
            if(!cull && spatial instanceof Geometry){
                ((Geometry)spatial).getMaterial().getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
            }

        }
    });
}
 
开发者ID:GSam,项目名称:Game-Project,代码行数:21,代码来源:WorldObject.java

示例9: addSpatial

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
public void addSpatial(Spatial s) {
	NEED_SUBSTANCES_UPDATE=true;
	s.depthFirstTraversal(new SceneGraphVisitor(){
		@Override
		public void visit(Spatial sx) {
			if(sx instanceof Geometry){
				Geometry geo=(Geometry)sx;
				Material mat=geo.getMaterial();
				String mat_name=mat==null?null:mat.getName();
				if(mat_name==null){
					System.err.println("Invalid material or missing name");
				}else{
					boolean exists=false;
					Iterator<Entry> e_i=ENTRIES.iterator();
					while(e_i.hasNext()){
						if(e_i.next().geo==geo){
							exists=true;
							break;
						}
					}
					if(!exists){
						Entry e=new Entry();
						e.geo=geo;
						ENTRIES.add(e);
					}
					// Apply substance
				}
			}
		}
	});
}
 
开发者ID:riccardobl,项目名称:JMELink-SP,代码行数:32,代码来源:SubstanceLinkAppState.java

示例10: CoursePath

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
/**
 * Course path constructor. Locate the course path and organise the points
 * into an ordered list. Rotate these points to create a smooth path.
 * @param scene Root node of scene.
 */
public CoursePath(Node scene, BulletAppState bullet) {
  // Locate each course point and create an array of those points ordered by
  // the order data in the user data of the spatials.
  Spatial coursePath = scene.getChild(COURSE_PATH_NODE_NAME);
  final TreeMap<Integer, Spatial> points = new TreeMap<Integer, Spatial>();
  coursePath.breadthFirstTraversal(new SceneGraphVisitor() {
    public void visit(Spatial spatial) {
      Integer order = spatial.getUserData(COURSE_ORDER_ATTR);
      if (order != null) {
        points.put(order, spatial);
      }
    }
  });
  coursePoints = points.values().toArray(new Spatial[0]);

  // To create a smooth rotation along the course, each course point is
  // rotated to look in the direction of the vector connecting the preceding
  // point with the succeeding point.
  for (int i = 0; i < coursePoints.length; ++i) {
    Spatial current = coursePoints[i];
    Spatial previous = i > 0
        ? coursePoints[i - 1] : coursePoints[coursePoints.length - 1];
    Spatial next = coursePoints[(i + 1) % coursePoints.length];
    Vector3f lookDirection
        = previous.getLocalTranslation().subtract(next.getLocalTranslation());
    current.getLocalRotation().lookAt(lookDirection,
                                      new Vector3f(0.0f, 1.0f, 0.0f));
    CollisionShape shape = CollisionShapeFactory.createBoxShape(current);
    GhostControl physics = new GhostControl(shape);
    current.addControl(physics);
    bullet.getPhysicsSpace().add(physics);
  }

  // Install listener for collisions between player and node.
  bullet.getPhysicsSpace()
      .addCollisionListener(new CoursePointCollisionListener(this));
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:43,代码来源:CoursePath.java

示例11: storeOriginalPathUserData

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
/**
 * Stores ORIGINAL_NAME and ORIGINAL_PATH UserData to given Spatial and all
 * sub-Spatials.
 *
 * @param spat
 */
public static void storeOriginalPathUserData(Spatial spat) {
    //TODO: only stores for geometry atm
    final ArrayList<String> geomMap = new ArrayList<String>();
    if (spat != null) {
        spat.depthFirstTraversal(new SceneGraphVisitor() {
            @Override
            public void visit(Spatial geom) {
                Spatial curSpat = geom;
                String geomName = curSpat.getName();
                if (geomName == null) {
                    logger.log(Level.WARNING, "Null Spatial name!");
                    geomName = "null";
                }
                geom.setUserData("ORIGINAL_NAME", geomName);
                logger.log(Level.FINE, "Set ORIGINAL_NAME for {0}", geomName);
                String id = SpatialUtil.getSpatialPath(curSpat);
                if (geomMap.contains(id)) {
                    logger.log(Level.WARNING, "Cannot create unique name for Spatial {0}: {1}", new Object[]{geom, id});
                }
                geomMap.add(id);
                geom.setUserData("ORIGINAL_PATH", id);
                logger.log(Level.FINE, "Set ORIGINAL_PATH for {0}", id);
            }
        });
    } else {
        logger.log(Level.SEVERE, "No Spatial available when trying to add Spatial paths.");
    }
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:35,代码来源:SpatialUtil.java

示例12: findTaggedSpatial

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
/**
 * Finds a previously marked spatial in the supplied root Spatial, creates
 * the name and path to be looked for from the given needle Spatial.
 *
 * @param root
 * @param needle
 * @return
 */
public static Spatial findTaggedSpatial(final Spatial root, final Spatial needle) {
    if (needle == null) {
        logger.log(Level.WARNING, "Trying to find null needle for {0}", root);
        return null;
    }
    final String name = needle.getName();
    final String path = getSpatialPath(needle);
    if (name == null || path == null) {
        logger.log(Level.WARNING, "Trying to find tagged Spatial with null name spatial for {0}.", root);
        return null;
    }
    final Class clazz = needle.getClass();
    String rootName = root.getUserData("ORIGINAL_NAME");
    String rootPath = root.getUserData("ORIGINAL_PATH");
    if (name.equals(rootName) && path.equals(rootPath)) {
        return root;
    }
    final SpatialHolder holder = new SpatialHolder();
    root.depthFirstTraversal(new SceneGraphVisitor() {
        @Override
        public void visit(Spatial spatial) {
            String spName = spatial.getUserData("ORIGINAL_NAME");
            String spPath = spatial.getUserData("ORIGINAL_PATH");
            if (name.equals(spName) && path.equals(spPath) && clazz.isInstance(spatial)) {
                if (holder.spatial == null) {
                    holder.spatial = spatial;
                } else {
                    logger.log(Level.WARNING, "Found Spatial {0} twice in {1}", new Object[]{path, root});
                }
            }
        }
    });
    return holder.spatial;
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:43,代码来源:SpatialUtil.java

示例13: removeAnimData

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
public static void removeAnimData(Spatial root) {
    root.depthFirstTraversal(new SceneGraphVisitor() {
        @Override
        public void visit(Spatial spat) {
            AnimControl animControl = spat.getControl(AnimControl.class);
            if (animControl != null) {
                spat.removeControl(animControl);
                SkeletonControl skeletonControl = spat.getControl(SkeletonControl.class);
                if (skeletonControl != null) {
                    spat.removeControl(skeletonControl);
                }
            }
        }
    });
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:16,代码来源:SpatialUtil.java

示例14: hasAnimations

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
/**
 * Finds out if a spatial has animations.
 *
 * @param root
 */
public static boolean hasAnimations(final Spatial root) {
    final AtomicBoolean animFound = new AtomicBoolean(false);
    root.depthFirstTraversal(new SceneGraphVisitor() {
        public void visit(Spatial spatial) {
            if (spatial.getControl(AnimControl.class) != null) {
                animFound.set(true);
            }
        }
    });
    return animFound.get();
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:17,代码来源:SpatialUtil.java

示例15: DemoSceneProcessor

import com.jme3.scene.SceneGraphVisitor; //导入依赖的package包/类
public DemoSceneProcessor(MainApp app, Node visualAid) {
	this.factory = app.getFactory();
    visualAid.depthFirstTraversal(new SceneGraphVisitor() {
        public void visit(Spatial s) {
            if (s instanceof Geometry) {
                visualAidGeos.add((Geometry)s);
            }
        }
    });
    
    hlMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
    hlMaterial.setColor("Color", ColorRGBA.Black);
}
 
开发者ID:dwhuang,项目名称:SMILE,代码行数:14,代码来源:DemoSceneProcessor.java


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