Hi all,
Not strictly an FLTK problem so apologies, just wanted to say i have my
3d game of life functioning nicely now, FLTK having GL support is a
real help and allows me to explore programming that i might otherwise
have discounted as 'too difficult to get started with' so am really
rather chuffed...here's a screenshot...
http://imageshack.us/photo/my-images/638/fltk3dgameoflife.jpg/
it works great, not done much
with the look of the interface as yet and as there are no 'true' rules
for the 3d space version of the algorithm there is some experimentation
with settings required there.I will probably just add controls to allow the
user to define their own.
One problem i am having is getting rotation consistent around the
origin, i mean if i switch axes (??) the model flips to whatever the
current angle but on the new axis, this is no surprise to me but my
limited GL knowledge means i am not sure how to remedy it. I had a look
at the cube test programs but it is not clear to me fron that how the
cubeview smoothly rotates in response to the sliders.
Here is my rotation callback:
void LifeWorld::RotateCB_i(Fl_Widget* wgt, void* v)
{
Fl_Button* button = (Fl_Button*) wgt;
string btnLabel = button->label();
if(btnLabel.compare("a+") == 0)
a++;
else if(btnLabel.compare("a-") == 0)
a--;
else if(btnLabel.compare("x+") == 0)
{
a++;
x = 1;
y = 0;
z = 0;
}
else if(btnLabel.compare("x-") == 0)
{
a--;
x = 1;
y = 0;
z = 0;
}
else if(btnLabel.compare("y+") == 0)
{
a++;
x = 0;
y = 1;
z = 0;
}
else if(btnLabel.compare("y-") == 0)
{
a--;
x = 0;
y = 1;
z = 0;
}
else if(btnLabel.compare("z+") == 0)
{
a++;
x = 0;
y = 0;
z = 1;
}
else if(btnLabel.compare("z-") == 0)
{
a--;
x = 0;
y = 0;
z = 1;
}
}
And later the values above are assigned to the private member vars for
use in the GL window drawing:
void GLwin::SetRotation(float a, float x,float y,float z)
{
ang = a;
xpos = x;
ypos = y;
zpos = z;
}
Then used in the draw() method:
//projection mode
//viewport etc
//
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0,0.0,-0.5);
glRotatef(ang,xpos,ypos,zpos);
glScalef(sX,sY,sZ);
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk