/** * @deprecated Use {@link #isGrouped()} instead. */ @Deprecated public boolean isBatched() { return isGrouped(); }
/** * 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); } }
/** * Associate this <code>Geometry</code> with a {@link GeometryGroupNode}. * * Should only be called by the parent {@link GeometryGroupNode}. * * @param node Which {@link GeometryGroupNode} to associate with. * @param startIndex The starting index of this geometry in the group. */ public void associateWithGroupNode(GeometryGroupNode node, int startIndex) { if (isGrouped()) { unassociateFromGroupNode(); } this.groupNode = node; this.startIndex = startIndex; }
@Override protected void setParent(Node parent) { super.setParent(parent); // If the geometry is managed by group node we need to unassociate. if (parent == null && isGrouped()) { unassociateFromGroupNode(); } }
@Override public boolean checkCulling(Camera cam) { if (isGrouped()) { setLastFrustumIntersection(Camera.FrustumIntersect.Outside); return false; } return super.checkCulling(cam); }
/** * 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); } }
/** * 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); } }
/** * recursively visit the subgraph and unbatch geometries * * @param s */ private void unbatchSubGraph(Spatial s) { if (s instanceof Node) { for (Spatial sp : ((Node) s).getChildren()) { unbatchSubGraph(sp); } } else if (s instanceof Geometry) { Geometry g = (Geometry) s; if (g.isGrouped()) { g.unassociateFromGroupNode(); } } }
private void ungroupSceneGraph(Spatial s) { if (s instanceof Node) { for (Spatial sp : ((Node) s).getChildren()) { ungroupSceneGraph(sp); } } else if (s instanceof Geometry) { Geometry g = (Geometry) s; if (g.isGrouped()) { // Will invoke onGeometryUnassociated automatically. g.unassociateFromGroupNode(); if (InstancedNode.getGeometryStartIndex(g) != -1) { throw new AssertionError(); } } } }
@Override protected void updateWorldTransforms() { super.updateWorldTransforms(); computeWorldMatrix(); if (isGrouped()) { groupNode.onTransformChange(this); } // geometry requires lights to be sorted worldLights.sort(true); }
private void instance(Spatial n) { if (n instanceof Geometry) { Geometry g = (Geometry) n; if (!g.isGrouped() && g.getBatchHint() != BatchHint.Never) { addToInstancedGeometry(g); } } else if (n instanceof Node) { for (Spatial child : ((Node) n).getChildren()) { if (child instanceof GeometryGroupNode) { continue; } instance(child); } } }
if (!g.isGrouped() || rebatch) { if (g.getMaterial() == null) { throw new IllegalStateException("No material is set for Geometry: " + g.getName() + " please set a material before batching");
@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; }
/** * Helper function used to recursively populate the outputGeometryList * with geometry children of scene node * * @param camera * @param scene * @param outputGeometryList */ private static void addGeometriesInCamFrustumFromNode(Camera camera, Node scene, RenderQueue.ShadowMode mode, GeometryList outputGeometryList) { if (scene.getCullHint() == Spatial.CullHint.Always) return; camera.setPlaneState(0); if (camera.contains(scene.getWorldBound()) != Camera.FrustumIntersect.Outside) { for (Spatial child: scene.getChildren()) { if (child instanceof Node) addGeometriesInCamFrustumFromNode(camera, (Node)child, mode, outputGeometryList); else if (child instanceof Geometry && child.getCullHint() != Spatial.CullHint.Always) { camera.setPlaneState(0); if (checkShadowMode(child.getShadowMode(), mode) && !((Geometry)child).isGrouped() && camera.contains(child.getWorldBound()) != Camera.FrustumIntersect.Outside) { outputGeometryList.add((Geometry)child); } } } } }
if (checkShadowMode(scene.getShadowMode(), mode) && !((Geometry)scene).isGrouped() ) { outputGeometryList.add((Geometry)scene);
&& !occluder.isGrouped() && occluder.getWorldBound()!=null) { BoundingVolume bv = occluder.getWorldBound(); BoundingVolume occBox = bv.transform(viewProjMatrix, vars.bbox);
/** * @deprecated Use {@link #isGrouped()} instead. */ @Deprecated public boolean isBatched() { return isGrouped(); }
/** * 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 public boolean checkCulling(Camera cam) { if (isGrouped()) { setLastFrustumIntersection(Camera.FrustumIntersect.Outside); return false; } return super.checkCulling(cam); }
@Override protected void setParent(Node parent) { super.setParent(parent); // If the geometry is managed by group node we need to unassociate. if (parent == null && isGrouped()) { unassociateFromGroupNode(); } }