#include <splines.h>
Collaboration diagram for idSplineList:

|
|
Definition at line 161 of file splines.h. 00161 {
00162 clear();
00163 }
|
|
|
Definition at line 165 of file splines.h. References name.
|
|
|
Definition at line 170 of file splines.h. 00170 {
00171 clear();
00172 };
|
|
|
Definition at line 168 of file splines.h. 00168 {
00169 clear();
00170 }
|
|
|
Definition at line 172 of file splines.h. References name.
|
|
|
Definition at line 177 of file splines.h. 00177 {
00178 clear();
00179 };
|
|
||||||||||||||||
|
Definition at line 229 of file splines.h. 00229 {
00230 controlPoints.Append(new idVec3_t(x, y, z));
00231 dirty = true;
00232 }
|
|
|
Definition at line 224 of file splines.h. References v. 00224 {
00225 controlPoints.Append(new idVec3_t(v));
00226 dirty = true;
00227 }
|
|
||||||||||||||||
|
Definition at line 222 of file splines.h. 00222 {
00223 controlPoints.Append(new idVec3_t(x, y, z));
00224 dirty = true;
00225 }
|
|
|
Definition at line 217 of file splines.h. References v. Referenced by idSplinePosition::addControlPoint(), idSplinePosition::addPoint(), and parse(). 00217 {
00218 controlPoints.Append(new idVec3_t(v));
00219 dirty = true;
00220 }
|
|
||||||||||||
|
Definition at line 278 of file splines.h. References assert. 00278 {
00279 assert(index >= 0 && index < splinePoints.Num());
00280 splineTime[index] += time;
00281 }
|
|
||||||||||||
|
Definition at line 271 of file splines.h. References assert. 00271 {
00272 assert(index >= 0 && index < splinePoints.Num());
00273 splineTime[index] += time;
00274 }
|
|
|
|
|
|
Definition at line 122 of file splines.cpp. References calcSpline(), controlPoints, debugLine(), i, j, idList::Num(), VectorCopy, x, y, and z. 00122 {
00123
00124 if (controlPoints.Num() == 0) {
00125 return;
00126 }
00127
00128 idVec3_t mins, maxs;
00129 idVec3_t yellow(1.0, 1.0, 0);
00130 idVec3_t white(1.0, 1.0, 1.0);
00131 int i;
00132
00133 for(i = 0; i < controlPoints.Num(); i++) {
00134 VectorCopy(*controlPoints[i], mins);
00135 VectorCopy(mins, maxs);
00136 mins[0] -= 8;
00137 mins[1] += 8;
00138 mins[2] -= 8;
00139 maxs[0] += 8;
00140 maxs[1] -= 8;
00141 maxs[2] += 8;
00142 debugLine( yellow, mins[0], mins[1], mins[2], maxs[0], mins[1], mins[2]);
00143 debugLine( yellow, maxs[0], mins[1], mins[2], maxs[0], maxs[1], mins[2]);
00144 debugLine( yellow, maxs[0], maxs[1], mins[2], mins[0], maxs[1], mins[2]);
00145 debugLine( yellow, mins[0], maxs[1], mins[2], mins[0], mins[1], mins[2]);
00146
00147 debugLine( yellow, mins[0], mins[1], maxs[2], maxs[0], mins[1], maxs[2]);
00148 debugLine( yellow, maxs[0], mins[1], maxs[2], maxs[0], maxs[1], maxs[2]);
00149 debugLine( yellow, maxs[0], maxs[1], maxs[2], mins[0], maxs[1], maxs[2]);
00150 debugLine( yellow, mins[0], maxs[1], maxs[2], mins[0], mins[1], maxs[2]);
00151
00152 }
00153
00154 int step = 0;
00155 idVec3_t step1;
00156 for(i = 3; i < controlPoints.Num(); i++) {
00157 for (float tension = 0.0f; tension < 1.001f; tension += 0.1f) {
00158 float x = 0;
00159 float y = 0;
00160 float z = 0;
00161 for (int j = 0; j < 4; j++) {
00162 x += controlPoints[i - (3 - j)]->x * calcSpline(j, tension);
00163 y += controlPoints[i - (3 - j)]->y * calcSpline(j, tension);
00164 z += controlPoints[i - (3 - j)]->z * calcSpline(j, tension);
00165 }
00166 if (step == 0) {
00167 step1[0] = x;
00168 step1[1] = y;
00169 step1[2] = z;
00170 step = 1;
00171 } else {
00172 debugLine( white, step1[0], step1[1], step1[2], x, y, z);
00173 step = 0;
00174 }
00175
00176 }
00177 }
00178 }
|
Here is the call graph for this function:

