コード例 #1
0
 /**
  * The method applies properties to the given spatial. The Properties instance cannot be directly
  * applied because the end-user might not have the blender plugin jar file and thus receive
  * ClassNotFoundException. The values are set by name instead.
  *
  * @param spatial the spatial that is to have properties applied
  * @param properties the properties to be applied
  */
 public void applyProperties(Spatial spatial, Properties properties) {
   List<String> propertyNames = properties.getSubPropertiesNames();
   if (propertyNames != null && propertyNames.size() > 0) {
     for (String propertyName : propertyNames) {
       Object value = properties.findValue(propertyName);
       if (value instanceof Savable
           || value instanceof Boolean
           || value instanceof String
           || value instanceof Float
           || value instanceof Integer
           || value instanceof Long) {
         spatial.setUserData(propertyName, value);
       } else if (value instanceof Double) {
         spatial.setUserData(propertyName, ((Double) value).floatValue());
       } else if (value instanceof int[]) {
         spatial.setUserData(propertyName, Arrays.toString((int[]) value));
       } else if (value instanceof float[]) {
         spatial.setUserData(propertyName, Arrays.toString((float[]) value));
       } else if (value instanceof double[]) {
         spatial.setUserData(propertyName, Arrays.toString((double[]) value));
       }
     }
   }
 }