//Create a particle system with;
//a texture id
//the max amount of particles the system should take
ParticleSystem::ParticleSystem(GLuint texture, int maxParticles) {

	//load the texture for the particles
	_texture = texture;

	MaxParticles = maxParticles;

	//set default values
	loadDefaultValues();
}
//Create a particle system with;
//a texture name
//the max amount of particles the system should take
ParticleSystem::ParticleSystem(char * particleTexture, int maxParticles) {

	//load the texture for the particles
	_texture = Texture::loadTexture(particleTexture);

	MaxParticles = maxParticles;

	//set default values
	loadDefaultValues();
}
Exemple #3
0
LinTVPlay::LinTVPlay(QWidget *parent, const QString & filename)
    : m_parent(parent),
      m_device(filename)
{
    m_deviceType = LinTVDeviceInfo::File;
    m_mplayerProcess = new LinTVProcess(this);

    loadDefaultValues();
    connectSlots();
}
Exemple #4
0
LinTVPlay::LinTVPlay(QWidget *parent, LinTVDeviceInfo::DeviceType deviceType,
                      const QString &deviceStr, int input)
    : m_parent(parent)
{
    loadDefaultValues();
    m_deviceType = deviceType;
    m_device = deviceStr;
    m_input = input;

    m_mplayerProcess = new LinTVProcess(this);

    connectSlots();
}
int main(int argc, char* argv[]){

	XMLParser* xml = new XMLParser();

	try{
		xml->loadXML(".\\settings.xml");
	} catch(std::exception& e){
		std::cout << e.what() <<std::endl;
		std::cout << "Default values will be applied" <<std::endl;
		loadDefaultValues(xml);

		xml->writeToXML(".\\settings.xml");
	}

	GLFWWindow* wnd;

	try{
		wnd = new GLFWWindow(xml->get<int>("Window", "width"),
							 xml->get<int>("Window", "height"),
							 "RayTracer",
							 xml->get<bool>("Window", "windowed"));
	} catch(std::exception& e){
		std::cout << e.what() << std::endl;
		std::cin.get();
		delete xml;
		
		return -1;
	}

	std::cout << "OpenGL Version: " << glGetString(GL_VERSION) <<std::endl;

	if(glewInit() != GLEW_OK){
		std::cout << "Could not initialize GLEW!" <<std::endl;
		std::cin.get();

		delete wnd;
		delete xml;

		return -1;
	} else {
		std::cout << "GLEW Version: " << glewGetString(GLEW_VERSION) <<std::endl;
	}


	GLFWInput* input = new GLFWInput();
	GLFWTimer* timer = new GLFWTimer();
	int maxFPS = xml->get<int>("Window", "maxFPS");
	int width = xml->get<int>("Window", "width");
	int height = xml->get<int>("Window", "height");
	boost::shared_ptr<TextureRenderer>	texRenderer;
	boost::shared_ptr<OpenGLRaytracer>	ort;
	boost::shared_ptr<Texture>			tex;
	boost::shared_ptr<Scene>			scene;
	boost::shared_ptr<SceneReader>		sceneReader;
	boost::shared_ptr<SceneLoader>		sceneLoader;
	boost::shared_ptr<InputControl>		inputControl;
	boost::shared_ptr<Camera>			camera;

	int frameCounter = 0, fps = 0;
	int reflectionDepth = xml->get<int>("Raytracing", "reflectionDepth"); 
	bool running = true;
	char i = 0;
	
	try{
		camera = boost::shared_ptr<Camera>(new Camera(xml->get<int>("Window", "width"), xml->get<int>("Window", "height"), xml->get<float>("Camera", "fovY"), 
													  glm::vec3(xml->get<float>("Camera", "posX"), xml->get<float>("Camera", "posY"),xml->get<float>("Camera", "posZ")), 
													  glm::vec3(xml->get<float>("Camera", "dirX"), xml->get<float>("Camera", "dirY"), xml->get<float>("Camera", "dirZ")),
													  glm::vec3(xml->get<float>("Camera", "upX"), xml->get<float>("Camera", "upY"), xml->get<float>("Camera", "upZ"))));

		tex = boost::shared_ptr<Texture>(new Texture(xml->get<int>("Window", "width"), xml->get<int>("Window", "height"), GL_RGBA8));
		texRenderer = boost::shared_ptr<TextureRenderer>(new TextureRenderer(xml->get<int>("Window", "width"), xml->get<int>("Window", "height"), tex));
		ort = boost::shared_ptr<OpenGLRaytracer>(new OpenGLRaytracer(tex, (*camera.get()), reflectionDepth));
		inputControl = boost::shared_ptr<InputControl>(new InputControl(xml->get<float>("Camera", "velocityRotate"), xml->get<float>("Camera", "velocityTranslate")));
		scene = boost::shared_ptr<Scene>(new Scene());
		sceneReader = boost::shared_ptr<SceneReader>(new SceneReader());
		sceneLoader = boost::shared_ptr<SceneLoader>(new SceneLoader((*ort.get())));

		for(int i = 0; i < argc; ++i){
			sceneReader->readScene((std::string(".\\")+std::string(argv[i])).c_str(), (*scene.get()));
			sceneLoader->loadScene((*scene.get()), (*ort.get()));
			scene->clear();
		}

		while(running){
			glGetError();
			if(timer->getTimeDiffWithoutActualization() > static_cast<double>(1.0)/static_cast<double>(maxFPS)){
				timer->getTimeDiff();

				inputControl->processInput((*camera.get()), reflectionDepth);
				camera->update();
			    
				ort->renderScene((*camera.get()), width, height, reflectionDepth);
				texRenderer->draw();
				wnd->swapBuffers();

				if(input->isKeyPressed(GLFW_KEY_ESC)){
					running = false;
				}

				frameCounter++;
				if(timer->getRefreshedTime() > 1.0){
					fps = frameCounter;
					frameCounter = 0;
					timer->resetTime();
				}

				wnd->setWindowTitle(boost::lexical_cast<std::string, int>(fps).c_str());
			}

			if(glGetError() != GL_NO_ERROR){
				throw std::exception("ERROR!");
			}

		}
		
	} catch(std::exception&e ){
		std::cout << e.what() <<std::endl;
		std::cin.get();
	}
	
	delete timer;
	delete input;
	delete wnd;
}
SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent)
{
	l_1LineEdit = new QLineEdit;
	l_2LineEdit = new QLineEdit;
	l_3LineEdit = new QLineEdit;
	l_4LineEdit = new QLineEdit;
	l_5LineEdit = new QLineEdit;
	l_6LineEdit = new QLineEdit;
	dLineEdit = new QLineEdit;
	eLineEdit = new QLineEdit;
	hLineEdit = new QLineEdit;
	psiLineEdit = new QLineEdit;
	thetaLineEdit = new QLineEdit;
	jointsSpeedLineEdit = new QLineEdit;
	delta1PlusRadioButton = new QRadioButton;
	delta1MinusRadioButton = new QRadioButton;
	delta2PlusRadioButton = new QRadioButton;
	delta2MinusRadioButton = new QRadioButton;
	delta5PlusRadioButton = new QRadioButton;
	delta5MinusRadioButton = new QRadioButton;
	okButton = new QPushButton("Ok");
	cancelButton = new QPushButton("Cancel");

	int lineEditWidth = 50;
	l_1LineEdit->setFixedWidth(lineEditWidth);
	l_2LineEdit->setFixedWidth(lineEditWidth);
	l_3LineEdit->setFixedWidth(lineEditWidth);
	l_4LineEdit->setFixedWidth(lineEditWidth);
	l_5LineEdit->setFixedWidth(lineEditWidth);
	l_6LineEdit->setFixedWidth(lineEditWidth);
	dLineEdit->setFixedWidth(lineEditWidth);
	eLineEdit->setFixedWidth(lineEditWidth);
	hLineEdit->setFixedWidth(lineEditWidth);
	psiLineEdit->setFixedWidth(lineEditWidth);
	thetaLineEdit->setFixedWidth(lineEditWidth);
	jointsSpeedLineEdit->setFixedWidth(lineEditWidth);

	QHBoxLayout* l_1Layout = new QHBoxLayout;
	l_1Layout->addWidget(new QLabel("l1"));
	l_1Layout->addWidget(l_1LineEdit);
	l_1Layout->addWidget(new QLabel("mm"));

	QHBoxLayout* l_2Layout = new QHBoxLayout;
	l_2Layout->addWidget(new QLabel("l2"));
	l_2Layout->addWidget(l_2LineEdit);
	l_2Layout->addWidget(new QLabel("mm"));

	QHBoxLayout* l_3Layout = new QHBoxLayout;
	l_3Layout->addWidget(new QLabel("l3"));
	l_3Layout->addWidget(l_3LineEdit);
	l_3Layout->addWidget(new QLabel("mm"));

	QHBoxLayout* l_4Layout = new QHBoxLayout;
	l_4Layout->addWidget(new QLabel("l4"));
	l_4Layout->addWidget(l_4LineEdit);
	l_4Layout->addWidget(new QLabel("mm"));

	QHBoxLayout* l_5Layout = new QHBoxLayout;
	l_5Layout->addWidget(new QLabel("l5"));
	l_5Layout->addWidget(l_5LineEdit);
	l_5Layout->addWidget(new QLabel("mm"));

	QHBoxLayout* l_6Layout = new QHBoxLayout;
	l_6Layout->addWidget(new QLabel("l6"));
	l_6Layout->addWidget(l_6LineEdit);
	l_6Layout->addWidget(new QLabel("mm"));

	QHBoxLayout* dLayout = new QHBoxLayout;
	dLayout->addWidget(new QLabel("d"));
	dLayout->addWidget(dLineEdit);
	dLayout->addWidget(new QLabel("mm"));

	QHBoxLayout* eLayout = new QHBoxLayout;
	eLayout->addWidget(new QLabel("e"));
	eLayout->addWidget(eLineEdit);
	eLayout->addWidget(new QLabel("mm"));

	QHBoxLayout* hLayout = new QHBoxLayout;
	hLayout->addWidget(new QLabel("h"));
	hLayout->addWidget(hLineEdit);
	hLayout->addWidget(new QLabel("mm"));

	QHBoxLayout* psiLayout = new QHBoxLayout;
	psiLayout->addWidget(new QLabel("Ψ"));
	psiLayout->addWidget(psiLineEdit);
	psiLayout->addWidget(new QLabel("°"));

	QHBoxLayout* thetaLayout = new QHBoxLayout;
	thetaLayout->addWidget(new QLabel("Θ"));
	thetaLayout->addWidget(thetaLineEdit);
	thetaLayout->addWidget(new QLabel("°"));

	QHBoxLayout* jointsSpeedLayout = new QHBoxLayout;
	jointsSpeedLayout->addWidget(new QLabel("ω"));
	jointsSpeedLayout->addWidget(jointsSpeedLineEdit);
	jointsSpeedLayout->addWidget(new QLabel("°/s"));

	QHBoxLayout* delta1Layout = new QHBoxLayout;
	delta1Layout->addWidget(new QLabel("δ1"));
	delta1Layout->addStretch();
	delta1Layout->addWidget(delta1PlusRadioButton);
	delta1Layout->addWidget(new QLabel("+1"));
	delta1Layout->addWidget(delta1MinusRadioButton);
	delta1Layout->addWidget(new QLabel("-1"));
	QGroupBox* delta1GroupBox = new QGroupBox;
	delta1GroupBox->setLayout(delta1Layout);

	QHBoxLayout* delta2Layout = new QHBoxLayout;
	delta2Layout->addWidget(new QLabel("δ2"));
	delta2Layout->addStretch();
	delta2Layout->addWidget(delta2PlusRadioButton);
	delta2Layout->addWidget(new QLabel("+1"));
	delta2Layout->addWidget(delta2MinusRadioButton);
	delta2Layout->addWidget(new QLabel("-1"));
	QGroupBox* delta2GroupBox = new QGroupBox;
	delta2GroupBox->setLayout(delta2Layout);

	QHBoxLayout* delta5Layout = new QHBoxLayout;
	delta5Layout->addWidget(new QLabel("δ5"));
	delta5Layout->addStretch();
	delta5Layout->addWidget(delta5PlusRadioButton);
	delta5Layout->addWidget(new QLabel("+1"));
	delta5Layout->addWidget(delta5MinusRadioButton);
	delta5Layout->addWidget(new QLabel("-1"));
	QGroupBox* delta5GroupBox = new QGroupBox;
	delta5GroupBox->setLayout(delta5Layout);

	QHBoxLayout* buttonsLayout = new QHBoxLayout;
	buttonsLayout->addStretch();
	buttonsLayout->addWidget(okButton);
	buttonsLayout->addWidget(cancelButton);

	QVBoxLayout* mainLayout = new QVBoxLayout;
	mainLayout->addWidget(new QLabel("<b>Regional part</b>"));
	mainLayout->addLayout(l_1Layout);
	mainLayout->addLayout(l_2Layout);
	mainLayout->addLayout(l_3Layout);
	mainLayout->addLayout(dLayout);
	mainLayout->addLayout(eLayout);
	mainLayout->addWidget(new QLabel("<b>Local part</b>"));
	mainLayout->addLayout(l_4Layout);
	mainLayout->addLayout(l_5Layout);
	mainLayout->addLayout(l_6Layout);
	mainLayout->addWidget(new QLabel("<b>Base height</b>"));
	mainLayout->addLayout(hLayout);
	mainLayout->addWidget(new QLabel("<b>Approach vector</b>"));
	mainLayout->addLayout(psiLayout);
	mainLayout->addLayout(thetaLayout);
	mainLayout->addWidget(new QLabel("<b>Position criterion</b>"));
	mainLayout->addWidget(delta1GroupBox);
	mainLayout->addWidget(delta2GroupBox);
	mainLayout->addWidget(delta5GroupBox);
	mainLayout->addWidget(new QLabel("<b>Joints speed</b>"));
	mainLayout->addLayout(jointsSpeedLayout);
	mainLayout->addLayout(buttonsLayout);
	this->setLayout(mainLayout);
	this->setWindowTitle("Settings");
	loadDefaultValues();
	connect(okButton, SIGNAL(clicked(bool)), this, SLOT(accept()));
	connect(cancelButton, SIGNAL(clicked(bool)), this, SLOT(reject()));
}
Exemple #7
0
ConfigBundle::ConfigBundle(ConfigMgr & mgr) 
    : _mgr(mgr)
{
    loadDefaultValues();
}
int main() {

    LPTSTR path = new TCHAR[100];
    GetModuleFileName(HINST_THISCOMPONENT,path, 100);

    std::cout << "Executing: " << path  << std::endl;

    XMLParser* xml = new XMLParser();

    try {
        xml->loadXML(".\\particles.xml");

    } catch(std::exception& e) {
        std::cout << e.what() <<std::endl;
        std::cout << "Default values will be applied!" <<std::endl;

        loadDefaultValues(xml);

        try {
            xml->writeToXML(".\\particles.xml");
        } catch(std::exception& e) {
            std::cout << e.what() <<std::endl;
        }
    }


    GLFWWindow* wnd;

    try {

        wnd = new GLFWWindow(xml->get<int>("Window", "width"),
                             xml->get<int>("Window", "height"),
                             "OpenGL_4.3_Particle_System",
                             xml->get<bool>("Window", "windowed"));

    } catch(std::exception& e) {
        std::cout << e.what() <<std::endl;
        std::cin.get();

        delete xml;

        return -1;
    }

    std::cout << "OpenGL Version: " << glGetString(GL_VERSION) << std::endl;

    if(glewInit() != GLEW_OK) {
        std::cout << "Could not initialize GLEW!" <<std::endl;
        std::cin.get();

        delete wnd;
        delete xml;

        return -1;
    } else {
        std::cout << "GLEW Version: " <<glewGetString(GLEW_VERSION) <<std::endl;
    }

    ParticleSystem* ps;

    try {
        ps = new ParticleSystem(xml->get<int>("Particles", "maxParticles"),
                                xml->get<int>("Particles", "iniRadius"),
                                xml->get<float>("Particles", "quadLength"),
                                xml->get<int>("Window", "maxFPS"),
                                xml->get<float>("Camera", "translation_velocity"),
                                xml->get<float>("Camera", "rotation_velocity"));

    } catch(std::exception& e) {
        std::cout << e.what() <<std::endl;
        std::cin.get();

        delete wnd;
        delete xml;

        return -1;
    }

    delete xml;

    try {
        ps->run(wnd);
    } catch(std::exception& e) {
        std::cout << e.what() <<std::endl;
        std::cin.get();
    }

    delete ps;
    delete wnd;

    return 0;
}
Exemple #9
0
LinTVPlay::LinTVPlay(QWidget *parent)
    : m_parent(parent)
{
    loadDefaultValues();
}