Sophie

Sophie

distrib > Mandriva > 10.0 > i586 > media > contrib > by-pkgid > 9347541fe87a5ea3f3b8dbc50f660e8e > files > 262

libQGLViewer-devel-1.3.6-1mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>libQGLViewer: Constraint class Reference</title>
<link href="qglviewer.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.3 -->
<div class="qindex"><a class="qindex" href="../index.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Compound&nbsp;List</a> | <a class="qindex" href="functions.html">All&nbsp;functions</a> | <a class="qindex" doxygen="_cgi:http://www-imagis.imag.fr/cgi-bin/DOXYGEN/search.cgi" href="http://www-imagis.imag.fr/cgi-bin/DOXYGEN/search.cgi">Search</a></div>
<h1>Constraint Class Reference</h1>A base class for <a class="el" href="classqglviewer_1_1Frame.html">Frame</a> constraints.  
<a href="#_details">More...</a>
<p>
Inherited by <a class="el" href="classqglviewer_1_1AxisPlaneConstraint.html">AxisPlaneConstraint</a>, and <a class="el" href="classqglviewer_1_1TriangleSetConstraint.html">TriangleSetConstraint</a>.
<p>
<a href="classqglviewer_1_1Constraint-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>virtual&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classqglviewer_1_1Constraint.html#a0">~Constraint</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classqglviewer_1_1Constraint.html#a1">constrainTranslation</a> (<a class="el" href="classqglviewer_1_1Vec.html">Vec</a> &amp;, <a class="el" href="classqglviewer_1_1Frame.html">Frame</a> *const)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classqglviewer_1_1Constraint.html#a2">constrainRotation</a> (<a class="el" href="classqglviewer_1_1Quaternion.html">Quaternion</a> &amp;, <a class="el" href="classqglviewer_1_1Frame.html">Frame</a> *const)</td></tr>

</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A base class for <a class="el" href="classqglviewer_1_1Frame.html">Frame</a> constraints. 
<p>
The different constraints that can be applied to a <a class="el" href="classqglviewer_1_1Frame.html">Frame</a> to limit its motion must all derive from this class. A frame can have its constrain defined with <a class="el" href="classqglviewer_1_1Frame.html#z45_1">Frame::setConstraint()</a>.<p>
<a class="el" href="classqglviewer_1_1Constraint.html#a1">constrainTranslation()</a> and <a class="el" href="classqglviewer_1_1Constraint.html#a2">constrainRotation()</a> can be overloaded to specify the constraint behavior. They take the desired displacement (translation or rotation) and the applied frame as parameters. The translation (resp. rotation) is then modified according to the constraint.<p>
The <a class="el" href="classqglviewer_1_1Frame.html#z39_0">Frame::translate()</a> and <a class="el" href="classqglviewer_1_1Frame.html#z39_5">Frame::rotate()</a> functions filter their input with the current <a class="el" href="classqglviewer_1_1Frame.html">Frame</a> constraint (if any): <div class="fragment"><pre>  Frame::translate(Vec&amp; T)
  {
    <span class="keywordflow">if</span> (constraint())
      constraint()-&gt;constrainTranslation(T, <span class="keyword">this</span>);
    t += T;
  }

  Frame::rotate(Quaternion&amp; Q)
  {
    <span class="keywordflow">if</span> (constraint())
      constraint()-&gt;constrainRotation(Q, <span class="keyword">this</span>);
    q *= Q;
  }
</pre></div><p>
Default behavior (<a class="el" href="classqglviewer_1_1Constraint.html">Constraint</a> base class) implements no constraint : <a class="el" href="classqglviewer_1_1Constraint.html#a1">constrainTranslation()</a> and <a class="el" href="classqglviewer_1_1Constraint.html#a2">constrainRotation()</a> are identity functions.<p>
Try the <a href="../examples/constrainedFrame.html">constrainedFrame</a> and <a href="../examples/constrainedCamera.html">constrainedCamera</a> examples for an illustration.<p>
<h3>Implemented constraints</h3>
<p>
Classical constraints are provided for convenience : see the <a class="el" href="classqglviewer_1_1LocalConstraint.html">LocalConstraint</a>, <a class="el" href="classqglviewer_1_1WorldConstraint.html">WorldConstraint</a> and <a class="el" href="classqglviewer_1_1CameraConstraint.html">CameraConstraint</a> classes for axial and plane constraints. The <a class="el" href="classqglviewer_1_1TriangleSetConstraint.html">TriangleSetConstraint</a> is very useful for walk through applications, in order to force the camera to remain on a given path.<p>
<h3>Definig new constraints</h3>
<p>
The implementation of a new <a class="el" href="classqglviewer_1_1Constraint.html">Constraint</a> class simply consists in overloading the filtering functions: <div class="fragment"><pre>  <span class="keyword">class </span>myConstraint : <span class="keyword">public</span> Constraint
  {
  <span class="keyword">public</span>:
    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classqglviewer_1_1Constraint.html#a1">constrainTranslation</a>(Vec&amp; t, Frame * <span class="keyword">const</span> fr)
      {
        <span class="comment">// The frame cannot have a negative z world coordinate.</span>
        <span class="keywordflow">if</span> (fr-&gt;position().z + t.z &lt; 0.0) <span class="comment">// new fr z coordinate</span>
          t.z = fr-&gt;position().z;         <span class="comment">// t.z is clamped</span>
      }
  };

  myFrame-&gt;setConstraint(<span class="keyword">new</span> myConstraint());
