本文整理汇总了Java中com.jme3.scene.Geometry类的典型用法代码示例。如果您正苦于以下问题:Java Geometry类的具体用法?Java Geometry怎么用?Java Geometry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Geometry类属于com.jme3.scene包,在下文中一共展示了Geometry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleRemovedObject
import com.jme3.scene.Geometry; //导入依赖的package包/类
@Override
@FXThread
protected void handleRemovedObject(@NotNull final Spatial model) {
super.handleRemovedObject(model);
final ModelEditor3DState editor3DState = getEditor3DState();
final Array<Geometry> geometries = ArrayFactory.newArray(Geometry.class);
NodeUtils.addGeometry(model, geometries);
if (!geometries.isEmpty()) {
geometries.forEach(geometry -> {
if (geometry.getQueueBucket() == RenderQueue.Bucket.Sky) {
editor3DState.removeCustomSky(geometry);
}
});
}
}
示例2: removeSpatial
import com.jme3.scene.Geometry; //导入依赖的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;
}
}
}
}
}
});
}
示例3: generateNames
import com.jme3.scene.Geometry; //导入依赖的package包/类
/**
* Generate names for materials.
*/
private void generateNames(@NotNull final ObjectDictionary<String, Geometry> mapping,
@NotNull final Geometry geometry) {
final Material material = geometry.getMaterial();
final String originalName = material.getName();
final String name = StringUtils.isEmpty(geometry.getName()) ? "geom" : geometry.getName();
String resultName = StringUtils.isEmpty(originalName) ? "embedded-mat-" + name : originalName;
if (!mapping.containsKey(resultName)) {
mapping.put(resultName, geometry);
} else {
for (int i = 1; mapping.containsKey(resultName); i++) {
resultName = (StringUtils.isEmpty(originalName) ? "embedded-mat-" : originalName) + name + "_" + i;
}
mapping.put(resultName, geometry);
}
}
示例4: addObject
import com.jme3.scene.Geometry; //导入依赖的package包/类
@Override
protected Spatial addObject(Entity e) {
Mesh mesh = factory.getMesh(e.get(componentType));
if(mesh == null){
LOGGER.info("Factory doesn't provide mesh for "+componentType+" "+e.getId());
return new Node("Empty mesh ("+componentType+") "+e.getId());
}
Geometry geom = new Geometry(componentType.getName()+" "+ e.getId(), mesh);
RigidBody body = e.get(RigidBody.class);
if(body.isKinematic()){
geom.setMaterial(createMaterial(ColorRGBA.Green));
}else {
if(body.getMass() == 0) {
geom.setMaterial(createMaterial(ColorRGBA.Cyan.mult(ColorRGBA.DarkGray)));
}else {
geom.setMaterial(createMaterial(ColorRGBA.Red));
}
}
rootNode.attachChild(geom);
return geom;
}
示例5: updateObject
import com.jme3.scene.Geometry; //导入依赖的package包/类
@Override
protected void updateObject(Spatial geom, Entity e) {
if(geom instanceof Node){
LOGGER.info("Can't update mesh for "+e.getId()+" recreate it!");
return;
}
Mesh mesh = factory.getMesh(e.get(componentType));
((Geometry)geom).setMesh(mesh);
geom.updateModelBound();
RigidBody body = e.get(RigidBody.class);
if(body.isKinematic()){
geom.setMaterial(createMaterial(ColorRGBA.Green));
}else {
if(body.getMass() == 0) {
geom.setMaterial(createMaterial(ColorRGBA.Cyan.mult(ColorRGBA.DarkGray)));
}else {
geom.setMaterial(createMaterial(ColorRGBA.Red));
}
}
}
示例6: findGeometry
import com.jme3.scene.Geometry; //导入依赖的package包/类
/**
* Find a first geometry in the {@link Spatial}.
*
* @param spatial the spatial
* @param name the name
* @return the geometry
*/
public static @Nullable Geometry findGeometry(@NotNull final Spatial spatial, @NotNull final String name) {
if (!(spatial instanceof Node)) return null;
final Node node = (Node) spatial;
for (final Spatial children : node.getChildren()) {
final Geometry geometry = findGeometry(children, name);
if (geometry != null) return geometry;
if (children instanceof Geometry && StringUtils.equals(children.getName(), name)) {
return (Geometry) children;
}
}
return null;
}
示例7: render
import com.jme3.scene.Geometry; //导入依赖的package包/类
public void render( List<Prof> ofs, Tweed tweed, ColorRGBA col, Node n ) {
// Random randy = new Random(ofs.hashCode());
Material mat = new Material( tweed.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md" );
// ColorRGBA col = new ColorRGBA(
// randy.nextFloat(),
// 0.2f+ 0.5f * randy.nextFloat(),
// 0.5f+ 0.5f * randy.nextFloat(), 1);
mat.setColor( "Diffuse", col );
mat.setColor( "Ambient", col.mult( 0.1f ) );
mat.setBoolean( "UseMaterialColors", true );
for (Prof p : ofs) {
Geometry g = new Geometry();
g.setMesh( p.renderStrip( TweedSettings.settings.profileHSampleDist/2, null ) );
g.setMaterial( mat );
n.attachChild( g );
}
}
示例8: setSpatial
import com.jme3.scene.Geometry; //导入依赖的package包/类
@Override
public void setSpatial(Spatial spatial) {
if (!(spatial instanceof Geometry)) {
throw new IllegalArgumentException("LodControl can only be attached to Geometry!");
}
super.setSpatial(spatial);
Geometry geom = (Geometry) spatial;
Mesh mesh = geom.getMesh();
numLevels = mesh.getNumLodLevels();
for (int i = 0; i < numLevels; i++)
if (mesh.getLodLevel( i ) == null)
numLevels--;
numTris = new int[numLevels];
for (int i = numLevels - 1; i >= 0; i--) {
numTris[i] = mesh.getTriangleCount(i);
}
}
示例9: getIndex
import com.jme3.scene.Geometry; //导入依赖的package包/类
/**
* Get the index of the object in the model.
*/
private static boolean getIndex(@NotNull final Object model, @NotNull final Object object,
@NotNull final AtomicInteger counter) {
counter.incrementAndGet();
if (Objects.equals(model, object)) {
return true;
} else if (model instanceof Geometry) {
return getIndex(((Geometry) model).getMesh(), object, counter);
} else if (!(model instanceof Node)) {
return false;
}
final Node node = (Node) model;
final List<Spatial> children = node.getChildren();
for (final Spatial child : children) {
if (getIndex(child, object, counter)) {
return true;
}
}
return false;
}
示例10: BaseMaterialEditor3DState
import com.jme3.scene.Geometry; //导入依赖的package包/类
public BaseMaterialEditor3DState(@NotNull final T fileEditor) {
super(fileEditor);
this.testBox = new Geometry("Box", new Box(2, 2, 2));
this.testSphere = new Geometry("Sphere", new Sphere(30, 30, 2));
this.testQuad = new Geometry("Quad", new Quad(4, 4));
this.testQuad.setLocalTranslation(QUAD_OFFSET);
this.lightEnabled = MaterialFileEditor.DEFAULT_LIGHT_ENABLED;
TangentGenerator.useMikktspaceGenerator(testBox);
TangentGenerator.useMikktspaceGenerator(testSphere);
TangentGenerator.useMikktspaceGenerator(testQuad);
final DirectionalLight light = notNull(getLightForCamera());
light.setDirection(LIGHT_DIRECTION);
final EditorCamera editorCamera = notNull(getEditorCamera());
editorCamera.setDefaultHorizontalRotation(H_ROTATION);
editorCamera.setDefaultVerticalRotation(V_ROTATION);
getModelNode().attachChild(getNodeForCamera());
}
示例11: addGeometry
import com.jme3.scene.Geometry; //导入依赖的package包/类
/**
* Collect all geometries.
*
* @param spatial the spatial
* @param container the container
*/
public static void addGeometry(@NotNull final Spatial spatial, @NotNull final Array<Geometry> container) {
if (spatial instanceof Geometry) {
container.add((Geometry) spatial);
return;
} else if (!(spatial instanceof Node)) {
return;
}
final Node node = (Node) spatial;
for (final Spatial children : node.getChildren()) {
addGeometry(children, container);
}
}
示例12: updateMaterialImpl
import com.jme3.scene.Geometry; //导入依赖的package包/类
/**
* Update the {@link Material} in the {@link EditorThread}.
*
* @param material the new material.
*/
@JMEThread
protected void updateMaterialImpl(@NotNull final Material material) {
final Geometry testBox = getTestBox();
testBox.setMaterial(material);
final Geometry testQuad = getTestQuad();
testQuad.setMaterial(material);
final Geometry testSphere = getTestSphere();
testSphere.setMaterial(material);
final RenderManager renderManager = EDITOR.getRenderManager();
try {
renderManager.preloadScene(testBox);
} catch (final RendererException | AssetNotFoundException | UnsupportedOperationException e) {
handleMaterialException(e);
testBox.setMaterial(EDITOR.getDefaultMaterial());
testQuad.setMaterial(EDITOR.getDefaultMaterial());
testSphere.setMaterial(EDITOR.getDefaultMaterial());
}
}
示例13: updateModel
import com.jme3.scene.Geometry; //导入依赖的package包/类
/**
* Update position and rotation of a model.
*/
@JMEThread
public void updateModel() {
final ScenePresentable object = getObject();
final Geometry model = getModel();
if (model == null || object == null) return;
// TODO implement getting parent
/*final Node parent = object.getParent();
if (parent != null) {
setLocalTranslation(parent.getWorldTranslation());
setLocalRotation(parent.getWorldRotation());
setLocalScale(parent.getWorldScale());
}*/
final Node editedNode = getEditedNode();
model.setLocalTranslation(editedNode.getWorldTranslation());
model.setLocalRotation(editedNode.getWorldRotation());
model.setLocalScale(editedNode.getWorldScale());
}
示例14: updateItem
import com.jme3.scene.Geometry; //导入依赖的package包/类
@Override
protected void updateItem(@Nullable final Integer level, final boolean empty) {
super.updateItem(level, empty);
final Geometry geometry = getEditObject();
final Mesh mesh = geometry.getMesh();
if (level == null || mesh == null) {
setText("None");
return;
}
int elements;
if (level < mesh.getNumLodLevels()) {
final VertexBuffer lodLevel = mesh.getLodLevel(level);
elements = lodLevel.getNumElements();
} else {
elements = mesh.getTriangleCount();
}
setText(Messages.MODEL_PROPERTY_LEVEL + ": " + level + " (" + elements + " " +
Messages.MODEL_PROPERTY_TRIANGLE_COUNT + ")");
}
示例15: reload
import com.jme3.scene.Geometry; //导入依赖的package包/类
@Override
@FXThread
protected void reload() {
if (!hasEditObject()) return;
final Geometry geometry = getEditObject();
final Mesh mesh = geometry.getMesh();
if (mesh == null) return;
final Integer element = getPropertyValue();
final ComboBox<Integer> levelComboBox = getLevelComboBox();
final ObservableList<Integer> items = levelComboBox.getItems();
items.clear();
final int numLodLevels = mesh.getNumLodLevels();
for (int i = 0; i < numLodLevels; i++) {
items.add(i);
}
if (items.isEmpty()) {
items.add(0);
}
levelComboBox.getSelectionModel().select(element);
}