Inside tests

Inside test

Realsoft's rendering engine supports true boolen operations and can tell wheter a point is inside an object or not.

Prepare for inside test


    #include <real/raytr/r3freng.h>

    /* create rendering engine */
    rend = R3New(R3CLID_FRENGINE, R3TAG_END);

    /* pass scene to the renderer */
    R3DoA(rend, R3FRM_BEGINWORLD, NULL);
    R3DoA(root, R3PRIMM_RENDER,
          R3T(R3PRIMA_RenderEngine, rend),
          R3T(R3PRIMA_RenderAlways, TRUE),
          R3TAG_END);
    R3DoA(dreng, R3FRM_ENDWORLD, NULL);

Then you can


   R3BOOL hitfound;

   R3VECTOR *points = ...; 
   int pcount = ...;
   
   for(i = 0; i < pcount; i++) {
      hitfound = (R3BOOL)R3DoA(rend, R3FRM_FINDINSIDE, &p);
      if(hitfound) {
          // do something
      }
    }

When you no longer need the renderer, dispose it:

    R3Dispose(rend);