#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(). 00384 {
00385 const char *token;
00386 //Com_MatchToken( text, "{" );
00387 do {
00388 token = Com_Parse( text );
00389
00390 if ( !token[0] ) {
00391 break;
00392 }
00393 if ( !Q_stricmp (token, "}") ) {
00394 break;
00395 }
00396
00397 do {
00398 // if token is not a brace, it is a key for a key/value pair
00399 if ( !token[0] || !Q_stricmp (token, "(") || !Q_stricmp(token, "}")) {
00400 break;
00401 }
00402
00403 Com_UngetToken();
00404 idStr key = Com_ParseOnLine(text);
00405 const char *token = Com_Parse(text);
00406 if (Q_stricmp(key.c_str(), "granularity") == 0) {
00407 granularity = atof(token);
00408 } else if (Q_stricmp(key.c_str(), "name") == 0) {
00409 name = token;
00410 }
00411 token = Com_Parse(text);
00412
00413 } while (1);
00414
00415 if ( !Q_stricmp (token, "}") ) {
00416 break;
00417 }
00418
00419 Com_UngetToken();
00420 // read the control point
00421 idVec3_t point;
00422 Com_Parse1DMatrix( text, 3, point );
00423 addPoint(point.x, point.y, point.z);
00424 } while (1);
00425
00426 //Com_UngetToken();
00427 //Com_MatchToken( text, "}" );
00428 dirty = true;
00429 }
|
Here is the call graph for this function:

|
|
Definition at line 291 of file splines.h. 00291 {
00292 //assert(i >= 0 && (splinePoints.Num() > 0 && i < splinePoints.Num()));
00293 activeSegment = i;
00294 }
|
|
|
Definition at line 284 of file splines.h. 00284 {
00285 //assert(i >= 0 && (splinePoints.Num() > 0 && i < splinePoints.Num()));
00286 activeSegment = i;
00287 }
|
|
|
Definition at line 328 of file splines.h. 00328 {
00329 baseTime = t;
00330 }
|
|
|
Definition at line 321 of file splines.h. 00321 {
00322 baseTime = t;
00323 }
|
|
||||||||||||||||||||
|
Definition at line 300 of file splines.h. 00300 {
00301 pathColor = path;
00302 segmentColor = segment;
00303 controlColor = control;
00304 activeColor = active;
00305 }
|
|
||||||||||||||||||||
|
Definition at line 293 of file splines.h. 00293 {
00294 pathColor = path;
00295 segmentColor = segment;
00296 controlColor = control;
00297 activeColor = active;
00298 }
|
|
|
Definition at line 246 of file splines.h. 00246 {
00247 granularity = f;
00248 }
|
|
|
Definition at line 239 of file splines.h. 00239 {
00240 granularity = f;
00241 }
|
|
|
Definition at line 311 of file splines.h. References name. 00311 {
00312 name = p;
00313 }
|
|
|
Definition at line 304 of file splines.h. References name. 00304 {
00305 name = p;
00306 }
|
|
||||||||||||
|
Definition at line 269 of file splines.h. References assert. 00269 {
00270 assert(index >= 0 && index < splinePoints.Num());
00271 splineTime[index] = time;
00272 }
|
|
||||||||||||
|
Definition at line 262 of file splines.h. References assert. 00262 {
00263 assert(index >= 0 && index < splinePoints.Num());
00264 splineTime[index] = time;
00265 }
|
|
|
|
|
|
Definition at line 336 of file splines.cpp. References controlPoints, i, idList::Num(), p, selected, and idVec3_t::Snap(). 00336 {
00337 if (p) {
00338 p->Snap();
00339 for(int i = 0; i < controlPoints.Num(); i++) {
00340 if (*p == *controlPoints[i]) {
00341 selected = controlPoints[i];
00342 }
00343 }
00344 } else {
00345 selected = NULL;
00346 }
00347 }
|
Here is the call graph for this function:

|
|
Definition at line 324 of file splines.h. References time(). 00324 {
00325 time = t;
00326 }
|
Here is the call graph for this function:

|
|
Definition at line 317 of file splines.h. References time(). 00317 {
00318 time = t;
00319 }
|
Here is the call graph for this function:

