Author Topic: load a 3d model  (Read 9969 times)

Offline romromrom

  • byte
  • *
  • Posts: 4
    • View Profile
load a 3d model
« on: March 08, 2013, 05:14:39 pm »
I try to load a 3d model in jpct-ae.
I looked at all the tutorials and I think I understood, but I don't succeed to use the 3d files I have.

Indeed, I use the code that I found on this forum and which is present on tutorials for jpct. (-> http://www.jpct.net/forum2/index.php/topic,2076.msg15290/topicseen.html#msg15290)

Normally, it's working and it's without errors.

these is the code

   
Code: [Select]
package com.example.jpct;

    import java.io.*;

    import java.lang.reflect.Field;
    import javax.microedition.khronos.egl.EGL10;
    import javax.microedition.khronos.egl.EGLConfig;
    import javax.microedition.khronos.egl.EGLDisplay;
    import javax.microedition.khronos.opengles.GL10;

    import com.threed.jpct.*;

    import android.app.Activity;
    import android.opengl.GLSurfaceView;
    import android.os.Bundle;
    import android.view.MotionEvent;
    import android.content.res.AssetManager;
    import android.content.res.Resources;
    import android.opengl.GLSurfaceView.EGLConfigChooser;
    import android.opengl.GLSurfaceView.Renderer;
    import android.util.Log;

     public class MainActivity extends Activity {
    private String thingName = "exquisit3dchair";
    private int thingScale = 1;//end
private static MainActivity master = null;

private GLSurfaceView mGLView;
private MyRenderer renderer = null;
private FrameBuffer buffer = null;

private World world = null;
private RGBColor back = new RGBColor(50, 50, 100);

private float touchTurn = 0;
private float touchTurnUp = 0;

private float xpos = -1;
private float ypos = -1;

private Object3D thing = null;
private int fps = 0;

private Light sun = null;
private Camera cam = null;

AssetManager assMan;
InputStream is;
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
mGLView = new GLSurfaceView(getApplication());
renderer = new MyRenderer();
mGLView.setRenderer(renderer);
setContentView(mGLView);
}

@Override
protected void onPause() {
super.onPause();
mGLView.onPause();
}

@Override
protected void onResume() {
super.onResume();
mGLView.onResume();
}

protected void onStop() {
super.onStop();
}

public boolean onTouchEvent(MotionEvent me) {

if (me.getAction() == MotionEvent.ACTION_DOWN) {
xpos = me.getX();
ypos = me.getY();
return true;
}

if (me.getAction() == MotionEvent.ACTION_UP) {
xpos = -1;
ypos = -1;
touchTurn = 0;
touchTurnUp = 0;
return true;
}

if (me.getAction() == MotionEvent.ACTION_MOVE) {
float xd = me.getX() - xpos;
float yd = me.getY() - ypos;

xpos = me.getX();
ypos = me.getY();

touchTurn = xd / -100f;
touchTurnUp = yd / -100f;
return true;
}

try {
Thread.sleep(15);
} catch (Exception e) {
// No need for this...
}

return super.onTouchEvent(me);
}

protected boolean isFullscreenOpaque() {
return true;
}

class MyRenderer implements GLSurfaceView.Renderer {

private long time = System.currentTimeMillis();
private boolean stop = false;

public MyRenderer() {
}

public void stop() {
stop = true;
}

public void onSurfaceChanged(GL10 gl, int w, int h) {
if (buffer != null) {
buffer.dispose();
}
buffer = new FrameBuffer(gl, w, h);

if (master == null) {

world = new World();
        world.setAmbientLight(150, 150, 150);

sun = new Light(world);
sun.setIntensity(250, 250, 250);

thing = loadModel("res/" + thingName + ".3ds", thingScale);
        thing.build();

world.addObject(thing);

cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(thing.getTransformedCenter());

SimpleVector sv = new SimpleVector();
sv.set(thing.getTransformedCenter());
sv.y -= 100;
sv.z -= 100;
sun.setPosition(sv);
//MemoryHelper.compact();

if (master == null) {
Logger.log("Saving master Activity!");
master = MainActivity.this;
}
}
}

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
}

public void onDrawFrame(GL10 gl) {

try {
if (!stop) {
if (touchTurn != 0) {
thing.rotateY(touchTurn);
touchTurn = 0;
}

if (touchTurnUp != 0) {
thing.rotateX(touchTurnUp);
touchTurnUp = 0;
}

buffer.clear(back);
world.renderScene(buffer);
world.draw(buffer);
buffer.display();

if (System.currentTimeMillis() - time >= 1000) {
Logger.log(fps + "fps");
fps = 0;
time = System.currentTimeMillis();
}
fps++;
} else {
if (buffer != null) {
buffer.dispose();
buffer = null;
}
}
} catch (Exception e) {
Logger.log(e, Logger.MESSAGE);
}
}

    private Object3D loadModel(String filename, float scale) {
assMan = getResources().getAssets();
is= new InputStream() {
@Override
public int read() throws IOException {
return 0;
}
};
        Object3D[] model = Loader.load3DS(is,scale);
        Object3D o3d = new Object3D(0);
        Object3D temp = null;
        for (int i = 0; i < model.length; i++) {
            temp = model[i];
            temp.setCenter(SimpleVector.ORIGIN);
            temp.rotateX((float)( -.5*Math.PI));
            temp.rotateMesh();
            temp.setRotationMatrix(new Matrix());
            o3d = Object3D.mergeObjects(o3d, temp);
            o3d.build();
        }
        return o3d;
    }
}
     }

