void ofx2DTrackedMappingView::update() {

    mapping_forms.updateForms();
    object_list.clear();
    updateObjectList();

}
Example #2
0
//--------------------------------------------------------------
void testApp::update(){
    
    // Update the control text based on the player's choice on the title screen.
    if ( gameState == 0 ) fWriteControls();
    
    // Don't update anything else if not on the game screen.
    if ( gameState != 1 ) return;
    
    // Reset essential conditionals.
    myPlayer.onSurface = false;
    
    if ( getThisOne < 0 ) getThisOne = objectList.size() - 1;
    if ( getThisOne > objectList.size() - 1 ) getThisOne = 0;
    
    // Apply gravity to the player.
    // Come back to this. Use it to fake analog sensitivity with jump height proportional to how long the button is held. Gravity only applies sometimes.
    myPlayer.applyForce( ofVec2f( 0.0, 0.3 ) );
    
    // Run collision detection.
    playerCollidesWithObject();
    
    // Update the player (duh).
    myPlayer.update();
    
    // Update the notes.
    updateObjectList();
    
    // Following up the boolean function we created above, this oF function sorts the vector according to the values of the booleans and then removes any with a 'true' value:
    ofRemove( objectList, bShouldIErase );
    ofRemove( recordedList, bShouldIErase );
}
void ofx2DMappingView::update() {

    mapping_forms.update();

    for(uint i = 0; i < add_button_params.size(); i++) {
        if(add_button_params.at(i)) {
            ctrl->getProjector(0)->copyShape(ctrl->getOptions().at(i));
            mapping_forms.updateForms();
            updateObjectList();
            add_button_params.at(i) = false;
        }
    }

}
void AppearanceOptions::actionSetCurrentAppearance(AppearanceView *pAppearance)
{
	if(pAppearance == 0)
	{
		m_pObjectListComboBox->clear();
		m_pObjectListComboBox->setDisabled(true);

		m_pMaterialSelectionSpinBox->setValue(0);
		m_pMaterialSelectionSpinBox->setDisabled(true);

		for(int i = 0; i < m_pDrawList->count(); i++)
		{
			if(m_pDrawList->item(i))
			{
				delete m_pDrawList->item(i);
			}
		}
		m_pDrawList->clear();
		m_pDrawList->setDisabled(true);

		m_pAddButton->setDisabled(true);
		m_pMinusButton->setDisabled(true);

		m_pAlphaButton->setDisabled(true);
		m_pBackgroundColorButton->setDisabled(true);

		return;
	}

	m_pCurrentAppearance = pAppearance;

	updateObjectList(m_pCurrentAppearance->objectList());

	m_bAlpha = !m_pCurrentAppearance->alphaDiscard();
	actionAlphaClicked();

	m_pObjectListComboBox->setDisabled(false);
	m_pMaterialSelectionSpinBox->setDisabled(false);
	m_pAddButton->setDisabled(false);
	m_pMinusButton->setDisabled(false);
	m_pDrawList->setDisabled(false);
	m_pAlphaButton->setDisabled(false);
	m_pBackgroundColorButton->setDisabled(false);
}
Example #5
0
//--------------------------------
void CGLWin::openCia3dFile()
{
	assert(m_pGLUIWin!=NULL);
	static QString dirPath = "";

    QString fname = QFileDialog::getOpenFileName(
		dirPath,
		//"Surface mesh(*.txt *.ply *.plt *.stl *.obj)",
		"Tecplot Output (*.plt)\nTriangle Meshes (*.obj *.ply *.stl *.txt)\nTetrahedral Meshes (*.mesh *.hmascii *.offv)\nAll Files (*.*)",
		this,
		"Open File Dialog",
		"Choose a mesh file to open"
		);
	//no filename as input
    if (fname.isEmpty()) return;
	if (_openCia3dFile(fname)){
		m_strFileName = fname;	
		setCaption(fname);
	}

	//update left side list
	updateObjectList();
}
void ofx2DMappingView::removeAllObjects() {
    ctrl->getProjector(0)->removeAllShapes();
    ctrl->getProjector(0)->updateOutlines();
    mapping_forms.updateForms();
    updateObjectList();
}
void ofx2DMappingView::importSvg() {
    ctrl->importSvg();
    mapping_forms.updateForms();
    object_list.clear();
    updateObjectList();
}
void ofx2DMappingView::setup(float x, float y, float w, float h) {

    control_rect.x = x;
    control_rect.y = y;
    control_rect.width= w;
    control_rect.height= h;

    //MAPPING RECT PANEL
    mapping_forms.setup("MAPPING FORMS", ctrl->getProjector(0), &object_list, w, h);
    mapping_forms.rebuild();
    mapping_forms.setMappingBackground(ctrl->getOutput());

    //MAIN OPTIONS PANEL

    main_panel.setup("MAPPING");

    save_btn.addListener(ctrl, &ofx2DMappingController::saveMappingDefault);
    save_btn.setup("save");
    main_panel.add(&save_btn);

    import_btn.addListener(this, &ofx2DMappingView::importSvg);
    import_btn.setup("import svg");
    main_panel.add(&import_btn);

    edit_mode_btn.addListener(this, &ofx2DMappingView::setEditMode);
    edit_mode_btn.setup("direct edit", direct_edit);
    main_panel.add(&edit_mode_btn);

    //CALIBRATION OPTIONS

    calibration_options.setup("CALIBRATION OPTIONS");

    calibration_options.add(ctrl->getCalibrating());
    calibration_options.add(ctrl->getCalBorder());
    calibration_options.add(ctrl->getCalGrey());

    main_panel.add(&calibration_options);

    //OBJECT LIST PANEL

    list_panel.setup("MAPPING OBJECTS");

    add_buttons_panel.setup("ADD MAPPING OBJECTS");

    add_button_params.clear();
    vector<ofPtr<ofx2DMappingObject>> options = ctrl->getOptions();
    for(uint i = 0; i < options.size(); i++) {
        add_button_params.push_back(ofParameter<bool>("add " + options.at(i)->name, false));
        add_buttons_panel.add(add_button_params.at(i));
    }

    list_panel.add(&add_buttons_panel);

    //LIST MANIPULATION OPTIONS

    list_options.setup("OBJECT MANIPULATION");

    select_all_btn.addListener(this, &ofx2DMappingView::selectAllObjects);
    select_all_btn.setup("select all");
    list_options.add(&select_all_btn);

    deselect_all_btn.addListener(this, &ofx2DMappingView::deselectAllObjects);
    deselect_all_btn.setup("deselect all");
    list_options.add(&deselect_all_btn);

    delete_all_btn.addListener(this, &ofx2DMappingView::removeAllObjects);
    delete_all_btn.setup("delete all");
    list_options.add(&delete_all_btn);

    list_panel.add(&list_options);

    //OBJECT LIST

    object_list.setup("MAPPING OBJECT LIST");
    ofAddListener(object_list.elementRemoved, this, &ofx2DMappingView::removeForm);
    ofAddListener(object_list.elementMovedStepByStep, this, &ofx2DMappingView::reorderForm);
    object_list.setHeaderBackgroundColor(ofColor::black);

    list_panel.add(&object_list);

    setSubpanelPositions();

    updateObjectList();


}
Example #9
0
//--------------------------------------------------------------
void testApp::update(){
    
    { // Repeated from setup. Allow controller to be switched on/off during play. Thanks to Michael Kahane for leading the way on this.
        if ( bUsingController == false ) {
            //CHECK IF THERE EVEN IS A GAMEPAD CONNECTED
            if(ofxGamepadHandler::get()->getNumPads()>0){
                bUsingController = true;
                ofxGamepad* pad = ofxGamepadHandler::get()->getGamepad(0);
                ofAddListener(pad->onAxisChanged, this, &testApp::axisChanged);
                ofAddListener(pad->onButtonPressed, this, &testApp::buttonPressed);
                ofAddListener(pad->onButtonReleased, this, &testApp::buttonReleased);
            } else {
                bUsingController = false;
            }
        }
    } // End ofxGamepad stuff
    
    // Don't update anything else if not on the game screen.
    if ( gameState < 1 ) return;
    
    myStaff.update();
    
    fCalcTrebleNotes();
    
    // Reset essential conditionals.
    myPlayer.onSurface = false;
    myPlayer2.onSurface = false;
    
    if ( bHighlightNote ) {
        if ( getThisOne < 0 ) getThisOne = objectList.size() - 1;
        if ( getThisOne > objectList.size() - 1 ) getThisOne = 0;
    }
    
    fApplyGravity();
    
    // Run collision detection.
    playerCollidesWithGroundOrSky();
    playerCollidesWithObstacle();
    playerCollidesWithObject();
    objectCollidesWithObstacle();
    
    // Calculate the player's success:
    iHitCounter = 0; // Reset this every frame.
    for ( int i = 0; i < objectList.size(); i++ ) {
        if ( objectList[ i ].bWasTouched == true ) {
            iHitCounter++;
        }
    }
    
    // Update the player (duh).
    myPlayer.update( gameState );
    if ( gameState >= 3 ) {
        myPlayer2.update( gameState );
    }
    
    // Update the notes.
    updateObjectList();
    
    ofRemove( objectList, bShouldIErase );
    ofRemove( recordedList, bShouldIErase );
}