예제 #1
0
bool Component::isContained(const Pnt2f& p, bool TestAgainstClipBounds) const
{
    if(!getVisible())
    {
        return false;
    }

    Pnt2f PointInCompSpace(DrawingSurfaceToComponent(p,this));
    Border* DrawnBorder(getDrawnBorder());
    Pnt2f TopLeft, BottomRight;
    if(TestAgainstClipBounds && getClipping())
    {
        TopLeft = getClipTopLeft();
        BottomRight = getClipBottomRight();
    }
    else
    {
        TopLeft.setValues(0,0);
        BottomRight = Pnt2f(getSize());
    }

    if(DrawnBorder == NULL)
    {
        return isContainedBounds(PointInCompSpace, TopLeft, BottomRight);
    }
    else
    {
        return isContainedBounds(PointInCompSpace, TopLeft, BottomRight) && 
            DrawnBorder->isContained(PointInCompSpace,0,0,getSize().x(),getSize().y());
    }
}
예제 #2
0
bool Component::setupClipping(Graphics* const Graphics) const
{
    if(getClipping())
    {    
        //Get Clipping initial settings
        Pnt2f ClipTopLeft,ClipBottomRight;
        getClipBounds(ClipTopLeft,ClipBottomRight);

        Vec4d LeftPlaneEquation  (1.0,0.0,0.0, -ClipTopLeft.x()     + Graphics->getClipPlaneOffset()),
              RightPlaneEquation (-1.0,0.0,0.0, ClipBottomRight.x() + Graphics->getClipPlaneOffset()),
              TopPlaneEquation   (0.0,1.0,0.0, -ClipTopLeft.y()     + Graphics->getClipPlaneOffset()),
              BottomPlaneEquation(0.0,-1.0,0.0, ClipBottomRight.y() + Graphics->getClipPlaneOffset());

        //glClipPlane
        //Clip with the Intersection of this components RenderingSurface bounds
        //and its parents RenderingSurface bounds
        if(ClipBottomRight.x()-ClipTopLeft.x() <= 0 || ClipBottomRight.y()-ClipTopLeft.y()<= 0)
        {
            return false;
        }

        if(!glIsEnabled(GL_CLIP_PLANE0)) { glEnable(GL_CLIP_PLANE0); }
        if(!glIsEnabled(GL_CLIP_PLANE1)) { glEnable(GL_CLIP_PLANE1); }
        if(!glIsEnabled(GL_CLIP_PLANE2)) { glEnable(GL_CLIP_PLANE2); }
        if(!glIsEnabled(GL_CLIP_PLANE3)) { glEnable(GL_CLIP_PLANE3); }

        //Clip Plane Equations
        //Clip Planes get transformed by the ModelViewMatrix when set
        //So we can rely on the fact that our current coordinate space
        //is relative to the this components position

        glClipPlane(GL_CLIP_PLANE0,LeftPlaneEquation.getValues());
        glClipPlane(GL_CLIP_PLANE1,RightPlaneEquation.getValues());
        glClipPlane(GL_CLIP_PLANE2,TopPlaneEquation.getValues());
        glClipPlane(GL_CLIP_PLANE3,BottomPlaneEquation.getValues());
    }
    else
    {
        if(glIsEnabled(GL_CLIP_PLANE0)) { glDisable(GL_CLIP_PLANE0); }
        if(glIsEnabled(GL_CLIP_PLANE1)) { glDisable(GL_CLIP_PLANE1); }
        if(glIsEnabled(GL_CLIP_PLANE2)) { glDisable(GL_CLIP_PLANE2); }
        if(glIsEnabled(GL_CLIP_PLANE3)) { glDisable(GL_CLIP_PLANE3); }
    }
    return true;
}
//-------------------------------------------------------------
void captureApp::draw(){
	
	if( state == CAP_STATE_DECODING ){
		camera3D.place();
		ofBackground(0, 0, 0);
		glEnable(GL_DEPTH_TEST);
			ofPushMatrix();
				ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2, -200);		
				ofRotate( ofMap(saveIndex, 0, imageSaver.getSize(), 180 -8, 180 + 8, true), 0, 1, 0);
				decoder.drawCloud();
			ofPopMatrix();
		glDisable(GL_DEPTH_TEST);			
		camera3D.remove();	
		//decoder.drawCurrentFrame(0, 0, 320, 240);
		
//		ofNoFill();
//		ofSetColor(100, 100, 100, 255);
//		ofRect( ofGetWidth()/4, ofGetHeight()-150, ofGetWidth()/2, 20);	
//		ofFill();
//		ofRect( ofGetWidth()/4, ofGetHeight()-150, ofMap(saveIndex, 0, imageSaver.getSize(), 0.0, 1.0, true) * (float)(ofGetWidth()/2), 20);			
		return;
	}
	
	if(!panel.getValueB("frameByFrame")){
		patternFrame = ofGetFrameNum() / panel.getValueI("patternRate");
	}
	
	if (!panel.getValueB("brightnessSetting")){
		ofSetColor(255, 255, 255, 255);
		curGenerator->get(patternFrame).draw(0, 0);
	} else {
		int checkBrightness = panel.getValueI("checkBrightness");
		ofSetColor(checkBrightness, checkBrightness, checkBrightness);
		ofRect(0, 0, ofGetWidth(), ofGetHeight());
	}
	
	if( state == CAP_STATE_CAPTURE ){
		return;
	}
	
	if( panel.getValueB("bSpotLight") ){
		if( state < CAP_STATE_FADEIN ){
			spotLightAlpha = 1.0;
		}else if( state > CAP_STATE_END_DECODE ){
			spotLightAlpha += 0.05;	
			spotLightAlpha = ofClamp(spotLightAlpha, 0, 1);	
		}
	}else if(  !panel.getValueB("bSpotLight") || state == CAP_STATE_CAPTURE ){
		spotLightAlpha = 0.0;
	}
	
	if( state == CAP_STATE_FADEIN ){
		float alpha = ofMap(ofGetElapsedTimef(), fadeInStartTime, fadeInStartTime + panel.getValueF("fadeInTime"), 255, 0.0);
		
		ofPushStyle();
		ofEnableAlphaBlending();
		ofSetColor(0, 0, 0, alpha);
		ofRect(0, 0, ofGetWidth(), ofGetHeight());
		ofPopStyle();
	}
	
	if( state >= CAP_STATE_END_DECODE ){
		ofPushStyle();
		ofSetColor(0, 0, 0, 255);
		ofRect(0, 0, ofGetWidth(), ofGetHeight());
		ofPopStyle();
	}
	
	if( spotLightAlpha <= 0.01 ){
		spotLightAlpha = 0.0;
	}else{
		ofPushStyle();
		ofEnableAlphaBlending();
		float val = 255.0 * panel.getValueF("spotLightBrightness");
		ofSetColor(val, val, val, spotLightAlpha*255.0);
		spotLightImage.draw( ofGetWidth()/2, ofGetHeight()/2, ofGetWidth(), ofGetHeight() );		
		ofPopStyle();
		
		if( state == CAP_STATE_FADEIN ){
			spotLightAlpha *= 0.94;
		}
	}
	
	// fade out/in the button
	serial.writeByte((unsigned int) (spotLightAlpha * 255));
	
	if( state == CAP_STATE_CAPTURE || state == CAP_STATE_FADEIN ){
		return;
	}
	
	if(debugState == CAP_DEBUG) {
		int cameraRate   = panel.getValueI("cameraRate");
		int cameraOffset = panel.getValueI("cameraOffset");
		ofPushStyle();
		ofPushMatrix();
		int padding = 8;
		ofTranslate(panel.getWidth() + padding * 2, padding);
		int recentWidth = 160;
		int recentHeight = 120;
		
		if( panel.getValueB("largeVideo") ){
			recentWidth		= 640;
			recentHeight	= 480;
		}
		
		for(int i = 0; i < curGenerator->size(); i++) {
			ofPushMatrix();
			ofTranslate(
						(i % 3) * (recentWidth + padding),
						(i / 3) * (recentHeight + padding));
			ofSetColor(255, 255, 255);
			if(needsUpdate[i]) {
				recent[i].update();
				needsUpdate[i] = false;
			}
			recent[i].draw(0, 0, recentWidth, recentHeight);
			ofSetColor(255, 0, 0);
			ofNoFill();
			ofRect(0, 0, recentWidth, recentHeight);
			
			// ito wrote..begin
			
			if (i == 0 && panel.getValueB("SHOW_RED") ) {
				ofImage clipping;
				getClipping(recent[i], clipping);
				ofEnableAlphaBlending();
				clipping.update();
				ofSetColor(255, 0, 0);
				clipping.draw(0, 0, recentWidth, recentHeight);
				ofDisableAlphaBlending();
			}
			
			// it wrote..end
			ofPopMatrix();
		}
		ofPopMatrix();
		ofPopStyle();
		
		panel.draw();
		
		if( do1394 && settings != NULL ){
			if( camState == CAMERA_OPEN ){
				settings->draw();
			}
		}
		
		ofSetColor(255, 0, 0);
		ofDrawBitmapString("app fps: " + ofToString(ofGetFrameRate(), 2), 810, 20);
		if(camState == CAMERA_OPEN)
			ofDrawBitmapString("cam fps: "+ofToString(camFps, 2), 810, 40);	
		if( panel.getValueB("B_FACE_TRIGGER") ){
			face.draw(800, 54, 50, 30);
		}else{
			ofDrawBitmapString("face trigger is off\n", 810, 50+18);
		}
	}
}
예제 #4
0
void Component::drawBorder(Graphics* const TheGraphics, const Border* Border, Real32 Opacity) const
{
    if(Border != NULL)
    {
        //Draw My Border
        Border->draw(TheGraphics,0,0,getSize().x(),getSize().y(), getOpacity()*Opacity, getClipping());
    }
}