============== Class: Mesh II ============== .. index:: class, mesh .. |a| image:: /images/all/blender-extended/pyramid-100.png Objectives ========== .. tabularcolumns:: | c | l | :border: none +-------+-------------------------------------------------------------------------+ | |a| | Now we will finish the pyramid class | | | | +-------+-------------------------------------------------------------------------+ Instructions ============ :Tasks: 1. Repeat the sub-steps shown here to create a class until you have a working version. 2. Create a class of its own »primitive«, eg. a wedge or the base form of a hex key. 3. Add a material to the class, which is given to the new object. Design data for a mesh ====================== Define the tip of the pyramid and defining the faces, is the last step. .. code-block:: python :emphasize-lines: 10, 13-16 def pyramid_values(): """ This function takes inputs and returns vertex and face arrays. no actual mesh data creation is done here. """ verts = [(-1, +1, 0), (+1, +1, 0), (+1, -1, 0), (-1, -1, 0), (0, 0, +2)] faces = [(0, 1, 2, 3), (0,1,4), (1,2,4), (2,3,4), (3,0,4)] return verts, faces Defining the faces is done clockwise and remember the indes starts with 0. The result ========== Now you are able to create as much pyramids as you like. .. image:: /images/all/blender-extended/pyramiden.png The final version of the class ============================== .. literalinclude:: files/pyramid2.py :language: python