/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, original); this.control = cloner.clone(control); this.lookUp = cloner.clone(lookUp); HashMap<Geometry, InstancedGeometry> newIgByGeom = new HashMap<Geometry, InstancedGeometry>(); for( Map.Entry<Geometry, InstancedGeometry> e : igByGeom.entrySet() ) { newIgByGeom.put(cloner.clone(e.getKey()), cloner.clone(e.getValue())); } this.igByGeom = newIgByGeom; HashMap<InstanceTypeKey, InstancedGeometry> newInstancesMap = new HashMap<InstanceTypeKey, InstancedGeometry>(); for( Map.Entry<InstanceTypeKey, InstancedGeometry> e : instancesMap.entrySet() ) { newInstancesMap.put(cloner.clone(e.getKey()), cloner.clone(e.getValue())); } this.instancesMap = newInstancesMap; }
@Override public Spatial detachChildAt(int index) { Spatial s = super.detachChildAt(index); if (s instanceof Node) { ungroupSceneGraph(s); } return s; }
/** * Removes the {@link GeometryGroupNode} association from this * <code>Geometry</code>. * * Should only be called by the parent {@link GeometryGroupNode}. */ public void unassociateFromGroupNode() { if (groupNode != null) { // Once the geometry is removed // from the parent, the group node needs to be updated. groupNode.onGeometryUnassociated(this); groupNode = null; // change the default to -1 to make error detection easier startIndex = -1; } }
/** * Sets the mesh to use for this geometry when rendering. * * @param mesh the mesh to use for this geometry * * @throws IllegalArgumentException If mesh is null */ public void setMesh(Mesh mesh) { if (mesh == null) { throw new IllegalArgumentException(); } this.mesh = mesh; setBoundRefresh(); if (isGrouped()) { groupNode.onMeshChange(this); } }
@Override public Node clone(boolean cloneMaterials) { BatchNode clone = (BatchNode) super.clone(cloneMaterials); if (batches.size() > 0) { for (Batch b : batches) { for (int i = 0; i < clone.children.size(); i++) { if (clone.children.get(i).getName().equals(b.geometry.getName())) { clone.children.remove(i); break; } } } clone.needsFullRebatch = true; clone.batches = new SafeArrayList<Batch>(Batch.class); clone.batchesByGeom = new HashMap<Geometry, Batch>(); clone.batch(); } return clone; }
/** * Sets the material to use for this geometry. * * @param material the material to use for this geometry */ @Override public void setMaterial(Material material) { this.material = material; nbSimultaneousGPUMorph = -1; if (isGrouped()) { groupNode.onMaterialChange(this); } }
@Override protected void updateWorldTransforms() { super.updateWorldTransforms(); computeWorldMatrix(); if (isGrouped()) { groupNode.onTransformChange(this); } // geometry requires lights to be sorted worldLights.sort(true); }
/** * Sets the LOD level to use when rendering the mesh of this geometry. * Level 0 indicates that the default index buffer should be used, * levels [1, LodLevels + 1] represent the levels set on the mesh * with {@link Mesh#setLodLevels(com.jme3.scene.VertexBuffer[]) }. * * @param lod The lod level to set */ @Override public void setLodLevel(int lod) { if (mesh.getNumLodLevels() == 0) { throw new IllegalStateException("LOD levels are not set on this mesh"); } if (lod < 0 || lod >= mesh.getNumLodLevels()) { throw new IllegalArgumentException("LOD level is out of range: " + lod); } lodLevel = lod; if (isGrouped()) { groupNode.onMeshChange(this); } }
@Override public Node clone(boolean cloneMaterials) { InstancedNode clone = (InstancedNode)super.clone(cloneMaterials); if (instancesMap.size() > 0) { // Remove all instanced geometries from the clone for (int i = 0; i < clone.children.size(); i++) { if (clone.children.get(i) instanceof InstancedGeometry) { clone.children.remove(i); } else if (clone.children.get(i) instanceof Geometry) { Geometry geom = (Geometry) clone.children.get(i); if (geom.isGrouped()) { throw new AssertionError(); } } } } // remove original control from the clone clone.controls.remove(this.control); // put clone's control in clone.control = new InstancedNodeControl(clone); clone.controls.add(clone.control); clone.lookUp = new InstanceTypeKey(); clone.igByGeom = new HashMap<Geometry, InstancedGeometry>(); clone.instancesMap = new HashMap<InstanceTypeKey, InstancedGeometry>(); clone.instance(); return clone; }
/** * Sets the material to use for this geometry. * * @param material the material to use for this geometry */ @Override public void setMaterial(Material material) { this.material = material; if (isGrouped()) { groupNode.onMaterialChange(this); } }
@Override protected void updateWorldTransforms() { super.updateWorldTransforms(); computeWorldMatrix(); if (isGrouped()) { groupNode.onTransformChange(this); } // geometry requires lights to be sorted worldLights.sort(true); }
@Override public Spatial detachChildAt(int index) { Spatial s = super.detachChildAt(index); if (s instanceof Node) { unbatchSubGraph(s); } return s; }
/** * Sets the mesh to use for this geometry when rendering. * * @param mesh the mesh to use for this geometry * * @throws IllegalArgumentException If mesh is null */ public void setMesh(Mesh mesh) { if (mesh == null) { throw new IllegalArgumentException(); } this.mesh = mesh; setBoundRefresh(); if (isGrouped()) { groupNode.onMeshChange(this); } }
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields(Cloner cloner, Object original) { super.cloneFields(cloner, original); this.batches = cloner.clone(batches); this.tmpFloat = cloner.clone(tmpFloat); this.tmpFloatN = cloner.clone(tmpFloatN); this.tmpFloatT = cloner.clone(tmpFloatT); HashMap<Geometry, Batch> newBatchesByGeom = new HashMap<Geometry, Batch>(); for (Map.Entry<Geometry, Batch> e : batchesByGeom.entrySet()) { newBatchesByGeom.put(cloner.clone(e.getKey()), cloner.clone(e.getValue())); } this.batchesByGeom = newBatchesByGeom; }
@Override public Node clone(boolean cloneMaterials) { BatchNode clone = (BatchNode) super.clone(cloneMaterials); if (batches.size() > 0) { for (Batch b : batches) { for (int i = 0; i < clone.children.size(); i++) { if (clone.children.get(i).getName().equals(b.geometry.getName())) { clone.children.remove(i); break; } } } clone.needsFullRebatch = true; clone.batches = new SafeArrayList<Batch>(Batch.class); clone.batchesByGeom = new HashMap<Geometry, Batch>(); clone.batch(); } return clone; }
/** * Removes the {@link GeometryGroupNode} association from this * <code>Geometry</code>. * * Should only be called by the parent {@link GeometryGroupNode}. */ public void unassociateFromGroupNode() { if (groupNode != null) { // Once the geometry is removed // from the parent, the group node needs to be updated. groupNode.onGeometryUnassociated(this); groupNode = null; // change the default to -1 to make error detection easier startIndex = -1; } }
@Override public Spatial detachChildAt(int index) { Spatial s = super.detachChildAt(index); if (s instanceof Node) { ungroupSceneGraph(s); } return s; }
/** * Sets the LOD level to use when rendering the mesh of this geometry. * Level 0 indicates that the default index buffer should be used, * levels [1, LodLevels + 1] represent the levels set on the mesh * with {@link Mesh#setLodLevels(com.jme3.scene.VertexBuffer[]) }. * * @param lod The lod level to set */ @Override public void setLodLevel(int lod) { if (mesh.getNumLodLevels() == 0) { throw new IllegalStateException("LOD levels are not set on this mesh"); } if (lod < 0 || lod >= mesh.getNumLodLevels()) { throw new IllegalArgumentException("LOD level is out of range: " + lod); } lodLevel = lod; if (isGrouped()) { groupNode.onMeshChange(this); } }
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, original); this.control = cloner.clone(control); this.lookUp = cloner.clone(lookUp); HashMap<Geometry, InstancedGeometry> newIgByGeom = new HashMap<Geometry, InstancedGeometry>(); for( Map.Entry<Geometry, InstancedGeometry> e : igByGeom.entrySet() ) { newIgByGeom.put(cloner.clone(e.getKey()), cloner.clone(e.getValue())); } this.igByGeom = newIgByGeom; HashMap<InstanceTypeKey, InstancedGeometry> newInstancesMap = new HashMap<InstanceTypeKey, InstancedGeometry>(); for( Map.Entry<InstanceTypeKey, InstancedGeometry> e : instancesMap.entrySet() ) { newInstancesMap.put(cloner.clone(e.getKey()), cloner.clone(e.getValue())); } this.instancesMap = newInstancesMap; }
@Override public Node clone(boolean cloneMaterials) { InstancedNode clone = (InstancedNode)super.clone(cloneMaterials); if (instancesMap.size() > 0) { // Remove all instanced geometries from the clone for (int i = 0; i < clone.children.size(); i++) { if (clone.children.get(i) instanceof InstancedGeometry) { clone.children.remove(i); } else if (clone.children.get(i) instanceof Geometry) { Geometry geom = (Geometry) clone.children.get(i); if (geom.isGrouped()) { throw new AssertionError(); } } } } // remove original control from the clone clone.controls.remove(this.control); // put clone's control in clone.control = new InstancedNodeControl(clone); clone.controls.add(clone.control); clone.lookUp = new InstanceTypeKey(); clone.igByGeom = new HashMap<Geometry, InstancedGeometry>(); clone.instancesMap = new HashMap<InstanceTypeKey, InstancedGeometry>(); clone.instance(); return clone; }