void ExampleApp::Draw (float dt)
{
	Eegeo::Rendering::GLState& glState = World().GetRenderContext().GetGLState();
	glState.ClearColor(0.8f, 0.8f, 0.8f, 1.f);
	m_exampleController.PreWorldDraw();
	World().Draw(dt);
	m_exampleController.Draw();
}
    void MobileExampleApp::UpdateLoadingScreen(float dt)
    {
        if (m_pLoadingScreen == NULL)
        {
            return;
        }

        Eegeo::EegeoWorld& eegeoWorld = World();

        if (!eegeoWorld.Initialising() && !m_pLoadingScreen->IsDismissed())
        {
            m_pLoadingScreen->Dismiss();
        }

        m_pLoadingScreen->SetProgress(eegeoWorld.GetInitialisationProgress());
        m_pLoadingScreen->Update(dt);

        if (!m_pLoadingScreen->IsVisible())
        {
            Eegeo_DELETE m_pLoadingScreen;
            m_pLoadingScreen = NULL;
            
            MyPinsModule().GetMyPinsService().LoadAllPinsFromDisk();
        }
    }
Example #3
0
void OnConnect(Client *c) {
	World world = World(500, 500);

	Robot* r1 = makeRobot(40, 40, Point(100.0f, 200.0f), &world);
	Robot* r2 = makeRobot(40, 40, Point(200.0f, 200.0f), &world);

	world.Add(r1);
	world.Add(r2);

	c->sendSelfInfo();
	c->sendEnemyInfo(20);
	c->sendGameInfo(&world);
	c->notifyStart();
	int sleepPeriod = 20;

	r1->Execute("MOV", "120.0");
	r1->Execute("FR", "");
	r1->Execute("ROT", "-0.75");
	//r2->Execute("FR", "");
	
	for(int i = 0; i < 26; i++)
		doLoobBody(world, c, sleepPeriod);
	//r1->Execute("FR", "");
	//r2->Execute("FR", "");
	while(true)
		doLoobBody(world, c, sleepPeriod);
}
Example #4
0
ModelPrivate::ModelPrivate(std::shared_ptr<Storage> storage) : _storage(storage) {
    /* Default storage type, which is memory */
    _model = librdf_new_model(World().get(), storage->get(), NULL);
    if (!_model) {
        throw InternalError("Failed to create RDF model");
    }
}
    void MobileExampleApp::Draw (float dt)
    {
        Eegeo::EegeoWorld& eegeoWorld = World();

        Eegeo::Modules::Map::Layers::InteriorsPresentationModule& interiorsModule = eegeoWorld.GetMapModule().GetInteriorsPresentationModule();
        Eegeo::Resources::Interiors::Camera::InteriorsCameraController& interiorsCameraController = interiorsModule.GetCameraController();
        
        Eegeo::Camera::CameraState cameraState(interiorsCameraController.IsEnabled()
                                               ? interiorsCameraController.GetCameraState()
                                               : m_pGlobeCameraController->GetCameraState());
        Eegeo::Camera::RenderCamera renderCamera(interiorsCameraController.IsEnabled()
                                                 ? interiorsCameraController.GetRenderCamera()
                                                 : m_pGlobeCameraController->GetRenderCamera());
        Eegeo::dv3 ecefInterestPoint(cameraState.InterestPointEcef());

        if(!eegeoWorld.Initialising())
        {
            WorldPinsModule().GetWorldPinsInFocusController().Update(dt, ecefInterestPoint, renderCamera);
        }

        Eegeo::EegeoDrawParameters drawParameters(cameraState.LocationEcef(),
                cameraState.InterestPointEcef(),
                cameraState.ViewMatrix(),
                cameraState.ProjectionMatrix(),
                m_screenProperties);

        eegeoWorld.Draw(drawParameters);

        if (m_pLoadingScreen != NULL)
        {
            m_pLoadingScreen->Draw();
        }
    }