As you see, I use one object: exquisitchair.3ds, that I have found on this site:

http://thefree3dmodels.com/stuff/furniture/exquisite_3d_chair/12-1-0-120

My problem is simple: How tu put his file in Eclipse ?

I have tried in the "res" directory, it's said error, "invalid resource directory name", I have tried without the extension, I have tried other 3dfiles, and I have tried to create a "raw directory" or an example directory and to change the path.
But the problem remains the same.

The code has nos errors, but of course I couldn't compile for the moment.

Can you help me please ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: load a 3d model
« Reply #1 on: March 08, 2013, 05:34:40 pm »
Either copy them to res/raw (you'll have to create raw in most cases, but res should be present) and get the input stream like

Code: [Select]
getResources().openRawResource(R.raw.name);

or create an "assets"-directory in the project and get the stream like

Code: [Select]
getResources().getAssets().open("filename");

You should be able to find more detailed information in the SDK documentation and help, because this is basic Android stuff. It's not jPCT-specific.

Offline romromrom

  • byte
  • *
  • Posts: 4
    • View Profile
Re: load a 3d model
« Reply #2 on: March 11, 2013, 02:43:40 pm »
Thank you, I solved the first problem, by putting the 3ds file in the assets: there are no more erros.
But the applications didn't work.

I tried to use your tutorials. I have several 3ds files, but the applications fails each time:



Code: [Select]
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.UnsupportedEncodingException;
    import java.lang.reflect.Field;

    import javax.microedition.khronos.egl.EGL10;
    import javax.microedition.khronos.egl.EGLConfig;
    import javax.microedition.khronos.egl.EGLDisplay;
    import javax.microedition.khronos.opengles.GL10;

    import android.app.Activity;
    import android.content.res.AssetManager;
    import android.opengl.GLSurfaceView;
    import android.os.Bundle;
    import android.view.MotionEvent;

    import com.threed.jpct.Camera;
    import com.threed.jpct.FrameBuffer;
    import com.threed.jpct.Light;
    import com.threed.jpct.Loader;
    import com.threed.jpct.Logger;
    import com.threed.jpct.Object3D;
    import com.threed.jpct.Primitives;
    import com.threed.jpct.RGBColor;
    import com.threed.jpct.SimpleVector;
    import com.threed.jpct.Texture;
    import com.threed.jpct.TextureManager;
    import com.threed.jpct.World;
    import com.threed.jpct.util.BitmapHelper;
    import com.threed.jpct.util.MemoryHelper;
    import java.io.*;


    import com.threed.jpct.*;

    import android.content.res.Resources;
    import android.opengl.GLSurfaceView.EGLConfigChooser;
    import android.opengl.GLSurfaceView.Renderer;
    import android.util.Log;

     /**
     * A simple demo. This shows more how to use jPCT-AE than it shows how to write
     * a proper application for Android. It includes basic activity management to
     * handle pause and resume...
     *
     * @author EgonOlsen
     *
     */
    public class MainActivity extends Activity {

// Used to handle pause and resume...
private static MainActivity master = null;

private GLSurfaceView mGLView;
private MyRenderer renderer = null;
private FrameBuffer fb = null;
private World world = null;
private RGBColor back = new RGBColor(50, 50, 100);

private float touchTurn = 0;
private float touchTurnUp = 0;

private float xpos = -1;
private float ypos = -1;

private Object3D cube = null;
private int fps = 0;

private Light sun = null;

AssetManager assMan;
InputStream is;

private String thingName = "palm-realviz";
private int thingScale = 1;//end


protected void onCreate(Bundle savedInstanceState) {

Logger.log("onCreate");

if (master != null) {
copy(master);
}

super.onCreate(savedInstanceState);
mGLView = new GLSurfaceView(getApplication());

mGLView.setEGLConfigChooser(new GLSurfaceView.EGLConfigChooser() {
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
// Ensure that we get a 16bit framebuffer. Otherwise, we'll fall
// back to Pixelflinger on some device (read: Samsung I7500)
int[] attributes = new int[] { EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE };
EGLConfig[] configs = new EGLConfig[1];
int[] result = new int[1];
egl.eglChooseConfig(display, attributes, configs, 1, result);
return configs[0];
}
});

renderer = new MyRenderer();
mGLView.setRenderer(renderer);
setContentView(mGLView);
}

@Override
protected void onPause() {
super.onPause();
mGLView.onPause();
}

@Override
protected void onResume() {
super.onResume();
mGLView.onResume();
}

@Override
protected void onStop() {
super.onStop();
}

private void copy(Object src) {
try {
Logger.log("Copying data from master Activity!");
Field[] fs = src.getClass().getDeclaredFields();
for (Field f : fs) {
f.setAccessible(true);
f.set(this, f.get(src));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}

public boolean onTouchEvent(MotionEvent me) {

if (me.getAction() == MotionEvent.ACTION_DOWN) {
xpos = me.getX();
ypos = me.getY();
return true;
}

if (me.getAction() == MotionEvent.ACTION_UP) {
xpos = -1;
ypos = -1;
touchTurn = 0;
touchTurnUp = 0;
return true;
}

if (me.getAction() == MotionEvent.ACTION_MOVE) {
float xd = me.getX() - xpos;
float yd = me.getY() - ypos;

xpos = me.getX();
ypos = me.getY();

touchTurn = xd / -100f;
touchTurnUp = yd / -100f;
return true;
}

try {
Thread.sleep(15);
} catch (Exception e) {
// No need for this...
}

return super.onTouchEvent(me);
}

protected boolean isFullscreenOpaque() {
return true;
}

class MyRenderer implements GLSurfaceView.Renderer {

private long time = System.currentTimeMillis();

public MyRenderer() {
}

public void onSurfaceChanged(GL10 gl, int w, int h) {
if (fb != null) {
fb.dispose();
}
fb = new FrameBuffer(gl, w, h);

if (master == null) {

world = new World();
world.setAmbientLight(20, 20, 20);

sun = new Light(world);
sun.setIntensity(250, 250, 250);

// Create a texture out of the icon...:-)
Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(getResources().getDrawable(R.drawable.ic_launcher)), 64, 64));
TextureManager.getInstance().addTexture("texture", texture);


try {
cube = loadModel("assets/" + thingName + ".3ds", thingScale);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Primitives.getCube(10);
//cube.calcTextureWrapSpherical();
//cube.setTexture("texture");
//cube.strip();
cube.build();

world.addObject(cube);

Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(cube.getTransformedCenter());

SimpleVector sv = new SimpleVector();
sv.set(cube.getTransformedCenter());
sv.y -= 100;
sv.z -= 100;
sun.setPosition(sv);
MemoryHelper.compact();

if (master == null) {
Logger.log("Saving master Activity!");
master = MainActivity.this;
}
}
}

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
}

public void onDrawFrame(GL10 gl) {
if (touchTurn != 0) {
cube.rotateY(touchTurn);
touchTurn = 0;
}

if (touchTurnUp != 0) {
cube.rotateX(touchTurnUp);
touchTurnUp = 0;
}

fb.clear(back);
world.renderScene(fb);
world.draw(fb);
fb.display();

if (System.currentTimeMillis() - time >= 1000) {
Logger.log(fps + "fps");
fps = 0;
time = System.currentTimeMillis();
}
fps++;
}

   private Object3D loadModel(String filename, float scale) throws UnsupportedEncodingException {
   
   InputStream stream = new ByteArrayInputStream(filename.getBytes("UTF-8"));
        Object3D[] model = Loader.load3DS(stream, scale);
        Object3D o3d = new Object3D(0);
        Object3D temp = null;
        for (int i = 0; i < model.length; i++) {
            temp = model[i];
            temp.setCenter(SimpleVector.ORIGIN);
            temp.rotateX((float)( -.5*Math.PI));
            temp.rotateMesh();
            temp.setRotationMatrix(new Matrix());
            o3d = Object3D.mergeObjects(o3d, temp);
            o3d.build();
        }
        return o3d;
    }

    }
    }
 

