|
| 1 | +package org.getaviz.generator; |
| 2 | + |
| 3 | +import org.getaviz.generator.SettingsConfiguration.BuildingType; |
| 4 | +import org.getaviz.generator.city.m2m.CityLayout; |
| 5 | +import org.getaviz.generator.city.m2m.Rectangle; |
| 6 | + |
| 7 | +public class OutputFormatHelper { |
| 8 | + static SettingsConfiguration config = SettingsConfiguration.getInstance(); |
| 9 | + |
| 10 | + public static String X3DHead() { |
| 11 | + StringBuilder builder = new StringBuilder(); |
| 12 | + builder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); |
| 13 | + builder.append("\n"); |
| 14 | + builder.append( |
| 15 | + "<!DOCTYPE X3D PUBLIC \"ISO//Web3D//DTD X3D 3.3//EN\" \"http://www.web3d.org/specifications/x3d-3.3.dtd\">"); |
| 16 | + builder.append("\n"); |
| 17 | + builder.append( |
| 18 | + "<X3D profile=\'Immersive\' version=\'3.3\' xmlns:xsd=\'http://www.w3.org/2001/XMLSchema-instance\' xsd:noNamespaceSchemaLocation=\'http://www.web3d.org/specifications/x3d-3.3.xsd\'>"); |
| 19 | + builder.append("\n"); |
| 20 | + builder.append(" <head>"); |
| 21 | + builder.append("\n"); |
| 22 | + builder.append(" <meta content=\'model.x3d\' name=\'title\'/>"); |
| 23 | + builder.append("\n"); |
| 24 | + builder.append(" <meta content=\'SVIS-Generator\' name=\'creator\'/>"); |
| 25 | + builder.append("\n"); |
| 26 | + builder.append("\t </head>"); |
| 27 | + builder.append("\n"); |
| 28 | + builder.append("\t <ContextSetup zWriteTrans=\'false\'/>"); |
| 29 | + builder.append("\n"); |
| 30 | + builder.append("<Scene>"); |
| 31 | + builder.append("\n"); |
| 32 | + return builder.toString(); |
| 33 | + } |
| 34 | + |
| 35 | + public static String settingsInfo() { |
| 36 | + StringBuilder builder = new StringBuilder(); |
| 37 | + builder.append("<SettingsInfo ClassElements=\'" + config.getClassElementsMode()); |
| 38 | + builder.append("\' SortModeCoarse=\'" + config.getClassElementsSortModeCoarse()); |
| 39 | + builder.append("\' SortModeFine=\'" + config.getClassElementsSortModeFine()); |
| 40 | + builder.append("\' SortModeFineReversed=\'" + config.isClassElementsSortModeFineDirectionReversed()); |
| 41 | + builder.append("\' Scheme=\'" + config.getScheme()); |
| 42 | + builder.append("\' ShowBuildingBase=\'" + config.isShowBuildingBase() + "\'"); |
| 43 | + builder.append("\n"); |
| 44 | + if (config.getBuildingType() == BuildingType.CITY_BRICKS) { |
| 45 | + builder.append("BrickLayout=\'" + config.getBrickLayout() + "\'"); |
| 46 | + builder.append("\n"); |
| 47 | + } else if (config.getBuildingType() == BuildingType.CITY_PANELS) { |
| 48 | + builder.append("AttributesAsCylinders=\'" + config.isShowAttributesAsCylinders()); |
| 49 | + builder.append("\' PanelSeparatorMode=\'" + config.getPanelSeparatorMode() + "\'"); |
| 50 | + builder.append("\n"); |
| 51 | + } |
| 52 | + builder.append("/>"); |
| 53 | + builder.append("\n"); |
| 54 | + return builder.toString(); |
| 55 | + } |
| 56 | + |
| 57 | + public static String viewports() { |
| 58 | + Rectangle rootEntity = CityLayout.rootRectangle; |
| 59 | + double width = rootEntity.getWidth(); |
| 60 | + double length = rootEntity.getLength(); |
| 61 | + StringBuilder builder = new StringBuilder(); |
| 62 | + builder.append("<Group DEF=\'Viewpoints\'>"); |
| 63 | + builder.append("\n"); |
| 64 | + builder.append("\t <Viewpoint description=\'Initial\' position=\'" + width * 0.5 + " " |
| 65 | + + ((width + length) / 2) * 0.25); |
| 66 | + builder.append("\' orientation=\'0 1 0 4\' centerOfRotation=\'" + width / 2 + " 0 " + length / 2 + "\'/>"); |
| 67 | + builder.append("\n"); |
| 68 | + builder.append("\t Viewpoint description=\'Opposite Side\' position=\'" + width * 1.5 + " " |
| 69 | + + ((width + length) / 2) * 0.25 + " " + length * 1.5); |
| 70 | + builder.append("\' orientation=\'0 1 0 0.8\' centerOfRotation=\'" + width / 2 + " 0 " + length / 2 + "\'/>"); |
| 71 | + builder.append("\n"); |
| 72 | + builder.append("\t <Viewpoint description=\'Screenshot\' position=\'" + -width * 0.5 + " " |
| 73 | + + ((width + length) / 2) * 0.75 + " " + -length * 0.5); |
| 74 | + builder.append( |
| 75 | + "\' orientation=\'0.1 0.95 0.25 3.8\' centerOfRotation=\'" + width / 2 + " 0 " + length / 2 + "\'/>"); |
| 76 | + builder.append("\n"); |
| 77 | + builder.append("\t <Viewpoint description=\'Screenshot Opposite Side\' position=\'" + width * 1.5 + " " |
| 78 | + + ((width + length) / 2) * 0.75 + " " + length * 1.5); |
| 79 | + builder.append( |
| 80 | + "\' orientation=\'-0.5 0.85 0.2 0.8\' centerOfRotation=\'" + width / 2 + " 0 " + length / 2 + "\'/>"); |
| 81 | + builder.append("\n"); |
| 82 | + builder.append("</Group>"); |
| 83 | + builder.append("\n"); |
| 84 | + return builder.toString(); |
| 85 | + } |
| 86 | + |
| 87 | + public static String X3DTail() { |
| 88 | + StringBuilder builder = new StringBuilder(); |
| 89 | + builder.append( |
| 90 | + "\t<Background DEF=\"_Background\" groundColor=\'1.0000000 1.0000000 1.0000000\' skyColor=\'1.0000000 1.0000000 1.0000000\'/>"); |
| 91 | + builder.append("\n"); |
| 92 | + builder.append("\t</Scene>"); |
| 93 | + builder.append("\n"); |
| 94 | + builder.append("</X3D>"); |
| 95 | + builder.append("\n"); |
| 96 | + return builder.toString(); |
| 97 | + } |
| 98 | + |
| 99 | + public static String AFrameHead() { |
| 100 | + StringBuilder builder = new StringBuilder(); |
| 101 | + builder.append("<!DOCTYPE html>"); |
| 102 | + builder.append("\n"); |
| 103 | + builder.append("<html>"); |
| 104 | + builder.append("\n"); |
| 105 | + builder.append("\t <head>"); |
| 106 | + builder.append("\n"); |
| 107 | + builder.append("\t\t <meta charset=\"utf-8\">"); |
| 108 | + builder.append("\n"); |
| 109 | + builder.append("\t <title>Ring</title>"); |
| 110 | + builder.append("\n"); |
| 111 | + builder.append("\t <meta name=\"description\" content=\"Getaviz\">"); |
| 112 | + builder.append("\n"); |
| 113 | + builder.append("\t </head>"); |
| 114 | + builder.append("\n"); |
| 115 | + builder.append("\t <body>"); |
| 116 | + builder.append("\n"); |
| 117 | + builder.append("\t\t <a-scene id=\"aframe-canvas\""); |
| 118 | + builder.append("\n"); |
| 119 | + builder.append("\t \t light=\"defaultLightsEnabled: false\""); |
| 120 | + builder.append("\n"); |
| 121 | + builder.append("\t \t cursor=\"rayOrigin: mouse\""); |
| 122 | + builder.append("\n"); |
| 123 | + builder.append("\t \t embedded=\"true\""); |
| 124 | + builder.append("\n"); |
| 125 | + builder.append("\t >"); |
| 126 | + builder.append("\n"); |
| 127 | + builder.append("\t\t <a-entity"); |
| 128 | + builder.append("\n"); |
| 129 | + builder.append("\t\t \t id=\"camera\""); |
| 130 | + builder.append("\n"); |
| 131 | + builder.append("\t\t \t camera=\"fov: 80; zoom: 1;\""); |
| 132 | + builder.append("\n"); |
| 133 | + builder.append("\t\t \t position=\"44.0 20.0 44.0\""); |
| 134 | + builder.append("\n"); |
| 135 | + builder.append("\t\t \t"); |
| 136 | + builder.append("rotation=\"0 -90 0\""); |
| 137 | + builder.append("\n"); |
| 138 | + builder.append("\t\t \t orbit-camera=\""); |
| 139 | + builder.append("\n"); |
| 140 | + builder.append("\t\t \t \t target: 15.0 1.5 15.0;"); |
| 141 | + builder.append("\n"); |
| 142 | + builder.append("\t\t \t \t enableDamping: true;"); |
| 143 | + builder.append("\n"); |
| 144 | + builder.append("\t\t \t \t dampingFactor: 0.25;"); |
| 145 | + builder.append("\n"); |
| 146 | + builder.append("\t\t \t \t rotateSpeed: 0.25;"); |
| 147 | + builder.append("\n"); |
| 148 | + builder.append("\t\t \t \t panSpeed: 0.25;"); |
| 149 | + builder.append("\n"); |
| 150 | + builder.append("\t\t \t \t invertZoom: true;"); |
| 151 | + builder.append("\n"); |
| 152 | + builder.append("\t\t \t \t logPosition: false;"); |
| 153 | + builder.append("\n"); |
| 154 | + builder.append("\t\t \t \t minDistance:0;"); |
| 155 | + builder.append("\n"); |
| 156 | + builder.append("\t\t \t \t maxDistance:1000;"); |
| 157 | + builder.append("\n"); |
| 158 | + builder.append("\t\t \t \t \""); |
| 159 | + builder.append("\n"); |
| 160 | + builder.append("\t\t \t mouse-cursor=\"\""); |
| 161 | + builder.append("\n"); |
| 162 | + builder.append("\t\t \t\t >"); |
| 163 | + builder.append("\n"); |
| 164 | + builder.append("\t\t </a-entity>"); |
| 165 | + builder.append("\n"); |
| 166 | + return builder.toString(); |
| 167 | + } |
| 168 | + |
| 169 | + public static String AFrameTail() { |
| 170 | + StringBuilder builder = new StringBuilder(); |
| 171 | + builder.append("\t\t </a-scene>"); |
| 172 | + builder.append("\n"); |
| 173 | + builder.append(" \t </body>"); |
| 174 | + builder.append("\n"); |
| 175 | + builder.append("</html>"); |
| 176 | + builder.append("\n"); |
| 177 | + return builder.toString(); |
| 178 | + } |
| 179 | +} |
0 commit comments