Exemplo n.º 1
0
void ImageComposer::mousePressEvent(QMouseEvent * event){
	/**
	 * Handle a user input through mouse click
	 */
	// FILL IN
	this->moved = true;
	sendMovement();
}
Exemplo n.º 2
0
void ImageComposer::keyPressEvent(QKeyEvent * event){
	/**
	 * Handle a user-input keyboard event
	 */
	if(event->key()==Qt::Key_Up){
//		udRotate.rotate(10,0,1,0);
		udAmount -= 10; // Change by 10 degrees
		updatePVM();	// Update the modelview
		this->moved = true;	// Indicate a new frame is needed
		sendMovement();	// Tell Legion
	}
	else if(event->key()==Qt::Key_Down){
//		udRotate.rotate(-10,0,1,0);
		udAmount += 10;
		updatePVM();
		this->moved = true;
		sendMovement();
	}
	else if(event->key()==Qt::Key_Left){
//		lrRotate.rotate(-10,1,0,0);
		lrAmount -= 10;
		updatePVM();
		this->moved = true;
		sendMovement();
	}
	else if(event->key()==Qt::Key_Right){
		lrAmount += 10;
//		lrRotate.rotate(10,1,0,0);
		updatePVM();
		this->moved = true;
		sendMovement();
	}
//	else if(event->key()==Qt::Key_Plus){
//		this->moved = true;
//		sendMovement();
//	}
//	else if(event->key()==Qt::Key_Minus){
//		this->moved = true;
//		sendMovement();
//	}
}
Exemplo n.º 3
0
ImageComposer::ImageComposer(ImageConnector *conn){
	/**
	 * Create a Qt Window for displaying images and transmitting user commands
	 */
	qRegisterMetaType<Movement>("Movement"); 	// Register Movement struct with Qt
	setFocusPolicy(Qt::ClickFocus);				// Setup window focus behavior
	setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);	// Qt window size behavior
	QObject::connect(conn, SIGNAL(transmitImage(int *,Movement,int,int)), this, SLOT(loadImage(int *,Movement,int,int))); // Connect the image loading slots and signals
	QObject::connect(this, SIGNAL(transmitMovement(Movement)), conn, SLOT(receiveMovement(Movement)));	// Connect the user interaction slots and signals
	QObject::connect( qApp, SIGNAL(lastWindowClosed()), conn, SLOT(receiveDone()) ); // Connect the window close slots and signals

	QLabel *resultLabel = new QLabel();	// Place to put images
	resultLabel->setMinimumWidth(resultSize.width());
	resultLabel->setMinimumHeight(resultSize.height());

	QGridLayout *mainLayout = new QGridLayout; 	// Standard adaptable grid windowing system
	mainLayout->addWidget(resultLabel, 0, 0);	// Only one thing to add
	mainLayout->setSizeConstraint(QLayout::SetFixedSize); // Fill screen
	setLayout(mainLayout);						// Place layout

	this->setAutoFillBackground(true);			// Autofill background between frames (no smearing)
	QPalette p( this->palette());				// Define background color
	p.setColor( QPalette::Window, QColor(Qt::black)); // Black
	this->setPalette(p);						// Set background color

	setWindowTitle(tr("Image Composition"));	// Set window head text
	QTimer *timer = new QTimer(this);			// Prepare frame counter
	connect(timer, SIGNAL(timeout()), this, SLOT(update())); // Connect framerate timer with update function
	timer->start(50);							// Run every 50 ms

//	PVMMatrix.perspective(60,45,0.0001,1000);
	Perspective.ortho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0);	// Orthographic projection for renderer
	Perspective.scale(0.002);							// Rescale the entire scene (should be in model projection)
	Perspective.translate(250,250,0);					// Move to center of screen
	Perspective.rotate(-90,0,0,1);						// Flip so upright

	lrAmount = 0;	// Initialize left-right rotation angle (degrees)
	udAmount = 0;	//		up-down rotation angle

	updatePVM();	// Initial modelview update

	this->counter = 0;	// Frame count
	this->moved = true;	// Creation is movement...
	sendMovement();		// Tell Legion to create an image
}
Exemplo n.º 4
0
core::AppState Client::onRunning() {
	_timeProvider->update(_now);
	core::AppState state = UIApp::onRunning();
	sendMovement();
	if (state == core::AppState::Running) {
		_posLerp.update(_now);
		const glm::vec3& pos = _posLerp.position();
		_camera.setPosition(pos);
		_network->update();
		_world->onFrame(_deltaFrame);
		if (_world->isCreated()) {
			// TODO: properly lerp this
			if (_viewDistance < 500) {
				const int advance = _world->getChunkSize() / 16;
				_viewDistance += advance;
				_fogRange += advance / 2;
			}
		}
	}

	return state;
}