============================= Material -- colored labyrinth ============================= .. index:: .. |a| image:: /images/all/blender-basics/h_material/material-100.png Objectives ========== .. tabularcolumns:: | c | l | :border: none +-------+-------------------------------------------------------------------------+ | |a| | So far, our objects are unique grey. Now lets make the new world | | | a little bit colorful. Therefor we are using materials | | | and/or textures. | +-------+-------------------------------------------------------------------------+ Instructions ============ :Tasks: 1. Construct your own new level as shown in the last station. 2. Create new types of objects for the character $ and @ (ie. cone, cylinder). 3. Add different colors for every type of object. Das Labyrinth ============= Creating the labyrinth is the same procedure as before but in addition we add a material. .. literalinclude:: files/colored_labyrinth.py :language: python :emphasize-lines: 0 :linenos: Create a new material ===================== Materials in Blender are distinguished by name and exists independent from objects. Therefor it is possible to put one material to different objects. .. literalinclude:: files/colored_labyrinth.py :language: python :emphasize-lines: 0 :lines: 35 Save object =========== The new object is allocated to a variable named »*obj*«. .. literalinclude:: files/colored_labyrinth.py :language: python :emphasize-lines: 5 :lines: 44-49 Function: setColor ================== The function *setColor* needs tree parameters: object, material and color. .. literalinclude:: files/colored_labyrinth.py :language: python :emphasize-lines: 0 :lines: 49 Allocate material ================= Within setColor the parameters are used to change the given object. .. literalinclude:: files/colored_labyrinth.py :language: python :emphasize-lines: 0 :lines: 52-55 Result ====== .. image:: /images/all/blender-basics/h_material/colored_labyrinth.png