Differences between revisions 3 and 4
Revision 3 as of 2012-04-13 22:24:25
Size: 580
Editor: JohnFlanagan
Comment:
Revision 4 as of 2012-04-13 22:33:30
Size: 1436
Editor: JohnFlanagan
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
To create a new Item3D widget use must inherit from EMItem3D (you will need to import this class from emitem3d). EMItem3D is a new style class so you don't need to multiply inherit from object. To create a new Item3D widget use must inherit from EMItem3D (you will need to import this class from emitem3d). EMItem3D is a new style class so you don't need to multiply inherit from object. To make a valid object you must re-implement several method and redefine two attributes
 1. class(static) attribute: ''name'', this gives a name for the new Item3D
 1. class(static) attribute: ''nodetype'', this classifies to Item3D. This name can be the same as other Itme3Ds. For example if I were making a torus Item3D, I would name this as "Shapenode" because that is what Cubes, Spheres, etc are named.
 1. method: ''getEvalString()'', this returns a string, which when evaled, creates an instance of this class. Generally you want this to create an instance of this class which is exactly the smae as the current instance because the purpose is for saving state.
 1. method: ''getItemInspector()'', this needs to return an inspector for this widget.
 1. method: ''renderShape()'', this implements the openGL code to actually render your object

Creating a new Item3D widget for use in EMScene3D

To create a new Item3D widget use must inherit from EMItem3D (you will need to import this class from emitem3d). EMItem3D is a new style class so you don't need to multiply inherit from object. To make a valid object you must re-implement several method and redefine two attributes

  1. class(static) attribute: name, this gives a name for the new Item3D

  2. class(static) attribute: nodetype, this classifies to Item3D. This name can be the same as other Itme3Ds. For example if I were making a torus Item3D, I would name this as "Shapenode" because that is what Cubes, Spheres, etc are named.

  3. method: getEvalString(), this returns a string, which when evaled, creates an instance of this class. Generally you want this to create an instance of this class which is exactly the smae as the current instance because the purpose is for saving state.

  4. method: getItemInspector(), this needs to return an inspector for this widget.

  5. method: renderShape(), this implements the openGL code to actually render your object

For exmaple:

   1 class EMNewItem(EMItem3D):
   2     name = "myname"
   3     nodetype = "mynodetype"
   4     def __init__(self, parent=None, children=None, transform=None):
   5         if not Transform: transform=transform()
   6         EMItem3D.__init__(self,parent=parent,children=children,transform=transform)

Eman2New3DItem (last edited 2012-04-16 23:13:18 by JohnFlanagan)