Melange - Culling



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

    On 08/11/2011 at 05:23, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:    
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hi!

    I am trying to interpret the polygon data correctly, so i can use culling. i was assuming that all data is just stored in order and i interpreted them accordingly. turned out they aren't. some objects might be copy of others and/or were mirrored in the creation process, thus returning in a wrong culling order. is there a way to check this and / or convert them so i can use them in my standalone importer?

    thanks for your time!

    Thomas



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

    On 08/11/2011 at 06:40, xxxxxxxx wrote:

    With Melange you simply read and write Cinema files. There is no automatic culling, e.g. as used for rendering. For this you have use your own culling algorithm/ polygon structures.

    cheers,
    Matthias



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

    On 08/11/2011 at 10:38, xxxxxxxx wrote:

    Thanks for your reply, Matthias.

    I probably need to go a bit deeper. My renderer that uses the C4D files is culling the backfaces, these can be either clockwise or counter-clockwise oriented. Is there a way to determine what is defined as front facing?

    I have a model, for example, that is rendering correct. The other one has only its backfaces rendered. So i need to determine how the culling order is defined for this model.

    This is even more a problem if someone has 2 similar objects in the scene, where one is a mirrored copy of the other (e.g. imagine an aircraft where one wing was modelled and then copied, scaled by -1 and added to the other side of the fuselage).

    So if there is no chance to get that information (i assume C4D is rendering without culling then) - i have to tell people to check if their face orientation is correct? (maya e.g. has stuff like that)

    Some more info: i am just getting the polygon/vertex list (i'm fine with that) and skip all matrices. Do i have to get the object space vertices (if this is possible?) and transform it with the provided (?) matrices to get correctly facing polygons?

    Thanks for your help!



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

    On 09/11/2011 at 01:39, xxxxxxxx wrote:

    Cinema uses a clockwise vertex order for outward facing polygons. There is no automatic check of the polygon facing.

    For rendering usally all vertices have to be transformed into global (world) space. In Melange you can do this by obtaining the global matrix of the polygon object with BaseObject::GetMg() and multiplying it with the vertex.

    Example:

      
    // op is a PolygonObject or PointObject  
    LONG pcnt = op->GetPointCount();  
    const Vector *padr = op->GetPointR();  
    Matrix mg = op->GetMg();  
      
    // iterate through all vertices of an object  
    for (LONG i=0; i<pcnt; i++)  
    {  
      
      Vector point = mg*padr[i]; // transforms vertices into global (world) space  
        
      // do something with point  
    }  
    

    cheers,
    Matthias


Log in to reply