Author Topic: request some new functions  (Read 5643 times)

Offline pitt

  • byte
  • *
  • Posts: 13
    • View Profile
request some new functions
« on: May 03, 2006, 10:57:38 am »
Hi, Egon. I need your help to continue my project.

- Could you enable the rest of PixelFormat args please.

PixelFormat(int bpp, int alpha, int depth, int stencil, int samples, int num_aux_buffers, int accum_bpp, int accum_alpha, boolean stereo)
 
You might add more variables in Config Ex. Config.glStencilBpp


- just draw a specific face by objid,polyid retrieved from VisList

World.draw(FrameBuffer buffer,int objid,int polyid)


These should be enough to make real time shadow in my project.

Thank you very much.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: request some new functions
« Reply #1 on: May 03, 2006, 05:36:00 pm »
Quote from: "pitt"

- just draw a specific face by objid,polyid retrieved from VisList

World.draw(FrameBuffer buffer,int objid,int polyid)
Wouldn't it be possible to simply use a different World/VisList instead?

Offline pitt

  • byte
  • *
  • Posts: 13
    • View Profile
request some new functions
« Reply #2 on: May 04, 2006, 04:29:25 am »
I don't get it. :?  

Here is my brief code for realtime shadow.



while (true)
{

  GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);

   World.renderScene(FrameBuffer);

    for (int i=0;i<VisList.getMaxSize();i++)
    {
      VisList.getData(i,data);
      if (IsShadowReceiver(data))
     {
          //render the face and the shadow
          glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
          glStencilFunc(GL_ALWAYS, 0x1, 0);
          glEnable(GL_DEPTH_TEST);
     
          //draw the face with stencil mask
             World.draw(FrameBuffer,Interact2D.getObjectID(data),Interact2D.getPolygonID(data));
            glDisable(GL_DEPTH_TEST);
   
          //projective shadow          
          glStencilFunc(GL_EQUAL, 1, 1);
          glEnable(GL_BLEND);
          list=shadowpolygon(data,lightpos);     //find the object that cast a shadow on this face
          for (int j=0;j<list.length;j++)
          {
           shadowmatrix(matrix,data,lightpos);  //create the matrix to project a shadow polygon on the face
           GL11.glPushMatrix();
           GL11.glMultMatrix(matrix);
           mydraw(list[j]);              //draw the projective shadow
           GL11.glPopMatrix();   
          }
          glDisable(GL_BLEND);

         //remove the stencil mask
         glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
         World.draw(FrameBuffer,Interact2D.getObjectID(data),Interact2D.getPolygonID(data));
         glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
      } else  
     {
       //no shadow just render the face
       World.draw(FrameBuffer,Interact2D.getObjectID(data),Interact2D.getPolygonID(data));
      }
    }

    FrameBuffer.update();
    FrameBuffer.updateGLOnly();
    Thread.yield();
}

Any suggestion?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
request some new functions
« Reply #3 on: May 05, 2006, 07:48:35 am »
I'll look at it next week (not at home during the weekend).

Offline pitt

  • byte
  • *
  • Posts: 13
    • View Profile
request some new functions
« Reply #4 on: May 05, 2006, 10:16:13 am »
Thanks a lot!  :D

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
request some new functions
« Reply #5 on: May 08, 2006, 06:54:25 pm »
Ok...it should be possible to add this. In fact, it's already there in the IRenderer-interface. You just can't use it because the actual renderer is not accessable by the API ATM. So the easiest way would be to make it accessable. But then, you would throw a lot of jPCT's optimizations out of the window by drawing each face separately. Would it be better to do something like draw(<VisList>, indexStart, indexEnd) instead to draw a batch of faces that are no shadow recievers in one call? If this possible for shadow recievers too? I.e. draw a batch of shadow revievers (by jPCT), draw a batch of shadows (on your own), draw the recievers again with  glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE)?

Offline pitt

  • byte
  • *
  • Posts: 13
    • View Profile
request some new functions
« Reply #6 on: May 09, 2006, 07:07:34 am »
That's great! ok.  :D

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
request some new functions
« Reply #7 on: May 10, 2006, 08:24:02 pm »
Ok, i've uploaded a modified version here: http://www.jpct.net/download/beta/jpctapi112_pre1.zip

You may now draw only parts of the visibility list as well as provide your own DisplayMode and/or PixelFormat for the GLRenderer (but i haven't tested this feature yet...) using Config.glAdditionalConfiguration.

I'm not sure if this is sufficient for you to add your shadow stuff. Just have a look.