Example #6
0
Scene Scene::load(const std::string &filename, const json11::Json &settings) {
    std::ifstream is(filename);
    std::stringstream ss;
    ss << is.rdbuf();

    std::string err;
    Json jsonRoot = Json::parse(ss.str(), err);
    if (jsonRoot.is_null()) {
        throw Exception("Failed to load scene from '%s' (error: %s)", filename, err);
    }

    _resolver = filesystem::resolver();
    _resolver.prepend(filesystem::path(filename).parent_path());

    Scene scene;

    // Patch settings
    auto settingsValues = jsonRoot["settings"].object_items();
    for (auto kv : settings.object_items()) {
        settingsValues[kv.first] = kv.second;
    }
    scene.settings = Properties(json11::Json(settingsValues));

    // Parse scene objects
    Json jsonScene = jsonRoot["scene"];
    if (jsonScene.is_object()) {
        auto jsonCamera = jsonScene["camera"];
        if (jsonCamera.is_object()) {
            Properties props(jsonCamera);
            scene.camera = Camera(jsonCamera);
        }
        auto jsonWorld = jsonScene["world"];
        if (jsonWorld.is_object()) {
            Properties props(jsonWorld);
            scene.world = World(jsonWorld);
        }
        for (auto jsonBox : jsonScene["boxes"].array_items()) {
            scene.boxes.emplace_back(Box(Properties(jsonBox)));
        }
        for (auto jsonSphere : jsonScene["spheres"].array_items()) {
            scene.spheres.emplace_back(Sphere(Properties(jsonSphere)));
        }
        for (auto jsonMesh : jsonScene["meshes"].array_items()) {
            scene.meshes.emplace_back(Mesh(Properties(jsonMesh)));
        }
        for (auto jsonCameraKeyframe : jsonScene["cameraKeyframes"].array_items()) {
            scene.cameraKeyframes.emplace_back(Camera(Properties(jsonCameraKeyframe)));
        }
        // Set default camera
        if (!jsonCamera.is_object()) {
            Vector3f center = scene.world.bounds.center();
            scene.camera.position += center;
            scene.camera.target += center;
        }
    }

    return scene;
}
 bool MobileExampleApp::CanAcceptTouch() const
 {
     const bool worldIsInitialising = World().Initialising();
     
     InitialExperience::SdkModel::IInitialExperienceModel& initialExperienceModel = m_initialExperienceModule.GetInitialExperienceModel();
     const bool lockedCameraStepsCompleted = initialExperienceModel.LockedCameraStepsCompleted();
     
     return !worldIsInitialising && lockedCameraStepsCompleted;
 }
Example #8
0
	void Login::parseworld(InPacket& recv)
	{
		uint8_t worldid = static_cast<uint8_t>(recv.readbyte());
		if (worldid != 255)
		{
			World toadd = World(worldid, recv);
			worlds.push_back(toadd);
		}
	}
Example #9
0
void ExampleApp::Event_TouchUp(const AppInterface::TouchData& data)
{
    if(World().Initialising())
	{
		return;
	}
    
	m_pCameraTouchController->Event_TouchUp(data);
}
Example #10
0
    void testMultipleSlotConnections()
    {
        boost::signals2::signal<void ()> sig;

        sig.connect(Hello());
        sig.connect(World());

        sig();
    }
void ExampleApp::Update (float dt)
{
	Eegeo::EegeoWorld& eegeoWorld = World();

	eegeoWorld.EarlyUpdate(dt);
	m_exampleController.EarlyUpdate(dt, *m_pGlobeCameraController, *m_pCameraTouchController);

	eegeoWorld.Update(dt);
	m_exampleController.Update(dt);
}
Example #12
0
HRESULT CPersistMemoryHelper2::GetSizeMax(ULONG * pul)
// It's slow, but hey, he asked for it. Maybe we could / should do work
// to cache the encoding for a possible later save, but we don't yet bother
	{
	OSSBUF encoding(World(), OSSBUF::free);
	HRESULT hr = Save(encoding);
	if (FAILED(hr)) return hr;
	*pul = encoding.length;
	return S_OK;
	}
