public void LoadObjects(ProjectLevel p) { for (int i = 0; i < p.getModels().size(); i++) { mParser = new ObjParser(this, p.getModels().get(i).getModel()); mParser.parse(); BaseObject3D obj = mParser.getParsedObject(); obj.setDepthMaskEnabled(true); obj.setDepthTestEnabled(true); obj.setBlendingEnabled(true); obj.setBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); if (p.getModels().get(i).isDoubleSided()) { obj.setDoubleSided(true); } if (p.getModels().get(i).isVideo()) { // Log.d("isvideo", "yeees"); // obj.setMaterial(vmaterial); // obj.addTexture(vt); } else { obj.setMaterial(new SimpleMaterial()); String tn = p.getModels().get(i).getTexture(); if (!textureNames.contains(tn)) { textureNames.add(tn); // store texture names for unique // textures int idx = textureNames.indexOf(tn); // get index Bitmap mBM = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + tn); TextureInfo ti = mTextureManager.addTexture(mBM); textureInfos.add(idx, ti); // store texture info with same // index as texture name obj.addTexture(ti); } else { int idx = textureNames.indexOf(tn); obj.addTexture(textureInfos.get(idx)); } } addChild(obj); BoundingBox bb = obj.getGeometry().getBoundingBox(); Number3D mi = bb.getMin(); Number3D mx = bb.getMax(); Number3D cnt = new Number3D((mi.x + mx.x) / 2, (mi.y + mx.y) / 2, (mi.z + mx.z) / 2); p.getModels().get(i).setCenter(cnt); p.getModels().get(i).setObj(obj); } Log.d("objloader", "objects in scene:" + getNumChildren()); }
public void setBounds(Vector3 min, Vector3 max) { mBounds.setMin(min); mBounds.setMax(max); }