Author Topic: setRenderHook(shader) not compiling  (Read 2914 times)

Offline take2316

  • byte
  • *
  • Posts: 12
    • View Profile
setRenderHook(shader) not compiling
« 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: setRenderHook(shader) not compiling
« Reply #1 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.

Offline take2316

  • byte
  • *
  • Posts: 12
    • View Profile
Re: setRenderHook(shader) not compiling
« Reply #2 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: setRenderHook(shader) not compiling
« Reply #3 on: March 11, 2013, 07:55:31 am »
I see. I've added a note to the wiki to make this more clear.

Offline binspaul

  • byte
  • *
  • Posts: 4
    • View Profile
Re: setRenderHook(shader) not compiling
« Reply #4 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;
}
---
Thanks & Regards,
Binu Paul