<!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>Crystal Space 1.2.1: csgeom/path.h Source File (Crystal Space 1.2.1 Public API Reference)</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <table border="0" cellpadding="0" cellspacing="0" width="100%" class="head"> <tr height="59"> <td class="head" width="202" valign="bottom" style="padding-left:0;"><a href="http://www.crystalspace3d.org/"><img src="csblur.png" width="236" height="59" alt="CrystalSpace" border="0"></a></td> <td class="head"><h2>Public API Reference</h2></td> </tr> <tr height="11"> <td colspan="2" class="headshadow" valign="top" style="padding-left:0;"><img src="csblurb.png" width="236" height="11" alt="" border="0"></td> </tr> </table> <div class="content"> <!-- Generated by Doxygen 1.5.3 --> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul> </div> <h1>csgeom/path.h</h1><a href="csgeom_2path_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> Copyright (C) 2001 by Jorrit Tyberghein</span> <a name="l00003"></a>00003 <span class="comment"></span> <a name="l00004"></a>00004 <span class="comment"> This library is free software; you can redistribute it and/or</span> <a name="l00005"></a>00005 <span class="comment"> modify it under the terms of the GNU Library General Public</span> <a name="l00006"></a>00006 <span class="comment"> License as published by the Free Software Foundation; either</span> <a name="l00007"></a>00007 <span class="comment"> version 2 of the License, or (at your option) any later version.</span> <a name="l00008"></a>00008 <span class="comment"></span> <a name="l00009"></a>00009 <span class="comment"> This library is distributed in the hope that it will be useful,</span> <a name="l00010"></a>00010 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00011"></a>00011 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00012"></a>00012 <span class="comment"> Library General Public License for more details.</span> <a name="l00013"></a>00013 <span class="comment"></span> <a name="l00014"></a>00014 <span class="comment"> You should have received a copy of the GNU Library General Public</span> <a name="l00015"></a>00015 <span class="comment"> License along with this library; if not, write to the Free</span> <a name="l00016"></a>00016 <span class="comment"> Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span> <a name="l00017"></a>00017 <span class="comment">*/</span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="preprocessor">#ifndef __CS_PATH_H__</span> <a name="l00020"></a>00020 <span class="preprocessor"></span><span class="preprocessor">#define __CS_PATH_H__</span> <a name="l00021"></a>00021 <span class="preprocessor"></span> <a name="l00022"></a>00022 <a name="l00030"></a>00030 <span class="preprocessor">#include "csextern.h"</span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="spline_8h.html" title="Splines.">csgeom/spline.h</a>"</span> <a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="vector3_8h.html" title="3D vector.">csgeom/vector3.h</a>"</span> <a name="l00034"></a>00034 <span class="preprocessor">#include "<a class="code" href="scf__implementation_8h.html" title="Crystal Space Shared Class Facility (SCF) - implementation creation support.">csutil/scf_implementation.h</a>"</span> <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="preprocessor">#include "<a class="code" href="igeom_2path_8h.html" title="3D path interfaces">igeom/path.h</a>"</span> <a name="l00037"></a>00037 <a name="l00044"></a><a class="code" href="classcsPath.html">00044</a> <span class="keyword">class </span>CS_CRYSTALSPACE_EXPORT <a class="code" href="classcsPath.html" title="A path in 3D.">csPath</a> : <a name="l00045"></a>00045 <span class="keyword">public</span> <a class="code" href="classscfImplementation1.html">scfImplementation1</a><csPath, iPath> <a name="l00046"></a>00046 { <a name="l00047"></a>00047 <span class="keyword">protected</span>: <a name="l00048"></a><a class="code" href="classcsPath.html#4ae74a9c7bfaba1d95c390ea8d142631">00048</a> <a class="code" href="classcsCatmullRomSpline.html" title="A CatmullRom spline.">csCatmullRomSpline</a> spline; <a name="l00049"></a>00049 <a name="l00050"></a>00050 <span class="keyword">private</span>: <a name="l00051"></a>00051 <span class="keywordtype">void</span> SetVectorAsDimensionValues (<span class="keywordtype">int</span> dim, <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>* v) <a name="l00052"></a>00052 { <a name="l00053"></a>00053 <span class="keywordtype">int</span> i; <a name="l00054"></a>00054 <span class="keywordtype">int</span> N = spline.GetPointCount(); <a name="l00055"></a>00055 <span class="keywordtype">float</span>* x, * y, * z; <a name="l00056"></a>00056 x = <span class="keyword">new</span> <span class="keywordtype">float</span> [N]; <a name="l00057"></a>00057 y = <span class="keyword">new</span> <span class="keywordtype">float</span> [N]; <a name="l00058"></a>00058 z = <span class="keyword">new</span> <span class="keywordtype">float</span> [N]; <a name="l00059"></a>00059 <span class="keywordflow">for</span> (i = 0 ; i < N ; i++) <a name="l00060"></a>00060 { <a name="l00061"></a>00061 x[i] = v[i].<a class="code" href="classcsVector3.html#823fdba459ff91e8a5e6834ded7c815f" title="The X component of the vector.">x</a>; <a name="l00062"></a>00062 y[i] = v[i].<a class="code" href="classcsVector3.html#e0a74264b61eb5d61da63b3c101af719" title="The Y component of the vector.">y</a>; <a name="l00063"></a>00063 z[i] = v[i].<a class="code" href="classcsVector3.html#3f761bd195c7ccec59ea863a87a1ad05" title="The Z component of the vector.">z</a>; <a name="l00064"></a>00064 } <a name="l00065"></a>00065 spline.SetDimensionValues (dim+0, x); <a name="l00066"></a>00066 spline.SetDimensionValues (dim+1, y); <a name="l00067"></a>00067 spline.SetDimensionValues (dim+2, z); <a name="l00068"></a>00068 <span class="keyword">delete</span>[] x; <a name="l00069"></a>00069 <span class="keyword">delete</span>[] y; <a name="l00070"></a>00070 <span class="keyword">delete</span>[] z; <a name="l00071"></a>00071 } <a name="l00072"></a>00072 <a name="l00073"></a>00073 <span class="keyword">public</span>: <a name="l00074"></a>00074 <a name="l00076"></a><a class="code" href="classcsPath.html#b1e775cfc8e243c53044959314e5158f">00076</a> <a class="code" href="classcsPath.html" title="A path in 3D.">csPath</a> (<span class="keywordtype">int</span> p) : <a class="code" href="classscfImplementation1.html">scfImplementationType</a>(this), spline (9, p) <a name="l00077"></a>00077 { } <a name="l00078"></a>00078 <a name="l00080"></a><a class="code" href="classcsPath.html#3e5011dafbee8ee65c8f826cd5091964">00080</a> <span class="keyword">virtual</span> ~<a class="code" href="classcsPath.html" title="A path in 3D.">csPath</a> () <a name="l00081"></a>00081 { } <a name="l00082"></a>00082 <a name="l00084"></a><a class="code" href="classcsPath.html#29ff2c85c39e43484bf6eede70c9e713">00084</a> <span class="keyword">virtual</span> <span class="keywordtype">int</span> Length () <a name="l00085"></a>00085 { <a name="l00086"></a>00086 <span class="keywordflow">return</span> spline.GetPointCount(); <a name="l00087"></a>00087 } <a name="l00088"></a>00088 <a name="l00090"></a><a class="code" href="classcsPath.html#f647db6e88420b3b6ddfae29cf44fee1">00090</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> CalculateAtTime (<span class="keywordtype">float</span> time) <a name="l00091"></a>00091 { <a name="l00092"></a>00092 spline.Calculate (time); <a name="l00093"></a>00093 } <a name="l00094"></a>00094 <a name="l00096"></a><a class="code" href="classcsPath.html#40adfbb9404fd2f1cf0146c46723e8cc">00096</a> <span class="keyword">virtual</span> <span class="keywordtype">int</span> GetCurrentIndex () <a name="l00097"></a>00097 { <a name="l00098"></a>00098 <span class="keywordflow">return</span> spline.GetCurrentIndex(); <a name="l00099"></a>00099 } <a name="l00101"></a><a class="code" href="classcsPath.html#88361d34013f698906dc5dd3bc421a75">00101</a> <span class="keyword">virtual</span> <span class="keywordtype">float</span> GetTime (<span class="keywordtype">int</span> idx) <a name="l00102"></a>00102 { <a name="l00103"></a>00103 <span class="keywordflow">return</span> spline.GetTimeValue(idx); <a name="l00104"></a>00104 } <a name="l00105"></a>00105 <a name="l00107"></a><a class="code" href="classcsPath.html#58b1a3f3dc015c86e106c41e56bcc3ad">00107</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetTime (<span class="keywordtype">int</span> idx, <span class="keywordtype">float</span> t) <a name="l00108"></a>00108 { <a name="l00109"></a>00109 spline.SetTimeValue(idx,t); <a name="l00110"></a>00110 } <a name="l00111"></a>00111 <a name="l00118"></a><a class="code" href="classcsPath.html#5ca6b626b710410bfdbfd7e6bc22cc3b">00118</a> <span class="keywordtype">void</span> SetTimes (<span class="keywordtype">float</span> <span class="keyword">const</span>* t) <a name="l00119"></a>00119 { <a name="l00120"></a>00120 spline.SetTimeValues(t); <a name="l00121"></a>00121 } <a name="l00122"></a>00122 <a name="l00124"></a><a class="code" href="classcsPath.html#a79dea73d57cf0e79a88c5102266cdf8">00124</a> <span class="keywordtype">float</span> <span class="keyword">const</span>* GetTimes ()<span class="keyword"> const</span> <a name="l00125"></a>00125 <span class="keyword"> </span>{ <a name="l00126"></a>00126 <span class="keywordflow">return</span> spline.GetTimeValues(); <a name="l00127"></a>00127 } <a name="l00128"></a>00128 <a name="l00130"></a><a class="code" href="classcsPath.html#d1d4fa81bd09470c1567b4d10da7ab98">00130</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetPositionVectors (<a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>* v) <a name="l00131"></a>00131 { <a name="l00132"></a>00132 SetVectorAsDimensionValues (0, v); <a name="l00133"></a>00133 } <a name="l00135"></a><a class="code" href="classcsPath.html#21089eee0a832a7fa61af6cd5357c8de">00135</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetUpVectors (<a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>* v) <a name="l00136"></a>00136 { <a name="l00137"></a>00137 SetVectorAsDimensionValues (3, v); <a name="l00138"></a>00138 } <a name="l00140"></a><a class="code" href="classcsPath.html#03dedfe361f1b09219aee5886a113bd3">00140</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetForwardVectors (<a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>* v) <a name="l00141"></a>00141 { <a name="l00142"></a>00142 SetVectorAsDimensionValues (6, v); <a name="l00143"></a>00143 } <a name="l00145"></a><a class="code" href="classcsPath.html#369a8cff153598f2e1087cadf65177ea">00145</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetPositionVector (<span class="keywordtype">int</span> idx, <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& v) <a name="l00146"></a>00146 { <a name="l00147"></a>00147 spline.SetDimensionValue (0, idx, v.<a class="code" href="classcsVector3.html#823fdba459ff91e8a5e6834ded7c815f" title="The X component of the vector.">x</a>); <a name="l00148"></a>00148 spline.SetDimensionValue (1, idx, v.<a class="code" href="classcsVector3.html#e0a74264b61eb5d61da63b3c101af719" title="The Y component of the vector.">y</a>); <a name="l00149"></a>00149 spline.SetDimensionValue (2, idx, v.<a class="code" href="classcsVector3.html#3f761bd195c7ccec59ea863a87a1ad05" title="The Z component of the vector.">z</a>); <a name="l00150"></a>00150 } <a name="l00152"></a><a class="code" href="classcsPath.html#6e10ef5b599b230a9c4bc319cf9ed966">00152</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetUpVector (<span class="keywordtype">int</span> idx, <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& v) <a name="l00153"></a>00153 { <a name="l00154"></a>00154 spline.SetDimensionValue (3, idx, v.<a class="code" href="classcsVector3.html#823fdba459ff91e8a5e6834ded7c815f" title="The X component of the vector.">x</a>); <a name="l00155"></a>00155 spline.SetDimensionValue (4, idx, v.<a class="code" href="classcsVector3.html#e0a74264b61eb5d61da63b3c101af719" title="The Y component of the vector.">y</a>); <a name="l00156"></a>00156 spline.SetDimensionValue (5, idx, v.<a class="code" href="classcsVector3.html#3f761bd195c7ccec59ea863a87a1ad05" title="The Z component of the vector.">z</a>); <a name="l00157"></a>00157 } <a name="l00159"></a><a class="code" href="classcsPath.html#c79b4f5043918b78f11b86c6545b8376">00159</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetForwardVector (<span class="keywordtype">int</span> idx, <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& v) <a name="l00160"></a>00160 { <a name="l00161"></a>00161 spline.SetDimensionValue (6, idx, v.<a class="code" href="classcsVector3.html#823fdba459ff91e8a5e6834ded7c815f" title="The X component of the vector.">x</a>); <a name="l00162"></a>00162 spline.SetDimensionValue (7, idx, v.<a class="code" href="classcsVector3.html#e0a74264b61eb5d61da63b3c101af719" title="The Y component of the vector.">y</a>); <a name="l00163"></a>00163 spline.SetDimensionValue (8, idx, v.<a class="code" href="classcsVector3.html#3f761bd195c7ccec59ea863a87a1ad05" title="The Z component of the vector.">z</a>); <a name="l00164"></a>00164 } <a name="l00166"></a><a class="code" href="classcsPath.html#e3e516426fea85e59a8c267196fcaa89">00166</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> GetPositionVector (<span class="keywordtype">int</span> idx, <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& v) <a name="l00167"></a>00167 { <a name="l00168"></a>00168 v.<a class="code" href="classcsVector3.html#823fdba459ff91e8a5e6834ded7c815f" title="The X component of the vector.">x</a> = spline.GetDimensionValue (0, idx); <a name="l00169"></a>00169 v.<a class="code" href="classcsVector3.html#e0a74264b61eb5d61da63b3c101af719" title="The Y component of the vector.">y</a> = spline.GetDimensionValue (1, idx); <a name="l00170"></a>00170 v.<a class="code" href="classcsVector3.html#3f761bd195c7ccec59ea863a87a1ad05" title="The Z component of the vector.">z</a> = spline.GetDimensionValue (2, idx); <a name="l00171"></a>00171 } <a name="l00173"></a><a class="code" href="classcsPath.html#7d31e5cb8656faf7c16d926299756a68">00173</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> GetUpVector (<span class="keywordtype">int</span> idx, <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& v) <a name="l00174"></a>00174 { <a name="l00175"></a>00175 v.<a class="code" href="classcsVector3.html#823fdba459ff91e8a5e6834ded7c815f" title="The X component of the vector.">x</a> = spline.GetDimensionValue (3, idx); <a name="l00176"></a>00176 v.<a class="code" href="classcsVector3.html#e0a74264b61eb5d61da63b3c101af719" title="The Y component of the vector.">y</a> = spline.GetDimensionValue (4, idx); <a name="l00177"></a>00177 v.<a class="code" href="classcsVector3.html#3f761bd195c7ccec59ea863a87a1ad05" title="The Z component of the vector.">z</a> = spline.GetDimensionValue (5, idx); <a name="l00178"></a>00178 } <a name="l00180"></a><a class="code" href="classcsPath.html#1c71be4f74697c9443143d141ed102c9">00180</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> GetForwardVector (<span class="keywordtype">int</span> idx, <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& v) <a name="l00181"></a>00181 { <a name="l00182"></a>00182 v.<a class="code" href="classcsVector3.html#823fdba459ff91e8a5e6834ded7c815f" title="The X component of the vector.">x</a> = spline.GetDimensionValue (6, idx); <a name="l00183"></a>00183 v.<a class="code" href="classcsVector3.html#e0a74264b61eb5d61da63b3c101af719" title="The Y component of the vector.">y</a> = spline.GetDimensionValue (7, idx); <a name="l00184"></a>00184 v.<a class="code" href="classcsVector3.html#3f761bd195c7ccec59ea863a87a1ad05" title="The Z component of the vector.">z</a> = spline.GetDimensionValue (8, idx); <a name="l00185"></a>00185 } <a name="l00186"></a>00186 <a name="l00188"></a><a class="code" href="classcsPath.html#00765fc3774592c16e94d43764d85e8a">00188</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> GetInterpolatedPosition (<a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& pos) <a name="l00189"></a>00189 { <a name="l00190"></a>00190 pos.<a class="code" href="classcsVector3.html#823fdba459ff91e8a5e6834ded7c815f" title="The X component of the vector.">x</a> = spline.GetInterpolatedDimension (0); <a name="l00191"></a>00191 pos.<a class="code" href="classcsVector3.html#e0a74264b61eb5d61da63b3c101af719" title="The Y component of the vector.">y</a> = spline.GetInterpolatedDimension (1); <a name="l00192"></a>00192 pos.<a class="code" href="classcsVector3.html#3f761bd195c7ccec59ea863a87a1ad05" title="The Z component of the vector.">z</a> = spline.GetInterpolatedDimension (2); <a name="l00193"></a>00193 } <a name="l00195"></a><a class="code" href="classcsPath.html#df23670f8bb465da336b15bba3d44f02">00195</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> GetInterpolatedUp (<a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& pos) <a name="l00196"></a>00196 { <a name="l00197"></a>00197 pos.<a class="code" href="classcsVector3.html#823fdba459ff91e8a5e6834ded7c815f" title="The X component of the vector.">x</a> = spline.GetInterpolatedDimension (3); <a name="l00198"></a>00198 pos.<a class="code" href="classcsVector3.html#e0a74264b61eb5d61da63b3c101af719" title="The Y component of the vector.">y</a> = spline.GetInterpolatedDimension (4); <a name="l00199"></a>00199 pos.<a class="code" href="classcsVector3.html#3f761bd195c7ccec59ea863a87a1ad05" title="The Z component of the vector.">z</a> = spline.GetInterpolatedDimension (5); <a name="l00200"></a>00200 } <a name="l00202"></a><a class="code" href="classcsPath.html#efcb6a00a18ad479b743aa3cd36bb0e1">00202</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> GetInterpolatedForward (<a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& pos) <a name="l00203"></a>00203 { <a name="l00204"></a>00204 pos.<a class="code" href="classcsVector3.html#823fdba459ff91e8a5e6834ded7c815f" title="The X component of the vector.">x</a> = spline.GetInterpolatedDimension (6); <a name="l00205"></a>00205 pos.<a class="code" href="classcsVector3.html#e0a74264b61eb5d61da63b3c101af719" title="The Y component of the vector.">y</a> = spline.GetInterpolatedDimension (7); <a name="l00206"></a>00206 pos.<a class="code" href="classcsVector3.html#3f761bd195c7ccec59ea863a87a1ad05" title="The Z component of the vector.">z</a> = spline.GetInterpolatedDimension (8); <a name="l00207"></a>00207 } <a name="l00209"></a><a class="code" href="classcsPath.html#8bc98d6e146a3585fee56ee0f18cdd0e">00209</a> <span class="keywordtype">float</span> <span class="keyword">const</span>* GetDimensionValues (<span class="keywordtype">int</span> dim)<span class="keyword"> const</span> <a name="l00210"></a>00210 <span class="keyword"> </span>{ <a name="l00211"></a>00211 <span class="keywordflow">return</span> spline.GetDimensionValues(dim); <a name="l00212"></a>00212 } <a name="l00214"></a><a class="code" href="classcsPath.html#616194b67d44b47461af6e1f13a5cb9f">00214</a> <span class="keywordtype">float</span> GetDimensionValue (<span class="keywordtype">int</span> dim, <span class="keywordtype">int</span> idx)<span class="keyword"> const</span> <a name="l00215"></a>00215 <span class="keyword"> </span>{ <a name="l00216"></a>00216 <span class="keywordflow">return</span> spline.GetDimensionValue(dim, idx); <a name="l00217"></a>00217 } <a name="l00222"></a><a class="code" href="classcsPath.html#ec4be6eabfd41e02091ac394a319d646">00222</a> <span class="keywordtype">void</span> InsertPoint (<span class="keywordtype">int</span> idx) <a name="l00223"></a>00223 { <a name="l00224"></a>00224 spline.InsertPoint(idx); <a name="l00225"></a>00225 } <a name="l00227"></a><a class="code" href="classcsPath.html#cbd00e6be47554f48f626ac1c57d552c">00227</a> <span class="keywordtype">void</span> RemovePoint (<span class="keywordtype">int</span> idx) <a name="l00228"></a>00228 { <a name="l00229"></a>00229 spline.RemovePoint(idx); <a name="l00230"></a>00230 } <a name="l00231"></a>00231 }; <a name="l00232"></a>00232 <a name="l00235"></a>00235 <span class="preprocessor">#endif // __CS_PATH_H__</span> </pre></div><hr size="1"><address><small>Generated for Crystal Space 1.2.1 by <a href="http://www.doxygen.org/index.html">doxygen</a> 1.5.3 </small></address> </div></body> </html>