Example #13
0
Topology::Topology(const RuntimeEnvironment *renv) :
	RR(renv),
	_amRoot(false)
{
	std::string alls(RR->node->dataStoreGet("peers.save"));
	const uint8_t *all = reinterpret_cast<const uint8_t *>(alls.data());
	RR->node->dataStoreDelete("peers.save");

	Buffer<ZT_PEER_SUGGESTED_SERIALIZATION_BUFFER_SIZE> *deserializeBuf = new Buffer<ZT_PEER_SUGGESTED_SERIALIZATION_BUFFER_SIZE>();
	unsigned int ptr = 0;
	while ((ptr + 4) < alls.size()) {
		try {
			const unsigned int reclen = ( // each Peer serialized record is prefixed by a record length
					((((unsigned int)all[ptr]) & 0xff) << 24) |
					((((unsigned int)all[ptr + 1]) & 0xff) << 16) |
					((((unsigned int)all[ptr + 2]) & 0xff) << 8) |
					(((unsigned int)all[ptr + 3]) & 0xff)
				);
			unsigned int pos = 0;
			deserializeBuf->copyFrom(all + ptr,reclen + 4);
			SharedPtr<Peer> p(Peer::deserializeNew(RR,RR->identity,*deserializeBuf,pos));
			ptr += pos;
			if (!p)
				break; // stop if invalid records
			if (p->address() != RR->identity.address())
				_peers.set(p->address(),p);
		} catch ( ... ) {
			break; // stop if invalid records
		}
	}
	delete deserializeBuf;

	clean(RR->node->now());

	std::string dsWorld(RR->node->dataStoreGet("world"));
	World cachedWorld;
	if (dsWorld.length() > 0) {
		try {
			Buffer<ZT_WORLD_MAX_SERIALIZED_LENGTH> dswtmp(dsWorld.data(),(unsigned int)dsWorld.length());
			cachedWorld.deserialize(dswtmp,0);
		} catch ( ... ) {
			cachedWorld = World(); // clear if cached world is invalid
		}
	}
	World defaultWorld;
	{
		Buffer<ZT_DEFAULT_WORLD_LENGTH> wtmp(ZT_DEFAULT_WORLD,ZT_DEFAULT_WORLD_LENGTH);
		defaultWorld.deserialize(wtmp,0); // throws on error, which would indicate a bad static variable up top
	}
	if (cachedWorld.shouldBeReplacedBy(defaultWorld,false)) {
		_setWorld(defaultWorld);
		if (dsWorld.length() > 0)
			RR->node->dataStoreDelete("world");
	} else _setWorld(cachedWorld);
}
void ExampleApp::Event_TouchMove(const AppInterface::TouchData& data)
{
    if(World().Initialising())
	{
		return;
	}
    
	if(!m_exampleController.Event_TouchMove(data))
	{
		m_pCameraTouchController->Event_TouchMove(data);
	}
}
int main()
{
//[ hello_world_multi_code_snippet
  boost::signals2::signal<void ()> sig;

  sig.connect(Hello());
  sig.connect(World());

  sig();
//]

  return 0;
};
Example #16
0
HRESULT CPersistMemoryHelper2::Load(BLOB* pblob)
// Load from the indicated blob
	{
	OSSBUF encoding(World(), OSSBUF::keep);
	encoding.length = pblob->cbSize;
	encoding.value  = pblob->pBlobData;

	HRESULT hr = Load(encoding);
	if (hr == S_OK)
		m_isDirty = FALSE;

	return hr;
	}
Example #17
0
	Animator(int w,int h) {

		screenWidth = w;
		screenHeight = h;

  		recordFile = RECORDFILE;
  		WORLD=World();
  		nextFrame=Frame();
  		mode = NONE;
  		nFrames = 0;
  		defaultNFrames = 5;
		frameNo = 0;
		capture = false;
	}