|
|
Definition at line 236 of file splines.h. 00236 {
00237 editMode = true;
00238 }
|
|
|
Definition at line 229 of file splines.h. 00229 {
00230 editMode = true;
00231 }
|
|
|
Definition at line 240 of file splines.h. 00240 {
00241 editMode = false;
00242 }
|
|
|
Definition at line 233 of file splines.h. 00233 {
00234 editMode = false;
00235 }
|
|
|
|
|
|
Definition at line 260 of file splines.cpp. References buildSpline(), controlPoints, i, idVec3_t::Length(), idList::Num(), and splinePoints. Referenced by initPosition(), and idSplinePosition::start(). 00260 {
00261
00262 if (controlPoints.Num() == 0) {
00263 return 0.0;
00264 }
00265
00266 if (dirty) {
00267 buildSpline();
00268 }
00269
00270 float dist = 0.0;
00271 idVec3_t temp;
00272 int count = splinePoints.Num();
00273 for(int i = 1; i < count; i++) {
00274 temp = *splinePoints[i-1];
00275 temp -= *splinePoints[i];
00276 dist += temp.Length();
00277 }
00278 return dist;
00279 }
|
Here is the call graph for this function:

|
|
|
|
|
Definition at line 328 of file splines.cpp. References dirty, move(), selected, and VectorAdd. 00328 {
00329 if (selected) {
00330 dirty = true;
00331 VectorAdd(*selected, move, *selected);
00332 }
00333 }
|
Here is the call graph for this function:

|
|
Definition at line 315 of file splines.h. 00315 {
00316 if (dirty) {
00317 buildSpline();
00318 }
00319 // gcc doesn't allow static casting away from bools
00320 // why? I've no idea...
00321 return (bool)(splineTime.Num() > 0 && splineTime.Num() == splinePoints.Num());
00322 }
|
|
|
Definition at line 308 of file splines.h. 00308 {
00309 if (dirty) {
00310 buildSpline();
00311 }
00312 // gcc doesn't allow static casting away from bools
00313 // why? I've no idea...
00314 return (bool)(splineTime.Num() > 0 && splineTime.Num() == splinePoints.Num());
00315 }
|
|
||||||||||||
|
|
|
||||||||||||
|
Definition at line 431 of file splines.cpp. References idStr::c_str(), controlPoints, FS_Write(), granularity, i, idStr::length(), idList::Num(), p, s, va(), x, y, and z. Referenced by idSplinePosition::write(). 00431 {
00432 idStr s = va("\t\t%s {\n", p);
00433 FS_Write(s.c_str(), s.length(), file);
00434 //s = va("\t\tname %s\n", name.c_str());
00435 //FS_Write(s.c_str(), s.length(), file);
00436 s = va("\t\t\tgranularity %f\n", granularity);
00437 FS_Write(s.c_str(), s.length(), file);
00438 int count = controlPoints.Num();
00439 for (int i = 0; i < count; i++) {
00440 s = va("\t\t\t( %f %f %f )\n", controlPoints[i]->x, controlPoints[i]->y, controlPoints[i]->z);
00441 FS_Write(s.c_str(), s.length(), file);
00442 }
00443 s = "\t\t}\n";
00444 FS_Write(s.c_str(), s.length(), file);
00445 }
|
Here is the call graph for this function:

|
|
Definition at line 339 of file splines.h. Referenced by draw(). |
|
|
Definition at line 343 of file splines.h. Referenced by draw(), getPosition(), and initPosition(). |
|
|
Definition at line 344 of file splines.h. Referenced by initPosition(). |
|
|
Definition at line 339 of file splines.h. Referenced by draw(). |
|
|
|
|
|
Definition at line 328 of file splines.h. Referenced by addToRenderer(), buildSpline(), draw(), setSelectedPoint(), totalDistance(), and write(). |
|
|
Definition at line 342 of file splines.h. Referenced by buildSpline(), parse(), and updateSelection(). |
|
|
|
|
|
|
|
|
Definition at line 333 of file splines.h. Referenced by parse(). |
|
|
Definition at line 339 of file splines.h. Referenced by draw(). |
|
|
Definition at line 339 of file splines.h. Referenced by draw(). |
|
|
|
|
|
Definition at line 331 of file splines.h. Referenced by setSelectedPoint(), and updateSelection(). |
|
|
|
|
|
Definition at line 329 of file splines.h. Referenced by buildSpline(), draw(), getPosition(), initPosition(), and totalDistance(). |
|
|
|
|
|
Definition at line 330 of file splines.h. Referenced by getPosition(), and initPosition(). |
|
|
Definition at line 345 of file splines.h. Referenced by initPosition(). |
|
|
|
1.3.9.1