|
|
|
|
|
Definition at line 182 of file splines.cpp. References idList::Append(), calcSpline(), clearSpline(), controlPoints, dirty, i, j, idList::Num(), splinePoints, x, y, and z. Referenced by draw(), initPosition(), totalDistance(), and idSplinePosition::updateSelection(). 00182 {
00183 //int start = Sys_Milliseconds();
00184 clearSpline();
00185 for(int i = 3; i < controlPoints.Num(); i++) {
00186 for (float tension = 0.0f; tension < 1.001f; tension += granularity) {
00187 float x = 0;
00188 float y = 0;
00189 float z = 0;
00190 for (int j = 0; j < 4; j++) {
00191 x += controlPoints[i - (3 - j)]->x * calcSpline(j, tension);
00192 y += controlPoints[i - (3 - j)]->y * calcSpline(j, tension);
00193 z += controlPoints[i - (3 - j)]->z * calcSpline(j, tension);
00194 }
00195 splinePoints.Append(new idVec3_t(x, y, z));
00196 }
00197 }
00198 dirty = false;
00199 //Com_Printf("Spline build took %f seconds\n", (float)(Sys_Milliseconds() - start) / 1000);
00200 }
|
Here is the call graph for this function:

|
||||||||||||
|
|
|
||||||||||||
|
Definition at line 316 of file splines.cpp. References pow(). Referenced by addToRenderer(), and buildSpline(). 00316 {
00317 switch(step) {
00318 case 0: return (pow(1 - tension, 3)) / 6;
00319 case 1: return (3 * pow(tension, 3) - 6 * pow(tension, 2) + 4) / 6;
00320 case 2: return (-3 * pow(tension, 3) + 3 * pow(tension, 2) + 3 * tension + 1) / 6;
00321 case 3: return pow(tension, 3) / 6;
00322 }
00323 return 0.0;
00324 }
|
Here is the call graph for this function:

|
|
Definition at line 198 of file splines.h. References idVec3_t::set(). 00198 {
00199 clearControl();
00200 clearSpline();
00201 splineTime.Clear();
00202 selected = NULL;
00203 dirty = true;
00204 activeSegment = 0;
00205 granularity = 0.025;
00206 pathColor.set(1.0, 0.5, 0.0);
00207 controlColor.set(0.7, 0.0, 1.0);
00208 segmentColor.set(0.0, 0.0, 1.0);
00209 activeColor.set(1.0, 0.0, 0.0);
00210 }
|
Here is the call graph for this function:

|
|
Definition at line 191 of file splines.h. References idVec3_t::set(). 00191 {
00192 clearControl();
00193 clearSpline();
00194 splineTime.Clear();
00195 selected = NULL;
00196 dirty = true;
00197 activeSegment = 0;
00198 granularity = 0.025;
00199 pathColor.set(1.0, 0.5, 0.0);
00200 controlColor.set(0.7, 0.0, 1.0);
00201 segmentColor.set(0.0, 0.0, 1.0);
00202 activeColor.set(1.0, 0.0, 0.0);
00203 }
|
Here is the call graph for this function:

