Je veux afficher un objet 3D dans une application Android en utilisant le cadre Rajawali. J'ai créé un objet 3D avec Autodesk 3DS MAX. (J'ai lu des articles qu'il est recommandé d'utiliser blender.Mais j'ai téléchargé un modèle que je veux utiliser et son un fichier .3ds)Afficher .obj dans Android en utilisant Rajawali ne fonctionne pas
Je mets le .obj et .mtl dans le dossier brut (renommé les fichiers comme recommandé dans mymodel_obj et mymodel_mtl), je créé une classe Renderer:
public class Renderer extends RajawaliRenderer {
private Context context;
private Object3D mObject;
//constructor
public Renderer(Context context) {
super(context);
this.context = context;
setFrameRate(60);
}
@Override
protected void initScene() {
try {
LoaderOBJ objParser = new LoaderOBJ(context.getResources(),mTextureManager, R.raw.denture_obj);
objParser.parse();
mObject = objParser.getParsedObject();
getCurrentScene().addChild(mObject);
}catch (ParsingException e){
e.printStackTrace();
}
}
@Override
public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) {}
@Override
public void onTouchEvent(MotionEvent event) {}
}
Je veux afficher le modèle dans un fragment. Ceci est le Fragment:
public class VisualizationFragment extends Fragment {
private IRajawaliSurface surface;
private Renderer mRenderer;
private final static String TAG = "VFRAG";
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View v = inflater.inflate(R.layout.visualization_frag, container, false);
mRenderer = new Renderer(getActivity());
applyRenderer(v);
return v;
}
protected void applyRenderer(View v) {
surface = (IRajawaliSurface) v.findViewById(R.id.brush_surface);
surface.setSurfaceRenderer(mRenderer);
}
}
Quand je commence ma demande que je viens d'obtenir un fond noir sans modèle et les erreurs suivantes:
11-25 20:33:19.677 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uModelMatrix returned -1!
11-25 20:33:19.678 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uTime returned -1!
11-25 20:33:19.683 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uModelMatrix returned -1!
11-25 20:33:19.683 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uTime returned -1!
11-25 20:33:19.686 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uModelMatrix returned -1!
11-25 20:33:19.686 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uTime returned -1!
11-25 20:33:19.689 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uModelMatrix returned -1!
11-25 20:33:19.689 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uTime returned -1!
J'ai aussi essayé d'exporter mon modèle dans le format 3ds, puis l'a importé dans un mélangeur et exporté à nouveau en .obj. Mais ça ne marche pas, aussi. J'ai fait attention aux règles d'exportation suivantes: https://github.com/Rajawali/Rajawali/wiki/Tutorial-17-Importing-.Obj-Files Mais je ne trouve pas l'option "Inclure les normales" dans blender, j'ai donc choisi "Écrire des normales".