void HudWriter::draw(RenderEngine& render_engine) { if (!vertex_buffer_.empty() && ((drawMode() == DynamicDraw) || (drawMode() == StaticDraw) || (drawMode() == StreamDraw)) ) { if (needsDataRefresh()) { prepareDrawing(render_engine); needs_data_refresh = false; } render_engine.drawVertexArrayObject(vertex_vao_, vertex_buffer_); } }
void Doc::PrepareDrawing() { ArrayPtrVoid params; IntTree tree; params.push_back( &tree ); // We first fill a tree of int with the staff/layer/verse numbers to be process //LogElapsedTimeStart( ); Functor prepareDrawing( &Object::PrepareDrawing ); this->Process( &prepareDrawing, params ); // The tree is used to process each staff/layer/verse separatly // For this, we use a MapOfTypeN that looks for each object if it is of the type // and with @n specified std::map<int,IntTree>::iterator staves; std::map<int,IntTree>::iterator layers; std::map<int,IntTree>::iterator verses; for (staves = tree.child.begin(); staves != tree.child.end(); ++staves) { for (layers = staves->second.child.begin(); layers != staves->second.child.end(); ++layers) { for (verses= layers->second.child.begin(); verses != layers->second.child.end(); ++verses) { //std::cout << staves->first << " => " << layers->first << " => " << verses->first << '\n'; MapOfTypeN map; map[ &typeid(Staff) ] = staves->first; map[ &typeid(Layer) ] = layers->first; map[ &typeid(Verse) ] = verses->first; ArrayPtrVoid paramsLyrics; Functor prepareLyrics( &Object::PrepareLyrics ); this->Process( &prepareLyrics, paramsLyrics, NULL, &map ); } } } //LogElapsedTimeEnd ( "Preparing drawing" ); }
//---------------------------------------------------------------------- void game::guiInput(int in){ //any gui input resets reset timer //start timer to go back to inactive state if(step != -1){ goToAttractStepI = ofGetElapsedTimef(); } if(in == 'b'){ ofToggleFullscreen(); } ////// if(step == -1){ //on attract / inactive state step = 0; goToAttractStepI = ofGetElapsedTimef(); } ////////////////////////////////////////////step 0 inputs ////////////////////////////////////////////step 0 inputs ////////////////////////////////////////////step 0 inputs else if(step == 0){ //waiting for an object to be selected //it cam be from the shapes on the center // or from the object menu on the side //////////////////////////////////////////////////////// //////////////////object menu on the side //waiting for shape to be selected if(in == '1') { //load object recieves (object id, boolean position, display position) loadObject(1,slicingPos,posP); } if(in == '2') { loadObject(2,slicingPos,posP); } if(in == '3') { loadObject(3,slicingPos,posP); } if(in == '4') { loadObject(4,slicingPos,posP); } if(in == '5') { loadObject(5,slicingPos,posP); } if(in == '6') { loadObject(6,slicingPos,posP); } if(in == '7') { loadObject(7,slicingPos,posP); } //if(in == '8') { // loadObject(8,objectPos,posP); //} if(in == '9') { prepareDrawing(); } } ////////////////////////////////////////////step 1 inputs ////////////////////////////////////////////step 1 inputs ////////////////////////////////////////////step 1 inputs else if(step == 1){ //is showing object with flat color //selected an object if(in == 'n') { //go to step 2 setCurrentStep(2); //show armature } else{ //waiting for shape to be selected if(in == '1') { //user can change the selected object clearDisplayedObject(); //load object recieves (object id, boolean position, display position) loadObject(1,slicingPos,posP); //pos.z its the torus radious } if(in == '2') { clearDisplayedObject(); loadObject(2,slicingPos,posP); } if(in == '3') { clearDisplayedObject(); loadObject(3,slicingPos,posP); } if(in == '4') { clearDisplayedObject(); loadObject(4,slicingPos,posP); } if(in == '5') { clearDisplayedObject(); loadObject(5,slicingPos,posP); } if(in == '6') { //user can change the selected object clearDisplayedObject(); loadObject(6,slicingPos,posP); } if(in == '7') { //user can change the selected object clearDisplayedObject(); loadObject(7,slicingPos,posP); } /*if(in == '8') { loadObject(8,objectPos,posP); }*/ if(in == '9') { clearDisplayedObject(); prepareDrawing(); } } } ////////////////////////////////////////////step 2 inputs ////////////////////////////////////////////step 2 inputs ////////////////////////////////////////////step 2 inputs else if(step == 2){ //waiting for armature to be selected if(in == '1') { //select armature 1 loadArmature(1); } if(in == '2') { //select armature 2 loadArmature(2); } } ////////////////////////////////////////////step 3 inputs ////////////////////////////////////////////step 3 inputs ////////////////////////////////////////////step 3 inputs else if(step == 3){ //armature was selected ////showing armature another armature can be selected if(in == '1') { //select armature 1 loadArmature(1); } if(in == '2') { //select armature 2 loadArmature(2); } //////////////////////////////move all armature if(in == 'l') { ofVec3f p = ofVec3f (5,0,0); moveA(p); } if(in == 'j') { ofVec3f p = ofVec3f (-5,0,0); moveA(p); } if(in == 'i') { ofVec3f p = ofVec3f (0,-5,0); moveA(p); } if(in == 'k') { ofVec3f p = ofVec3f (0,5,0); moveA(p); } ///z movement if(in == 'o') { ofVec3f p = ofVec3f (0,0,5); moveA(p); } if(in == 'p') { ofVec3f p = ofVec3f (0,0,-5); moveA(p); }//////////////////////////////rotate all armature if(in == 'c') {//rotate around y ofVec3f r = ofVec3f (0,5,0); rotateA(r); } if(in == 'x') {//rotate around y ofVec3f r = ofVec3f (0,-5,0); rotateA(r); } if(in == 'w') {//rotate around x ofVec3f r = ofVec3f (5,0,0); //degrees!!! rotateA(r); } if(in == 's') {//rotate around x ofVec3f r = ofVec3f (-5,0,0); rotateA(r); } if(in == 'e') {//rotate around z ofVec3f r = ofVec3f (0,0,5); //degrees!!! rotateA(r); } if(in == 'd') {//rotate around z ofVec3f r = ofVec3f (0,0,-5); rotateA(r); } /////////////////a puzzle can be made if(in == 'n') { //send the armature rotations to the 3dObject applyArmRotations(); //now we know the offset position from the armature to create-> cutter & slicer createCutterSlicer(); //do slicing createPuzzle(posP);//create Puzzle goes to step 4 to show the puzzle } } ////////////////////////////////////////////step 4 inputs ////////////////////////////////////////////step 4 inputs ////////////////////////////////////////////step 4 inputs else if(step == 4){ //showing puzzle with colors //waiting for color change if(in == '1') { //call color change funtion ofFloatColor sc = ofFloatColor (1, 1, 0); //yellow ofFloatColor menuColor = ofFloatColor (1, 0, 1); //this color comes from the GUI changeColorToColor(sc,menuColor); } //pressed NEXT if(in == 'n') { //go to step 5 setCurrentStep(5); } ///////////////////////////////move all puzzle if(in == 'l') { SG_VECTOR p = {10,0,0}; moveP(p); } if(in == 'j') { SG_VECTOR p = {-10,0,0}; moveP(p); } if(in == 'i') { SG_VECTOR p = {0,-10,0}; moveP(p); } if(in == 'k') { SG_VECTOR p = {0,10,0}; moveP(p); } /////////////rotate all puzzle // two finger swipe gesture //if(in == 'm') {//rotate right // SG_VECTOR r = {0,10,0};//{0,0.1,0}; // rotateP(r); //} //if(in == 'n') {//rotate left // SG_VECTOR r = {0,-10,0};//{0,-0.1,0}; // rotateP(r); //} //if(in == 'y') {//rotate up // SG_VECTOR r = {10,0,0};// {0.1,0,0}; // rotateP(r); //} //if(in == 'h') {//rotate down // SG_VECTOR r = {-10,0,0};//{-0.1,0,0}; // ofVec3f v; // rotateP(r); //} } ////////////////////////////////////////////step 5 inputs ////////////////////////////////////////////step 5 inputs ////////////////////////////////////////////step 5 inputs else if(step == 5){ //selected color (or not, its not mandatory) //pressed next on color palette step //showing puzzle //now the puzzle can be played with int randcubie=13;//rand()%26;//to follow this cubie for now //this will be decided upon touch, or click on top of puzzle if(myPuzzle->isMoving() == false){ //this is to prevent from reading events while puzzle is moving if(in == 'u'){ //undo last move unDo(); } ////////////////////////////////////////////// FACE ROTATIONS ////////////////////////////// if(in == 'z') { //do rotationbased ontwo cubies id int cubieA = 11; int cubieB = 10; rotateTwoIds(cubieA,cubieB,true); } ////////////////////////////////////////////// FACE ROTATIONS ////////////////////////////// //////// x axis //// x axis if(in == 'q') { //clockwise SG_VECTOR axis = {1,0,0}; rotateByIDandAxis(randcubie,axis,true); } if(in == 'a') { //counter clockwise SG_VECTOR axis = {1,0,0}; rotateByIDandAxis(randcubie,axis,false); } //////// y axis //// y axis if(in == 'w') { //clockwise SG_VECTOR axis = {0,1,0}; rotateByIDandAxis(randcubie,axis,true); }if(in == 's') { //counter clockwise SG_VECTOR axis = {0,1,0}; rotateByIDandAxis(randcubie,axis,false); } //////// z axis //// z axis if(in == 'e') { //clockwise SG_VECTOR axis = {0,0,1}; rotateByIDandAxis(randcubie,axis,true); }if(in == 'd') { //counter clockwise SG_VECTOR axis = {0,0,1}; rotateByIDandAxis(randcubie,axis,false); } } ////////////////////////////////////move all puzzle if(in == 'l') { SG_VECTOR p = {10,0,0}; moveP(p); } if(in == 'j') { SG_VECTOR p = {-10,0,0}; moveP(p); } if(in == 'i') { SG_VECTOR p = {0,-10,0}; moveP(p); } if(in == 'k') { SG_VECTOR p = {0,10,0}; moveP(p); } /////////////rotate all puzzle // two finger swipe gesture //if(in == 'm') {//rotate right // SG_VECTOR r = {0,2,0};//{0,0.1,0}; // rotateP(r); //} //if(in == 'n') {//rotate left // SG_VECTOR r = {0,-2,0};//{0,-0.1,0}; // rotateP(r); //} //if(in == 'y') {//rotate up // SG_VECTOR r = {2,0,0};// {0.1,0,0}; // rotateP(r); //} //if(in == 'h') {//rotate down // SG_VECTOR r = {-2,0,0};//{-0.1,0,0}; // ofVec3f v; // rotateP(r); //} //if(in == 'o') {//rotate c // SG_VECTOR r = {0,0,-2};// {0.1,0,0}; // rotateP(r); //} //if(in == 'p') {//rotate cc // SG_VECTOR r = {0,0,2};//{-0.1,0,0}; // ofVec3f v; // rotateP(r); //} }else if(step == 6){ ////////////////////////////extrusion if(in == 'e') { //take drawing data //check for existing drawing if(myCanvas->drawingExists()){ //make extruded object if(extrudeObject(myCanvas->getPolyline())){ }else{ prepareDrawing(); } } }else if(in == 's'){ ofPolyline *draw = new ofPolyline(); //star draw->addVertex(ofVec2f(-5,-210)); draw->addVertex(ofVec2f(60,-60)); draw->addVertex(ofVec2f(210,-45)); draw->addVertex(ofVec2f(105,60)); draw->addVertex(ofVec2f(150,210)); draw->addVertex(ofVec2f(-5,135)); draw->addVertex(ofVec2f(-150,210)); draw->addVertex(ofVec2f(-105,60)); draw->addVertex(ofVec2f(-210,-45)); draw->addVertex(ofVec2f(-60,-60)); draw->addVertex(ofVec2f(-5,-210)); //draw->close(); // close the shape extrudeObject(draw); } //////////////////////////////////////////////////////// //////////////////object menu on the side //waiting for shape to be selected else if(in == '1') { clearDisplayedObject(); //load object recieves (object id, boolean position, display position) loadObject(1,slicingPos,posP); } else if(in == '2') { clearDisplayedObject(); loadObject(2,slicingPos,posP); } else if(in == '3') { clearDisplayedObject(); loadObject(3,slicingPos,posP); } else if(in == '4') { clearDisplayedObject(); loadObject(4,slicingPos,posP); } else if(in == '5') { clearDisplayedObject(); loadObject(5,slicingPos,posP); } else if(in == '6') { clearDisplayedObject(); loadObject(6,slicingPos,posP); } else if(in == '7') { clearDisplayedObject(); loadObject(7,slicingPos,posP); } //if(in == '8') { // loadObject(8,objectPos,posP); //} else if(in == '9') { clearDisplayedObject(); prepareDrawing(); } } ///////////////////////////////////////////////////////////////// ////////////////RESART button can work on any step, its not showed on step 1 (object selected) if(in == 'r'){ //tell a game to restart restart(); } }