[x3d-public] TriangleStripSet and ccw

Joe D Williams joedwil at earthlink.net
Fri Oct 30 09:49:38 PDT 2015


> The Mantis bug should explain how similar corresponding 
> clarifications are needed for X3D IndexedTriangleStripSet, that also 
> emphasize similar triangle order definition

The standard is not user tutorial or intended to emphasize any 
particular constraint(s). What happens in any triangle or polygon is 
defined and works everywhere the same for our beloved X3D and mostly 
elsewhere and is fully described just fine and in not too many places 
in the current X3D standards, I think.

The standard provides definitions of the functionality independent of 
the application and is addressed to the creator of the X3D component 
that finally processes the user code to produce the real time 
interactive visualization (the sense of what constitutes 'user code' 
includes ever more diverse forms) and not to include various warnings 
and hints to potential users of this and every other simple 
convenience geometry element.

However, X3D standards should produce the best ever complete words and 
picture definition of how each of these convenience nodes actually 
shall be implemented - especially since not part of the current core 
ogl. I don't think you will need to remind implemention designers what 
to do if their machine gets vertices that don't index as intended to 
produce some nonstandard result some users might attempt by plan or 
default. This is because there is only one choice (or the other) for 
any set of points with or without a user/default index set, and 
regardless of the order and number of the points and the order and 
number of the user or default index set, the application would already 
know what viz to produce no matter what.

The standard should consist of the minimum possible keystrokes 
addressed to behavior of the implementation, not padded by repeated 
warnings to users. I mean once you get how these vertex geometry 
thingees work, it ts everywhere the same, right?

Thanks and Best,
Joe






----- Original Message ----- 
From: "Don Brutzman" <brutzman at nps.edu>
To: "Roy Walmsley" <roy.walmsley at ntlworld.com>; <x3d-public at web3d.org>
Cc: <x3d at web3d.org>
Sent: Friday, October 30, 2015 7:41 AM
Subject: Re: [x3d-public] TriangleStripSet and ccw


