batchNode.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(batchNode);
/** * Generate the page nodes * * @param root where to generate pages on */ private void generatePages(Node root) { pages = new ArrayList<>(((int) Math.ceil(mapData.getHeight() / (float) PAGE_SQUARE_SIZE)) * ((int) Math.ceil(mapData.getWidth() / (float) PAGE_SQUARE_SIZE))); for (int y = 0; y < (int) Math.ceil(mapData.getHeight() / (float) PAGE_SQUARE_SIZE); y++) { for (int x = 0; x < (int) Math.ceil(mapData.getWidth() / (float) PAGE_SQUARE_SIZE); x++) { Node page = new Node(x + "_" + y); // Create batch nodes for ceiling, floor and walls BatchNode floor = new BatchNode("floor"); floor.setShadowMode(RenderQueue.ShadowMode.Receive); // Floors don't cast generateTileNodes(floor, x, y); page.attachChild(floor); BatchNode wall = new BatchNode("wall"); wall.setShadowMode(RenderQueue.ShadowMode.CastAndReceive); // Walls cast and receive shadows generateTileNodes(wall, x, y); page.attachChild(wall); BatchNode ceiling = new BatchNode("ceiling"); ceiling.setShadowMode(RenderQueue.ShadowMode.Off); // No lights above ceilings generateTileNodes(ceiling, x, y); page.attachChild(ceiling); pages.add(page); root.attachChild(page); } } }
@Override public Spatial construct() { super.construct(); // Pillars if (hasPillars()) { BatchNode pillarsNode = new BatchNode("Pillars"); contructPillars(pillarsNode); if (!pillarsNode.getChildren().isEmpty()) { pillarsNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive); pillarsNode.batch(); getRootNode().attachChild(pillarsNode); } } return getRootNode(); }
public Spatial construct() { setupCoordinates(); // Add the floor getRootNode().detachAllChildren(); BatchNode floorNode = constructFloor(); if (floorNode != null) { floorNode.setName("Floor"); floorNode.setShadowMode(getFloorShadowMode()); floorNode.batch(); getRootNode().attachChild(floorNode); } // Custom wall BatchNode wallNode = constructWall(); if (wallNode != null) { wallNode.setName("Wall"); wallNode.setShadowMode(getWallShadowMode()); wallNode.batch(); getRootNode().attachChild(wallNode); } // The objects on the floor Node objectsNode = constructObjects(); if (objectsNode != null) { objectsNode.setName("Objects"); objectsNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive); getRootNode().attachChild(objectsNode); } return getRootNode(); }