📄 coinhistory.cpp.in
字号:
// O SoTranslation * trans_o = new SoTranslation; trans_o->translation.setValue(1.75f, 2.5f, 0.0f); separator->addChild(trans_o); SoScale * scale_o = new SoScale; scale_o->scaleFactor.setValue(0.57f, 0.57f, 1.0f); separator->addChild(scale_o); SoText3 * o = new SoText3; o->string.setValue( "O" ); o->parts.setValue( SoText3::ALL ); separator->addChild(o); // I SoTranslation * trans_i = new SoTranslation; trans_i->translation.setValue(2.5f, 1.1f, 0.0f); separator->addChild(trans_i); SoScale * scale_i = new SoScale; scale_i->scaleFactor.setValue(0.7f, 0.7f, 1.0f); separator->addChild(scale_i); SoText3 * i = new SoText3; i->string.setValue( "I" ); i->parts.setValue( SoText3::ALL ); separator->addChild(i); // N SoTranslation * trans_n = new SoTranslation; trans_n->translation.setValue(-0.8f, -6.3f, 0.0f); separator->addChild(trans_n); SoScale * scale_n = new SoScale; scale_n->scaleFactor.setValue(0.6f, 0.6f, 1.0f); separator->addChild(scale_n); SoText3 * n = new SoText3; n->string.setValue( "N" ); n->parts.setValue( SoText3::ALL ); separator->addChild(n); // separator sep->addChild(separator); // top SoTranslation * trans_t = new SoTranslation; trans_t->translation.setValue(3.6f, -0.9f, -0.5f); sep->addChild(trans_t); SoScale * scale_t = new SoScale; scale_t->scaleFactor.setValue(0.2f, 0.8f, 0.5f); sep->addChild(scale_t); SoCube * t = new SoCube; sep->addChild(t); // bottom SoTranslation * trans_b = new SoTranslation; trans_b->translation.setValue(0.0f, 11.4f, 0.0f); sep->addChild(trans_b); SoCube * b = new SoCube; sep->addChild(b); sep->unrefNoDelete(); return sep;}SoTexture2 *create_texture(int width, int height, int bpp, unsigned char * raw, bool blend){ SoTexture2 * texture = new SoTexture2; texture->image.setValue(SbVec2s(width, height), bpp, raw); texture->model = (blend?SoTexture2::BLEND:SoTexture2::DECAL); texture->blendColor.setValue(1.0, 0.0, 0.0); return texture;}intmain( int argc, char ** argv ){ textpos = 0; currpart = 0; firstletter = true; @WIDGET@ window = So@Gui@::init(argv[0]); if (window == NULL) exit(1); vp.setWindowSize(SbVec2s(400, 400)); root = new SoSeparator; root->ref(); root->addChild( camera = new SoPerspectiveCamera ); root->addChild( new SoDirectionalLight ); SoShapeHints * hints = new SoShapeHints; hints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE; hints->shapeType = SoShapeHints::SOLID; hints->creaseAngle = 0.91f; root->addChild( hints ); SoSeparator * instructsep = new SoSeparator; root->addChild(instructsep); SoOrthographicCamera * ocam = new SoOrthographicCamera; instructsep->addChild(ocam); SoTranslation * instructtrans = new SoTranslation; // instructtrans->translation = SbVec3f(0.0f, -1.0f, 0.0f); instructsep->addChild(instructtrans); SoText2 * instructions = new SoText2; const char * str[] = { "","","","","","","","", "","","","","","","","", "","","","","","","","", "","","","","","","","", "","","","","","","","", "(Press 'q' to exit)." }; instructions->string.setValues(0, sizeof(str) / sizeof(char *), str); instructions->justification = SoText2::LEFT; instructsep->addChild(instructions); logo = new SoSeparator; SoTransform *logoxf; logo->addChild(logoxf = new SoTransform); logoxf->translation.setValue(SbVec3f(4.0f, -2.0f, 25.0f)); logo->addChild(logorot = new SoRotation); logo->addChild(create_logo(create_texture(64,64,4,(unsigned char*)envq_raw,true))); root->addChild(logo); SoBaseColor * basecol = new SoBaseColor; basecol->rgb.setValue( float(rand())/float(RAND_MAX), float(rand())/float(RAND_MAX), float(rand())/float(RAND_MAX) ); root->addChild( basecol ); textlen = strlen(text2); char tt[2]; tt[1] = 0; num_particles = NUM_PARTICLES; particles = new particleinfo[num_particles]; SoSphere *ball; SoSeparator *textsep = new SoSeparator; root->addChild(textsep); int i; srand( (unsigned)time( NULL ) ); line=0; spos=0; deltax=0.0f; textpos = 0; // add empty text for (i=0; i<num_particles; i++) { particles[i].ax=0.0; particles[i].ay=-9.8f*2.0f; particles[i].az=-4.0f*2.0f; particles[i].delay = -100.0f; textsep->addChild(particles[i].p = new SoSeparator); particles[i].p->addChild(particles[i].xf = new SoTransform); particles[i].p->addChild(particles[i].rot = new SoRotation); SoScale * s = new SoScale; s->scaleFactor.setValue(0.1f, 0.1f, 0.1f); particles[i].p->addChild(s); particles[i].t = new SoText3; tt[0] = ' '; particles[i].t->string.setValue(tt); // particles[i].t->parts.setValue(SoText3::FRONT); particles[i].t->parts.setValue(SoText3::ALL); particles[i].t->justification=SoText3::LEFT; particles[i].p->addChild(particles[i].t); }; lastlettertime = SbTime::getTimeOfDay(); // SoWinExaminerViewer *viewer = new SoWinExaminerViewer(window); So@Gui@ExaminerViewer * viewer = new So@Gui@ExaminerViewer(window);#ifdef HAVE_SOGLRENDERACTION_SORTED_OBJECT_SORTED_TRIANGLE_BLEND viewer->setTransparencyType( SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND );#else // !HAVE_SOGLRENDERACTION_SORTED_OBJECT_SORTED_TRIANGLE_BLEND viewer->setTransparencyType( SoGLRenderAction::SORTED_OBJECT_BLEND );#endif // !HAVE_SOGLRENDERACTION_SORTED_OBJECT_SORTED_TRIANGLE_BLEND viewer->setSceneGraph( root ); viewer->setViewportRegion(vp); camera->viewAll(logo, vp); float x,y,z; SbVec3f cpos; cpos = camera->position.getValue(); cpos.getValue(x, y, z); // camera->position.setValue(x, y, z-10.0f); camera->nearDistance = 1.0; camera->farDistance = 100.0; SoTimerSensor *timerSensor; timerSensor = new SoTimerSensor(timerSensorCallback, NULL); timerSensor->setInterval(SbTime(0, 1000*10)); timerSensor->schedule(); lasttime = SbTime::getTimeOfDay(); starttime = lasttime; viewer->setDecoration(FALSE); viewer->show(); So@Gui@::show( window );#ifdef HAVE_SOCOMPONENT_SETFULLSCREEN // Must do this _after_ show() to avoid the "Start"-bar being // visible with SoWin. (Bug!) (void)viewer->setFullScreen(TRUE);#endif // HAVE_SOCOMPONENT_SETFULLSCREEN So@Gui@::mainLoop(); root->unref(); delete [] particles; return 0;} // main()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -