From the code fragment all 'num_points' is doing is presetting the expected 
number of points in the object so it can pre-allocated the point array, etc.  
In the case of the sphere it pre-calculates the number of points from a few 
user parameters but there's no particular reason why you need to do it that way.

And to answer your question about polys vs triangles, there's not a lot of 
difference since polys do get broken into rTriangles for rendering.  The main 
difference is that a poly can draw its outline rather than drawing all the 
inner triangles, and it has some idea of its vertex interconnections.

-jonathan

On Apr 20, 2011, at 7:32 AM, Stephen Newbold wrote:

> Don't worry, I just answered my own question.  It is just taking the last 
> argument as 'true' and the previous 3 points are defining a 3-sided poly, or 
> triangle.  Man, long day!  Still not sure what 'num_points' does as changing 
> it seems to make little difference.
> 
> Steve
> 
> 
> Stephen Newbold wrote:
>> 
>> Having looked at the 'docs' again, am I right in saying that Polygon() 
>> requires arguments for the points plus a boolean value for whether the poly 
>> is open or closed?  If I use this out.add_primitive(obj, new Polygon(0, 1, 
>> 2, 3, true)) I get a closed poly, if I use this, out.add_primitive(obj, new 
>> Polygon(0, 1, 2, 3, false)) I get an open poly.  Makes sense.  But if I 
>> don't provide this final argument why do I get a triangle rather than it 
>> defaulting to open/closed?
>> 
>> Steve
>> 
>> 
>> Stephen Newbold wrote:
>>> 
>>> Ok, so I quickly went over this and due to the pointers you gave me the 
>>> Sphere.cpp makes more sense.  So anyway, I've kind of got it working but 
>>> there something weird that I need to run past you.
>>> 
>>> If you look at the code below (which is essentially a butchered version of 
>>> the Sphere.cpp stuff, it compiles fine but I get a triangle comprising of 
>>> the first 3 points rather that a 4 sided polygon.  If I change the add 
>>> primitive line to out.add_primitive(obj, new Polygon(0, 1, 2, 3, 4)); I get 
>>> the result I expect, a poly with its vertexes at the coords I define.  But 
>>> not sure why 5 values works and only put it in as a wild stab-in-the-dark!
>>> 
>>> Any idea what's going on?  Also, a bit lost about what 'num_points' is 
>>> actually doing.  Am I right to set this to 'n' for a a n-sided poly?
>>> 
>>> Steve
>>> 
>>> 
>>> 
>>> void create_geometry(Scene& scene, GeometryList& out)
>>>   {
>>>     int obj = 0;
>>> 
>>>     unsigned num_points = 4;
>>> 
>>>     if (rebuild(Mask_Primitives))
>>>     {
>>>       out.delete_objects();
>>>       out.add_object(obj);
>>> 
>>>       out.add_primitive(obj, new Polygon(0, 1, 2, 3));
>>> 
>>>       set_rebuild(Mask_Points | Mask_Attributes);
>>>     }
>>> 
>>>     if (rebuild(Mask_Points)) {
>>>       // Generate points:
>>>       PointList* points = out.writable_points(obj);
>>>       points->resize(num_points);
>>> 
>>>           
>>>       (*points)[0].set(0, 0, 0);
>>>       (*points)[1].set(0, 10, 0);
>>>       (*points)[2].set(6, 8, 0);
>>>       (*points)[3].set(5, 2, 0);     
>>>       
>>>     }
>>>     
>>>   }
>>> 
>>> Stephen Newbold wrote:
>>>> 
>>>> That's all useful stuff.  Cheers guys.  I'll give it a proper go as soon 
>>>> as I get a few spare hours.
>>>> 
>>>> Steve
>>>> 
>>>> 
>>>> 
>>>> Jonathan Egstad wrote:
>>>>> 
>>>>> Btw if you can't preset the primitive sufficiently ahead of time (I had 
>>>>> this snag with a custom subd primitive) you can set the vertices variable 
>>>>> in the GeoInfo directly but you'll need to hack the header to get access.
>>>>> 
>>>>> -jonathan
>>>>> 
>>>>> Sent from my iPhone
>>>>> 
>>>>> On Apr 19, 2011, at 3:02 PM, Jonathan Egstad <jegs...@earthlink.net> 
>>>>> wrote:
>>>>> 
>>>>>   
>>>>>> No, just make sure the primitive contains all vert entries - their 
>>>>>> values don't matter, just the total number of them.
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> Sent from my iPhone
>>>>>> 
>>>>>> On Apr 19, 2011, at 2:29 PM, Nhat Phong Tran 
>>>>>> <nhatphong.t...@googlemail.com> wrote:
>>>>>> 
>>>>>>     
>>>>>>> Does that mean that all the PointList stuff and set(x,y,z) should 
>>>>>>> happen before add_primitive()??
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> ----------------------------------------------------------
>>>>>>> nhat phong tran
>>>>>>> dipl. digital artist (FH)
>>>>>>> computer graphics & visual effects
>>>>>>> 
>>>>>>> m_us: +1 (310) 866-6871
>>>>>>> m_de: +49 (176) 24 26 34 27
>>>>>>> fax: +49 (321) 213 25 866
>>>>>>> 
>>>>>>> santa monica, ca 90401
>>>>>>> 
>>>>>>> sent via iPhone
>>>>>>> ----------------------------------------------------------
>>>>>>> 
>>>>>>> On Apr 19, 2011, at 13:30, Jonathan Egstad <jegs...@earthlink.net> 
>>>>>>> wrote:
>>>>>>> 
>>>>>>>       
>>>>>>>> One (of many) details that's not obvious is the accounting of vertices 
>>>>>>>> inside the GeoInfo and its importance in maintaining any vertex 
>>>>>>>> attribute arrays.  If you add additional vertices to a primitive 
>>>>>>>> *after* the primitive has already been added to the GeoInfo (via 
>>>>>>>> GeoInfo::add_primitive()) then vertex attribute array sizes can get 
>>>>>>>> out of sync possibly causing a crash.
>>>>>>>> 
>>>>>>>> So until that's fixed make sure to completely build your primitive 
>>>>>>>> first before adding it to the GeoInfo.
>>>>>>>> 
>>>>>>>> -jonathan
>>>>>>>> 
>>>>>>>> 
>>>>>>>> On Apr 19, 2011, at 11:55 AM, Nhat Phong Tran wrote:
>>>>>>>> 
>>>>>>>>         
>>>>>>>>> Well first you need to add an object which holds your primitives (i.e.
>>>>>>>>> a polygon) to your output GeometryList. You can do this like this:
>>>>>>>>> 
>>>>>>>>> out.addObject(yourObjectID);
>>>>>>>>> 
>>>>>>>>> Now that you have an object created, you can add your primitives to
>>>>>>>>> it, in your case a polygon.
>>>>>>>>> 
>>>>>>>>> out.add_primitive(obj, new Polygon(0, 1, 2, 3));
>>>>>>>>> 
>>>>>>>>> So this allocates a polygon class and assigns points 0-3 to be its
>>>>>>>>> vertices. But this doesn't mean that the polygon's shape has been
>>>>>>>>> defined yet, because the points 0-3 have not a set position yet. To do
>>>>>>>>> this you create a pointer to the pointlist that contains the points of
>>>>>>>>> your object, then you need to resize the pointlist to fit all of your
>>>>>>>>> primitives points. Then you iterate through the points of the polygon
>>>>>>>>> of your interest and set the coordinates of each point.
>>>>>>>>> 
>>>>>>>>> PointList* points = out.writable_points(yourObjectID);
>>>>>>>>> points->resize(num_points);
>>>>>>>>> 
>>>>>>>>> for(unsigned int p=0; p<4; p++){
>>>>>>>>> (*points)[p].set(x_pos, y_pos, z_pos);
>>>>>>>>> }
>>>>>>>>> 
>>>>>>>>> Hope this helps!
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> Nhat
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> ----------------------------------------------------------
>>>>>>>>> nhat phong tran
>>>>>>>>> dipl. digital artist (FH)
>>>>>>>>> computer graphics & visual effects
>>>>>>>>> 
>>>>>>>>> m_us: +1 (310) 866-6871
>>>>>>>>> m_de: +49 (176) 24 26 34 27
>>>>>>>>> fax: +49 (321) 213 25 866
>>>>>>>>> 
>>>>>>>>> santa monica, ca 90401
>>>>>>>>> 
>>>>>>>>> sent via iPhone
>>>>>>>>> ----------------------------------------------------------
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> On 19 April 2011 09:07, Stephen Newbold 
>>>>>>>>> <stephe...@moving-picture.com> wrote:
>>>>>>>>>           
>>>>>>>>>> Hi.  Anybody know of any easy to understand documentation on how to 
>>>>>>>>>> create
>>>>>>>>>> polygons using the NDK?  I had a look through the Sphere.cpp example 
>>>>>>>>>> that
>>>>>>>>>> ships with Nuke and like most things it went completely over my 
>>>>>>>>>> head.  I'm
>>>>>>>>>> hoping to be able to create something simple, just a four sided poly 
>>>>>>>>>> defined
>>>>>>>>>> by 4 corner points, but have zero idea on how to go about it.
>>>>>>>>>> 
>>>>>>>>>> Cheers,
>>>>>>>>>> Steve
>>>>>>>>>> 
>>>>>>>>>> --
>>>>>>>>>> Stephen Newbold
>>>>>>>>>> Senior Compositor - Film
>>>>>>>>>> MPC
>>>>>>>>>> 127 Wardour Street
>>>>>>>>>> Soho, London, W1F 0NL
>>>>>>>>>> Main - + 44 (0) 20 7434 3100
>>>>>>>>>> www.moving-picture.com
>>>>>>>>>> 
>>>>>>>>>> _______________________________________________
>>>>>>>>>> Nuke-dev mailing list
>>>>>>>>>> Nuke-dev@support.thefoundry.co.uk
>>>>>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>>>>>>>>>> 
>>>>>>>>>>             
>>>>>>>>> _______________________________________________
>>>>>>>>> Nuke-dev mailing list
>>>>>>>>> Nuke-dev@support.thefoundry.co.uk
>>>>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>>>>>>>>>           
>>>>>>>> _______________________________________________
>>>>>>>> Nuke-dev mailing list
>>>>>>>> Nuke-dev@support.thefoundry.co.uk
>>>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>>>>>>>>         
>>>>>>> _______________________________________________
>>>>>>> Nuke-dev mailing list
>>>>>>> Nuke-dev@support.thefoundry.co.uk
>>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>>>>>>>       
>>>>>> _______________________________________________
>>>>>> Nuke-dev mailing list
>>>>>> Nuke-dev@support.thefoundry.co.uk
>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>>>>>>     
>>>>> _______________________________________________
>>>>> Nuke-dev mailing list
>>>>> Nuke-dev@support.thefoundry.co.uk
>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>>>>>   
>>>> 
>>>> 
>>>> -- 
>>>> Stephen Newbold
>>>> Senior Compositor - Film
>>>> MPC
>>>> 127 Wardour Street
>>>> Soho, London, W1F 0NL
>>>> Main - + 44 (0) 20 7434 3100
>>>> www.moving-picture.com
>>>>   
>>>> 
>>>> _______________________________________________
>>>> Nuke-dev mailing list
>>>> Nuke-dev@support.thefoundry.co.uk
>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>>>>   
>>> 
>>> 
>>> -- 
>>> Stephen Newbold
>>> Senior Compositor - Film
>>> MPC
>>> 127 Wardour Street
>>> Soho, London, W1F 0NL
>>> Main - + 44 (0) 20 7434 3100
>>> www.moving-picture.com
>>>   
>>> 
>>> _______________________________________________
>>> Nuke-dev mailing list
>>> Nuke-dev@support.thefoundry.co.uk
>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>>>   
>> 
>> 
>> -- 
>> Stephen Newbold
>> Senior Compositor - Film
>> MPC
>> 127 Wardour Street
>> Soho, London, W1F 0NL
>> Main - + 44 (0) 20 7434 3100
>> www.moving-picture.com
>>   
>> 
>> _______________________________________________
>> Nuke-dev mailing list
>> Nuke-dev@support.thefoundry.co.uk
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>>   
> 
> 
> -- 
> Stephen Newbold
> Senior Compositor - Film
> MPC
> 127 Wardour Street
> Soho, London, W1F 0NL
> Main - + 44 (0) 20 7434 3100
> www.moving-picture.com
> _______________________________________________
> Nuke-dev mailing list
> Nuke-dev@support.thefoundry.co.uk
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev

_______________________________________________
Nuke-dev mailing list
Nuke-dev@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev

Reply via email to