www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: take2316 on March 10, 2013, 01:43:48 am

Title: setRenderHook(shader) not compiling
Post by: take2316 on March 10, 2013, 01:43:48 am
Eclipse is giving me this error for the following code:
The method setRenderHook(IRenderHook) in the type Object3D is not applicable for the arguments (GLSLShader)

Code: [Select]
GLSLShader shader = new GLSLShader(vertex, fragment);
cube.setRenderHook(shader);
world.addObject(cube);

I tried casting shader to an IRenderHook, but when the code runs, I get this fatal exception error: E/AndroidRuntime(30731): java.lang.ClassCastException: com.threed.jpct.GLSLShader cannot be cast to com.threed.jpct.IRenderHook

Any ideas on how to fix this?
Title: Re: setRenderHook(shader) not compiling
Post by: EgonOlsen on March 10, 2013, 09:15:10 am
That's the way you are doing it desktop jPCT. In jPCT-AE, you have a dedicated setShader()-method. Please refer to AE's documentation, not desktop jPCT's.
Title: Re: setRenderHook(shader) not compiling
Post by: take2316 on March 11, 2013, 04:29:37 am
Thanks, it works now. I was following the wiki page: http://www.jpct.net/wiki/index.php/Shaders but had forgotten that jPCT-AE might work differently.
Title: Re: setRenderHook(shader) not compiling
Post by: EgonOlsen on March 11, 2013, 07:55:31 am
I see. I've added a note to the wiki to make this more clear.
Title: Re: setRenderHook(shader) not compiling
Post by: binspaul on July 18, 2013, 01:59:50 pm
Hi,

1. I am working on the integration with Vuforia. I was able to load the 3D model of chair using the following code. But, the app is very slow in initializing. is there any method to optimize the integration.

2. I don't want to have the 3D model displayed when I am out of the reference image and want to track when I am on the reference image again. How can I achieve that?

---
/** Called to draw the current frame. */
public void onDrawFrame(GL10 gl)
{
   if (!mIsActive)
      return;

   // Update render view (projection matrix and viewport) if needed:
   mActivity.updateRenderView();

   // Call our native function to render content
   renderFrame();
   
   updateCamera();
   
   world.renderScene(fb);
   world.draw(fb);
   fb.display();
}

public void updateModelviewMatrix(float mat[]) {
   modelViewMat = mat;
}

public void updateCamera() {
   Matrix m = new Matrix();
   
   if(modelViewMat!=null) {
      m.setDump(modelViewMat);
      cam.setBack(m);
   }
}

private Object3D loadModel(String filename, float scale) {
   Object3D o3d = null;
   try {          
      Object3D[] model = Loader.load3DS(mActivity.getResources().getAssets().open(filename),scale);
      o3d = new Object3D(0);
      Object3D temp = null;
      for (int i = 0; i < model.length; i++) {
         temp = model;
         temp.setCenter(SimpleVector.ORIGIN);
         temp.rotateX((float)( -.5*Math.PI));
         temp.rotateMesh();
         temp.setRotationMatrix(new Matrix());
         o3d = Object3D.mergeObjects(o3d, temp);
         o3d.build();
      }
      
   } catch(Exception e) {}
   
   return o3d;
}
---