예제 #1
0
 protected void setScale(ModelInfo objInfo, BasicModelData obj) {
   double scaleX =
       randomizeDouble(objInfo.getScaleSettings().getMinX(), objInfo.getScaleSettings().getMaxX());
   if (objInfo.getScaleSettings().isEqual()) {
     obj.setScale(scaleX, scaleX, scaleX);
   } else {
     obj.setScale(
         scaleX,
         randomizeDouble(
             objInfo.getScaleSettings().getMinY(), objInfo.getScaleSettings().getMaxY()),
         randomizeDouble(
             objInfo.getScaleSettings().getMinZ(), objInfo.getScaleSettings().getMaxZ()));
   }
 }
예제 #2
0
 protected void correctPosition(
     BasicModelData obj, PositionSettings pos, List<HeightInfo> positions) {
   double xVar = xRatio;
   double zVar = zRatio;
   double x = obj.getX();
   double z = obj.getZ();
   if (!positions.isEmpty() || collisionTree != null) {
     HeightInfo actual = new HeightInfo(obj.getX(), 0, obj.getZ());
     HeightInfo nearest = new HeightInfo(Double.MAX_VALUE, 0, Double.MAX_VALUE);
     if (!positions.isEmpty()) {
       nearest = findNearest(positions, actual, nearest);
       x = nearest.getX();
       z = nearest.getZ();
     }
     if (collisionTree != null) {
       actual.setSx(obj.getSx());
       actual.setSz(obj.getSz());
       TreeNode place = collisionTree.findPlace(actual);
       if (place != null) {
         x = place.getMid()[0];
         z = place.getMid()[1];
         double nodeRange = place.getRange();
         xVar = nodeRange + 1 - actual.getSx();
         zVar = nodeRange + 1 - actual.getSz();
         TreeNode.mark(place);
       } else {
         collisionDetected = true;
       }
     }
   }
   obj.setX(x + randomizeDouble(-xVar, xVar));
   obj.setZ(z + randomizeDouble(-zVar, zVar));
   correctPosition(obj, pos);
 }
예제 #3
0
 protected void setRotation(ModelInfo objInfo, BasicModelData obj) {
   obj.setRotation(
       randomizeDouble(
           objInfo.getRotationSettings().getMinX(), objInfo.getRotationSettings().getMaxX()),
       randomizeDouble(
           objInfo.getRotationSettings().getMinY(), objInfo.getRotationSettings().getMaxY()),
       randomizeDouble(
           objInfo.getRotationSettings().getMinZ(), objInfo.getRotationSettings().getMaxZ()));
 }
예제 #4
0
 protected void setPosition(
     PositionSettings pos, List<HeightInfo> heights, BasicModelData obj, int heightPos) {
   HeightInfo height = heights.get(heightPos);
   obj.setPosition(
       height.getX() + randomizeDouble(-xRatio, xRatio),
       randomizeDouble(pos.getMinY(), pos.getMaxY()),
       height.getZ() + randomizeDouble(-zRatio, zRatio));
   correctPosition(obj, pos, heights);
 }
예제 #5
0
 protected void correctPosition(BasicModelData obj, PositionSettings pos) {
   if (obj.getX() > pos.getMaxX()) {
     obj.setX(pos.getMaxX() - randomizeDouble(0, xRatio));
   }
   if (obj.getX() < pos.getMinX()) {
     obj.setX(pos.getMinX() + randomizeDouble(0, xRatio));
   }
   if (obj.getZ() > pos.getMaxZ()) {
     obj.setZ(pos.getMaxZ() - randomizeDouble(0, zRatio));
   }
   if (obj.getZ() < pos.getMinZ()) {
     obj.setZ(pos.getMinZ() + randomizeDouble(0, zRatio));
   }
 }