Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

spline.cpp File Reference

#include <windows.h>
#include "bspline.h"
#include "locmath.h"
#include "tll.h"
#include "mmgr.h"

Go to the source code of this file.

Functions

void AddSpline (int Number)
void DeleteSpline (int Number)
int LoadSplines (char *SplineFileName)
void SetSplines ()

Variables

int visible
int numSplines
int cameraMode
int currentSpline
int lookAtPath
char * SplineFileName
SPLINEspline
LinkedList< SPLINESplineList


Function Documentation

void AddSpline int    Number
 

Definition at line 18 of file spline.cpp.

References SPLINE::Active, SPLINE::Blue, SPLINE::Control, SPLINE::CopyOfEndTime, SPLINE::CopyOfStartTime, SPLINE::Degree, SPLINE::EndTime, SPLINE::Green, LinkedList< T >::Insert(), SPLINE::linkPosition, SPLINE::NumControl, SPLINE::NumPoints, SPLINE::Output, SPLINE::Red, SPLINE::Repeat, SPLINE::StartTime, VECTOR::x, VECTOR::y, and VECTOR::z.

Referenced by LoadSplines(), and SetSplines().

00019 {
00020     SPLINE* spline2 = new SPLINE;
00021     spline2->Active = 1;
00022     spline2->Repeat = 1;
00023     spline2->Degree = 3;
00024     spline2->NumControl = 7;
00025     spline2->NumPoints = 100;
00026     spline2->Control = new VECTOR[100];
00027     spline2->Output = new VECTOR[1000];
00028     spline2->StartTime = 5000;
00029     spline2->EndTime = 25000;
00030     spline2->CopyOfStartTime = spline2->StartTime;
00031     spline2->CopyOfEndTime = spline2->EndTime;
00032 
00033     spline2->Red = ((float)(rand()%226) + 30.0) / 255;
00034     spline2->Green = ((float)(rand()%226) + 30.0) / 255;
00035     spline2->Blue = ((float)(rand()%226) + 30.0) / 255;
00036 
00037     for (int loop = 0; loop < 100; loop++)
00038     {
00039         spline2->Control[loop].x = (rand()%60) - 29;  spline2->Control[loop].y = (rand()%60) - 29;  spline2->Control[loop].z = (rand()%60) - 29;
00040     }
00041 
00042     spline2->linkPosition = Number;   //Set the link position of the spline
00043     SplineList.Insert(spline2);       //Insert spline in linked list
00044 }

void DeleteSpline int    Number
 

Definition at line 46 of file spline.cpp.

References LinkedList< T >::Delete().

Referenced by LoadSplines(), and WndProc().

00047 {
00048     SplineList.Delete(Number);
00049 }

int LoadSplines char *    SplineFileName
 

Definition at line 51 of file spline.cpp.

References SPLINE::Active, AddSpline(), SPLINE::Blue, SPLINE::Control, SPLINE::CopyOfEndTime, SPLINE::CopyOfStartTime, currentSpline, SPLINE::Degree, DeleteSpline(), SPLINE::EndTime, FALSE, LinkedList< T >::Get(), SPLINE::Green, lookAtPath, SPLINE::NumControl, SPLINE::NumPoints, numSplines, SPLINE::Red, SPLINE::Repeat, SplineFileName, SPLINE::StartTime, VECTOR::x, VECTOR::y, and VECTOR::z.

Referenced by SetSplines().

00052 {
00053     const int stringLength = 33;
00054     char tempString[stringLength];
00055     FILE* SplineFile;
00056     SplineFile = fopen(SplineFileName, "rt");
00057     if (!SplineFile)
00058     {
00059         MessageBox(NULL, "Spline File didn't open", "Error", MB_OK | MB_ICONERROR);
00060         return 0;
00061     }
00062     fseek(SplineFile, 0, SEEK_SET);
00063     int InitialNumSplines = numSplines;
00064     if (!fgets(tempString, stringLength, SplineFile))
00065     {
00066         MessageBox(NULL, "Error reading from the spline data file", "Error", MB_OK | MB_ICONERROR);
00067         numSplines = InitialNumSplines;
00068         return FALSE;
00069     }
00070     numSplines = atoi(tempString);
00071     if (InitialNumSplines > numSplines)
00072     {
00073         for (int loop = InitialNumSplines - 1; loop >= numSplines; loop--)
00074         {
00075             DeleteSpline(loop);
00076         }
00077     }
00078     if (numSplines > InitialNumSplines)
00079     {
00080         for (int loop = InitialNumSplines; loop < numSplines; loop++)
00081         {
00082             AddSpline(loop);
00083         }
00084     }
00085     for (int loop = 0; loop < numSplines; loop++)
00086     {
00087         spline = SplineList.Get(loop);
00088         // Active flag
00089         fgets(tempString, stringLength, SplineFile);
00090         spline->Active = atoi(tempString);
00091         // Repeat flag
00092         fgets(tempString, stringLength, SplineFile);
00093         spline->Repeat = atoi(tempString);
00094         // Degree
00095         fgets(tempString, stringLength, SplineFile);
00096         spline->Degree = atoi(tempString);
00097         // NumControl
00098         fgets(tempString, stringLength, SplineFile);
00099         spline->NumControl = atoi(tempString);
00100         // NumPoints
00101         fgets(tempString, stringLength, SplineFile);
00102         spline->NumPoints = atoi(tempString);
00103         // StartTime
00104         fgets(tempString, stringLength, SplineFile);
00105         spline->StartTime = atof(tempString);
00106         // EndTime
00107         fgets(tempString, stringLength, SplineFile);
00108         spline->EndTime = atof(tempString);
00109         // Red
00110         fgets(tempString, stringLength, SplineFile);
00111         spline->Red = atof(tempString);
00112         // Green
00113         fgets(tempString, stringLength, SplineFile);
00114         spline->Green = atof(tempString);
00115         // Blue
00116         fgets(tempString, stringLength, SplineFile);
00117         spline->Blue = atof(tempString);
00118 
00119         for (int loop2 = 0; loop2 <= spline->NumControl; loop2++)
00120         {
00121             fgets(tempString, stringLength, SplineFile);
00122             spline->Control[loop2].x = atof(tempString);
00123             fgets(tempString, stringLength, SplineFile);
00124             spline->Control[loop2].y = atof(tempString);
00125             fgets(tempString, stringLength, SplineFile);
00126             spline->Control[loop2].z = atof(tempString);
00127         }
00128         spline->CopyOfStartTime = spline->StartTime;
00129         spline->CopyOfEndTime = spline->EndTime;
00130     }
00131 
00132     currentSpline = numSplines - 1;
00133     if (lookAtPath >= numSplines)
00134         lookAtPath = numSplines - 1;
00135     if (fclose(SplineFile))
00136         MessageBox(NULL, "File didn't close", "Error", MB_OK | MB_ICONERROR);
00137     return 1;
00138 }

void SetSplines  
 

Definition at line 140 of file spline.cpp.

References AddSpline(), LoadSplines(), numSplines, and SplineFileName.

Referenced by InitGL().

00141 {
00142     srand((unsigned)time(NULL));
00143     //Create a new spline
00144     for (int loop = 0; loop < numSplines; loop++)
00145     {
00146         AddSpline(loop);
00147     }
00148     //Load splines from data file
00149     LoadSplines(SplineFileName);
00150 }


Variable Documentation

int cameraMode
 

Definition at line 11 of file spline.cpp.

Referenced by InitGL(), WinMain(), and WndProc().

int currentSpline
 

Definition at line 12 of file spline.cpp.

Referenced by LoadSplines().

int lookAtPath
 

Definition at line 13 of file spline.cpp.

Referenced by LoadSplines().

int numSplines
 

Definition at line 10 of file spline.cpp.

Referenced by LoadSplines(), SetSplines(), and WndProc().

SPLINE* spline
 

Definition at line 15 of file spline.cpp.

char* SplineFileName
 

Definition at line 14 of file spline.cpp.

Referenced by LoadSplines(), and SetSplines().

LinkedList<SPLINE> SplineList
 

Definition at line 16 of file spline.cpp.

int visible
 

Definition at line 9 of file spline.cpp.


Generated on Fri Dec 23 05:15:51 2005 for Constructive Solid Geometry by doxygen1.2.15