<!-- Converted by db4-upgrade version 1.0 -->

<article xmlns="http://docbook.org/ns/docbook" version="5.0">
  <info><title>Refining a Mug Model</title>
    

    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../../books/en/tutorial_series_authors.xml" xpointer="Intro_MGED_Tutorial_Series_II_authors"/>
 
    <legalnotice>
       <para>Approved for public release; distribution is unlimited</para>
   </legalnotice>
  </info>

   <para xml:id="refining_mug_overviewlist">
      In this lesson, you will:
      <itemizedlist mark="bullet">
	<listitem>
	  <para>Assign material properties to the mug using the mater command.</para>
	</listitem>
	<listitem>
	  <para>Refine the mug.</para>
	</listitem>
	<listitem>
	  <para>Combine the shapes.</para>
	</listitem>
      </itemizedlist>
    </para>

    <para xml:id="refining_mug_intro1">
      In this lesson, you will refine the mug you made in the previous lesson.
      If you stopped at the end of that lesson, open the database mug.g before
      continuing.
    </para>

    <section xml:id="mug_mater_prop_mater_cmd"><info><title>Assigning Material Properties to the Mug Using the <command>mater</command> Command</title></info>
      
      <para>
	Assigning material properties to a region can be done with either the
	mater or shader command. The program will respond with a series of
	questions. These concern the various parameters of the shader you select
	to use in rendering the object.
      </para>
      <para>
	The most commonly used shader is the plastic shader, which uses a Phong
	lighting model. Select the plastic shader and set the color to a medium
	shade of green. The dialog in the Command Window should appear as follows:
	
	<userinput><prompt>mged&gt;</prompt> mater mug.r[Enter]</userinput>
      </para>
      
      <literallayout class="normal">
   Current shader string =
   Specify shader.  Enclose spaces within quotes.  E.g., "light invisible=1"
   Shader? ('del' to delete, '.' to skip) plastic[Enter]
   Current color = (No color specified)
   R, G, B color values (0 to 255)? ('del' to delete, '.' to skip) 32 128 32[Enter]
   Current inheritance = 0: lower nodes (towards leaves) override
   Should this object's shader override lower nodes? ('.' to skip) 0[Enter]
      </literallayout>
      
      <para>
	Enter the appropriate information that is shown in bold font. If you want
	to use the streamlined version, type:
	
	<command>mater mug.r plastic 32 128 32 0[Enter]</command>
      </para>
      <para>
	Diagrammed, this command says:
	<informaltable>
	  <tgroup cols="5">
	    <tbody>
	      <row>
		<entry>mater</entry>
		<entry>mug.r</entry>
		<entry>plastic</entry>
		<entry>32 128 32</entry>
		<entry>0</entry>
	      </row>
	      <row>
		<entry>Assign material properties to a region</entry>
		<entry>Called mug.r</entry>
		<entry>Make the material plastic</entry>
		<entry>Color the mug green</entry>
		<entry>Turn inheritance off*</entry>
	      </row>
	    </tbody>
	  </tgroup>
	</informaltable>
      </para>
      
      <note>
	<para>
	  Inheritance is an advanced topic beyond the scope of the present
	  discussion.
	</para>
      </note>
    </section>

    <section xml:id="mug_raytrace1"><info><title>Raytracing the Mug</title></info>
      
      <para>
	Open the Raytrace Control Panel and select Raytrace. You should get an
	image of a green mug on a dark background (we use a white background here
	to save printing ink). If your mug is not green, you probably need to
	redraw your wireframe before raytracing.
      </para>

      <informalfigure>
	<mediaobject>
	  <imageobject>
	    <imagedata align="center" fileref="../../lessons/en/images/mged11_mug_raytraced_norim.png" format="PNG"/>
	  </imageobject>
	  <caption>
	    <para>
	     Raytraced Mug Without Rim
	    </para>
	  </caption>
	</mediaobject>
      </informalfigure>

    </section>
    
    <section xml:id="mug_refining"><info><title>Refining the Mug</title></info>
      
      <para>
	Now let's improve the cup. Notice that the lip of the cup looks a little
	too squared off. To fix this, you will need to add a rounded top to the
	lip. You can do this by positioning a circular torus shape exactly at the
	top of the cup. Then you can add it to the combination body.c.
      </para>
      
      <para>
	At the <application>MGED</application> prompt, type:
	
	<command>in  rim.s tor 0 0 3.5 0 0 1 1.625 0.125[Enter]</command>
      </para>
      
      <informaltable>
	<tgroup cols="7">
	  <tbody>
	    <row>
	      <entry>in</entry>
	      <entry>rim.s</entry>
	      <entry>tor</entry>
	      <entry>0 0 3.5</entry>
	      <entry>0 0 1</entry>
	      <entry>1.625</entry>
	      <entry>0.125</entry>
	    </row>
	    <row>
	      <entry>Make a shape</entry>
	      <entry>Call it rim.s</entry>
	      <entry>Make the shape a torus</entry>
	      <entry>With x, y, and z vertices of 0, 0, and 3.5</entry>
	      <entry>With x, y, and z of normal vector being 0, 0, and 1</entry>
	      <entry>Radius 1 is 1.625 inches and</entry>
	      <entry>Radius 2 is 0.125 inches</entry>
	    </row>
	  </tbody>
	</tgroup>
      </informaltable>
    </section>

    <section xml:id="mug_torus_cup_combine"><info><title>Combining the Shapes</title></info>
      
      <para>
	To combine the torus with the cup, you will need to type at the prompt:
	
	<command>comb body.c u rim.s[Enter]</command>
      </para>
      <para>
	Now you are faced with a unique situation. The shape rim.s was added to
	the list of objects being displayed when it was created. However, now it
	is also a part of mug.r (via body.c). If you raytrace the current view,
	you will have two copies of this shape. The raytracer will complain that
	they overlap.
      </para>
      <para>
	One way to fix this is to clear the display, redisplay the new, complete
	object, and then raytrace. As discussed previously, the fbclear  command
	in the Raytrace Control Panel clears the framebuffer display, and the Z
	command in the Command Window clears all wireframed objects. You can
	redisplay the objects you want to raytrace with the draw command. Type at
	the prompt:
	
	<command>Z[Enter]</command>
	
	<command>draw mug.r[Enter]</command>
      </para>
      <para>
	Raytrace your mug. It should now look similar to the following.

      <informalfigure>
	<mediaobject>
	  <imageobject>
	    <imagedata align="center" fileref="../../lessons/en/images/mged11_mug_raytraced_rim.png" format="PNG"/>
	  </imageobject>
	  <caption>
	    <para>
	     The Mug Made Through the Command Line
	    </para>
	  </caption>
	</mediaobject>
      </informalfigure>

      </para>
    </section>
    
    <section xml:id="refining_mug_review"><info><title>Review</title></info>
      
      <para>
	In this chapter, you:
	<itemizedlist mark="bullet">
	  <listitem>
	    <para>Assigned material properties to the mug using the mater command.</para>
	  </listitem>
	  <listitem>
	    <para>Refined the mug by smoothing the lip.</para>
	  </listitem>
	  <listitem>
	    <para>Combined the shapes.</para>
	  </listitem>
	</itemizedlist>
      </para>
    </section>

  </article>