</pre></div><p>
<h3>Combining constraints</h3>
<p>
Combining constraints can easily be achieved by creating a new class that will apply the different constraint filters: <div class="fragment"><pre>  myConstraint::constrainTranslation(Vec&amp; v, Frame* <span class="keyword">const</span> fr)
  {
    const1-&gt;constrainTranslation(v, fr);
    const2-&gt;constrainTranslation(v, fr);
    <span class="comment">// and so on, with possible branches, tests, loops...</span>
  }
</pre></div>Much more complex constraint composition classes can be created in the same way.<p>
<dl compact><dt><b>Attention:</b></dt><dd><a class="el" href="classqglviewer_1_1Frame.html#z37_0">Frame::setTranslation()</a>, <a class="el" href="classqglviewer_1_1Frame.html#z37_3">Frame::setRotation()</a> and similar functions will actually <em>set</em> the frame position and orientation, without taking the constraint into consideration. Use the <em>WithConstraint</em> versions of these functions to enforce the constraint. </dd></dl>

<p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a name="a0" doxytag="qglviewer::Constraint::~Constraint"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> virtual ~<a class="el" href="classqglviewer_1_1Constraint.html">Constraint</a> </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline, virtual]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Virtual empty destructor.     </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a name="a2" doxytag="qglviewer::Constraint::constrainRotation"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> virtual void constrainRotation </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="classqglviewer_1_1Quaternion.html">Quaternion</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="classqglviewer_1_1Frame.html">Frame</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>const</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [inline, virtual]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Default un-constrained rotation function. Desired rotation is expressed in <em>local</em> frame coordinate system.<p>
Overload this function in your own <a class="el" href="classqglviewer_1_1Constraint.html">Constraint</a> class to define a new rotational constraint. The frame which is applied a constrained rotation is given as a parameter. It is not defined <code>const</code>, but you should refrain from directly changing its value in the constraint. 
<p>
Reimplemented in <a class="el" href="classqglviewer_1_1AxisPlaneConstraint.html#z31_0">AxisPlaneConstraint</a>, <a class="el" href="classqglviewer_1_1LocalConstraint.html#a2">LocalConstraint</a>, <a class="el" href="classqglviewer_1_1WorldConstraint.html#a2">WorldConstraint</a>, and <a class="el" href="classqglviewer_1_1CameraConstraint.html#a3">CameraConstraint</a>.    </td>
  </tr>
</table>
<a name="a1" doxytag="qglviewer::Constraint::constrainTranslation"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> virtual void constrainTranslation </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="classqglviewer_1_1Vec.html">Vec</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="classqglviewer_1_1Frame.html">Frame</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>const</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [inline, virtual]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Default un-constrained translation function. Desired translation is expressed in <em>local</em> frame coordinate system.<p>
Overload this function in your own <a class="el" href="classqglviewer_1_1Constraint.html">Constraint</a> class to define a new translation constraint. The frame which is applied a constrained translation is given as a parameter. It is not defined <code>const</code>, but you should refrain from directly changing its value in the constraint. 
<p>
Reimplemented in <a class="el" href="classqglviewer_1_1AxisPlaneConstraint.html#z29_0">AxisPlaneConstraint</a>, <a class="el" href="classqglviewer_1_1LocalConstraint.html#a1">LocalConstraint</a>, <a class="el" href="classqglviewer_1_1WorldConstraint.html#a1">WorldConstraint</a>, <a class="el" href="classqglviewer_1_1CameraConstraint.html#a2">CameraConstraint</a>, and <a class="el" href="classqglviewer_1_1TriangleSetConstraint.html#a2">TriangleSetConstraint</a>.    </td>
  </tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Wed Feb 11 17:22:07 2004 for libQGLViewer by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
</a>1.3.3 </small></address>
</body>
</html>