Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - indigo

#1
Support / Re: When to load the models?
December 01, 2012, 11:38:26 PM
Ah, thanks. I forgot I could just pass the context around. :)
#2
Support / [solved] When to load the models?
December 01, 2012, 11:24:00 PM
Hi all,
My question would basically be when it is a good idea to load the models? I am playing around with a very small test App (just the MainActivity and a MyRenderer implementing Renderer). Right now, I trying to create my Object3Ds in MyRenderer's OnSurfaceCreated method. This works fine as long as I do something primitive like
model = Primitives.getBox(1.f, 1.f);

However, if I try and load an actual model like this:
InputStream in = Resources.getSystem().openRawResource(R.raw.model);
model = Loader.load3DS(in, 1.f)[0];


I run into problems:
Exception android.content.res.Resources$NotFoundException(<No current context>)
  breakpoint hit in android.opengl.GLSurfaceView$GLThread at line 1244 by thread <11> GLThread 81.


Apparently, this is the case because the Resources are only available from the Activity, not from the Renderer. On the other hand, the Renderer is where my World and all the other goodness is at, so loading it from the Activity is not viable either. What is the preferred way of going about this?

Thanks in advance.
#3
Support / Re: Problem with Camera - Object collision
October 27, 2011, 08:10:58 PM
Erm, sorry. Ostensibly I ran an old build or something (it worked now after I restarted the emulator).

Thanks for your time though!
#4
Support / Problem with Camera - Object collision
October 27, 2011, 07:26:54 PM
Hi,
First to introduce myself: I'm new here. Wowzah.

I did install JPCT-AE today and downloaded the basic example code, and I was able to compile and run it in the emulator. I then wanted to build a bit more around that barebone. I intended to make the camera moveable and colliding with objects.

I added/changed the following parts of the main class (just toying around):
onKeyDown (in HelloWorld) public boolean onKeyDown(int kc, KeyEvent e) {

if (kc == KeyEvent.KEYCODE_DPAD_UP) {
if (world.checkCameraCollision(Camera.CAMERA_MOVEIN, 2.f)) {
AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Collision");
alertDialog.setMessage("Happens.");
alertDialog.show();
}

} else if (kc == KeyEvent.KEYCODE_DPAD_DOWN) {
        world.checkCameraCollision(Camera.CAMERA_MOVEOUT, 2.f);
} else {
                        return false;
                }

return true;

}

in onSurfaceChanged (in MyRenderer) cube = Primitives.getSphere(10); //ik...
cube.calcTextureWrapSpherical();
cube.setTexture("texture");
cube.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
cube.strip();
cube.build();

Of course I also did the necessary import for the AlertDialog.

Yet it doesn't work: I get neither an AlertDialog nor does the camera stop when it hits the sphere.

Is my code wrong and can you help me correct it or am I going entirely the wrong way?

Thanks!