class initialization problem

Tim Roberts timr at probo.com
Sat Sep 19 21:03:15 EDT 2009


rantingrick <rantingrick at gmail.com> wrote:
>
>WHY did i need do this you may ask?
>I am creating geometry with OpenGL. When you create a face you must
>specify a winding order (clockwise or counter clockwise) this winding
>order controls which side of the face will be visible (since only one
>side of a face is rendered). So to create a two sided face you must
>create two faces that share the exact same points, BUT have opposite
>windings, hence the need to create a face with a "backface" attribute
>that contains the mirrored face instance. So now i can move the
>frontface around and i have a handy reference to the backface so i can
>make it follow!

Surely it would be better to use inheritance for this.  Create a class
RawFace that encapsulated the points, then have a derived class Face that
creates a second RawFace for the backface.  No recursion problems with
that.

As it is, you have a somewhat confusing situation.  If I do this:

    x = Face( points )

Now I can refer to x.backface, but there is no x.backface.backface.
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list