problem with tristrips

Hi,

i’ve got a problem with my primitives while trying to make some tristrips.

I want to use to use the same primitive to make more than one tristrip.
But the second strip is each time rendered upside-down ( the third is good ) ( i never had more than 3 )

my code looks like this ( in python) :

format = GeomVertexFormat.getV3n3c4t2()
data = GeomVertexData(‘polycross’, format, Geom.UHStatic)
vertex = GeomVertexWriter(vdata, ‘vertex’)
normal = GeomVertexWriter(vdata, ‘normal’)
vertex_color = GeomVertexWriter(vdata, ‘color’)
tex_coord = GeomVertexWriter(vdata, ‘texcoord’)

normal_value = (0.000000,0.000000,1.000000)
primitives = GeomTristrips(Geom.UHStatic)
for strip,tex in zip(strips,tex_coords):
for num_vertex, v in enumerate(strip) :
vertex.addData3f(*v)
normal.addData3f(*normal_value)
vertex_color.addData4f(*color)
tex_coord.addData2f(tex[num_vertex][0], tex[num_vertex][1])

    primitives.addNextVertices(len(strip))
    primitives.closePrimitive()

geom = Geom(vdata)
geom.addPrimitive(primitives)

can anyone help me finding what’s wrong ? ( my strips, tested independently, appears correct)

Are you sure you’re defining your triangle strips correctly? Triangle strips are defined in a very specific, nonintuitive fashion. The odd-numbered triangles in the strip (counting from 1) are defined with vertices in a counter-clockwise order, while the even-numbered triangles are defined with the vertices is a clockwise order. It is very easy to get this wrong, and when you do, the whole triangle strip can appear upside-down or inside-out, or broken in some more complex way.

It’s often easier just to define individual triangles (using GeomTriangles instead of GeomTristrips), and with most PC graphics cards, these render at about the same speed as triangle strips anyway.

David

my strips are correct ( i think) , because they show correctly when they are separated.

which mean, strip 1 can show correctly and strip 2 too.
but if a put the strip 2 in the same primitive as strip 1 ( with the closeprimitive between) the entire strip 2 is show upside-down.

the two strip start the same way, with a cw order for the first triangle, ccw for the second.

Hmm, Panda also strongly prefers its triangle strips to contain an even number of triangles. This is because even-length triangle strips can be stitched together to be sent all in one batch, while odd-length triangle strips must be sent as individual commands to the graphics card (much, much more expensive).

Panda’s supposed to handle it correctly if you give it odd-length triangle strips anyway, but there might be a bug in there. Are your triangle strips even-length?

David

thank, that’s work now
( i append a degenerated triangle at the end of my odd-length triangle strips )