|
|
Definition at line 181 of file splines.h. References i. 00181 {
00182 for (int i = 0; i < controlPoints.Num(); i++) {
00183 delete controlPoints[i];
00184 }
00185 controlPoints.Clear();
00186 }
|
|
|
Definition at line 174 of file splines.h. References i. 00174 {
00175 for (int i = 0; i < controlPoints.Num(); i++) {
00176 delete controlPoints[i];
00177 }
00178 controlPoints.Clear();
00179 }
|
|
|
Definition at line 188 of file splines.h. References i. 00188 {
00189 for (int i = 0; i < splinePoints.Num(); i++) {
00190 delete splinePoints[i];
00191 }
00192 splinePoints.Clear();
00193 }
|
|
|
Definition at line 181 of file splines.h. References i. Referenced by buildSpline(). 00181 {
00182 for (int i = 0; i < splinePoints.Num(); i++) {
00183 delete splinePoints[i];
00184 }
00185 splinePoints.Clear();
00186 }
|
|
|
Definition at line 201 of file splines.cpp. References activeColor, activeSegment, buildSpline(), controlColor, controlPoints, count, glBox(), i, idList::Num(), pathColor, qglBegin, qglColor3fv, qglEnd, qglPointSize, qglVertex3fv, segmentColor, and splinePoints. Referenced by idSplinePosition::draw(). 00201 {
00202 int i;
00203 vec4_t yellow(1, 1, 0, 1);
00204
00205 if (controlPoints.Num() == 0) {
00206 return;
00207 }
00208
00209 if (dirty) {
00210 buildSpline();
00211 }
00212
00213
00214 qglColor3fv(controlColor);
00215 qglPointSize(5);
00216
00217 qglBegin(GL_POINTS);
00218 for (i = 0; i < controlPoints.Num(); i++) {
00219 qglVertex3fv(*controlPoints[i]);
00220 }
00221 qglEnd();
00222
00223 if (editMode) {
00224 for(i = 0; i < controlPoints.Num(); i++) {
00225 glBox(activeColor, *controlPoints[i], 4);
00226 }
00227 }
00228
00229 //Draw the curve
00230 qglColor3fv(pathColor);
00231 qglBegin(GL_LINE_STRIP);
00232 int count = splinePoints.Num();
00233 for (i = 0; i < count; i++) {
00234 qglVertex3fv(*splinePoints[i]);
00235 }
00236 qglEnd();
00237
00238 if (editMode) {
00239 qglColor3fv(segmentColor);
00240 qglPointSize(3);
00241 qglBegin(GL_POINTS);
00242 for (i = 0; i < count; i++) {
00243 qglVertex3fv(*splinePoints[i]);
00244 }
00245 qglEnd();
00246 }
00247 if (count > 0) {
00248 //assert(activeSegment >=0 && activeSegment < count);
00249 if (activeSegment >=0 && activeSegment < count) {
00250 glBox(activeColor, *splinePoints[activeSegment], 6);
00251 glBox(yellow, *splinePoints[activeSegment], 8);
00252 }
00253 }
00254
00255 }
|
Here is the call graph for this function:

|
|
Definition at line 287 of file splines.h. 00287 {
00288 return activeSegment;
00289 }
|
|
|
Definition at line 280 of file splines.h. 00280 {
00281 return activeSegment;
00282 }
|
|
|
Definition at line 250 of file splines.h. 00250 {
00251 return granularity;
00252 }
|
|
|
Definition at line 243 of file splines.h. 00243 {
00244 return granularity;
00245 }
|
|
|
Definition at line 307 of file splines.h. References name.
|
|
|
Definition at line 300 of file splines.h. References name.
|
|
|
Definition at line 258 of file splines.h. References assert. 00258 {
00259 assert(index >= 0 && index < controlPoints.Num());
00260 return controlPoints[index];
00261 }
|
|
|
Definition at line 251 of file splines.h. References assert. Referenced by idSplinePosition::getPoint(). 00251 {
00252 assert(index >= 0 && index < controlPoints.Num());
00253 return controlPoints[index];
00254 }
|
|
|
|
|
|
Definition at line 349 of file splines.cpp. References activeSegment, assert, Com_Printf(), count, idList::Num(), splinePoints, splineTime, t, v1, and v2. Referenced by idSplinePosition::getPosition(). 00349 {
00350 static idVec3_t interpolatedPos;
00351 //static long lastTime = -1;
00352
00353 int count = splineTime.Num();
00354 if (count == 0) {
00355 return &zero;
00356 }
00357
00358 Com_Printf("Time: %d\n", t);
00359 assert(splineTime.Num() == splinePoints.Num());
00360
00361 while (activeSegment < count) {
00362 if (splineTime[activeSegment] >= t) {
00363 if (activeSegment > 0 && activeSegment < count - 1) {
00364 double timeHi = splineTime[activeSegment + 1];
00365 double timeLo = splineTime[activeSegment - 1];
00366 double percent = (timeHi - t) / (timeHi - timeLo);
00367 // pick two bounding points
00368 idVec3_t v1 = *splinePoints[activeSegment-1];
00369 idVec3_t v2 = *splinePoints[activeSegment+1];
00370 v2 *= (1.0 - percent);
00371 v1 *= percent;
00372 v2 += v1;
00373 interpolatedPos = v2;
00374 return &interpolatedPos;
00375 }
00376 return splinePoints[activeSegment];
00377 } else {
00378 activeSegment++;
00379 }
00380 }
00381 return splinePoints[count-1];
00382 }
|
Here is the call graph for this function:

