示例#1
0
void LoadedMap::loadObjectGroup(XMLElement *element)
{
    Logger.logMessage(LOG_STATE, LOG_MAP, "LoadedMap::loadObjectGroup start\n");

    assert(element);

    ObjectGroup parsed_group;

    parsed_group.draworder = getAttributeString(element, XML_OBJECTGROUP_DRAWORDER);
    parsed_group.name = getAttributeString(element, XML_OBJECTGROUP_NAME);

    stringstream width (element->Attribute(XML_OBJECTGROUP_WIDTH.c_str()));
    stringstream height (element->Attribute(XML_OBJECTGROUP_HEIGHT.c_str()));

    width >> parsed_group.width;
    height >> parsed_group.height;

    XMLElement *first_object = element->FirstChildElement(XML_OBJECT.c_str());
    loadObjects(first_object, &parsed_group);

    XMLElement *properties = element->FirstChildElement(XML_OBJECTGROUP_PROPS.c_str());
    if(properties != NULL)
    {
        loadObjectGroupProperties(properties, &parsed_group);
    }
    m_objectgroups.push_back(parsed_group);

    Logger.logMessage(LOG_STATE, LOG_MAP, "LoadedMap::loadObjectGroup end\n");
}
示例#2
0
MojErr MojDbSearchCursor::load()
{
    // pull unique ids from index
    ObjectSet ids;
    MojErr err = loadIds(ids);
    MojErrCheck(err);

    // load objects into memory
    err = loadObjects(ids);
    MojErrCheck(err);
    // sort results
    if (!m_orderProp.empty()) {
        err = sort();
        MojErrCheck(err);
    }
    // distinct
    if (!m_distinct.empty()) {
        distinct();
    }
    // reverse for desc
    if (m_query.desc()) {
        err = m_items.reverse();
        MojErrCheck(err);
    }
    // set limit and pos
    if (m_limit >= m_items.size()) {
        m_limitPos = m_items.end();
    } else {
        m_limitPos = m_items.begin() + m_limit;
    }
    m_pos = m_items.begin();

    return MojErrNone;
}
示例#3
0
int main() {	
    /* Initialization function.  Connects to FreeWRL EAI server.  This function must be called before any other EAI calls */
	printf("Step 1: X3D_initialize()\n");
	X3D_initialize("");

	loadObjects();

    printf("Sleeping...");
    /* Wait so we can observe the results */

  //  while(1){
		////unqueue_callback(); 
		////dequeue_callback_ev(0);
		////dequeue_callback_ev(1);
		//printf("*");
		//getchar();
  //  }
	getchar();
    /* Free memory */
    X3D_freeNode(root);
    X3D_freeNode(touchSensor);
    X3D_freeNode(shape1);
    X3D_freeEventIn(addChildren);
    X3D_freeEventOut(selectionEvent);
	X3D_freeEventIn(centerField);

	if(foundParents > 0)
		free(parents);

    /* Shutdown FreeWRL */
    X3D_shutdown();
	//   exit(0);

    return 0;
}
示例#4
0
c_Store::c_Store(gameStates prevState)
{
	I_Audio_system::playSound("doorOpen.wav");

	entityManager = c_Entity_manager();
	tileArray = c_Tile::loadTiles("emptyStore.map", TOTAL_TILES, LEVEL_WIDTH, LEVEL_HEIGHT);
	loadObjects();
	
	extensionDoor.x = 0;
	extensionDoor.y = LEVEL_HEIGHT/4;
	extensionDoor.w = 1;
	extensionDoor.h = HIDDEN_DOOR_HEIGHT;

	switch (prevState)
	{
	case STATE_OVERWORLD:{ store_player->init( (entityManager.get(5)->getX()) + 3, (entityManager.get(5)->getY())- 45 ); }break;
	case STATE_STORE_EXTENSION: store_player->init(extensionDoor.x + SPRITE_WIDTH/2, extensionDoor.y); break;
	}

	if (!initStereo()){
		return;
	}

	store_player->setLevel(LEVEL_WIDTH, LEVEL_HEIGHT);

	if (store_enemy != NULL){
		store_enemy->LEVEL_HEIGHT = this->LEVEL_HEIGHT;
		store_enemy->LEVEL_WIDTH = this->LEVEL_WIDTH;
	}
}
TLevelScene::TLevelScene(const Parameters& info, GE::TGameEngine* engine) :
    scene()
{
    SetGameEngine(engine);
    loadResources(info);
    loadObjects(info);
}
示例#6
0
文件: Scene.cpp 项目: MrMCG/MGL
// 1. derive from MGL or MGLRenderer
Scene::Scene() {

	// 2. Build window
	MGLContext::BuildWindow(new MGLWindow());

	// 3. Init GL features and Instances
	MGLRenderer::InitMGL();

	// 4. Create your scene!

	// Create new shader program
	shader = new MGLShader();
	shader->LoadShader("shaders/vert.glsl", GL_VERTEX_SHADER);
	shader->LoadShader("shaders/frag.glsl", GL_FRAGMENT_SHADER);
	shader->Link();
	shader->Use();

	// Load new texture into handler
	MGLI_Tex->LoadTexture("textures/raptor.jpg", "raptor", MGL_TEXTURE_DIFFUSE, GL_FALSE);
	MGLI_Tex->LoadTexture("textures/cty1.jpg", "city", MGL_TEXTURE_DIFFUSE, GL_TRUE);
	MGLI_Tex->LoadTexture("textures/ds.jpg", "death star", MGL_TEXTURE_DIFFUSE, GL_FALSE);

	// set camera options
	camera->SetMoveSpeed(100.0f);
	camera->SetPosition(glm::vec3(25, 0, 50));

	// load objects
	loadObjects();

	// Set input commands
	InitInputFuncs();
}
示例#7
0
void MainWindow::loadObjects()
{
	QString dirPath = QFileDialog::getExistingDirectory(this, tr("Loading objects... Select a directory."), Settings::workingDirectory());
	if(!dirPath.isEmpty())
	{
		loadObjects(dirPath);
	}
}
/*
	This function creates and adds many GameObjects to the initial list for the game.
*/
void Controller::initObjects()
{
	// Load all walls from file
	std::vector<GameObject*> ws = loadObjects(sf::String("txts/walls.txt"));
	for (auto it = ws.begin(); it != ws.end(); ++it)
	{
		addObjectBeginning(*it);
	}

	// Player
	p = new Player();
	p->setPosition(vec::Vector2(-190, -190));
	addObject(p);

	Global::player = p;

	//Turret* t = new Turret(vec::Vector2(50, -50), new Weapon(1, 1, 100), 0, 360);
	//addObject(t);

	// Hangar shield
	/*
	sf::Texture* shieldTex = Global::globalSpriteSheet->getTex("shield_64.png");
	shieldTex->setRepeated(true);

	PlayerShield* w4 = new PlayerShield(vec::Vector2(-32, -64 * 5),
		vec::Vector2(32, 64 * 5),
		shieldTex);
	w4->setPosition(vec::Vector2(64 * 5, 0));
	addObject(w4);
	
	// Hangar Walls
	sf::Texture* wallTex = Global::globalSpriteSheet->getTex(sf::String("wall_64.png"));
	wallTex->setRepeated(true);
	*/

	enemyHangar();

	// Vehicles
	Vehicle* vehicle = new TransportShip();
	vehicle->setPosition(vec::Vector2(200, -200));
	vehicle->vel = vec::Vector2(10, 10);
	addObject(vehicle);

	vehicle = new BasicShip();
	vehicle->setPosition(vec::Vector2(200, 200));
	vehicle->vel = vec::Vector2(10, 10);

	addObject(vehicle);
	vehicle = NULL;

	// Enemies

	// General visual stuff
	view->spawnRenderables();

	// UI
	view->menu->clear();
}
示例#9
0
int script_dump() {
    con_passthrough = 1;

    if (loadObjects(resmgr)) {
        fprintf(stderr, "Unable to load object hierarchy\n");
        return 1;
    }

    printObject(object_root, SCRIPT_PRINT_METHODS | SCRIPT_PRINT_CHILDREN);
    return 0;
}
示例#10
0
c_Store_Extension::c_Store_Extension()
{
	entityManager = c_Entity_manager();
	tileArray = c_Tile::loadTiles("storeExtension.map", TOTAL_TILES, LEVEL_WIDTH, LEVEL_HEIGHT);
	loadObjects();

	exit.x = LEVEL_WIDTH;
	exit.y = LEVEL_HEIGHT/2;
	exit.w = 0;
	exit.h = HIDDEN_DOOR_HEIGHT;
	
	store_player->setLevel(LEVEL_WIDTH, LEVEL_HEIGHT);
	store_player->init(exit.x - (SPRITE_WIDTH*2), exit.y);
	store_player->deadfriend_visited = true;
}
示例#11
0
int ContainerObjectsMap::size() {
	loadObjects();

	return containerObjects.size();

	/*
	Locker locker(&loadMutex);

	if (oids != NULL)
		return oids->size();
	else
		return containerObjects.size();

		*/
}
示例#12
0
MojErr MojDbSearchCursor::load()
{
    LOG_TRACE("Entering function %s", __FUNCTION__);

    // pull unique ids from index
    ObjectSet ids;
    MojErr err = loadIds(ids);
    MojErrCheck(err);

    // load objects into memory
    err = loadObjects(ids);
    MojErrCheck(err);
    // sort results
    if (!m_orderProp.empty()) {
        err = sort();
        MojErrCheck(err);
    }
    // distinct
    if (!m_distinct.empty()) {
        distinct();
    }
    // reverse for desc
    if (m_query.desc()) {
        err = m_items.reverse();
        MojErrCheck(err);
    }
    // next page
    if (!m_page.empty()) {
        err = setPagePosition();
        MojErrCheck(err);
    } else {
        // set begin/last position.
        m_pos = m_items.begin();
        if (m_limit >= m_items.size()) {
            m_limitPos = m_items.end();
        } else {
            // if item size is bigger than limit, set next page.
            m_limitPos = m_items.begin() + m_limit;
            MojDbStorageItem* nextItem = m_limitPos->get();
            const MojObject nextId = nextItem->id();
            m_page.fromObject(nextId);
        }
    }
    // set remainder count
    m_count = m_items.end() - m_pos;

    return MojErrNone;
}
示例#13
0
c_Manor_2F::c_Manor_2F(void)
{
	entityManager = c_Entity_manager();
	tileArray = c_Tile::loadTiles("manor2floor.map", TOTAL_TILES, LEVEL_WIDTH, LEVEL_HEIGHT);
	loadObjects();

	manor_player->setLevel(LEVEL_WIDTH, LEVEL_HEIGHT);
	manor_player->init( (entityManager.get(5)->getX()) + 3, (entityManager.get(5)->getY())- 45 );

	if (manor_2F_enemy != NULL){
		manor_2F_enemy->LEVEL_HEIGHT = this->LEVEL_HEIGHT;
		manor_2F_enemy->LEVEL_WIDTH = this->LEVEL_WIDTH;
	}
	
	isVisited = true;
}
示例#14
0
c_stageOne::c_stageOne(void)
{
	entityManager = c_Entity_manager();
	tileArray = c_Tile::loadTiles("stageThree.map", TOTAL_TILES, LEVEL_WIDTH, LEVEL_HEIGHT);
	loadObjects();
	I_Audio_system::playMUS("scary.wav");

	player->setLevel(LEVEL_WIDTH, LEVEL_HEIGHT);
	enemy = NULL;

	narrator = c_dialog_System();

	exit.x = (TILE_WIDTH*3);
	exit.y = 0;
	exit.w = (TILE_WIDTH*2);
	exit.h = 5;
}
示例#15
0
bool MainState::init(Game* game)
{
	mFont = NULL;

	mPaddleHitSound = NULL;
	mWallHitSound = NULL;

	mPlayer1Score = 0;
	mPlayer2Score = 0;

	mLockBallCollisionCheck = false;

	loadMedia(game);
	loadObjects();

	return true;
}
    LuaGameState::LuaGameState(const std::shared_ptr<const TMX>& pTMX, const std::shared_ptr<Shader>& pShader, const glm::mat4& model, const AssetManager& assets)
        : GameState()
        , mAssets(assets)
        , mpTiledMap(new TiledMap(pTMX, pShader, model, assets.pTextureManager.get()))
        , mECS()
        , mECSWatchers(mECS, pShader)
        , mLuaStateECS(mECS, mECSWatchers)
    {
        assert(pTMX && pShader);

        loadObjects(*pTMX, model, mAssets, mECS);
        try {
            mLuaStateECS.loadScript(pTMX->meta.path + "/main.lua");
            mLuaStateECS.runScript();
        } catch (const std::runtime_error& ex) {
            std::clog << "Warning: LuaGameState: Could not load main.lua." << std::endl;
            std::clog << ex.what() << std::endl;
        }
    }
