Jump to content

Custom geometry display : GR and triangles/quads


Recommended Posts

Hi,

 

  I am studying the tetprim example code.

 

  I see the following code and would like to find out if the returned GL buffer always expect one to fill them in with triangles ? Therefore if we have quads, we need to split it up into two triangles per quads ?

 

  If I have misunderstood the GL buffer returned by pos->map() and that it supports n-gon, where should one specify the per-polygon vertex count ?

 

  I have had a look at the GT code and it has the concept of vertex_order[] so I am fine with that. I want to test out a GR implementation hence the above question.

 

============= CODE =======================

    // Initialize the number of points in the geometry.

    myGeo->setNumPoints( 12 * num_tets);

 

    

    // Fetch P (point position). If its cache version matches, no upload is

    // required.

    pos = myGeo->findCachedAttribOrArray(r, posname, RE_GPU_FLOAT32, 3,

RE_ARRAY_POINT, true);

    if(pos->getCacheVersion() != p.geo_version)

    {

// map() returns a pointer to the GL buffer

UT_Vector3F *pdata = static_cast<UT_Vector3F *>(pos->map®);

if(pdata)

{

    for(int t=0; t<num_tets; t++)

    {

pdata[0] = pt(t*4);

pdata[1] = pt(t*4+1);

pdata[2] = pt(t*4+2);

   

pdata[3] = pt(t*4);

pdata[4] = pt(t*4+2);

pdata[5] = pt(t*4+3);

 

pdata[6] = pt(t*4+1);

pdata[7] = pt(t*4+2);

pdata[8] = pt(t*4+3);

 

pdata[9] = pt(t*4);

pdata[10] = pt(t*4+3);

pdata[11] = pt(t*4+1);

 

pdata += 12;

    }

 

Cheers

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...