|
@@ -141,39 +141,9 @@ public class ReverseSceneServiceImpl implements IReverseSceneService {
|
|
|
|
|
|
JSONObject pose = new JSONObject();
|
|
|
sweepLocation.put("pose", pose);
|
|
|
- pose.put("rotation", observerObj.getJSONObject("quaternion"));
|
|
|
- JSONObject translation = new JSONObject();
|
|
|
- pose.put("translation", translation);
|
|
|
- JSONArray positions = observerObj.getJSONArray("position");
|
|
|
- for(int j = 0; j < positions.size(); j++){
|
|
|
- BigDecimal v = (BigDecimal) positions.get(j);
|
|
|
- if(j == 0){
|
|
|
- translation.put("x", v);
|
|
|
- }
|
|
|
- if(j == 1){
|
|
|
- translation.put("y", v);
|
|
|
- }
|
|
|
- if(j == 2){
|
|
|
- translation.put("z", v);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- JSONObject puck = new JSONObject();
|
|
|
- sweepLocation.put("puck", puck);
|
|
|
- JSONArray standing_positions = observerObj.getJSONArray("standing_position");
|
|
|
- for(int j = 0; j < standing_positions.size(); j++){
|
|
|
- BigDecimal v = (BigDecimal) standing_positions.get(j);
|
|
|
- if(j == 0){
|
|
|
- puck.put("x", v);
|
|
|
- }
|
|
|
- if(j == 1){
|
|
|
- puck.put("y", v);
|
|
|
- }
|
|
|
- if(j == 2){
|
|
|
- puck.put("z", v);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ pose.put("rotation", this.transferRrotation(observerObj));
|
|
|
+ pose.put("translation", this.transferPosition(observerObj, "position"));
|
|
|
+ sweepLocation.put("puck", this.transferPosition(observerObj, "standing_position"));
|
|
|
sweepLocation.put("group", 0);
|
|
|
sweepLocation.put("subgroup", observerObj.getInteger("floor_index"));
|
|
|
sweepLocation.put("device", 0);
|
|
@@ -204,6 +174,55 @@ public class ReverseSceneServiceImpl implements IReverseSceneService {
|
|
|
return observers.size();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private JSONObject transferPosition(JSONObject observerObj, String sourceKey){
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ JSONArray positions = observerObj.getJSONArray(sourceKey);
|
|
|
+ for(int j = 0; j < positions.size(); j++){
|
|
|
+ BigDecimal v = (BigDecimal) positions.get(j);
|
|
|
+ if(j == 0){
|
|
|
+ result.put("x", v);
|
|
|
+ }
|
|
|
+ if(j == 2){
|
|
|
+ result.put("y", v.negate());
|
|
|
+ }
|
|
|
+ if(j == 1){
|
|
|
+ result.put("z", v);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private JSONObject transferRrotation(JSONObject observerObj){
|
|
|
+ JSONObject rotation = new JSONObject();
|
|
|
+ JSONObject quaternion = observerObj.getJSONObject("quaternion");
|
|
|
+ rotation.put("x", quaternion.getBigDecimal("x"));
|
|
|
+ rotation.put("y", quaternion.getBigDecimal("z").negate());
|
|
|
+ rotation.put("z", quaternion.getBigDecimal("y"));
|
|
|
+ rotation.put("w", quaternion.getBigDecimal("w"));
|
|
|
+ return rotation;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+
|
|
|
+ List<String> strings = FileUtil.readUtf8Lines("D:\\test\\新疆\\src_model\\obj\\output_00.obj");
|
|
|
+ for(int i = 0; i < strings.size(); i++){
|
|
|
+ String string = strings.get(i);
|
|
|
+ StringBuilder result = new StringBuilder("v ");
|
|
|
+ if(string.startsWith("v ")){
|
|
|
+ String[] split = string.split(" ");
|
|
|
+ result.append(split[1]).append(" ");
|
|
|
+ result.append(split[3]).append(" ");
|
|
|
+ result.append(new BigDecimal(split[2]).negate());
|
|
|
+ strings.set(i, result.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ FileUtil.writeUtf8Lines(strings, "D:\\test\\新疆\\src_model\\obj\\222.obj");
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private void genPano(String num, String dataSource) throws Exception {
|
|
|
//全景图计算根目录
|
|
|
String target = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "reverseScene_images";
|
|
@@ -315,7 +334,23 @@ public class ReverseSceneServiceImpl implements IReverseSceneService {
|
|
|
FileUtil.copyContent(new File(dataSource + "/src_model/mtl/"), new File(filePath), true);
|
|
|
List<File> objFiles = FileUtil.loopFiles(new File(dataSource + "/src_model/obj/"));
|
|
|
for (File objFile : objFiles) {
|
|
|
- FileUtil.copyContent(objFile, new File(filePath + "mesh.obj"), true);
|
|
|
+ String name = objFile.getName();
|
|
|
+ if(!name.endsWith(".obj")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<String> strings = FileUtil.readUtf8Lines(objFile);
|
|
|
+ for(int i = 0; i < strings.size(); i++){
|
|
|
+ String string = strings.get(i);
|
|
|
+ StringBuilder result = new StringBuilder("v ");
|
|
|
+ if(string.startsWith("v ")){
|
|
|
+ String[] split = string.split(" ");
|
|
|
+ result.append(split[1]).append(" ");
|
|
|
+ result.append(split[3]).append(" ");
|
|
|
+ result.append(new BigDecimal(split[2]).negate());
|
|
|
+ strings.set(i, result.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FileUtil.writeUtf8Lines(strings, filePath + "mesh.obj");
|
|
|
}
|
|
|
this.writeDataJson(path);
|
|
|
CreateObjUtil.build3dModel(path , "1");
|