21did21

04-07-2012, 11:30 AM

Hello all,

it's been a while since I have not done C + + and a fortiori the openGL. In the past i made sphere but now I try to do several things (in different coordinates) with a little more complex forms.

=> Example : I will like to start by making several ellipsoids with differents directions orientation.

the problem is that I do not know how to do this, it sounds complicated to me, no ...?

Thank you in advance for the help you can give me

A +

ps: this is my code for spheres, how i can modify them to have ellipsoides ?

GLUquadric* sphere;

QVector <GLUquadric*> params;

for ( int k = 0 ; k < 400 ; ++k )

{

sphere=gluNewQuadric();

params.push_back(sphere);

}

//--------------------------------tirage au sort des coordonnées-------------------------------------

//on initialise le temps

qsrand(time(NULL));

//Et dans la boucle on utilise tirage entre -5000 et +5000 puis en divise par 1000

float c1=0.0;

float c2=0.0;

float c3=0.0;

//---------------------------------------------------------------------------------------------------

int e=0;

for ( int k = 0 ; k < globalNb ; ++k )

{

for ( int i = 0 ; i < 200 ; ++i )

{

c1 =((qrand() % (5000-(-5000)+1)) + (-5000))/10000.0;

c2 =((qrand() % (5000-(-5000)+1)) + (-5000))/10000.0;

c3 =((qrand() % (5000-(-5000)+1)) + (-5000))/10000.0;

//tracer de la sphere

glPushMatrix( );//save axis system

glTranslatef(c1,c2,c3);

gluSphere(params[e],0.0001*i,10,10);

glPopMatrix( ); //load the saved matrix

e=e+1;

}

}

it's been a while since I have not done C + + and a fortiori the openGL. In the past i made sphere but now I try to do several things (in different coordinates) with a little more complex forms.

=> Example : I will like to start by making several ellipsoids with differents directions orientation.

the problem is that I do not know how to do this, it sounds complicated to me, no ...?

Thank you in advance for the help you can give me

A +

ps: this is my code for spheres, how i can modify them to have ellipsoides ?

GLUquadric* sphere;

QVector <GLUquadric*> params;

for ( int k = 0 ; k < 400 ; ++k )

{

sphere=gluNewQuadric();

params.push_back(sphere);

}

//--------------------------------tirage au sort des coordonnées-------------------------------------

//on initialise le temps

qsrand(time(NULL));

//Et dans la boucle on utilise tirage entre -5000 et +5000 puis en divise par 1000

float c1=0.0;

float c2=0.0;

float c3=0.0;

//---------------------------------------------------------------------------------------------------

int e=0;

for ( int k = 0 ; k < globalNb ; ++k )

{

for ( int i = 0 ; i < 200 ; ++i )

{

c1 =((qrand() % (5000-(-5000)+1)) + (-5000))/10000.0;

c2 =((qrand() % (5000-(-5000)+1)) + (-5000))/10000.0;

c3 =((qrand() % (5000-(-5000)+1)) + (-5000))/10000.0;

//tracer de la sphere

glPushMatrix( );//save axis system

glTranslatef(c1,c2,c3);

gluSphere(params[e],0.0001*i,10,10);

glPopMatrix( ); //load the saved matrix

e=e+1;

}

}