> wow what a great group effort, looks like we are converging on 
> excellent clarifications.
>
> very glad to see the references... curiously OpenGL 
> Programming/Basics/2DObjects is silent about vertex-order reversals 
> for even-numbered triangles.
> https://en.wikibooks.org/wiki/OpenGL_Programming/Basics/2DObjects
>
> alternatively the wikipedia reference quotes the OpenGL Programming 
> Guide (red book) in a helpful manner, and the example list of 
> vertices is numbered from zero, but the illustrating figure is 
> numbered from 1.
>
> https://en.wikipedia.org/wiki/Triangle_strip
> https://en.wikipedia.org/wiki/Triangle_strip#/media/File:Triangle_Strip_In_OpenGL.svg
> ========================================================================================
> Quoted directly from the OpenGL Programming Guide:
>
> GL_TRIANGLE_STRIP
>
> Draws a series of triangles (three-sided polygons) using vertices 
> v0, v1, v2, then v2, v1, v3 (note the order), then v2, v3, v4, and 
> so on. The ordering is to ensure that the triangles are all drawn 
> with the same orientation so that the strip can correctly form part 
> of a surface.
> ========================================================================================
>
> We might do well to quote or paraphrase the above. To be totally 
> clear we should also include a closeup diagram showing four TSS 
> triangles and order/normals defined by v0..v6.
>
> The Mantis bug should explain how similar corresponding 
> clarifications are needed for X3D IndexedTriangleStripSet, that also 
> emphasize similar triangle order definition, with normal directions 
> alternating, since this is further confusable when the indirection 
> of indices is included.
>
> Interesting OpenGl also includes GL_QUAD_STRIP. Perhaps we should 
> define a pair of new X3D nodes, QuadStripSet and 
> IndexedQuadStripSet, corresponding to QuadSet and IndexedQuadSet? 
> Defining a Mantis bug for this is probably good, the CAD Working 
> Group can then explore whether there is much content provided out in 
> the wild (i.e. in other formats) that would benefit from this. We 
> would also want feedback from the SRC team in this respect.
>
> https://en.wikibooks.org/wiki/OpenGL_Programming/Basics/2DObjects#Using_glBegin_with_GL_TRIANGLE_STRIP_or_GL_QUAD_STRIP
>
> Double check: wondering if anyone is familiar with, or can at least 
> locate, similar references for DirectX/Direct3D?
>
>
>
> On 10/29/2015 4:16 AM, Roy Walmsley wrote:
>> Hi all,
>>
>> I have reviewed the implementation of triangle strip sets with 
>> OpenGL. They are programmed as shown in the following example (from 
>> https://en.wikibooks.org/wiki/OpenGL_Programming/Basics/2DObjects):
>>
>> glBegin(GL_TRIANGLE_STRIP); // draw in triangle strips
>>                 glVertex2f(0.0f, 0.75f); // top of the roof
>>                 glVertex2f(-0.5f, 0.25f); // left corner of the 
>> roof
>>                 glVertex2f(0.5f, 0.25f); // right corner of the 
>> roof
>>                 glVertex2f(-0.5f, -0.5f); // bottom left corner of 
>> the house
>>                 glVertex2f(0.5f, -0.5f); //bottom right corner of 
>> the house
>> glEnd();
>>
>> A triangle strip set, when discussed from the perspective of a user 
>> looking at a 2D image, does indeed have vertex ordering 
>> alternating. The ccw flag specifies the ordering for the first, and 
>> subsequent odd numbered, triangles. The even numbered triangles 
>> have the opposite ordering.
>>
>> Within OpenGL, if normal are automatically calculated, then this 
>> will be taken care of internally. If normal are provided by the 
>> user, would they have to incorporate the alternating ordering? I 
>> don't know the answer to that.
>>
>> If an implementation does not pass the triangle strip directly to 
>> OpenGL as above, but uses, say GL_TRIANGLES, then it must 
>> internally correct for the alternating ordering before sending each 
>> set of three vertices to OpenGL.
>>
>> In my opinion the specification 19775-1 needs a sentence or two to 
>> clarify the meaning of the ccw field for both TriangleStripSet and 
>> IndexedTriangleStripSet.
>>
>> As noted during our meeting yesterday, the issue does not arise 
>> with triangle fan sets, as all triangles are oriented the same way.
>>
>> Regards,
>>
>> Roy
>>
>> -----Original Message-----
>> From: x3d-public [mailto:x3d-public-bounces at web3d.org] On Behalf Of 
>> simon place
>> Sent: 27 August 2015 16:23
>> To: x3d-public at web3d.org
>> Subject: Re: [x3d-public] TriangleStripSet and ccw
>>
>> my thinking is that you could think of list-order and 
>> drawing-order, as not necessarily the same thing, then;
>>
>> the definition of a Triangle Strip (see wikipedia) is telling you 
>> the drawing-order of even numbered triangles is reversed from their 
>> list-order, in which case the CCW is correct for the drawing-order.
>>
>> of course this should be explicit, or refer to an external 
>> definition of triangle strip.
>>
>>
>>
>> On 27 August 2015 at 15:08, Alekseyev, Vsevolod (NIH/NIAID) [E] 
>> <VAlekseyev at niaid.nih.gov> wrote:
>>> Any trivial one with 3 triangles will do.
>>>
>>>
>>>
>>>         <Scene>
>>>
>>>                <Transform>
>>>
>>>                       <Shape>
>>>
>>>                             <Appearance><Material diffuseColor="0 
>>> 0.5
>>> 0.5"/></Appearance>
>>>
>>>                             <IndexedTriangleStripSet index="0 1 2 
>>> 3 4">
>>>
>>>                                    <Coordinate point="0 0 0 1 0 1 
>>> 1 0 0
>>> 2 0 1
>>> 2 0 0"/>
>>>
>>>                             </IndexedTriangleStripSet>
>>>
>>>                       </Shape>
>>>
>>>                </Transform>
>>>
>>>         </Scene>
>>>
>>>
>>>
>>>
>>>
>>> From: Roy Walmsley [mailto:roy.walmsley at ntlworld.com]
>>> Sent: Wednesday, August 26, 2015 6:49 PM
>>> To: Alekseyev, Vsevolod (NIH/NIAID) [E] 
>>> <VAlekseyev at niaid.nih.gov>;
>>> x3d-public at web3d.org
>>> Cc: x3d at web3d.org
>>> Subject: RE: [x3d-public] TriangleStripSet and ccw
>>>
>>>
>>>
>>> Vsevolod,
>>>
>>>
>>>
>>> Great catch!
>>>
>>>
>>>
>>> Tomorrow I’ll raise a Mantis issue covering this and let you know 
>>> the
>>> details.
>>>
>>>
>>>
>>> Do you have a reference to an X3D example file that can be used to
>>> test implementations?
>>>
>>>
>>>
>>> Roy
>>>
>>>
>>>
>>> From: x3d-public [mailto:x3d-public-bounces at web3d.org] On Behalf 
>>> Of
>>> Alekseyev, Vsevolod (NIH/NIAID) [E]
>>> Sent: 24 August 2015 20:58
>>> To: x3d-public at web3d.org
>>> Subject: [x3d-public] TriangleStripSet and ccw
>>>
>>>
>>>
>>> While we’re on the topic of standard ambiguities, here’s another 
>>> issue.
>>>
>>>
>>>
>>> Imagine a TriangleStripSet. It has a sequence of points with a 
>>> sliding
>>> window logic to them – the first triangle is points 0, 1, 2, the
>>> second is 1,2,3, then 2, 3, 4, etc. It’s illustrated perfectly at
>>> http://www.web3d.org/documents/specifications/19775-1/V3.3/Images/Tria
>>> ngleStripSet.png
>>>
>>>
>>>
>>> The element also has a ccw flag that tells us which side of the
>>> triangle is the outer side.
>>>
>>>
>>>
>>> Now, the issue. If the ccw logic is to be followed *for every
>>> triangle*, every second triangle would look the other way from the 
>>> previous one.
>>>
>>>
>>>
>>> Look at the image. For the first triangle, the logic for 
>>> determining
>>> the outer side is – if you look at the triangle from the outside,
>>> vertices 0, 1,
>>> 2 should go counterclockwise. But if you look from the same 
>>> vantage
>>> point at the second triangle, vertices 1, 2, 3 would go 
>>> *clockwise*
>>> instead. Were the algorithm to go by the strict letter of the ccw
>>> rule, one would have to conclude that odd numbered triangles in 
>>> the
>>> strip look one way, even numbered ones look the other way.
>>>
>>>
>>>
>>> Fortunately, few implementors think so. Neither X3DOM nor X3D-Edit
>>> read the standard that way. My Blender X3D importer flips the 
>>> vertex
>>> order for every odd triangle, too. The only implementation that 
>>> does
>>> not is meshlab. Upon rendering, it gives a very characteristic
>>> “checkerboard” pattern – triangles that are seen from the inside 
>>> are dark.
>>>
>>>
>>>
>>> The same issue would obviously plague IndexedTriangleStripSet, but 
>>> not
>>> [Indexed]TriangleFanSet.
>>>
>>>
>>>
>>> Maybe a clarification in the standard would be in order, that ccw 
>>> only
>>> applies to the *first* triangle in the strip, for the subsequent 
>>> ones
>>> one should go by consistent orientation of adjacent triangles.
>>>
>>>
>>>
>>> Vsevolod "Seva" Alekseyev
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> x3d-public mailing list
>>> x3d-public at web3d.org
>>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>>>
>>
>> _______________________________________________
>> x3d-public mailing list
>> x3d-public at web3d.org
>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>>
>>
>> _______________________________________________
>> x3d-public mailing list
>> x3d-public at web3d.org
>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>>
>
>
> all the best, Don
> -- 
> Don Brutzman  Naval Postgraduate School, Code USW/Br 
> brutzman at nps.edu
> Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA 
> +1.831.656.2149
> X3D graphics, virtual worlds, navy robotics 
> http://faculty.nps.edu/brutzman
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
> 




More information about the x3d-public mailing list