Detect Polys Hidden From Viewport Camera?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/03/2011 at 15:28, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   12 
    Platform:      Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    I'm drawing onto an object's polygons with DrawTexture().

    I want to draw onto polys facing the camera and not hidden by other objects. BackfaceCulling() lets me skip polys facing away from the camera but the drawing is visible though other objects.

    Is there a way of detecting whether a poly is hidden from the viewport camera by another object?

    While searching I came across unresolved questions about BackfaceCulling() usage. For the archives, it works in camera space:-
    face normal: bd.WC_V(global_normal)
    face centre: bd.WC(global_position)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/03/2011 at 16:40, xxxxxxxx wrote:

    Howdy,

    Take a look at the GeRayCollider class. Do a search here for it and you'll find quite a bit if info.

    Adios,
    Cactus Dan



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/03/2011 at 02:36, xxxxxxxx wrote:

    Thanks, I'm getting my head around it now. I'm not sure how this will go speed-wise but it seems to be the best option.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/03/2011 at 03:58, xxxxxxxx wrote:

    Well, I've given it a shot. For each poly, I sent a ray from the camera to the poly centre and tested every object in the scene for intersection with the ray. This detected the hidden polys perfectly but was unfortunately prohibitively slow.

    Unless there's another approach, it seems that I may have to accept my drawn elements showing through other objects.

    It's been a worthwhile exercise anyway and I'm sure that what I've learned will be useful down the track.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/03/2011 at 07:01, xxxxxxxx wrote:

    Howdy,

    Are you drawing from a ToolData plugin?

    Can you give a more detailed explanation of what kind of plugin you're drawing from?

    Adios,
    Cactus Dan



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/03/2011 at 12:42, xxxxxxxx wrote:

    Well, don't know how many polygons you have. If it's a lot, the GeRayCollider might get a bit slow. Anyway, ensure you're not re-initializing the collider class for every polygon. The slowest part is always the initialization of the collider.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/03/2011 at 08:29, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Howdy,
    Are you drawing from a ToolData plugin?
    Can you give a more detailed explanation of what kind of plugin you're drawing from?
    Adios,
    Cactus Dan

    No, I'm drawing from a TagData plugin. GeRayCollider has actually solved another more important problem: the need to cull self-hidden front-facing polys, so thanks again for the tip. And it does this at an acceptable speed.

    Originally posted by xxxxxxxx

    Well, don't know how many polygons you have. If it's a lot, the GeRayCollider might get a bit slow. Anyway, ensure you're not re-initializing the collider class for every polygon. The slowest part is always the initialization of the collider.

    Good point, I was actually re-initializing the class for each polygon using the approach described above. A pretty obvious mistake! I'll try it the other way round, initializing each object once and checking multiple polys against it. I'm processing a lot of polys so it may still be too slow but it's worth a try. Thanks for your help.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/04/2011 at 21:50, xxxxxxxx wrote:

    Hi,

    i just have nearly the same problem,
    i need to know if Points are visible to active viewport or not in a SceneSaverData plugin.

    So i set up a ColliderChache and a ColliderEngine at start of the Plugin:

    cEngine = cEngine->Alloc();
          cCache = cCache->Alloc();

    BaseObject* opc = doc->GetFirstObject();
          while(opc){
              FillColliderCache(cCache, opc);
              opc = opc->GetNext();
          }

    This seems to be ok.
    So now i want to detect if a point is visible with DoRayCollide-Function,
    so i see if a ray that is giong from Camera to my Point collides with the ColliderCache.

    But I got stuck by setting up the ray, which should go from the Camera to the Point to test.
    The Camera point i got with

    Vector wtail = bd->GetMi().off;

    seems to be wrong if i paint it with

    bd->DrawLine(bd->WS(wtail),bd->WS(va),0); //va is the vector I test
    (Picture below, i teast actually more points, but where the lines join, there should by my camera ???)

    Thanks for help,

    Marc

    It shows up like this:



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/04/2011 at 00:10, xxxxxxxx wrote:

    Hey Mike,

    To get the correct camera position use:

    BaseObject* cam = bd->GetSceneCamera(doc) ? bd->GetSceneCamera(doc) : bd->GetEditorCamera();
    CameraObject* camera = (CameraObject* )cam;
    wtail = camera->GetMg().off

    Or something like that:

    LONG Left, Top, Right, Bottom;
    bd->GetFrame(&Left, &Top, &Right, &Bottom);
    Right /=2;
    Bottom /=2;
    wtail = bd->SW(Vector(Right,Bottom,0));

    Good Luck!



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/04/2011 at 14:06, xxxxxxxx wrote:

    Additionally it´s is better to use GeRayCollider instead of  ColliderChache.

    You check if the first intersection is the point position. With ColliderChache you got not so easy a result.


Log in to reply