Re: load a .obj file in JPCT-AE demo

Started by RhoX, July 29, 2011, 11:35:42 PM

Previous topic - Next topic

RhoX

Alright. Now I've realized that.  "Wrong positions" I meant something related to the scene, but - like you said - those commands werent about loading a scene setup. I've misundertood. Sorry.

In fact, I'm with a problem loading up my models: I've separated the code for loading the model from the onDrawFrame method, and now  I doesnt show up anything at the scene. In terms of code, it is...

I have my method for loading models:


public Object3D arrangeWorld(int objType)
{
Object3D mainTemp = null;
switch (objType)
{
//.OBJ
case 0:
break;
//.MD2
case 1:
mainTemp = Loader.loadSerializedObject(res.openRawResource(R.raw.serbird_final));

Texture birdy = new Texture(res.openRawResource(R.raw.bird_final));
tm.addTexture("bird_final", birdy);

mainTemp.setCenter(SimpleVector.ORIGIN);
//mainTemp.rotateX((float)( -.5*Math.PI));
            mainTemp.rotateMesh();
mainTemp.setRotationMatrix( new Matrix() );
mainTemp.setTexture("bird_final");
break;
//.3DS
case 2:
Object3D temp = null;
Object3D chair[] = new Object3D[7];

chair[0] = Loader.loadSerializedObject(res.openRawResource(R.raw.serchair0));
chair[1] = Loader.loadSerializedObject(res.openRawResource(R.raw.serchair1));
chair[2] = Loader.loadSerializedObject(res.openRawResource(R.raw.serchair2));
chair[3] = Loader.loadSerializedObject(res.openRawResource(R.raw.serchair3));
chair[4] = Loader.loadSerializedObject(res.openRawResource(R.raw.serchair4));
chair[5] = Loader.loadSerializedObject(res.openRawResource(R.raw.serchair5));
chair[6] = Loader.loadSerializedObject(res.openRawResource(R.raw.serchair6));

Texture chairy = new Texture(res.openRawResource(R.raw.decoo));
tm.addTexture("chair", chairy);

int l = chair.length;
for(int i = 0; i < l; i++)
{
temp = chair[i];
temp.setCenter(SimpleVector.ORIGIN);
temp.rotateX((float)( -.5*Math.PI));
            temp.rotateMesh();
temp.setRotationMatrix( new Matrix() );
temp.setTexture("chair");
mainTemp = Object3D.mergeObjects(mainTemp, temp);
}
break;
default:

}

return mainTemp;
}


And, in  the onDrawFrame method I have the following sequence:


//... some other codes
mainObj = new Object3D(arrangeWorld(objType));

world.addObject(mainObj);
world.buildAllObjects();
//... some other codes


What do you think about that?

ps: Sorry if here isnt the right place to make this question =/

EgonOlsen

Looks fine at first glance. Maybe the objects are out of sight or too small or unlit?

RhoX

No, It doesnt seem to be a problem related to sight, or size. Cause when I try to use tha "mainObj", it is an empty object. I doesnt have the characteristcs of the model created in arrangeWorld() method. And, when I tried to use cloneObject() like this:

mainObj = (arrangeWorld(objType)).cloneObject();

I get a NullPointerException =/.

EgonOlsen

Which value does objType actually have?

RhoX

Man, it worked!

Actually, from your post, I started to search where the objType was beeing assigned. Then I discovered: nowhere XD!

Thank you very much for your attention!