예제 #1
0
void scrPointCloud::begin()
{
    ofPushStyle();
	
	//temporarily store the viewport
	glGetIntegerv(GL_VIEWPORT, _viewport_temp);
	
	//set the viewport to our screen only
	int boundsx,boundsy,boundswidth,boundsheight;
	getLiveBounds(boundsx, boundsy, boundswidth, boundsheight);
	boundsy = ofGetHeight()-boundsy-boundsheight;
	glViewport(boundsx, boundsy, boundswidth, boundsheight);
	
	//camera
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	gluPerspective(50.0f, float(boundswidth)/float(boundsheight), 0.1f, 10.0f);
	gluLookAt(0, 0, -distance, 0, 0, 0, 0, 1, 0);
	
	//modelview
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
	glRotatef(spin.x, 1, 0, 0);
	glRotatef(spin.y, 0, 1, 0);
	glTranslatef(translate.x, translate.y, translate.z);
	
	glEnable(GL_DEPTH_TEST);
	glPointSize(pointSize);
}
예제 #2
0
void scrBase::getLiveBounds(int &x, int &y, int &w, int &h) {
    ofRectangle liveBounds = getLiveBounds();
    
    x = liveBounds.x;
    y = liveBounds.y;
    w = liveBounds.width;
    h = liveBounds.height;
}
예제 #3
0
void scrBase::drawChrome() {
	int x, y, width, height;
	getLiveBounds(x, y, width, height);
	
	int x2, y2;
	x2 = x+width; y2 = y+height;
	
	
	//
	// BORDER
	//
	ofPushStyle();
	ofNoFill();
	ofSetLineWidth(GUI_INTERFACE_BORDER_LINE_WIDTH);
	ofSetColor(255,255,255);
	
	int inset=GUI_INTERFACE_BORDER_LINE_WIDTH/2;
	
	//top,bottom,left,right
	ofLine(x, y+inset, x2, y+inset);
	ofLine(x, y2-inset, x2, y2-inset);
	
	ofLine(x+inset, y, x+inset, y2);
	ofLine(x2-inset, y, x2-inset, y2);
	
	ofPopStyle();
	
		
	//
	//CAPTION
	//
	ofPushStyle();
	ofSetColor(255,255,255);
	ofSetLineWidth(0);
	ofFill();
	ofRectangle boundBox;
	boundBox.x = x;
	boundBox.y = y;
	boundBox.width = caption.length() * 10 + 6;
	boundBox.height = 16;
	ofRect(boundBox);
	ofPopStyle();
	
	ofPushStyle();
	ofSetColor(0, 0, 0);
	ofDrawBitmapString(caption, x+3, y+14);
	ofPopStyle();
}
예제 #4
0
void scrPointCloud::mouseDragged(int x, int y, int dx, int dy, int button)
{
	int boundsx, boundsy, boundswidth, boundsheight;
	getLiveBounds(boundsx, boundsy, boundswidth, boundsheight);
	
	if (button==0)
	{
		spin.x += float(dy) / float(boundsheight) * 360.0f;
		spin.y -= float(dx) / float(boundswidth) * 360.0f;
		
		spin.x = ofClamp(spin.x, -180, 180);
	} else {
		distance +=float(dy) / float(boundsheight) * 4.0f;
		distance = ofClamp(distance, 0.1, 10);
		
		translate.z +=float(dx) / float(boundswidth) * 2.0f;
	}
}
예제 #5
0
void scrBase::draw() {
	if (enabled) {
		
		if (_lock != 0)
			if (!_lock->tryLock())
				return;
		drawContent();
		
		ofRectangle liveBounds = getLiveBounds();
		ofNotifyEvent(evtDraw, liveBounds, this);
		
		if (_lock != 0)
			_lock->unlock();
		
	}
	
	if (_hasChrome && g_isInterfaceEnabled)
		drawChrome();
}
예제 #6
0
void scrPointCloud::end()
{
    //clear world states
	glDisable(GL_DEPTH_TEST);	
	
	//clear matricies
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	
	//let's get our full viewport back
	glViewport(_viewport_temp[0], _viewport_temp[1],
			   _viewport_temp[2], _viewport_temp[3]);
    
    int x, y, w, h;
    getLiveBounds(x,y,w,h);
    
    ofDrawBitmapString(ofToString(_nPoints), x + 10, y + 30);
}
예제 #7
0
ofVec2f scrBase::normaliseMouse(float x, float y) {
	ofRectangle b = getLiveBounds();
    return ofVec2f((x-b.x) / b.width,
				   (y-b.y) / b.height);

}
예제 #8
0
void scrBase::transformMouse(float mouseX, float mouseY, float &screenX, float &screenY) {
    ofRectangle liveBounds = getLiveBounds();
    
	screenX = (mouseX - float(liveBounds.x)) / liveBounds.width;
	screenY = (mouseY - float(liveBounds.y)) / liveBounds.height;
}
예제 #9
0
bool scrBase::isHit(float x, float y) {
	return getLiveBounds().inside(x, y);
}