Esempio n. 1
0
ClientHandler::ClientHandler(
    Ogre::TexturePtr texture, 
    Ogre::RenderWindow *window, 
    OIS::Mouse* mouse, 
    Ogre::Camera* camera,
    Ogre::SceneManager* sceneManager,
    WorldPtr world,
    AppContextPtr context
) 
:
renderTexture(texture),
window(window),
mouse(mouse),
keyTimer(new Ogre::Timer()),
context(context),
sceneManager(sceneManager)
{
    this->context->camera = camera;
    this->context->world = world;
    ForwardedFunctionHandlerPtr toggleWireframe(new ToggleWireframeHandler(context));
    ForwardedFunctionHandlerPtr createVoxelHandler(new CreateVoxelHandler(context));
    ForwardedFunctionHandlerPtr clearVoxelsHandler(new ClearVoxelsHandler(context));
    ForwardedFunctionHandlerPtr defineVoxelHandler(new DefineVoxelHandler(context));
    ForwardedFunctionHandlerPtr createVoxelsHandler(new CreateVoxelsHandler(context));
    
    functionHandlers.insert({toggleWireframe->GetFunctionName(), toggleWireframe});
    functionHandlers.insert({createVoxelHandler->GetFunctionName(), createVoxelHandler});
    functionHandlers.insert({clearVoxelsHandler->GetFunctionName(), clearVoxelsHandler});
    functionHandlers.insert({defineVoxelHandler->GetFunctionName(), defineVoxelHandler});
    functionHandlers.insert({createVoxelsHandler->GetFunctionName(), createVoxelsHandler});
}
void LVRMainWindow::assertToggles()
{
    togglePoints(m_actionShow_Points->isChecked());
    toggleNormals(m_actionShow_Normals->isChecked());
    toggleMeshes(m_actionShow_Mesh->isChecked());
    toggleWireframe(m_actionShow_Wireframe->isChecked());
}
int GLWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGLWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0:
            toggleWireframe((*reinterpret_cast< bool(*)>(_a[1])));
            break;
        case 1:
            toggleBoidAnimation((*reinterpret_cast< bool(*)>(_a[1])));
            break;
        case 2:
            toggleGoalAnimation((*reinterpret_cast< bool(*)>(_a[1])));
            break;
        case 3:
            toggleRecord((*reinterpret_cast< bool(*)>(_a[1])));
            break;
        case 4:
            setMass((*reinterpret_cast< double(*)>(_a[1])));
            break;
        case 5:
            setMaxSpeed((*reinterpret_cast< double(*)>(_a[1])));
            break;
        case 6:
            setMaxForce((*reinterpret_cast< double(*)>(_a[1])));
            break;
        case 7:
            setSepDist((*reinterpret_cast< double(*)>(_a[1])));
            break;
        case 8:
            setCohDist((*reinterpret_cast< double(*)>(_a[1])));
            break;
        case 9:
            setAliDist((*reinterpret_cast< double(*)>(_a[1])));
            break;
        case 10:
            setGoalInf((*reinterpret_cast< int(*)>(_a[1])));
            break;
        case 11:
            removeBoid();
            break;
        case 12:
            addBoid();
            break;
        case 13:
            resetGoals();
            break;
        default:
            ;
        }
        _id -= 14;
    }
    return _id;
}
Esempio n. 4
0
Camera::Camera(float fov, float nearp, float farp) {
    init();
    this->fov = fov;
    this->nearPlane = nearp;
    this->farPlane = farp;

    this->x = this->y = this->z = 0;
    this->rx = this->ry = this->rz = 0;
    target = 0;

    wireframe = true;
    toggleWireframe();
}
void LuckyLeprechauns::update(const GameTime& gameTime)
{
	if (player)
	{
		LeprechaunController& leprechaun = player->getLeprechaun();

		// Cheats
		if (Keyboard::isKeyPress('4'))
			leprechaun.collectItem(ItemType::invisibility);
		else if (Keyboard::isKeyPress('5'))
			leprechaun.collectItem(ItemType::explosionTrap);
		else if (Keyboard::isKeyPress('6'))
			leprechaun.collectItem(ItemType::pigRobbery);
		else if (Keyboard::isKeyPress('7'))
			leprechaun.collectItem(ItemType::attackDouble);
		else if (Keyboard::isKeyPress('8'))
			leprechaun.collectItem(ItemType::invulnerability);
		else if (Keyboard::isKeyPress('9'))
			leprechaun.collectItem(ItemType::showInvisibility);
		else if (Keyboard::isKeyPress('0'))
			leprechaun.collectItem(ItemType::speedBoost);
		else if (Keyboard::isKeyPress('I'))
			leprechaun.setInvulnerable(!leprechaun.hasInvulnerability());
	}

	if (Keyboard::isKeyPress(VK_TAB))
		toggleWireframe();
	else if (Keyboard::isKeyPress('M'))
		toggleCursor();
	else if (Keyboard::isKeyPress('C'))
		toggleCamera(true);
	else if (Keyboard::isKeyPress('H'))
		getGuiManager().setVisible(!getGuiManager().isVisible());
	else if (Keyboard::isKeyPress('L'))
		getCamera().toggleLock();
	else if (Keyboard::isKeyPress('R'))
		getPlayer().getLeprechaun().setPosition(getCamera().getPosition());
	else if (Keyboard::isKeyPress('B'))
		((LLSoundManager&)getSoundManager()).toggleBackgroundMusic();

	if (player)
		player->BasicComponent<Game>::setEnabled(&getCamera() == camera);

	Game::update(gameOver ? gameOverTime : gameTime);
}
void VegetationRendering::update(const GameTime& gameTime)
{
	camera->update(gameTime);
	inputManager->update(gameTime);

	if (captureMode)
	{
		if (currentCaptureView < camera->getCurrentViewCounter())
		{
			outputSum();
			goToNextCaptureFile();
		}

		currentCaptureTime += gameTime.elapsed;
		if(currentCaptureTime > CAPTURE_INIT_TIME)
		{
			double frames = (double)DXUTGetFPS();
			captureFile << frames << std::endl;
			frameSum += frames;
			frameCount++;
		}

		if (camera->getCurrentViewCounter() == -1)
		{
			stopCapturing();
			instancesIndex++;
			if (instancesIndex < instancesCount)
				startCapturing(captureFilename);
			else
			{
				captureSumFile.close();
				trunk->setDrawInstanceCount(50);
			}
		}
	}

	if (Keyboard::isKeyPress('M'))
		toggleCursor();
	else if (Keyboard::isKeyPress('F'))
		toggleWireframe();
	else if (Keyboard::isKeyPress('T'))
		complexGrass->toggleTessellationMode();
	else if (Keyboard::isKeyPress('C'))
		gsCullingEnabled = !gsCullingEnabled;
	else if (Keyboard::isKeyPress('P'))
	{
		showSavedEnabled = !showSavedEnabled;
		if(showSavedEnabled)
		{
			savedViewMatrix = camera->getView();
			savedProjectionMatrix = camera->getProjection(complexGrass->getGrassNearPlane(), complexGrass->getGrassFarPlane());
		}
	}
	/*else if (Keyboard::isKeyPress('L'))
		camera->outputCameraView("CameraViews.txt");
	else if (Keyboard::isKeyPress('V'))
		camera->pauseVisitCameraViews();
	else if (Keyboard::isKeyPress('N'))
		camera->goToNextCameraView();*/
	/*else if (Keyboard::isKeyPress('7'))
	{
		instancesIndex = 0;
		instancesCount = grassTestInstanceCounts.size();
		grassTests = true;
		capturedBorder = complexGrass->getBorder();
		captureSumFile.open("GrassSum.txt", std::ios::out);
		startCapturing("GrassResults");
	}
	else if (Keyboard::isKeyPress('8'))
	{
		instancesIndex = 0;
		instancesCount = treeTestInstanceCounts.size();
		grassTests = false;
		capturedBorder = trunk->getBorder();
		captureSumFile.open("TreeSum.txt", std::ios::out);
		startCapturing("TreeResults");
	}*/
	/*else if (Keyboard::isKeyPress('1'))
		gsGrassEnabled = !gsGrassEnabled;*/
	else if (Keyboard::isKeyPress('2'))
		complexGrassEnabled = !complexGrassEnabled;
	else if (Keyboard::isKeyPress('3'))
		defaultGrassEnabled = !defaultGrassEnabled;
	else if (Keyboard::isKeyPress('4'))
		treeModelsEnabled = !treeModelsEnabled;
	else if (Keyboard::isKeyPress('5'))
		complexTreesEnabled = !complexTreesEnabled;
	else if (Keyboard::isKeyPress('6'))
		defaultTreesEnabled = !defaultTreesEnabled;
	/*else if (Keyboard::isKeyPress('Q'))
		defaultDetailedEnabled = !defaultDetailedEnabled;*/
}
Esempio n. 7
0
QWzmViewer::QWzmViewer(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow()), psModel(NULL), timer(new QTimer(this))
{
	QSettings settings;
	ui->setupUi(this);

	connectorsModel.setColumnCount(4);
	connectorsModel.setHeaderData(0, Qt::Horizontal, QString("X"));
	connectorsModel.setHeaderData(1, Qt::Horizontal, QString("Y"));
	connectorsModel.setHeaderData(2, Qt::Horizontal, QString("Z"));
	connectorsModel.setHeaderData(3, Qt::Horizontal, QString(tr("Type")));

	animationModel.setColumnCount(8);
	animationModel.setHeaderData(0, Qt::Horizontal, QString(tr("Time")));
	animationModel.setHeaderData(1, Qt::Horizontal, QString("Tex"));
	animationModel.setHeaderData(2, Qt::Horizontal, QString("Trs X"));
	animationModel.setHeaderData(3, Qt::Horizontal, QString("Trs Y"));
	animationModel.setHeaderData(4, Qt::Horizontal, QString("Trs Z"));
	animationModel.setHeaderData(5, Qt::Horizontal, QString("Rot X"));
	animationModel.setHeaderData(6, Qt::Horizontal, QString("Rot Y"));
	animationModel.setHeaderData(7, Qt::Horizontal, QString("Rot Z"));

	fileNameLabel = new QLabel(tr("No file loaded"), ui->statusBar);

	selectedMeshComboBox = new QComboBox(ui->statusBar);
	selectedMeshComboBox->setToolTip(tr("Selected Mesh"));
	selectedMeshComboBox->setEnabled(false);

	visibleMeshComboBox = new QComboBox(ui->statusBar);
	visibleMeshComboBox->setEnabled(false);
	visibleMeshComboBox->setToolTip(tr("Visible Mesh"));
	visibleMeshComboBox->addItem(tr("All"));

	teamComboBox = new QComboBox(ui->statusBar);
	teamComboBox->setToolTip(tr("Team Colour"));
	teamComboBox->addItem(tr("Green"));
	teamComboBox->addItem(tr("Yellow"));
	teamComboBox->addItem(tr("Grey"));
	teamComboBox->addItem(tr("Black"));
	teamComboBox->addItem(tr("Red"));
	teamComboBox->addItem(tr("Blue"));
	teamComboBox->addItem(tr("Pink"));
	teamComboBox->addItem(tr("Cyan"));

	scaleSlider = new QSlider(ui->statusBar);
	scaleSlider->setToolTip(tr("Scale"));
	scaleSlider->setRange(1, 1000);
	scaleSlider->setValue(100);
	scaleSlider->setOrientation(Qt::Horizontal);
	scaleSlider->setEnabled(false);

	ui->statusBar->addPermanentWidget(fileNameLabel);
	ui->statusBar->addPermanentWidget(selectedMeshComboBox);
	ui->statusBar->addPermanentWidget(visibleMeshComboBox);
	ui->statusBar->addPermanentWidget(teamComboBox);
	ui->statusBar->addPermanentWidget(scaleSlider);

	ui->connectorTableView->setModel(&connectorsModel);
	ui->animationTableView->setModel(&animationModel);

	ui->animationDockWidget->hide();
	ui->connectorDockWidget->hide();

	connect(timer, SIGNAL(timeout()), this, SLOT(tick()));
	connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(actionOpen()));
	connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(actionSave()));
	connect(ui->actionSaveAs, SIGNAL(triggered()), this, SLOT(actionSaveAs()));
	connect(ui->actionQuit, SIGNAL(triggered()), QApplication::instance(), SLOT(quit()));
	connect(ui->actionImport_3DS, SIGNAL(triggered()), this, SLOT(open3DS()));
	connect(ui->actionWireframe, SIGNAL(triggered()), this, SLOT(toggleWireframe()));
	connect(ui->actionHelpContents, SIGNAL(triggered()), ui->glView, SLOT(help()));
	connect(ui->actionAboutQt, SIGNAL(triggered()), QApplication::instance(), SLOT(aboutQt()));
	connect(ui->actionAboutApplication, SIGNAL(triggered()), this, SLOT(actionAboutApplication()));
	connect(ui->actionAxis, SIGNAL(triggered()), ui->glView, SLOT(toggleAxisIsDrawn()));
	connect(ui->actionCulling, SIGNAL(triggered()), this, SLOT(toggleCulling()));
	connect(ui->actionAnimation, SIGNAL(triggered()), this, SLOT(toggleAnimation()));
	connect(ui->actionScaleModel, SIGNAL(triggered()), this, SLOT(toggleScale()));
	connect(selectedMeshComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setMesh(int)));
	connect(visibleMeshComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setVisibleMesh(int)));
	connect(teamComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setTeam(int)));
	connect(ui->actionSwapYZ, SIGNAL(triggered()), this, SLOT(toggleSwapYZ()));
	connect(ui->actionReverseWinding, SIGNAL(triggered()), this, SLOT(toggleReverseWinding()));
	connect(ui->actionFlipVerticalTexCoords, SIGNAL(triggered()), this, SLOT(toggleFlipVerticalTexCoords()));
	connect(ui->actionFramesEditor, SIGNAL(toggled(bool)), this, SLOT(toggleEditAnimation(bool)));
	connect(ui->actionConnectorsEditor, SIGNAL(toggled(bool)), this, SLOT(toggleEditConnectors(bool)));
	connect(ui->animationDockWidget, SIGNAL(visibilityChanged(bool)), ui->actionFramesEditor, SLOT(setChecked(bool)));
	connect(ui->connectorDockWidget, SIGNAL(visibilityChanged(bool)), ui->actionConnectorsEditor, SLOT(setChecked(bool)));
	connect(ui->prependFrameButton, SIGNAL(pressed()), this, SLOT(prependFrame()));
	connect(ui->appendFrameButton, SIGNAL(pressed()), this, SLOT(appendFrame()));
	connect(ui->removeFrameButton, SIGNAL(pressed()), this, SLOT(removeFrame()));

	// Set defaults
	toggleAnimation();

	ui->actionSave->setEnabled(false);
	ui->actionSaveAs->setEnabled(false);

	restoreGeometry(settings.value("geometry").toByteArray());
	restoreState(settings.value("windowState").toByteArray());

	timer->start(25);
}