@Override public void simpleInitApp() { timer = new NanoTimer(); batch = new BatchNode("theBatchNode");
/** * 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 protected BatchNode constructFloor() { BatchNode root = new BatchNode(); String modelName = roomInstance.getRoom().getCompleteResource().getName(); //Point start = roomInstance.getCoordinates().get(0); // Contruct the tiles for (Point p : roomInstance.getCoordinates()) { // Figure out which peace by seeing the neighbours boolean N = roomInstance.hasCoordinate(new Point(p.x, p.y - 1)); boolean NE = roomInstance.hasCoordinate(new Point(p.x + 1, p.y - 1)); boolean E = roomInstance.hasCoordinate(new Point(p.x + 1, p.y)); boolean SE = roomInstance.hasCoordinate(new Point(p.x + 1, p.y + 1)); boolean S = roomInstance.hasCoordinate(new Point(p.x, p.y + 1)); boolean SW = roomInstance.hasCoordinate(new Point(p.x - 1, p.y + 1)); boolean W = roomInstance.hasCoordinate(new Point(p.x - 1, p.y)); boolean NW = roomInstance.hasCoordinate(new Point(p.x - 1, p.y - 1)); // 2x2 Node model = constructQuad(assetManager, modelName, N, NE, E, SE, S, SW, W, NW); //AssetUtils.scale(model); AssetUtils.translateToTile(model, p); root.attachChild(model); } return root; }
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode(); String modelName = roomInstance.getRoom().getCompleteResource().getName(); //Point start = roomInstance.getCoordinates().get(0); // Contruct the tiles for (Point p : roomInstance.getCoordinates()) { // Figure out which peace by seeing the neighbours boolean N = roomInstance.hasCoordinate(new Point(p.x, p.y - 1)); boolean NE = roomInstance.hasCoordinate(new Point(p.x + 1, p.y - 1)); boolean E = roomInstance.hasCoordinate(new Point(p.x + 1, p.y)); boolean SE = roomInstance.hasCoordinate(new Point(p.x + 1, p.y + 1)); boolean S = roomInstance.hasCoordinate(new Point(p.x, p.y + 1)); boolean SW = roomInstance.hasCoordinate(new Point(p.x - 1, p.y + 1)); boolean W = roomInstance.hasCoordinate(new Point(p.x - 1, p.y)); boolean NW = roomInstance.hasCoordinate(new Point(p.x - 1, p.y - 1)); // 2x2 Node model = constructQuad(assetManager, modelName, N, NE, E, SE, S, SW, W, NW); //AssetUtils.scale(model); AssetUtils.translateToTile(model, p); root.attachChild(model); } // Set the transform and scale to our scale and 0 the transform //AssetUtils.scale(root); //AssetUtils.moveToTile(root, start); return root; }
@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(); }
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode(); String modelName = roomInstance.getRoom().getCompleteResource().getName();
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode(); String modelName = roomInstance.getRoom().getCompleteResource().getName();
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode(); String modelName = roomInstance.getRoom().getCompleteResource().getName(); // Contruct the tiles int i = 0; Point start = roomInstance.getCoordinates().get(0); for (Point p : roomInstance.getCoordinates()) { Spatial tile = AssetUtils.loadModel(assetManager, modelName + i++, false, true); // Reset moveSpatial(tile, start, p); root.attachChild(tile); } // Set the transform and scale to our scale and 0 the transform AssetUtils.translateToTile(root, start); return root; }
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode(); // 3 by 3, a simple case int i = 0; Point start = roomInstance.getCoordinates().get(0); for (Point p : roomInstance.getCoordinates()) { Spatial tile = (Spatial) AssetUtils.loadModel(assetManager, roomInstance.getRoom().getCompleteResource().getName() + i, false, true); moveSpatial(tile, start, p); root.attachChild(tile); i++; } // Set the transform and scale to our scale and 0 the transform //AssetUtils.scale(root); AssetUtils.translateToTile(root, start); return root; }
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode(); String modelName = roomInstance.getRoom().getCompleteResource().getName();
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode();
@Override protected BatchNode constructWall() { BatchNode root = new BatchNode();
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode(); String modelName = roomInstance.getRoom().getCompleteResource().getName();
@Override protected BatchNode constructWall() { BatchNode root = new BatchNode();
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode(); String modelName = roomInstance.getRoom().getCompleteResource().getName();
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode(); String modelName = roomInstance.getRoom().getCompleteResource().getName(); //Point center = roomInstance.getCenter(); // Contruct the tiles int j = 0; for (Point p : roomInstance.getCoordinates()) { int piece = (roomInstance.getDirection() == Direction.WEST || roomInstance.getDirection() == Direction.SOUTH) ? j + 3 : 5 - j; Spatial tile = AssetUtils.loadModel(assetManager, modelName + piece, false, true); j++; moveSpatial(tile, p); root.attachChild(tile); // Set the transform and scale to our scale and 0 the transform switch (roomInstance.getDirection()) { case NORTH: tile.rotate(0, -FastMath.HALF_PI, 0); break; case EAST: tile.rotate(0, FastMath.PI, 0); break; case SOUTH: tile.rotate(0, FastMath.HALF_PI, 0); break; } } //root.move(-MapLoader.TILE_WIDTH / 2, 0, -MapLoader.TILE_WIDTH / 2); return root; }
spatial = new BatchNode(); int firstPiece = (i == 0 ? 4 : 6); if (firstPiece == 4 && (section.getDirection() == WallSection.WallDirection.EAST
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode();
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode();