| 1 |
#include "gplaut04.h" |
| 2 |
#include "../createDisk.h" |
| 3 |
#include "../solution.h" |
| 4 |
|
| 5 |
float libPtScaler = 1.0; |
| 6 |
float smallPrimRadius=1.0; |
| 7 |
float largePrimRadius=1.0; |
| 8 |
int numOfStars = 100; |
| 9 |
double mass = 0.0; |
| 10 |
bool blMassDependantOption = false; |
| 11 |
|
| 12 |
SoSeparator *createR3BPoints(float nodemin[], float nodemax[]) |
| 13 |
{ |
| 14 |
SoSeparator *result = new SoSeparator; |
| 15 |
float dis = std::max(std::max((nodemax[0]-nodemin[0]), |
| 16 |
(nodemax[1]-nodemin[1])), |
| 17 |
(nodemax[2]-nodemin[2])); |
| 18 |
|
| 19 |
if(whichType == SOLUTION && whichCoordSystem != ROTATING_F) |
| 20 |
{ |
| 21 |
if(options[OPT_REF_PLAN]) |
| 22 |
{ |
| 23 |
float radius =diskRadius; |
| 24 |
if(whichCoordSystem == INERTIAL_B ) radius = 1-mass; |
| 25 |
SoSeparator *diskSep = createDisk(diskPosition,radius); |
| 26 |
result->addChild(diskSep); |
| 27 |
} |
| 28 |
result->addChild(mySolNode->createInertialFrameScene(dis)); |
| 29 |
return result; |
| 30 |
} |
| 31 |
|
| 32 |
if(whichType == BIFURCATION) dis = 1.0; |
| 33 |
if(options[OPT_LIB_POINTS]) |
| 34 |
{ |
| 35 |
SoSeparator * libPtsSep = createLibrationPoint(mass, dis, libPtScaler, |
| 36 |
whichCoordSystem); |
| 37 |
result->addChild(libPtsSep); |
| 38 |
} |
| 39 |
|
| 40 |
// create reference DISK |
| 41 |
if(options[OPT_REF_PLAN]) |
| 42 |
{ |
| 43 |
float position[3]; |
| 44 |
SoSeparator *diskSep; |
| 45 |
if(whichType == BIFURCATION) |
| 46 |
{ |
| 47 |
diskSep = createDisk(diskPosition,diskRadius); |
| 48 |
} |
| 49 |
else |
| 50 |
{ |
| 51 |
position[0]=-mass; |
| 52 |
position[1]=position[2]=0; |
| 53 |
diskSep = createDisk(position,1.0); |
| 54 |
} |
| 55 |
result->addChild(diskSep); |
| 56 |
} |
| 57 |
|
| 58 |
// create the primaries |
| 59 |
if(options[OPT_PRIMARY]) |
| 60 |
{ |
| 61 |
double pos1 = 1-mass; |
| 62 |
double pos2 = -mass; |
| 63 |
char *txtureFileName = new char [strlen(autoDir) + 30]; |
| 64 |
sprintf(txtureFileName, "%s%s", autoDir, "/plaut04/widgets/large.jpg"); |
| 65 |
result->addChild(createPrimary(1-mass, pos2, 0.25*largePrimRadius, txtureFileName)); |
| 66 |
sprintf(txtureFileName, "%s%s", autoDir, "/plaut04/widgets/small.jpg"); |
| 67 |
result->addChild(createPrimary(mass, pos1, 0.25*smallPrimRadius, txtureFileName)); |
| 68 |
delete [] txtureFileName; |
| 69 |
} |
| 70 |
return result; |
| 71 |
} |
| 72 |
|
| 73 |
#if 0 |
| 74 |
//////////////////////////////////////////////////////////////////////// |
| 75 |
// |
| 76 |
// Set the initial values for the variables: animationLabel, orbitSpeed |
| 77 |
// satSpeed. |
| 78 |
// |
| 79 |
void |
| 80 |
initPara() |
| 81 |
// |
| 82 |
//////////////////////////////////////////////////////////////////////// |
| 83 |
{ |
| 84 |
if(solHead != NULL) |
| 85 |
{ |
| 86 |
solutionp cur = solHead; |
| 87 |
while(cur) |
| 88 |
{ |
| 89 |
cur=cur->next; |
| 90 |
delete solHead; |
| 91 |
solHead = cur; |
| 92 |
} |
| 93 |
} |
| 94 |
solHead = NULL; |
| 95 |
animationLabel = MY_ALL; |
| 96 |
orbitSpeed = 1.0; |
| 97 |
satSpeed = 0.5; |
| 98 |
} |
| 99 |
|
| 100 |
////////////////////////////////////////////////////////////////////////// |
| 101 |
// |
| 102 |
SoSeparator * |
| 103 |
createStarryBackground(int total, float diameter) |
| 104 |
// |
| 105 |
////////////////////////////////////////////////////////////////////////// |
| 106 |
{ |
| 107 |
static bool starsCreated = false; |
| 108 |
static SoSeparator * myBg = new SoSeparator; |
| 109 |
if(!starsCreated) |
| 110 |
{ |
| 111 |
starsCreated = true; |
| 112 |
srand(time(NULL)); |
| 113 |
SoSphere * star = new SoSphere; |
| 114 |
star->radius = 0.002*(rand()%5+1); |
| 115 |
float x, y, z; |
| 116 |
for(int i=0; i<total; ++i) |
| 117 |
{ |
| 118 |
SoSeparator * aStar = new SoSeparator; |
| 119 |
SoTranslation *starTrans = new SoTranslation; |
| 120 |
x = ((rand()%200)/100.0-1)*diameter; |
| 121 |
y = ((rand()%200)/100.0-1)*diameter; |
| 122 |
z = ((rand()%200)/100.0-1)*diameter; |
| 123 |
starTrans->translation.setValue(x, y, z); |
| 124 |
aStar->addChild(starTrans); |
| 125 |
aStar->addChild(star); |
| 126 |
myBg->addChild(aStar); |
| 127 |
} |
| 128 |
} |
| 129 |
myBg->unrefNoDelete(); |
| 130 |
return myBg; |
| 131 |
} |
| 132 |
#endif |