Example #18
0
int main(int argc ,char **argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
    screen_width = glutGet(GLUT_SCREEN_WIDTH);
    screen_height = glutGet(GLUT_SCREEN_HEIGHT);

    glutInitWindowPosition(0,0);
    glutInitWindowSize(screen_width,screen_height);
    glutCreateWindow("Graphics.... :)");

    initRendering();
    //world.gen_missing();
    //world.gen_moving();
    //world.gen_coins();

    temp_world[0] = World(no_lane_x,no_lane_z,lane_width_x,lane_depth_z);
    temp_world[1] = World(no_lane_x,no_lane_z,lane_width_x,lane_depth_z);
    temp_world[2] = World(no_lane_x,no_lane_z,lane_width_x,lane_depth_z);
    current_origin.x = 0.0;
    current_origin.y = 0.0;
    current_origin.z = 0.0;
    load_textures();

    glutDisplayFunc(draw_scene);
    glutReshapeFunc(reshape_window);
    glutKeyboardFunc(handle_keyboard_keys);
    glutSpecialFunc(handle_special_keyboard_keys);
    glutSpecialUpFunc(release_keyboard_keys);
    glutMouseFunc(click_action);
    glutMotionFunc(click_hold_action);
    //glutPassiveMotionFunc(mouse_action);
    glutTimerFunc(60,update_world,0);
    glutTimerFunc(10,robot_move_forward,0);
    glutMainLoop();
    return 0;
}
Example #19
0
World LoadWorldFromFile(std::string const& filename)
{
	TiXmlDocument doc(filename);
	bool success = doc.LoadFile();
	if(!success)
	{
		return World();
	}

	World world;
	XMLWorldVisitor v(&world);
	doc.Accept(&v);

	return world;
}
Example #20
0
void ExampleApp::Update (float dt)
{
	Eegeo::EegeoWorld& eegeoWorld = World();
    
    m_pCameraTouchController->Update(dt);

	eegeoWorld.EarlyUpdate(dt);
    m_pCameraController->Update(dt);
    
    Eegeo::Camera::CameraState cameraState(m_pCameraController->GetCameraState());
    Eegeo::Streaming::IStreamingVolume& streamingVolume(World().GetMapModule().GetStreamingVolume());
    
    Eegeo::EegeoUpdateParameters updateParameters(dt,
                                                  cameraState.LocationEcef(),
                                                  cameraState.InterestPointEcef(),
                                                  cameraState.ViewMatrix(),
                                                  cameraState.ProjectionMatrix(),
                                                  streamingVolume,
                                                  m_screenPropertiesProvider.GetScreenProperties());
    
	eegeoWorld.Update(updateParameters);
    
    UpdateLoadingScreen(dt);
}
Example #21
0
Manager::Manager() :
  env( SDL_putenv(const_cast<char*>("SDL_VIDEO_CENTERED=center")) ),
  jgdata( JSONGamedata::getInstance() ),
  io( IOManager::getInstance() ),
  clock( Clock::getInstance() ),
  screen( io.getScreen() ),
  worlds(),
  viewport( Viewport::getInstance() ),
  explosions(),
  sprites(),
  player(jgdata.getStr("player.name")),
  currentSprite(0),
  TICK_INTERVAL(jgdata.getInt("fpsController.tickInterval")),
  nextTime(clock.getTicks()+TICK_INTERVAL)
{
  clock.pause();
  if (SDL_Init(SDL_INIT_VIDEO) != 0) {
    throw string("Unable to initialize SDL: ");
  }
  atexit(SDL_Quit);

  JSONValue* backs = jgdata.getValue("backgrounds");
  unsigned int numbacks = backs->CountChildren();
  std::cout << "Loading " << numbacks << " backgrounds" << std::endl;
  for(unsigned i = 0; i < numbacks; i++){
    std::string name = backs->Child(i)->Child("name")->AsString();
    int fact = 1;
    if (backs->Child(i)->HasChild("fact"))
      fact = backs->Child(i)->Child("fact")->AsNumber();

    worlds.push_back( World(FrameFactory::getInstance().getFrame(name), fact) );
  }

  unsigned int n = jgdata.getInt("triForce.num");
  float smin = jgdata.getFloat("triForce.scale.min");
  float smax = jgdata.getFloat("triForce.scale.max");
  sprites.reserve(n+2);
  for(unsigned i = 0; i < n; i++){
    sprites.push_back(new Sprite("triForce",smin,smax));
  }

  explosions.push_back(new TwowayMultiframeSprite("Etank"));

  sort(sprites.begin(), sprites.end());

  viewport.setObjectToTrack(player.getSprite());
}
Example #22
0
    void testOrderedSlotConnections()
    {
        boost::signals2::signal<void ()> sig;

        sig.connect(1, World()); // connect with group 1
        sig.connect(0, Hello()); // connect with group 0

        //sig.connect(GoodMorning(), boost::signals2::at_front);
        sig.connect(GoodMorning()); // ungrouped

        // slots are invoked this order:
        // 1) ungrouped slots connected with boost::signals2::at_front
        // 2) grouped slots according to ordering of their groups
        // 3) ungrouped slots connected with boost::signals2::at_back

        sig();
    }
Example #23
0
void ExampleApp::Draw (float dt)
{
    Eegeo::EegeoWorld& eegeoWorld = World();
    
    Eegeo::Camera::CameraState cameraState(m_pCameraController->GetCameraState());
    
    Eegeo::EegeoDrawParameters drawParameters(cameraState.LocationEcef(),
                                              cameraState.InterestPointEcef(),
                                              cameraState.ViewMatrix(),
                                              cameraState.ProjectionMatrix(),
                                              m_screenPropertiesProvider.GetScreenProperties());
    
    eegeoWorld.Draw(drawParameters);
    
    if (m_pLoadingScreen != NULL)
    {
        //m_pLoadingScreen->Draw();
    }
}
Example #24
0
HRESULT CPersistMemoryHelper2::Save(BLOB* pblob, BOOL fClearDirty)
// Save ourselves to the blob, clearing our dirty flag if asked
	{
	OSSBUF encoding(World(), OSSBUF::free);
	HRESULT hr = Save(encoding);
	if (SUCCEEDED(hr))
		{
		pblob->cbSize = encoding.length;
		pblob->pBlobData = (BYTE*)CopyToTaskMem(encoding.length, encoding.value);

		if (pblob->pBlobData == NULL)
			return E_OUTOFMEMORY;

		if (fClearDirty)
			m_isDirty = FALSE;

		return S_OK;
		}
	return hr;
	}
Example #25
0
World WorldLoader::getWorld(int id) {
        //CWH: There are some good uses of the comma operator, but it is usually more trouble than it is worth
        //I have a rule of thumb that I generally don't bother using it unless I have a good reason
	string name, temp, temp2;
	World world;
	ifstream file;
	int counter = 0;
	char map[8][15];
	file.open(worldsPath.c_str());
	while (!file.eof())
	{
		counter++;
		getline(file, temp);
		if (counter == 1)
		{
			stringstream ss(temp);
			getline(ss, name, ':');
			if (name == to_string(id)) {
				getline(ss, name, ':');
				for (int y = 0; y < 8; y++)
				{
					getline(file, temp2);
					for (int x = 0; x < 15; x++)
					{
						map[y][x] = temp2[x];
					}
				}
				WorldLinks wl = setWorldLinks(id);
				world = World(id, name, wl.n, wl.e, wl.s, wl.w, map);
				file.seekg(0, ios_base::end);
			}
		}
		else if (counter == 9)
		{
			counter = 0;
		}
	}
	file.close();

	return world;
}
Example #26
0
void CServer::Think()
{
   int i;

   UpdateMsec(); // calculate the msec value
   CheckClients(); // check and update our client list

   BotManager()->Think();
   World()->Think();

   for (i = 0; i < GetMaxClients(); i++) {
      if (m_rgpClients[i] != NULL) {
         // check if this client is a bot
         CBaseBot *pBot = m_rgpClients[i]->GetBotPointer();
         if (pBot) {
            // this is a bot...
            pBot->BotThink(); // call its think function to make it run
         }
      }
   }
}
Example #27
0
int main()
{
//[ hello_world_ordered_code_snippet
  boost::signals2::signal<void ()> sig;

  sig.connect(1, World());  // connect with group 1
  sig.connect(0, Hello());  // connect with group 0
//]

//[ hello_world_ordered_invoke_code_snippet
  // by default slots are connected at the end of the slot list
  sig.connect(GoodMorning());

  // slots are invoked this order:
  // 1) ungrouped slots connected with boost::signals2::at_front
  // 2) grouped slots according to ordering of their groups
  // 3) ungrouped slots connected with boost::signals2::at_back
  sig();
//]

  return 0;
};
void WorldCreatorResourcesWidget::loadWorld()
{
    World world = World();
    QString filter = "XML files (*.xml);;All files (*.*)";
    QString defaultFilter = "XML files (*.xml)";
    QString filePath = QFileDialog::getOpenFileName(this,tr("Load the world of your dreams"),"../save",
                                                    filter,&defaultFilter);
    SaveManager saveManager;
    saveManager.loadWorld(filePath, &world);

    //delete old animals
    std::list<std::shared_ptr<Entity>> entities = world.getEntities();
    for(std::list<std::shared_ptr<Entity>>::iterator e=entities.begin() ; e!=entities.end() ; ++e)
    {
        if(std::shared_ptr<Resource> resource = std::dynamic_pointer_cast<Resource>(*e))
        {
            resources.push_back(resource);
        }
    }
    ui->lb_loadedWorld->setText(filePath);
    editorWidget.updateScene();
    toolBox.setWorldSize(config::WORLD_SIZE_X,config::WORLD_SIZE_Y);
}
Example #29
0
Game::Game(MessageActionMap* const messageActionMap, OglEngine* const graphicsEngine) :
	_previousPlayerPosition(vec_f::Zero()),
	_graphicsEngine(graphicsEngine),
	_physics(PhysicsSystem(std::make_shared<BucketBroadphase>())),
	_context(World(&_physics)),
	_bufferGenerator(OglGeometryBufferGenerator()),
	_messageActionMap(messageActionMap),
	_playerCamera(Camera()),
	_player(PlayerEntity(_messageActionMap, &_physics, &_bufferGenerator))
{
	auto vertices = std::make_unique<List<vec_f>>();
	vertices->Add(vec_f(0, 0));
	vertices->Add(vec_f(10, 0));
	vertices->Add(vec_f(10, 10));
	vertices->Add(vec_f(0, 10));
	auto roVerts = std::make_shared<ReadOnlyList<vec_f>>(vertices.get());

	_verticesComponent = std::make_shared<VerticesComponent>(roVerts);
	_physicsBodyComponent = std::make_shared<PhysicsBodyComponent>(&_physics, _verticesComponent, vec_f::Zero());
	_verticesDrawableComponent = std::make_shared<VerticesDrawableComponent>(_verticesComponent, _physicsBodyComponent);

	_polygonEditorComponent = std::make_shared<PolygonEditorComponent>(_messageActionMap, &_playerCamera);
}
Example #30
0
void ExampleApp::UpdateLoadingScreen(float dt)
{
    if (m_pLoadingScreen == NULL)
    {
        return;
    }
    
    Eegeo::EegeoWorld& eegeoWorld = World();
    
    if (!eegeoWorld.Initialising() && !m_pLoadingScreen->IsDismissed())
    {
        m_pLoadingScreen->Dismiss();
    }
    
    m_pLoadingScreen->SetProgress(eegeoWorld.GetInitialisationProgress());
    m_pLoadingScreen->Update(dt);
    
    if (!m_pLoadingScreen->IsVisible())
    {
        Eegeo_DELETE m_pLoadingScreen;
        m_pLoadingScreen = NULL;
    }
}