示例#17
0
c_stageOne::c_stageOne(gameStates prevState)
{
	entityManager = c_Entity_manager();
	tileArray = c_Tile::loadTiles("stageThree.map", TOTAL_TILES, LEVEL_WIDTH, LEVEL_HEIGHT);

	loadObjects();

	switch (prevState)
	{
		case STATE_HOUSE1: player->init( (entityManager.get(0)->getBox().x + DOOR_X_BUFFER), 
							   (entityManager.get(0)->getBox().y + entityManager.get(0)->getBox().h + DOOR_Y_BUFFER) );
			break;

		case STATE_HOUSE2: player->init( (entityManager.get(1)->getBox().x + DOOR_X_BUFFER), 
							   (entityManager.get(1)->getBox().y + entityManager.get(1)->getBox().h + DOOR_Y_BUFFER) ); 
			break;

		case STATE_STORE: player->init( (entityManager.get(2)->getBox().x + DOOR_X_BUFFER), 
							   (entityManager.get(2)->getBox().y + entityManager.get(2)->getBox().h + DOOR_Y_BUFFER) );
			break;

		case STATE_MANOR: player->init( (entityManager.get(3)->getBox().x + DOOR_X_BUFFER), 
						   (entityManager.get(3)->getBox().y + entityManager.get(3)->getBox().h + DOOR_Y_BUFFER) );
			break;
	};
	
	player->setLevel(LEVEL_WIDTH, LEVEL_HEIGHT);

	narrator = c_dialog_System();
	I_Audio_system::playSound("doorClose.wav");

	exit.x = (TILE_WIDTH*3);
	exit.y = 0;
	exit.w = (TILE_WIDTH*2);
	exit.h = 5;

	if (enemy != NULL){
		enemy->LEVEL_HEIGHT = this->LEVEL_HEIGHT;
		enemy->LEVEL_WIDTH = this->LEVEL_WIDTH;
	}
}
示例#18
0
void RayTracerCuda::start()
{
    Bitmap bitmap;
    bitmap.width = theScene->camera->getViewportWidth();
    bitmap.height = theScene->camera->getViewportHeight();
    bitmap.pixelWidth = theScene->camera->getWindowWidth() / bitmap.width;
    bitmap.pixelHeight = theScene->camera->getWindowHeight() / bitmap.height;
    bitmap.firstPixel = Float3D(theScene->camera->windowLeft + bitmap.pixelWidth / 2, theScene->camera->windowBottom + bitmap.pixelHeight / 2, -theScene->camera->near);

    doViewTrans();

    int numObjects = theScene->objects.size();
    Mesh objects[numObjects];
    loadObjects(objects);

    int numLights = 0;
    for (int x = 0; x < 8; x++)
    {
        if (theScene->lights->lights[x].lightSwitch == Lights::Light::ON)
            numLights++;
    }
    LightCuda lights[numLights];
    loadLights(lights);

    Options options;
    options.spheresOnly = rayTracer->spheresOnly;
    options.reflections = rayTracer->reflections;
    options.refractions = rayTracer->refractions;
    options.shadows = rayTracer->shadows;
    options.maxRecursiveDepth = rayTracer->maxRecursiveDepth;

    cudaStart(&bitmap, objects, numObjects, lights, numLights, &options);

    if (rayTracer->data != nullptr)
    {
        free(rayTracer->data);
        rayTracer->data = nullptr;
    }
    rayTracer->data = bitmap.data;
}
示例#19
0
c_Manor::c_Manor(gameStates prevState)
{
	entityManager = c_Entity_manager();
	tileArray = c_Tile::loadTiles("manor.map", TOTAL_TILES, LEVEL_WIDTH, LEVEL_HEIGHT);
	loadObjects();

	if (prevState == STATE_OVERWORLD){
		manor_player->init( (entityManager.get(5)->getBox().x + DOOR_X_BUFFER), (entityManager.get(5)->getBox().y - (DOOR_Y_BUFFER*3)) ); 
		I_Audio_system::playSound("doorOpen.wav");
	}

	else if (prevState == STATE_MANOR2F){
		manor_player->init( (entityManager.get(0)->getBox().x + DOOR_X_BUFFER), (entityManager.get(0)->getBox().y + entityManager.get(0)->getBox().h + DOOR_Y_BUFFER) );
	}

	manor_player->setLevel(LEVEL_WIDTH, LEVEL_HEIGHT);
	
	if ( manor_enemy != NULL ){
		manor_enemy->LEVEL_HEIGHT = LEVEL_HEIGHT;
		manor_enemy->LEVEL_WIDTH = LEVEL_WIDTH;
		manor_enemy->init(LEVEL_WIDTH/2, LEVEL_HEIGHT/2);
	}
}
示例#20
0
//Initialisation function.
void init(int argc, char **argv) {
  //Initialise GLUT.
  glutInit(&argc, argv);

  // Use doule buffering.
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
  glutInitWindowSize(760, 760);

  //Create window.
  glutCreateWindow("Come Fly With Me - by Chris Patuzzo");

  //Set up camera.
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(90, 1, 0.00001, 1 / SCALE_FACTOR);
  glMatrixMode(GL_MODELVIEW);

  //Set the clear color.
  glClearColor(0, 0, 0, 1);

  //Use z-buffer, lighting, normal scaling.
  glEnable(GL_DEPTH_TEST);

  //Set up two lights; the sun and its reflection.
  setupLights();

  //Use vertex arrays.
  glEnableClientState(GL_VERTEX_ARRAY);
  glEnable(GL_TEXTURE_2D);

  //Load skybox and objects.
  loadSkybox();
  loadObjects();

  //Calculate cloud plane.
  calculateCloudPlane();
}
示例#21
0
//Called after the window and OpenGL are initialized. Called exactly once, before the main loop.
void init()
{
	InitializeProgram();

	try
	{
		loadObjects();
	}
	catch(std::exception &except)
	{
		printf("%s\n", except.what());
		throw;
	}

	glEnable(GL_CULL_FACE);
	glCullFace(GL_BACK);
	glFrontFace(GL_CW);

	glEnable(GL_DEPTH_TEST);
	glDepthMask(GL_TRUE);
	glDepthFunc(GL_LEQUAL);
	glDepthRange(0.0f, 1.0f);
	glEnable(GL_DEPTH_CLAMP);
}
示例#22
0
// Camera ownership transferred
MainWindow::MainWindow(Camera * camera, QWidget * parent) :
	QMainWindow(parent),
	camera_(camera),
	likelihoodCurve_(0),
	lowestRefreshRate_(99),
	objectsModified_(false)
{
	ui_ = new Ui_mainWindow();
	ui_->setupUi(this);
	aboutDialog_ = new AboutDialog(this);
	this->setStatusBar(new QStatusBar());

	likelihoodCurve_ = new rtabmap::PdfPlotCurve("Likelihood", &imagesMap_, this);
	ui_->likelihoodPlot->addCurve(likelihoodCurve_, false);
	ui_->likelihoodPlot->setGraphicsView(true);

	if(!camera_)
	{
		camera_ = new Camera(this);
	}
	else
	{
		camera_->setParent(this);
	}

	ui_->dockWidget_parameters->setVisible(false);
	ui_->dockWidget_plot->setVisible(false);
	ui_->widget_controls->setVisible(false);

	QByteArray geometry;
	QByteArray state;
	Settings::loadSettings(Settings::iniDefaultPath(), &geometry, &state);
	this->restoreGeometry(geometry);
	this->restoreState(state);

	ui_->toolBox->setupUi();
	connect((QDoubleSpinBox*)ui_->toolBox->getParameterWidget(Settings::kCamera_4imageRate()),
			SIGNAL(editingFinished()),
			camera_,
			SLOT(updateImageRate()));
	ui_->menuView->addAction(ui_->dockWidget_parameters->toggleViewAction());
	ui_->menuView->addAction(ui_->dockWidget_objects->toggleViewAction());
	ui_->menuView->addAction(ui_->dockWidget_plot->toggleViewAction());
connect(ui_->toolBox, SIGNAL(parametersChanged(const QStringList &)), this, SLOT(notifyParametersChanged(const QStringList &)));

	ui_->imageView_source->setGraphicsViewMode(false);
	ui_->imageView_source->setTextLabel(tr("Press \"space\" to start the camera..."));
	ui_->imageView_source->setMirrorView(Settings::getGeneral_mirrorView());
	connect((QCheckBox*)ui_->toolBox->getParameterWidget(Settings::kGeneral_mirrorView()),
				SIGNAL(stateChanged(int)),
				this,
				SLOT(updateMirrorView()));

	ui_->widget_controls->setVisible(Settings::getGeneral_controlsShown());
	connect((QCheckBox*)ui_->toolBox->getParameterWidget(Settings::kGeneral_controlsShown()),
				SIGNAL(stateChanged(int)),
				this,
				SLOT(showHideControls()));

	//buttons
	connect(ui_->pushButton_restoreDefaults, SIGNAL(clicked()), ui_->toolBox, SLOT(resetCurrentPage()));
	connect(ui_->pushButton_updateObjects, SIGNAL(clicked()), this, SLOT(updateObjects()));
	connect(ui_->horizontalSlider_objectsSize, SIGNAL(valueChanged(int)), this, SLOT(updateObjectsSize()));

	ui_->actionStop_camera->setEnabled(false);
	ui_->actionPause_camera->setEnabled(false);
	ui_->actionSave_objects->setEnabled(false);

	// Actions
	connect(ui_->actionAdd_object_from_scene, SIGNAL(triggered()), this, SLOT(addObjectFromScene()));
	connect(ui_->actionAdd_objects_from_files, SIGNAL(triggered()), this, SLOT(addObjectsFromFiles()));
	connect(ui_->actionLoad_scene_from_file, SIGNAL(triggered()), this, SLOT(loadSceneFromFile()));
	connect(ui_->actionStart_camera, SIGNAL(triggered()), this, SLOT(startProcessing()));
	connect(ui_->actionStop_camera, SIGNAL(triggered()), this, SLOT(stopProcessing()));
	connect(ui_->actionPause_camera, SIGNAL(triggered()), this, SLOT(pauseProcessing()));
	connect(ui_->actionExit, SIGNAL(triggered()), this, SLOT(close()));
	connect(ui_->actionSave_objects, SIGNAL(triggered()), this, SLOT(saveObjects()));
	connect(ui_->actionLoad_objects, SIGNAL(triggered()), this, SLOT(loadObjects()));
	connect(ui_->actionCamera_from_video_file, SIGNAL(triggered()), this, SLOT(setupCameraFromVideoFile()));
	connect(ui_->actionCamera_from_directory_of_images, SIGNAL(triggered()), this, SLOT(setupCameraFromImagesDirectory()));
	connect(ui_->actionAbout, SIGNAL(triggered()), aboutDialog_ , SLOT(exec()));
	connect(ui_->actionRestore_all_default_settings, SIGNAL(triggered()), ui_->toolBox, SLOT(resetAllPages()));
	connect(ui_->actionRemove_all_objects, SIGNAL(triggered()), this, SLOT(removeAllObjects()));

	connect(ui_->pushButton_play, SIGNAL(clicked()), this, SLOT(startProcessing()));
	connect(ui_->pushButton_stop, SIGNAL(clicked()), this, SLOT(stopProcessing()));
	connect(ui_->pushButton_pause, SIGNAL(clicked()), this, SLOT(pauseProcessing()));
	connect(ui_->horizontalSlider_frames, SIGNAL(valueChanged(int)), this, SLOT(moveCameraFrame(int)));
	connect(ui_->horizontalSlider_frames, SIGNAL(valueChanged(int)), ui_->label_frame, SLOT(setNum(int)));
	ui_->pushButton_play->setVisible(true);
	ui_->pushButton_pause->setVisible(false);
	ui_->pushButton_stop->setEnabled(true);
	ui_->horizontalSlider_frames->setEnabled(false);
	ui_->label_frame->setVisible(false);

	ui_->objects_area->addAction(ui_->actionAdd_object_from_scene);
	ui_->objects_area->addAction(ui_->actionAdd_objects_from_files);
	ui_->objects_area->setContextMenuPolicy(Qt::ActionsContextMenu);

	ui_->actionStart_camera->setShortcut(Qt::Key_Space);
	ui_->actionPause_camera->setShortcut(Qt::Key_Space);

	ui_->actionCamera_from_video_file->setChecked(!Settings::getCamera_5mediaPath().isEmpty() && !UDirectory::exists(Settings::getCamera_5mediaPath().toStdString()));
	ui_->actionCamera_from_directory_of_images->setChecked(!Settings::getCamera_5mediaPath().isEmpty() && UDirectory::exists(Settings::getCamera_5mediaPath().toStdString()));

	if(Settings::getGeneral_autoStartCamera())
	{
		// Set 1 msec to see state on the status bar.
		QTimer::singleShot(1, this, SLOT(startProcessing()));
	}
}
示例#23
0
/**	Initializes the visualization, creates the window and draws the objects.
@param  void
@return void
*/
void Cyb3DWorld::init()
{
    CybParameters *cybCore = CybParameters::getInstance();
    int p[1] = { 1 };
    char **config = new char*[2];
    config[0] = windowName;
    config[1] = NULL;


    cybCore->viewType = viewNumber;

    if(viewNumber != 5)
    {

        glutInit(p, config);

        if(stereo)
            glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STEREO );
        else
            glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

        glutInitWindowSize(cybCore->Resx, cybCore->Resy);
        glutInitWindowPosition(50, 50);
        double aspect = (double)cybCore->Resx / (double)cybCore->Resy
                        frustum = new CybPerpectiveFrustum(PI / 3.0, aspect, 1, 100);

        glutCreateWindow(windowName);

        /*If texturing is active*/
        if(cybCore->nTextures)
        {
            for(int j=0; j < cybCore->nTextures; j++)
                loadBMPTexture(cybCore->texName[j],j);
        }
        glutDisplayFunc(mainDisplay);
        glutReshapeFunc(mainReshape);
        glutIdleFunc(mainIdle);

        if(cybCore->isKeyboardEnable())
        {
            glutKeyboardFunc(mainKeyboard);
            glutSpecialFunc(mainSpecialKey);
        }
        glutMouseFunc(mainMouseFunc);
        glutMotionFunc(mainMouseMotionFunc);
        glutPassiveMotionFunc(mainMousePassiveMotionFunc);
        loadObjects();
        glutMainLoop();

    }
    else
    {

        glutInit(p, config);
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

        if(!defResolution)
        {
            std::cout << "Warning: Resolution has not been defined!. Using default 800x600 Resolution." << std::endl;
        }

        glutInitWindowSize(horResolution, verResolution);
        double aspect = (double)horResolution / (double)verResolution;
        frustum = new CybPerpectiveFrustum(PI / 3.0, aspect, 1, 100);

        /*If texturing is active*/
        if(cybCore->nTextures)
        {
            for(int j=0; j < cybCore->nTextures; j++)
                loadBMPTexture(cybCore->texName[j],j);
        }


        //Left Window
        if(swap)
        {
            glutInitWindowPosition(horResolution, 0);
        }
        else
        {
            glutInitWindowPosition(0, 0);
        }

        leftWindow = glutCreateWindow(windowName);
        glutSetWindow(leftWindow);

        glutDisplayFunc(mainDisplay);
        glutReshapeFunc(mainReshape);
        glutIdleFunc(mainIdle);

        if(cybCore->isKeyboardEnable())
        {
            glutKeyboardFunc(mainKeyboard);
            glutSpecialFunc(mainSpecialKey);
        }
        glutMouseFunc(mainMouseFunc);
        glutMotionFunc(mainMouseMotionFunc);
        glutPassiveMotionFunc(mainMousePassiveMotionFunc);


        //Right Window

        if(swap)
        {
            glutInitWindowPosition(0, 0);
        }
        else
        {
            glutInitWindowPosition(horResolution, 0);
        }

        rightWindow = glutCreateWindow(windowName);
        glutSetWindow(rightWindow);

        glutDisplayFunc(mainDisplay);
        glutReshapeFunc(mainReshape);
        glutIdleFunc(mainIdle);

        if(cybCore->isKeyboardEnable())
        {
            glutKeyboardFunc(mainKeyboard);
            glutSpecialFunc(mainSpecialKey);
        }
        glutMouseFunc(mainMouseFunc);
        glutMotionFunc(mainMouseMotionFunc);
        glutPassiveMotionFunc(mainMousePassiveMotionFunc);
        loadObjects2();
        glutMainLoop();

    }
}
示例#24
0
bool SceneLoader::loadScene()
{ 
	sgxElement = doc.FirstChildElement( "sgx" );
	globalsElement = sgxElement->FirstChildElement( "globals" );
	viewElement = sgxElement->FirstChildElement( "view" );
	illuminationElement = sgxElement->FirstChildElement("illumination");
	texturesElement = sgxElement->FirstChildElement("textures");
	objectsElement = sgxElement->FirstChildElement("objects");
	materialsElement = sgxElement->FirstChildElement("materials");

	Material * mat;
	Texture * tex;


	// Inicialização
	// Um exemplo de um conjunto de nós bem conhecidos e obrigatórios

	if(sgxElement == NULL) {
		cout << "Bloco sgx nao encontrado\n";
		system("pause");
		return false;
	}
	
	if(globalsElement != NULL)
	{
		if(!loadGlobals())
			return false;
	}
	else
	{
		cout<<"Bloco globals nao encontrado\n";
		system("pause");
		return false;
	}

	if (viewElement != NULL) 
	{
		if(!loadView())
			return false;
	}
	else
	{
		cout << "Bloco view nao encontrado\n";
		system("pause");
		return false;
	}

	if(illuminationElement != NULL)
	{
		if(!loadIllumination())
			return false;
	}
	else
	{
		cout<<"Bloco illumination nao econtrado\n";
		system("pause");
		return false;
	}
	
	if(texturesElement != NULL)
	{
		if(!loadTextures())
			return false;
	}
	else
	{
		cout<<"Bloco textures nao econtrado\n";
		system("pause");
		return false;
	}
	if(materialsElement != NULL)
	{
		if(!loadMaterials())
			return false;
	}
	else
	{
		cout<<"Bloco materials nao econtrado\n";
		system("pause");
		return false;
	}
	if(objectsElement!=NULL)
	{
		if(!loadObjects())
			return false;
		if(!loadCompound())
			return false;
		root_object=findObject(global.root);
		if(root_object==NULL)
			return false;
		if(root_object->mat_id=="null")
			mat=this->mat_base;
		else
		{
			mat=findMaterial(root_object->mat_id);
			if(mat==NULL)
				return false;
		}
		if(!aplicaMaterials(root_object, mat))
			return false;

		if(root_object->tex_id=="null"||root_object->tex_id=="clear")
			tex=this->no_tex;
		else
		{
			tex=findTexture(root_object->tex_id);
			if(tex==NULL)
				return false;
		}
		if(!aplicaTextures(root_object, tex))
			return false;


	}
	else
	{
		cout<<"Bloco objects nao econtrado\n";
		system("pause");
		return false;
	}

	return true;
}
示例#25
0
ManagedReference<SceneObject*> ContainerObjectsMap::get(uint64 oid) {
	loadObjects();

	return containerObjects.get(oid);
}
示例#26
0
//--------------------------------------------------
Scene::Scene(Input *input)
{
	camera = new Camera();
	cameraSpeed = 0.3f;
	this->input = input;

	sun = new Light(GL_LIGHT0);

	//SetupOpenGL

	//Blending
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_ALPHA_TEST);
	glAlphaFunc(GL_GREATER, 0.01f);

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);
	glEnable(GL_NORMALIZE);

	glDisable(GL_COLOR_MATERIAL);
	glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

	texturLoader = new Texture();
	shLoader = new Shaderloader();

	mainObj = new Object();
	loadObjects("default", mainObj);

	terrain = new Terrain(texturLoader);
	skybox = new Skybox(texturLoader);
	water = new Object();
	ObjModel* watermod = new ObjModel();
	watermod->load("water", texturLoader, shLoader);
	water->addModel(watermod);

	armor = new ObjModel();
	armor->load("ruestung_old", texturLoader, shLoader);
	armorRotation = 0.0;

	torch1 = new ParticleSystem(texturLoader, Vector3f(15.0 - 300, 202.0, 26.0 + 700));
	torch2 = new ParticleSystem(texturLoader, Vector3f(287.0 - 300, 202.0, 26.0 + 700));

	helpText = new Text(texturLoader);

	//Save ModelMatrix
	glLoadIdentity();
	mainObj->saveModelMatrix();


	camera->move(200, -170, -500);

	// for students: uncomment this if you implemented environment mapping
	envShader = new Shader();
	envShader->load("./Daten/Shaders/Env_Mapping.vert", "./Daten/Shaders/Env_Mapping.frag");
	// end for students

	// set up our dynamic cubemap
	// uncomment this if you implemented environment mapping
	glEnable(GL_TEXTURE_CUBE_MAP_ARB);
	glGenTextures(1, &envText);
	glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, envText);
	// end

	// set up some parameters
	// uncomment this if you implemented environment mapping
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
	//end

	// set up min and max filters
	// uncomment this if you implemented environment mapping
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	for (int i = 0; i < 6; i++)
	{
		glTexImage2D(cubeMapDefines[i], 0, GL_RGBA, CUBE_MAP_SIZE, CUBE_MAP_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
	}

	glDisable(GL_TEXTURE_CUBE_MAP_ARB);

	shadowMode = 0;

	//create shadowmap-texture

	shMapW = width;
	shMapH = height;

	shadowMap = 0;
	glGenTextures(1, &shadowMap);
	glBindTexture(GL_TEXTURE_2D, shadowMap);
	glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32_ARB, shMapW, shMapH, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

	shadowMapping = new Shader();
	shadowMapping->load("./Daten/Shaders/Shadow_Mapping.vert", "./Daten/Shaders/Shadow_Mapping.frag");
	shadowMappingAliased = new Shader();
	shadowMappingAliased->load("./Daten/Shaders/Shadow_Mapping.vert",
														 "./Daten/Shaders/Shadow_Mapping_Aliased.frag");

	// load toon shader
	toonShader = new Shader();
	toonShader->load("./Daten/Shaders/toon.vert", "./Daten/Shaders/toon.frag");
}
示例#27
0
void ContainerObjectsMap::put(uint64 oid, SceneObject* object) {
	loadObjects();

	containerObjects.put(oid, object);
}
示例#28
0
void Controller::input()
{

	// reset player's important key presses
	if (p) {
		p->inputs.F = false;
		p->inputs.RClick = false;
	}

		// EVENT-BASED INPUT
	sf::Event e;
	while (view->window.pollEvent(e))
	{
		switch (e.type)
		{
		case sf::Event::Closed:
			view->window.close();
			break;

		case sf::Event::GainedFocus:
			inFocus = true;
			Global::INFOCUS = true;
			break;
		case sf::Event::LostFocus:
			inFocus = false;
			Global::INFOCUS = false;
			break;

		case sf::Event::KeyReleased:
			if (e.key.code == sf::Keyboard::Escape)
				view->window.close();
			break;

		case sf::Event::KeyPressed:
			if (inFocus && p && e.key.code == sf::Keyboard::F) p->inputs.F = true;
			break;

		case sf::Event::Resized:
			view->WINDOW_WIDTH = e.size.width;
			view->WINDOW_HEIGHT = e.size.height;
			Global::middleWindowCoords = sf::Vector2i(e.size.width / 2, e.size.height / 2);
			break;

		case sf::Event::MouseButtonPressed:
			if (inFocus && view->menu->processClick(e.mouseButton.x, e.mouseButton.y)) break;
			if (inFocus && p && e.mouseButton.button == sf::Mouse::Right) p->inputs.RClick = true;
			break;
		}

		if (!view->window.isOpen())
			break;
	}

	// REAL-TIME INPUT
	// Set the static mouse coordinates
	Global::mouseWindowCoords = sf::Mouse::getPosition(view->window);


	// Wall loading
	if (Global::DEBUG)
	{
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::R))
		{
			// Delete old objects
			for (auto it = gameObjects.begin(); it != gameObjects.end(); ++it)
			{
				if (*it != NULL && (*it)->getTag() == sf::String("Obj_T"))
				{
					delObject(*it);
				}
			}

			// Add new walls
			std::vector<GameObject*> ws = loadObjects(sf::String("txts/walls.txt"));
			for (auto it = ws.begin(); it != ws.end(); ++it)
			{
				addObjectBeginning(*it);
			}
		}
	}
}
ObjectTrajectoryProcessing::ObjectTrajectoryProcessing(QString inputFile, QString outputFile)
{
    loadObjects(inputFile);
    filterObjects();
    dumpObjects(outputFile);
}
示例#30
0
文件: map_v1.cpp 项目: Fyre91/scummvm
void Map_v1::loadMapObjects(const char *avjFile) {
	char avoName[128];
	byte *dataBuf;
	int16 tmp;
	int32 flag;
	int16 gobDataCount;
	int16 objDataCount;
	uint32 gobsPos;
	uint32 objsPos;

	strcpy(avoName, _sourceFile);
	strcat(avoName, ".avo");

	int32 size;
	dataBuf = _vm->_dataIO->getFile(avoName, size);
	if (!dataBuf) {
		dataBuf = _vm->_dataIO->getFile(avjFile, size);
		_loadFromAvo = false;
	} else
		_loadFromAvo = true;

	Common::MemoryReadStream mapData(dataBuf, 4294967295U);

	init();

	if (_loadFromAvo) {
		mapData.read(_passMap, _mapHeight * _mapWidth);

		for (int y = 0; y < _mapHeight; y++)
			for (int x = 0; x < _mapWidth; x++)
				_itemsMap[y][x] = mapData.readSByte();

		for (int i = 0; i < 40; i++) {
			_wayPoints[i].x = mapData.readUint16LE();
			_wayPoints[i].y = mapData.readUint16LE();
		}

		for (int i = 0; i < 20; i++) {
			_itemPoses[i].x      = mapData.readByte();
			_itemPoses[i].y      = mapData.readByte();
			_itemPoses[i].orient = mapData.readByte();
		}
	}

	mapData.skip(32 + 76 + 4 + 20);

	for (int i = 0; i < 3; i++) {
		tmp = mapData.readUint16LE();
		mapData.skip(tmp * 14);
	}

	loadSounds(mapData);

	mapData.skip(4 + 24);

	gobDataCount = mapData.readUint16LE();
	objDataCount = mapData.readUint16LE();

	gobsPos = mapData.pos();
	Common::MemoryReadStream gobsData(dataBuf + gobsPos, 4294967295U);
	mapData.skip(gobDataCount * 8);

	objsPos = mapData.pos();
	Common::MemoryReadStream objsData(dataBuf + objsPos, 4294967295U);
	mapData.skip(objDataCount * 8);

	loadGoblins(mapData, gobsPos);
	loadObjects(mapData, objsPos);

	tmp = mapData.readUint16LE();
	for (int i = 0; i < tmp; i++) {
		mapData.skip(30);

		flag = mapData.readSint32LE();
		mapData.skip(56);

		if (flag != 0)
			mapData.skip(30);
	}

	mapData.skip(50);
	loadItemToObject(mapData);

	delete[] dataBuf;
}