So the applications fails, here is my logCat

Code: [Select]
    FATAL EXCEPTION: GLThread 93
    java.lang.RuntimeException: [ 1363008600568 ] - ERROR: Not a valid 3DS file!
at com.threed.jpct.Logger.log(Logger.java:189)
at com.threed.jpct.Loader.load3DS(Loader.java:1554)
  at com.threed.jpct.Loader.load3DS(Loader.java:154)
at com.example.jpct.MainActivity$MyRenderer.loadModel(MainActivity.java:269)
    at com.example.jpct.MainActivity$MyRenderer.onSurfaceChanged(MainActivity.java:207)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)


the 3d file is in the "assets" folder, and is a 3ds valid file (I tested it on other 3d engine)

I don' succeed ton load any 3ds file, even a simple cube. (But i succeeded with a jpct cube (getcube etc)
   


Can you help me please?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: load a 3d model
« Reply #3 on: March 11, 2013, 03:02:31 pm »
You are still not loading the file from the assets-directory. Just do what i posted above:

Code: [Select]
getResources().getAssets().open("filename");

to get the InputStream for that file.

Offline romromrom

  • byte
  • *
  • Posts: 4
    • View Profile
Re: load a 3d model
« Reply #4 on: March 11, 2013, 04:55:09 pm »
ok but I don't see where tu put it, how to use it
 I tried here, but the application still fails:

Code: [Select]
package com.example.jpct;

import java.io.IOException;
    import java.io.InputStream;
    import java.io.UnsupportedEncodingException;
    import java.lang.reflect.Field;

    import javax.microedition.khronos.egl.EGL10;
    import javax.microedition.khronos.egl.EGLConfig;
    import javax.microedition.khronos.egl.EGLDisplay;
    import javax.microedition.khronos.opengles.GL10;

    import android.app.Activity;
    import android.content.res.AssetManager;
    import android.opengl.GLSurfaceView;
    import android.os.Bundle;
    import android.view.MotionEvent;

    import com.threed.jpct.Camera;
    import com.threed.jpct.FrameBuffer;
    import com.threed.jpct.Light;
    import com.threed.jpct.Loader;
    import com.threed.jpct.Logger;
    import com.threed.jpct.Object3D;
    import com.threed.jpct.Primitives;
    import com.threed.jpct.RGBColor;
    import com.threed.jpct.SimpleVector;
    import com.threed.jpct.Texture;
    import com.threed.jpct.TextureManager;
    import com.threed.jpct.World;
    import com.threed.jpct.util.BitmapHelper;
    import com.threed.jpct.util.MemoryHelper;
    import java.io.*;


    import com.threed.jpct.*;

    import android.content.res.Resources;
    import android.opengl.GLSurfaceView.EGLConfigChooser;
    import android.opengl.GLSurfaceView.Renderer;
    import android.util.Log;

     /**
     * A simple demo. This shows more how to use jPCT-AE than it shows how to write
     * a proper application for Android. It includes basic activity management to
     * handle pause and resume...
     *
     * @author EgonOlsen
     *
     */
    public class HelloWorld extends Activity {

// Used to handle pause and resume...
private static HelloWorld master = null;

private GLSurfaceView mGLView;
private MyRenderer renderer = null;
private FrameBuffer fb = null;
private World world = null;
private RGBColor back = new RGBColor(50, 50, 100);

private float touchTurn = 0;
private float touchTurnUp = 0;

private float xpos = -1;
private float ypos = -1;

private Object3D cube = null;
private int fps = 0;

private Light sun = null;

AssetManager assMan;
InputStream is;

private String thingName = "index.3ds";
private int thingScale = 1;//end


protected void onCreate(Bundle savedInstanceState) {

Logger.log("onCreate");

if (master != null) {
copy(master);
}

super.onCreate(savedInstanceState);
mGLView = new GLSurfaceView(getApplication());

mGLView.setEGLConfigChooser(new GLSurfaceView.EGLConfigChooser() {
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
// Ensure that we get a 16bit framebuffer. Otherwise, we'll fall
// back to Pixelflinger on some device (read: Samsung I7500)
int[] attributes = new int[] { EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE };
EGLConfig[] configs = new EGLConfig[1];
int[] result = new int[1];
egl.eglChooseConfig(display, attributes, configs, 1, result);
return configs[0];
}
});

renderer = new MyRenderer();
mGLView.setRenderer(renderer);
setContentView(mGLView);
}