|
|
Definition at line 263 of file splines.h. References assert. 00263 {
00264 assert(index >= 0 && index < splinePoints.Num());
00265 return splinePoints[index];
00266 }
|
|
|
Definition at line 256 of file splines.h. References assert. 00256 {
00257 assert(index >= 0 && index < splinePoints.Num());
00258 return splinePoints[index];
00259 }
|
|
|
Definition at line 274 of file splines.h. References assert. 00274 {
00275 assert(index >= 0 && index < splinePoints.Num());
00276 return splineTime[index];
00277 }
|
|
|
Definition at line 267 of file splines.h. References assert. 00267 {
00268 assert(index >= 0 && index < splinePoints.Num());
00269 return splineTime[index];
00270 }
|
|
|
Definition at line 220 of file splines.h. 00220 {
00221 return selected;
00222 }
|
|
|
Definition at line 213 of file splines.h. 00213 {
00214 return selected;
00215 }
|
|
||||||||||||
|
|
|
||||||||||||
|
Definition at line 281 of file splines.cpp. References activeSegment, idList::Append(), assert, baseTime, buildSpline(), idList::Clear(), i, idVec3_t::Length(), idList::Num(), splinePoints, splineTime, time, and totalDistance(). Referenced by idSplinePosition::start(). 00281 {
00282
00283 if (dirty) {
00284 buildSpline();
00285 }
00286
00287 if (splinePoints.Num() == 0) {
00288 return;
00289 }
00290
00291 baseTime = bt;
00292 time = totalTime;
00293
00294 // calc distance to travel ( this will soon be broken into time segments )
00295 splineTime.Clear();
00296 splineTime.Append(bt);
00297 double dist = totalDistance();
00298 double distSoFar = 0.0;
00299 idVec3_t temp;
00300 int count = splinePoints.Num();
00301 //for(int i = 2; i < count - 1; i++) {
00302 for(int i = 1; i < count; i++) {
00303 temp = *splinePoints[i-1];
00304 temp -= *splinePoints[i];
00305 distSoFar += temp.Length();
00306 double percent = distSoFar / dist;
00307 percent *= totalTime;
00308 splineTime.Append(percent + bt);
00309 }
00310 assert(splineTime.Num() == splinePoints.Num());
00311 activeSegment = 0;
00312 }
|
Here is the call graph for this function:

|
|
Definition at line 254 of file splines.h. 00254 {
00255 return controlPoints.Num();
00256 }
|
|
|
Definition at line 247 of file splines.h. Referenced by idSplinePosition::numPoints(). 00247 {
00248 return controlPoints.Num();
00249 }
|
|
|
Definition at line 296 of file splines.h. 00296 {
00297 return splinePoints.Num();
00298 }
|
|
|
Definition at line 289 of file splines.h. 00289 {
00290 return splinePoints.Num();
00291 }
|
|
|
|
|
|
Definition at line 384 of file splines.cpp. References addPoint(), atof(), idStr::c_str(), Com_Parse(), Com_Parse1DMatrix(), Com_ParseOnLine(), Com_UngetToken(), dirty, granularity, name, point, Q_stricmp(), token, point::x, and point::y. Referenced by idSplinePosition::parse(). |