Exemple #1
0
 public static SECameraData loadCameraDataFromXml(XmlPullParser parser) {
   SECameraData cameraData = new SECameraData();
   try {
     cameraData.mFov = Float.valueOf(parser.getAttributeValue(null, ThemeColumns.FOV));
     cameraData.mNear = Float.valueOf(parser.getAttributeValue(null, ThemeColumns.NEAR));
     cameraData.mFar = Float.valueOf(parser.getAttributeValue(null, ThemeColumns.FAR));
     XmlUtils.nextElement(parser);
     while (true) {
       String item = parser.getName();
       if (ThemeColumns.LOCATION.equals(item)) {
         cameraData.mLocation = new SEVector3f();
         cameraData.mLocation.initFromXml(parser);
         XmlUtils.nextElement(parser);
       } else if (ThemeColumns.ZAXIS.equals(item)) {
         cameraData.mAxisZ = new SEVector3f();
         cameraData.mAxisZ.initFromXml(parser);
         XmlUtils.nextElement(parser);
       } else if (ThemeColumns.UP.equals(item)) {
         cameraData.mUp = new SEVector3f();
         cameraData.mUp.initFromXml(parser);
         XmlUtils.nextElement(parser);
       } else {
         break;
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return cameraData;
 }
Exemple #2
0
 public static HashMap<String, String> loadSpecialAttributeForModel(
     Context context, ModelInfo modelInfo) {
   InputStream is = null;
   try {
     HashMap<String, String> values = new HashMap<String, String>();
     String assetPath = modelInfo.mAssetsPath;
     if (assetPath.contains("assets")) {
       // length of "assets/" is 7
       String filePath = assetPath.substring(7) + "/special_config.xml";
       is = context.getAssets().open(filePath);
     } else {
       is = new FileInputStream(assetPath + "/special_config.xml");
     }
     XmlPullParser parser = Xml.newPullParser();
     parser.setInput(is, "utf-8");
     XmlUtils.beginDocument(parser, "config");
     XmlUtils.nextElement(parser);
     while (true) {
       String name = parser.getName();
       if (TextUtils.isEmpty(name)) {
         break;
       }
       values.put(name, parser.getAttributeValue(null, "value"));
       XmlUtils.nextElement(parser);
     }
     return values;
   } catch (XmlPullParserException e) {
   } catch (IOException e) {
   } finally {
     try {
       if (is != null) {
         is.close();
       }
     } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   return null;
 }