Maybe "best" practice is aiming too high. Does anyone even have a personal opinion on, or have good/bad experiences with using graphics.Group to wrap vertex lists in a batch for turning GL states on/off, or insert nested rotations, translations, etc.? What works well, what doesn't?
I'm wondering what the Pyglet designer(s) envisioned; because these are fundamentally necessary actions, even for something as simple as a moon orbiting a planet. And what is the intent of the generic vertex list attributes? Can I use them like I did in the block demo? Gumm On Sun, Oct 24, 2010 at 10:03 PM, B W <[email protected]> wrote: > Howdy again. > > Would anyone happen to have collected or written any best practices docs, > examples, or utilities for working with batches and groups, or simply have > any fundamental tips? > > Reason I ask is that my first attempt, built upon the brief description in > the Pyglet programming guide, resulted in many subclasses of graphics.Group > and some hairy problems like how to elegantly insert translations for a > group of textures. For example, a cube made out of six quads. > > I ended up doing something like this: > > # Add hierarchical group to batch (init the modes, lights, and > transformations) > group = TextureEnableGroup(parent= > LightingOnGroup(parent= > ShadeModelGroup(parent= > > TranslationGroup(parent=pyglet.graphics.OrderedGroup(0)))) > batch.add(1, 0, group, '0g1f') > group = TextureBindGroup(parent= > pyglet.graphics.OrderedGroup(1)) > # add cube vertex lists to batch > for name in cube_sides: # 'top', 'front', etc. > verts = cube_sides[name] > norms = cube_normals[name] > texcoords = cube_tex_coords[name] > batch.add(len(verts), GL_QUAD, group, > # vertex list specs... > ) > # Add hierarchical group to batch (Unset-modes in the same manner > as the first group) > > Hope that conveys the general idea. If not, I've uploaded the full program > here: > http://worldkit.googlecode.com/files/block_vs_group.zip -- see class > ShadedCubeScene or TexturedCubeScene. > > Initially, I found it unwieldy to specify one polygon just to init the > modes via a hierarchical group, all but one polygon in a loop for economy, > and the final polygon to unset the modes via another group. What if I only > had one polygon, I'd be SOL. :) So naturally I wonder how it's typically > done. > > Grasping for ideas, I discovered that Pyglet batches would let me add an > empty generic vertex attribute with a group that simply changes state, as > shown above. I have no idea what the generic vertex attributes are intended > for, and half expect the practice might be considered an abuse. Would anyone > comment on this, please? > > Also, if anyone has the guts to dig into my noob code I would greatly > appreciate his/her constructive feedback. =) If I'm doing anything > particularly wrong, I'd prefer to nip the bad habit in the bud. (And you'll > notice light and shadow are a work in progress.) > > Thanks in advance for your sage advice! :) > > Gumm > -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en.