@Override
protected void onPause() {
super.onPause();
mGLView.onPause();
}

@Override
protected void onResume() {
super.onResume();
mGLView.onResume();
}

@Override
protected void onStop() {
super.onStop();
}

private void copy(Object src) {
try {
Logger.log("Copying data from master Activity!");
Field[] fs = src.getClass().getDeclaredFields();
for (Field f : fs) {
f.setAccessible(true);
f.set(this, f.get(src));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}

public boolean onTouchEvent(MotionEvent me) {

if (me.getAction() == MotionEvent.ACTION_DOWN) {
xpos = me.getX();
ypos = me.getY();
return true;
}

if (me.getAction() == MotionEvent.ACTION_UP) {
xpos = -1;
ypos = -1;
touchTurn = 0;
touchTurnUp = 0;
return true;
}

if (me.getAction() == MotionEvent.ACTION_MOVE) {
float xd = me.getX() - xpos;
float yd = me.getY() - ypos;

xpos = me.getX();
ypos = me.getY();

touchTurn = xd / -100f;
touchTurnUp = yd / -100f;
return true;
}

try {
Thread.sleep(15);
} catch (Exception e) {
// No need for this...
}

return super.onTouchEvent(me);
}

protected boolean isFullscreenOpaque() {
return true;
}

class MyRenderer implements GLSurfaceView.Renderer {

private long time = System.currentTimeMillis();

public MyRenderer() {
}

public void onSurfaceChanged(GL10 gl, int w, int h) {
if (fb != null) {
fb.dispose();
}
fb = new FrameBuffer(gl, w, h);

if (master == null) {

world = new World();
world.setAmbientLight(20, 20, 20);

sun = new Light(world);
sun.setIntensity(250, 250, 250);

// Create a texture out of the icon...:-)
Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(getResources().getDrawable(R.drawable.ic_launcher)), 64, 64));
TextureManager.getInstance().addTexture("texture", texture);


try {
cube = loadModel("assets/" + thingName + ".3ds", thingScale);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//Primitives.getCube(10);
//cube.calcTextureWrapSpherical();
//cube.setTexture("texture");
//cube.strip();
cube.build();

world.addObject(cube);

Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(cube.getTransformedCenter());

SimpleVector sv = new SimpleVector();
sv.set(cube.getTransformedCenter());
sv.y -= 100;
sv.z -= 100;
sun.setPosition(sv);
MemoryHelper.compact();

if (master == null) {
Logger.log("Saving master Activity!");
master = HelloWorld.this;
}
}
}

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
}

public void onDrawFrame(GL10 gl) {
if (touchTurn != 0) {
cube.rotateY(touchTurn);
touchTurn = 0;
}

if (touchTurnUp != 0) {
cube.rotateX(touchTurnUp);
touchTurnUp = 0;
}

fb.clear(back);
world.renderScene(fb);
world.draw(fb);
fb.display();

if (System.currentTimeMillis() - time >= 1000) {
Logger.log(fps + "fps");
fps = 0;
time = System.currentTimeMillis();
}
fps++;
}

   private Object3D loadModel(String filename, float scale) throws IOException {
   
   InputStream stream = getResources().getAssets().open(filename);

        Object3D[] model = Loader.load3DS(stream, scale);
        Object3D o3d = new Object3D(0);
        Object3D temp = null;
        for (int i = 0; i < model.length; i++) {
            temp = model[i];
            temp.setCenter(SimpleVector.ORIGIN);
            temp.rotateX((float)( -.5*Math.PI));
            temp.rotateMesh();
            temp.setRotationMatrix(new Matrix());
            o3d = Object3D.mergeObjects(o3d, temp);
            o3d.build();
        }
        return o3d;
    }

    }
    }

here the LogCat

Code: [Select]
FATAL EXCEPTION: main
 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo java.lang.ClassNotFoundException: com.example.jpct.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.jpct-2.apk]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
  at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
  at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.ClassNotFoundException: com.example.jpct.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.jpct-2.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
... 11 more

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: load a 3d model
« Reply #5 on: March 11, 2013, 07:25:41 pm »
That exception has nothing to do with the model loading. Looks like as if you've defined an Activity called MainActivity in your project's setup but your class isn't called like that. Fix your project setup.

Offline romromrom

  • byte
  • *
  • Posts: 4
    • View Profile
Re: load a 3d model
« Reply #6 on: March 12, 2013, 10:51:26 am »
ok you were right, I changed th activity name in the manifest.

Now I have this in my LogCat

 
Code: [Select]
  java.io.FileNotFoundException: assets/exquisit3dchair.3ds
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:317)
at android.content.res.AssetManager.open(AssetManager.java:291)
at com.example.jpct.HelloWorld$MyRenderer.loadModel(HelloWorld.java:267)
at com.example.jpct.HelloWorld$MyRenderer.onSurfaceChanged(HelloWorld.java:206)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1381)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1138)
exiting tid=10
threadid=9: thread exiting with uncaught exception (group=0x4001e578)
 
FATAL EXCEPTION: GLThread 10
 java.lang.NullPointerException
 at com.example.jpct.HelloWorld$MyRenderer.onSurfaceChanged(HelloWorld.java:216)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1381)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1138)


If I understand well, It doesn't found the file. But the file is in the assets directory, and You can see the codes in the precedent post
« Last Edit: March 12, 2013, 10:54:41 am by romromrom »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: load a 3d model
« Reply #7 on: March 12, 2013, 01:05:56 pm »
Not

Code: [Select]
assets/exquisit3dchair.3ds

just

Code: [Select]
exquisit3dchair.3ds

Offline binspaul

  • byte
  • *
  • Posts: 4
    • View Profile
Re: load a 3d model
« Reply #8 on: July 20, 2013, 04:57:50 am »
Hello,

I was able to integrate Vuforia with jPCT-AE. I was also able to load the 3D chair model using the code segments described in this thread. But, the model is not rendered correctly. The rear legs of the chair are misplaced. Is it due to the issue in the model or is it because of the FOV (Field of Vision) issue?

When I followed the steps specified in the post: http://www.jpct.net/wiki/index.php/Integrating_JPCT-AE_with_Vuforia for setting up the FOV, the model is disappearing. How can I correct this issue?

Thanks,
Binu Paul.

[attachment deleted by admin]
Thanks & Regards,
Binu Paul

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: load a 3d model
« Reply #9 on: July 20, 2013, 08:57:11 pm »
I can't try the model ATM, but i'm pretty sure that it's an issue with the model. The 3ds loader doesn't fully support all kinds of transformations that can be part of a 3ds. Sometimes it helps to load them in some other tool (one that actually loads it fine, if you can find such thing...a lot of them are having the same problem that my importer has) and export it again.
Do you have a screen shot?