/* * Chaostreff Announcement fuer CT am 22.6.2004 - by Clifford Wolf * * g++ -o cngw cngw.cc \ * $( coin-config --cppflags --cxxflags --ldflags --libs ) \ * $( soxt-config --cppflags --cxxflags --ldflags --libs ) * */ #include #include #include #include char s[] = "Chaostreff 22.6.2004 ab 19:00 im Kaeuzchen, Gardegasse 8."; char x[] = "QWERTYUIOPASDFGHJKLZXCVBNM0123456789QWERTYUIOPASDFGHJKLZX"; SoText3 *text; float lcolors[6][3] = { { 0.7, 0.0, 0}, { 0.0, 0.7, 0.0}, { 0.0, 0.0, 0.7}, { 0.7, 0.0, 0}, { 0.0, 0.7, 0.0}, { 0.0, 0.0, 0.7} }; SoPointLight *light[6]; SoPerspectiveCamera *pcam; float xpos = -30; void pos_light(int n) { float cpos = 6.0/(n+1) + (xpos+100)/50.0; light[n]->location.setValue(SbVec3f(xpos+cos(cpos)*100+100, sin(cpos)*30, n%2 ? 100 : -5)); } void create_world(SoSeparator *root) { pcam = new SoPerspectiveCamera; pcam->position.setValue(SbVec3f(xpos, -3, 30)); pcam->orientation.setValue(SbVec3f(0.37, -0.93, -0.02), 1.05); root->addChild(pcam); for (int i=0; i<6; i++) { light[i] = new SoPointLight; pos_light(i); light[i]->color.setValue(lcolors[i]); root->addChild(light[i]); } SoSeparator *cube = new SoSeparator(); { SoTransform *cubeTrans = new SoTransform(); cubeTrans->translation.setValue(300, 20, -20); cube->addChild(cubeTrans); SoMaterial *cubeMat = new SoMaterial(); cubeMat->diffuseColor.setValue(.8, .8, .8); cube->addChild(cubeMat); SoCube *cubeCube = new SoCube; cubeCube->width = 1000; cubeCube->height = 100; cubeCube->depth = 10; cube->addChild(cubeCube); } root->addChild(cube); SoFont *font = new SoFont; font->size.setValue(30); root->addChild(font); text = new SoText3; text->string.setValue("--"); root->addChild(text); } void animate_world(void *, SoSensor *) { static int i=0, d=0; int j, k; pcam->position.setValue(SbVec3f(xpos+=0.25, -3, 30)); for (j=0; j<6; j++) pos_light(j); if (!s[i] || d++<5) return; for (d=k=0; k<10; k++) { for (j=i; s[j]; j++) x[j] = ((x[j] + (i-j+1)&127) + 32)&127; if (x[i] == s[i]) { i++; break; } } text->string.setValue(x); } int main(int argc, char **argv) { Widget win = SoXt::init(argv[0]); SoSeparator *root = new SoSeparator; root->ref(); create_world(root); SoTimerSensor *sensor = new SoTimerSensor(animate_world, root); sensor->setInterval(SbTime(0.01)); sensor->schedule(); SoXtExaminerViewer *view = new SoXtExaminerViewer(win); view->setTitle("CNGW Chaostreff"); view->setViewing(FALSE); view->setSceneGraph(root); view->show(); SoXt::show(win); SoXt::mainLoop(); return 0; }