setRenderHook(shader) not compiling

Started by take2316, March 10, 2013, 01:43:48 AM

Previous topic - Next topic

take2316

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)


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?

EgonOlsen

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.

take2316

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.

EgonOlsen

I see. I've added a note to the wiki to make this more clear.

binspaul

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;
}
---
Thanks & Regards,
Binu Paul