Beispiel #1
0
void SimpleRenderContext::createImage(const std::string& prefix)
{

    if (mWidth == 0 || mHeight == 0) {
        throw Exception("Height and width of the image can't be 0.");
    }

    Ogre::Real aspectRatio = static_cast<float>(mWidth) / static_cast<float>(mHeight);

    S_LOG_VERBOSE("Setting aspect ratio of camera to " << aspectRatio);
    mCamera->setAspectRatio(aspectRatio);

    //the width and height needs to be multipes of 2
    mWidth = Ogre::Bitwise::firstPO2From(mWidth);
    mHeight = Ogre::Bitwise::firstPO2From(mHeight);

    //first, create a RenderTexture to which the Ogre renderer should render the image
    S_LOG_VERBOSE("Creating new rendertexture " << (prefix + "_SimpleRenderContextRenderTexture") << " with w:" << mWidth << " h:" << mHeight);
    Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual(prefix + "_SimpleRenderContextRenderTexture", "Gui", Ogre::TEX_TYPE_2D, mWidth, mHeight, 0, Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET, &mResourceLoader);
    if (texture.isNull()) {
        S_LOG_WARNING("Could not create a texture.");
        return;
    }

    setTexture(texture);
}
void EntityCEGUITexture::createImage(const std::string& imageSetName)
{
	//create a CEGUI texture from our Ogre texture
	S_LOG_VERBOSE("Creating new CEGUI texture from Ogre texture.");
	Ogre::TexturePtr texturePtr(mRenderContext->getTexture());
	mCeguiTexture = &GUIManager::getSingleton().getGuiRenderer()->createTexture(texturePtr);

	//we need a imageset in order to create GUI elements from the ceguiTexture
	S_LOG_VERBOSE("Creating new CEGUI imageset with name " << imageSetName + "_EntityCEGUITextureImageset");
	mImageSet = &CEGUI::ImagesetManager::getSingleton().create(imageSetName + "_EntityCEGUITextureImageset", *mCeguiTexture);

	int width = 1;
	int height = 1;
	if (!texturePtr.isNull()) {
		width = texturePtr->getWidth();
		height = texturePtr->getHeight();
	}

	//we only want one element: the whole texture
	//the width and height of the texture differs from the supplied width of this instance since it will have been adjusted to a power-of-two size
	mImageSet->defineImage("full_image", CEGUI::Rect(0, 0, width, height), CEGUI::Point(0,0));

	//assign our image element to the StaticImage widget
	mImage = &mImageSet->getImage("full_image");

}
TexturePair AssetsManager::createTextureImage(Ogre::TexturePtr texturePtr, const std::string& imageSetName)
{
	// 	if (mOgreCEGUITexture) {
	// 		GUIManager::getSingleton().getGuiRenderer()->destroyTexture(mOgreCEGUITexture);
	// 		mOgreCEGUITexture = 0;
	// 	}


	CEGUI::Imageset* textureImageset;

	if (CEGUI::ImagesetManager::getSingleton().isDefined(imageSetName)) {
		textureImageset = &CEGUI::ImagesetManager::getSingleton().get(imageSetName);
	} else {
		//create a CEGUI texture from our Ogre texture
		S_LOG_VERBOSE("Creating new CEGUI texture from Ogre texture.");
		CEGUI::Texture* ogreCEGUITexture = &GUIManager::getSingleton().getGuiRenderer()->createTexture(texturePtr);

		//we need a imageset in order to create GUI elements from the ceguiTexture
		S_LOG_VERBOSE("Creating new CEGUI imageset with name " << imageSetName);
		textureImageset = &CEGUI::ImagesetManager::getSingleton().create(imageSetName, *ogreCEGUITexture);

		//we only want one element: the whole texture
		textureImageset->defineImage("full_image", CEGUI::Rect(0, 0, texturePtr->getWidth(), texturePtr->getHeight()), CEGUI::Point(0, 0));
	}
	//assign our image element to the StaticImage widget
	const CEGUI::Image* textureImage = &textureImageset->getImage("full_image");

	return TexturePair(texturePtr, textureImage, textureImageset);

}
Beispiel #4
0
bool OgreResourceLoader::addResourceDirectory(const std::string& path, const std::string& type, const std::string& section, bool recursive, bool reportFailure, bool throwOnFailure)
{
	if (isExistingDir(path)) {
		S_LOG_VERBOSE("Adding dir " << path);
		try {
			Ogre::ResourceGroupManager::getSingleton().addResourceLocation(path, type, section, recursive);
			return true;
		} catch (const std::exception&) {
			if (throwOnFailure) {
				throw Ember::Exception(std::string("Could not load from required directory '") + path + "'. This is fatal and Ember will shut down. The probable cause for this error is that you haven't properly installed all required media.");
			}
			if (reportFailure) {
				S_LOG_FAILURE("Couldn't load " << path << ". Continuing as if nothing happened.");
			}
		}
	} else {
		if (throwOnFailure) {
			throw Ember::Exception(std::string("Could not find required directory '") + path + "'. This is fatal and Ember will shut down. The probable cause for this error is that you haven't properly installed all required media.");
		}
		if (reportFailure) {
			S_LOG_VERBOSE("Couldn't find resource directory " << path);
		}
	}
	return false;
}
Beispiel #5
0
void TimedLog::report(const std::string& reportName)
{
	auto currentTime = std::chrono::steady_clock::now();
	auto microDuration = std::chrono::duration_cast<std::chrono::microseconds>(currentTime - mStart);
	if (mLastReport.time_since_epoch().count()) {
		auto microLastReportDuration = std::chrono::duration_cast<std::chrono::microseconds>(currentTime - mLastReport);
		S_LOG_VERBOSE("Reported '" << reportName << "' on task '" << mLogName << "' after " << microDuration.count() << " microseconds, "<< microLastReportDuration.count() <<" since last reported time.");
	} else {
		S_LOG_VERBOSE("Reported '" << reportName << "' on task '" << mLogName << "' after " << microDuration.count() << " microseconds.");
	}
	mLastReport = currentTime;
}
void XMLModelDefinitionSerializer::readAnimationParts(TiXmlElement* mAnimPartNode, AnimationDefinition* animDef)
{
	const char* tmp = 0;
	bool nopartfound = true;

	for (TiXmlElement* apElem = mAnimPartNode->FirstChildElement();
            apElem != 0; apElem = apElem->NextSiblingElement())
	{
		std::string name;
		nopartfound = false;

		// name
		tmp =  apElem->Attribute("name");
		if (tmp) {
			name = tmp;
			S_LOG_VERBOSE( "  Add animation  : "+ name );
		}

		AnimationPartDefinition* animPartDef = animDef->createAnimationPartDefinition(name);

		TiXmlElement* elem = apElem->FirstChildElement("bonegrouprefs");
		if (elem) {
			for (TiXmlElement* boneGroupRefElem = elem->FirstChildElement();
					boneGroupRefElem != 0; boneGroupRefElem = boneGroupRefElem->NextSiblingElement())
			{
				tmp = boneGroupRefElem->Attribute("name");
				if (tmp) {
					BoneGroupRefDefinition boneGroupRef;
					boneGroupRef.Name = tmp;
					tmp = boneGroupRefElem->Attribute("weight");
					if (tmp) {
						boneGroupRef.Weight = Ogre::StringConverter::parseReal(tmp);
					} else {
						boneGroupRef.Weight = 1.0f;
					}
					animPartDef->BoneGroupRefs.push_back(boneGroupRef);
				}
			}
		}


	}

	if(nopartfound)
	{
		S_LOG_VERBOSE( "   No anim parts found." );
	}
}
Beispiel #7
0
void EmberEntity::onTalk(const Atlas::Objects::Operation::RootOperation& talkArgs)
{
  Domain::EntityTalk entityTalk(talkArgs);

  //some talk operations come with a predefined set of suitable responses, so we'll store those so that they can later on be queried by the GUI for example
  mSuggestedResponses = entityTalk.getSuggestedResponses();

  std::string message = "<";
  message.append(getName());
  message.append(",");
  const std::string& type = getType()->getName(); // Eris type as a string
  message.append(type);
  message.append("> ");
  message.append(entityTalk.getMessage());
  S_LOG_VERBOSE("Entity says: [" << message << "]\n");

  EventTalk.emit(entityTalk);

  // Make a sound in OpenAL -- mafm: call doesn't exist
  //	EmberServices::getSingleton().getSoundService().playTalk(msg,
  //		getPosition(),getOrientation());

  // Call the method of the base class (since we've overloaded it)
  Eris::Entity::onTalk(talkArgs);
}
void  XMLModelDefinitionSerializer::readParticleSystems(ModelDefinitionPtr modelDef, TiXmlElement* mParticleSystemsNode)
{
	TiXmlElement* elem;
	ModelDefinition::ParticleSystemSet& particleSystems = modelDef->mParticleSystems;

	const char* tmp = 0;

	for (TiXmlElement* apElem = mParticleSystemsNode->FirstChildElement();
            apElem != 0; apElem = apElem->NextSiblingElement())
	{
		ModelDefinition::ParticleSystemDefinition def;

		// name
		tmp =  apElem->Attribute("script");
		if (tmp)
			def.Script = tmp;
		S_LOG_VERBOSE( "  Add particlescript  : "+ def.Script );

		elem = apElem->FirstChildElement("bindings");
		if (elem)
			readParticleSystemsBindings(def, elem);

		elem = apElem->FirstChildElement("direction");
		if (elem) {
			def.Direction = XMLHelper::fillVector3FromElement(elem);
		} else {
			def.Direction = Ogre::Vector3(std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN());
		}


		particleSystems.push_back(def);
	}
}
void XMLModelDefinitionSerializer::readAnimations(TiXmlElement* mAnimationsNode, ActionDefinition* action)
{
	const char* tmp = 0;
	bool nopartfound = true;


	for (TiXmlElement* animElem = mAnimationsNode->FirstChildElement();
            animElem != 0; animElem = animElem->NextSiblingElement())
	{
		int iterations(1);
		nopartfound = false;

		// name
		tmp =  animElem->Attribute("iterations");
		if (tmp) {
			iterations = Ogre::StringConverter::parseInt(tmp);
		}

		AnimationDefinition* animDef = action->createAnimationDefinition(iterations);
		readAnimationParts(animElem, animDef);
	}

	if(nopartfound)
	{
		S_LOG_VERBOSE( "  No animations found!!" );
	}

}
void XMLModelDefinitionSerializer::readActivations(TiXmlElement* activationsNode, ActionDefinition* action)
{
	const char* tmp = 0;

	for (TiXmlElement* activationElem = activationsNode->FirstChildElement();
            activationElem != 0; activationElem = activationElem->NextSiblingElement())
	{
		tmp = activationElem->Attribute("type");
		if (tmp)
		{
			std::string typeString(tmp);

			ActivationDefinition::Type type;
			if (typeString == "movement") {
				type = ActivationDefinition::MOVEMENT;
			} else if (typeString == "action") {
				type = ActivationDefinition::ACTION;
			} else if (typeString == "task") {
				type = ActivationDefinition::TASK;
			} else {
				S_LOG_WARNING("No recognized activation type: " << typeString);
				continue;
			}
			std::string trigger = activationElem->GetText();
			action->createActivationDefinition(type, trigger);
			S_LOG_VERBOSE( "  Add activation: " << typeString << " : " << trigger);
		}
	}
}
void XMLModelDefinitionSerializer::readSounds(TiXmlElement* mAnimationsNode, ActionDefinition* action)
{
	const char* tmp = 0;

	for (TiXmlElement* soundElem = mAnimationsNode->FirstChildElement();
            soundElem != 0; soundElem = soundElem->NextSiblingElement())
	{
		tmp = soundElem->Attribute("group");
		if (tmp)
		{
			std::string groupName(tmp);

			unsigned int playOrder = 0;
			tmp = soundElem->Attribute("playOrder");
			if (tmp)
			{
				std::string playO(tmp);
				if (playO == "linear")
					playOrder = 0;
				else
				if (playO == "inverse")
					playOrder = 1;
				else
				if (playO == "random")
					playOrder = 2;
			}

			action->createSoundDefinition(groupName, playOrder);
			S_LOG_VERBOSE( "  Add Sound: " << groupName);
		}
	}
}
Beispiel #12
0
void GUIManager::runCommand(const std::string &command, const std::string &args)
{
	if (command == ToggleInputMode.getCommand()) {
		getInput().toggleInputMode();
	} else if (command == ToggleGui.getCommand()) {

		S_LOG_VERBOSE("Toggle Gui Initiated -- " << getInput().getInputMode());

		if (mEnabled) {
			S_LOG_INFO("Disabling GUI");
			mEnabled = false;

			getInput().removeAdapter(mCEGUIAdapter);

		} else {
			S_LOG_INFO("Enabling GUI");
			mEnabled = true;

			getInput().addAdapter(mCEGUIAdapter);
		}
	} else if (command == ReloadGui.getCommand()) {
		Ogre::TextureManager* texMgr = Ogre::TextureManager::getSingletonPtr();
		Ogre::ResourcePtr resource = texMgr->getByName("cegui/" + getDefaultScheme() + ".png");
		if (!resource.isNull()) {
			resource->reload();
		}
	}
}
Beispiel #13
0
TimedLog::TimedLog(const std::string& logName, bool reportStart) :
	mLogName(logName), mStart(std::chrono::steady_clock::now())
{
	if (reportStart) {
		S_LOG_VERBOSE("Started task '" << mLogName << "'.");
	}
}
Beispiel #14
0
void EmberEntity::init(const Atlas::Objects::Entity::RootEntity &ge, bool fromCreateOp)
{
  if (mEntityMapping) {
    //Calling this will result in the graphical represention being correctly set up.
    //It's important that we call initialize before call Eris::Entity::init, since else we get strange results.
    mEntityMapping->initialize();
  }

  Eris::Entity::init(ge, fromCreateOp);

  // Setup Sounds
  //	setSounds();

  // set the Ogre node position and orientation based on Atlas data
  std::stringstream ss;
  if (getPredictedPos().isValid()) {
    ss << "Entity " << getId() << "(" << getName() << ") placed at (" << getPredictedPos().x() << "," << getPredictedPos().y() << "," << getPredictedPos().x() << ")";
  }
  S_LOG_VERBOSE(ss.str());

  mIsInitialized = true;

  //If the entity had no bounding box, the onBboxChanged will never have been called, and we want to do that now instead.
  if (!hasBBox()) {
    onBboxChanged();
  }

  will_not_compile++;
}
Beispiel #15
0
void SimpleRenderContext::setupScene(const std::string& prefix)
{
    S_LOG_VERBOSE("Creating new SimpleRenderContext for prefix " << prefix << " with w:" << mWidth << " h:" << mHeight);
    mSceneManager = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, prefix + "_sceneManager");
    //One might wonder why we're not setting the fog to FOG_NONE. The reason is that it seems that due to a bug in either Ogre or OpenGL when doing that, none of the other fog values would be set. Since we use shaders and in the shaders look for the alpha value of the fog colour to determine whether fog is enabled or not, we need to make sure that the fog colour indeed is set.
    mSceneManager->setFog(Ogre::FOG_EXP2, Ogre::ColourValue(0, 0, 0, 0), 0.0f, 0.0f, 0.0f);
// 	mSceneManager->setFog(Ogre::FOG_NONE, Ogre::ColourValue(1,1,1,1), 0.0f, 10000000.0f, 100000001.0f);

    mRootNode = mSceneManager->getRootSceneNode();

    mEntityNode = mRootNode->createChildSceneNode();

    //make the cameranode a child of the main entity node
    mCameraNode = mRootNode->createChildSceneNode();

    mCameraPitchNode = mCameraNode->createChildSceneNode();

    createCamera(prefix);
    //setVisible(false);
    Ogre::ColourValue colour(0.5, 0.5, 0.5);
    mMainLight = mSceneManager->createLight("MainLight");
    mMainLight->setType(Ogre::Light::LT_DIRECTIONAL);
    mMainLight->setDirection(Ogre::Vector3(-1, 0, 0));
    mMainLight->setPowerScale(10); // REALLY bright.
    mMainLight->setDiffuseColour(colour);
    mMainLight->setSpecularColour(colour);
    mMainLight->setVisible(true);

    mSceneManager->setAmbientLight(colour);
    mCameraPitchNode->attachObject(mMainLight);

    resetCameraOrientation();
}
void XMLModelDefinitionSerializer::readParticleSystemsBindings(ModelDefinition::ParticleSystemDefinition& def, TiXmlElement* mParticleSystemsNode)
{
	const char* tmp = 0;
// 	bool nopartfound = true;

	for (TiXmlElement* apElem = mParticleSystemsNode->FirstChildElement();
            apElem != 0; apElem = apElem->NextSiblingElement())
	{
		ModelDefinition::BindingDefinition binding;

		// emittervar
		tmp =  apElem->Attribute("emittervar");
		if (tmp)
			binding.EmitterVar = tmp;
		else
			continue;

		// atlasattribute
		tmp =  apElem->Attribute("atlasattribute");
		if (tmp)
			binding.AtlasAttribute = tmp;
		else
			continue;

		S_LOG_VERBOSE( "  Add binding between "<< binding.EmitterVar << " and " << binding.AtlasAttribute << "." );


		def.Bindings.push_back(binding);
	}

}
Beispiel #17
0
AvatarLogger::AvatarLogger(EmberEntity& avatarEntity)
: mChatLogger(nullptr)
{
	assert(&avatarEntity);

	//Put log files in a "logs" subdirectory of the home directory.
	const std::string dir = EmberServices::getSingleton().getConfigService().getHomeDirectory() + "/logs/";
	try {
		//make sure the directory exists

		oslink::directory osdir(dir);

		if (!osdir.isExisting()) {
			oslink::directory::mkdir(dir.c_str());
		}
		//perform setup of the stream
		std::stringstream logFileSS;
		logFileSS << dir << "/" << avatarEntity.getName() << "_chatlog.log";
		mChatLogger = std::unique_ptr<std::ofstream>(new std::ofstream(logFileSS.str().c_str(), std::ios::app));
		S_LOG_VERBOSE("Chat Logging set to write in [ " << logFileSS.str() << " ]");

		*mChatLogger << "-------------------------------------------------------" << std::endl;
		*mChatLogger << "Chat Logging Initialized at " <<  Time::getLocalTimeStr() << std::endl;
		*mChatLogger << "-------------------------------------------------------" << std::endl;

		//wait with connecting until everything has been properly set up
		GUIManager::getSingleton().AppendIGChatLine.connect(sigc::mem_fun(*this, &AvatarLogger::GUIManager_AppendIGChatLine));

	} catch (const std::exception& ex) {
		S_LOG_FAILURE("Error when creating directory for logs." << ex);
	}
}
void TerrainPageSurfaceLayer::populate(const TerrainPageGeometry& geometry)
{
	const SegmentVector validSegments = geometry.getValidSegments();
	for (SegmentVector::const_iterator I = validSegments.begin(); I != validSegments.end(); ++I) {
#if 0
		//the current Mercator code works such that whenever an Area is added to Terrain, _all_ surfaces for the affected segments are invalidated, thus requiering a total repopulation of the segment
		//If however that code was changed to only invalidate the affected surface the code below would be very much handy
		Mercator::Surface* surface(getSurfaceForSegment(I->segment));
		if (surface) {
			surface->populate();
		}
#else

		Mercator::Segment* segment(I->segment);
		if (!segment->isValid()) {
			segment->populate();
		}

		Mercator::Segment::Surfacestore::iterator I2(segment->getSurfaces().find(mSurfaceIndex));
		if (I2 == segment->getSurfaces().end()) {
			//the segment doesn't contain this surface yet, lets add it
			if (mShader.checkIntersect(*segment)) {
				S_LOG_VERBOSE("Adding new surface with id " << mSurfaceIndex << " to segment at x: " << segment->getXRef() << " y: " << segment->getYRef());
				Mercator::Segment::Surfacestore & sss = segment->getSurfaces();
				sss[mSurfaceIndex] = mShader.newSurface(*segment);
			}
		}
		//NOTE: we have to repopulate all surfaces mainly to get the foliage to work.
		segment->populateSurfaces();
#endif
	}
}
bool EmberPagingLandScapeData2D_HeightField::_load(unsigned int x, unsigned int z)
{
	assert(!mHeightData);

	EmberPagingSceneManager* emberPagingSceneManager = static_cast<EmberPagingSceneManager*> (mParent->getSceneManager());
	IPageDataProvider* provider = emberPagingSceneManager->getProvider();
	if (provider) {
		mXDimension = mZDimension = provider->getPageIndexSize();

		mMaxArrayPos = mSize * mSize;
		mHeightData = new Ogre::Real[mMaxArrayPos];
		mHeightDataPtr = boost::shared_array<Ogre::Real>(mHeightData);
		Ogre::Real* heightDataPtr = mHeightData;
		for (size_t i = 0; i < mMaxArrayPos; ++i) {
			*(heightDataPtr++) = 0.0f;
		}

		static size_t totalSize = 0;
		totalSize += (mMaxArrayPos * sizeof(Ogre::Real));
		S_LOG_VERBOSE("Created height data of size " << mMaxArrayPos << ". Total data size: " << totalSize << ".");

		EmberTerrainPageBridge* bridge = new EmberTerrainPageBridge(*emberPagingSceneManager->getData2DManager(), mHeightDataPtr, mMaxArrayPos, std::pair<unsigned int, unsigned int>(x, z));
		provider->setUpTerrainPageAtIndex(IPageDataProvider::OgreIndex(x, z), bridge);

		return true;
	}
	return false;
}
void EntityCreatorCreationInstance::finalizeCreation()
{
	// Final position
	mEntityMessage["pos"] = Convert::toWF<WFMath::Point<3>>(mEntityNode->getPosition()).toAtlas();
	mEntityMessage["orientation"] = Convert::toWF(mEntityNode->getOrientation()).toAtlas();

	// Making create operation message
	Atlas::Objects::Operation::Create c;
	EmberEntity& avatar = mWorld.getAvatar()->getEmberEntity();
	c->setFrom(avatar.getId());
	//if the avatar is a "creator", i.e. and admin, we will set the TO property
	//this will bypass all of the server's filtering, allowing us to create any entity and have it have a working mind too
	if (avatar.getType()->isA(mTypeService.getTypeByName("creator"))) {
		c->setTo(avatar.getId());
	}

	c->setArgsAsList(Atlas::Message::ListType(1, mEntityMessage));
	mWorld.getView().getAvatar()->getConnection()->send(c);

	std::stringstream ss;
	ss << mPos;
	S_LOG_INFO("Trying to create entity at position " << ss.str());
	S_LOG_VERBOSE("Sending entity data to server: " << AtlasHelper::serialize(c, "xml"));

}
Beispiel #21
0
void EntityEditor::operationGetGoalInfoResult(const Atlas::Objects::Operation::RootOperation& op)
{
	//What we receive here has been relayed from the mind of the entity. That means that this op
	//is potentially unsafe, as it could be of any type (Set, Logout etc.), all depending on what the
	//mind client decided to send (i.e. someone might want to try to hack). We should therefore treat it
	//very carefully.

	if (op->getClassNo() == Atlas::Objects::Operation::ROOT_OPERATION_NO) {
		//An empty root operation signals a timeout; we never got any answer from the entity.
		return;
	}

	//Since we'll just be iterating over the args we only need to do an extra check that what we got is a
	//"info" operation.
	if (op->getClassNo() != Atlas::Objects::Operation::INFO_NO) {
		S_LOG_WARNING("Got goal info operation with wrong type.");
		return;
	}

	if (!op->getArgs().empty()) {
		auto goalInfos = op->getArgsAsList();
		for (auto goalInfo : goalInfos) {
			EventGotGoalInfo(goalInfo);
		}
	} else {
		S_LOG_VERBOSE("Got goal info op without any goals.");
	}
}
Beispiel #22
0
void Input::setMouseGrab(bool enabled) {
	S_LOG_VERBOSE("Setting mouse catching to " << (enabled ? "enabled": "disabled"));
	SDL_WM_GrabInput(enabled ? SDL_GRAB_ON : SDL_GRAB_OFF);
	if (enabled) {
		mMouseGrabbingRequested = false;
	}
}
Beispiel #23
0
void EntityEditor::submitChanges()
{
	if (mRootAdapter->hasChanges()) {
		Atlas::Message::Element rootElement = mRootAdapter->getSelectedChangedElements();
		if (rootElement.isMap()) {
			std::map<std::string, ::Atlas::Message::Element> attributes(rootElement.asMap());
			if (attributes.size()) {

				std::stringstream ss;

				Atlas::Message::QueuedDecoder decoder;

				Atlas::Codecs::XML codec(ss, decoder);
				Atlas::Formatter formatter(ss, codec);
				Atlas::Message::Encoder encoder(formatter);
				formatter.streamBegin();
				encoder.streamMessageElement(attributes);
				formatter.streamEnd();
				S_LOG_VERBOSE("Sending attribute update to server:\n" << ss.str());

				EmberServices::getSingleton().getServerService().setAttributes(&mEntity, attributes);
			}
		}
	}
}
void TerrainPageCreationTask::executeTaskInMainThread()
{
	if (mPage) {
		S_LOG_VERBOSE("Adding loaded terrain page to TerrainHandler: " << "[" << mPage->getWFIndex().first << "|" << mPage->getWFIndex().second <<"]");
		mTerrainHandler.addPage(mPage);
	}
}
Beispiel #25
0
void SimpleRenderContext::setTexture(Ogre::TexturePtr texture)
{
    if (texture != mTexture) {
        if (mRenderTexture) {
            mRenderTexture->removeAllViewports();
        }
        mTexture = texture;
        mRenderTexture = texture->getBuffer()->getRenderTarget();
        mRenderTexture->removeAllViewports();

        mRenderTexture->setAutoUpdated(false);
        //initially deactivate it until setActive(true) is called
        mRenderTexture->setActive(false);

        S_LOG_VERBOSE("Adding camera.");
        mViewPort = mRenderTexture->addViewport(mCamera);
        mViewPort->setOverlaysEnabled(false);
        mViewPort->setShadowsEnabled(false);
        //make sure the camera renders into this new texture
        //this should preferrably be a transparent background, so that CEGUI could itself decide what to show behind it, but alas I couldn't get it to work, thus black
        mViewPort->setBackgroundColour(mBackgroundColour);
        //	mViewPort->setBackgroundColour(Ogre::ColourValue::ZERO);
        //don't show the CEGUI
        mViewPort->setOverlaysEnabled(false);
        //the cegui renderer wants a TexturePtr (not a RenderTexturePtr), so we just ask the texturemanager for texture we just created (rttex)
    }
}
void EmberEntityPartAction::deactivate(EntityMapping::ChangeContext& context)
{
	S_LOG_VERBOSE("Hiding part " << mPartName);
	Model::ModelRepresentation* representation = Model::ModelRepresentationManager::getSingleton().getRepresentationForEntity(mEntity);
	if (representation) {
		representation->setModelPartShown(mPartName, false);
	}
}
void XMLModelDefinitionSerializer::readSubEntities(TiXmlElement* mSubEntNode, PartDefinition* def)
{

	const char* tmp = 0;
	bool notfound = true;

	for (TiXmlElement* seElem = mSubEntNode->FirstChildElement();
            seElem != 0; seElem = seElem->NextSiblingElement())
	{
		SubEntityDefinition* subEntityDef = 0;
		// name
		tmp =  seElem->Attribute("index");
		if (tmp) {
				notfound = false;
				subEntityDef = def->createSubEntityDefinition(Ogre::StringConverter::parseInt(tmp));
				S_LOG_VERBOSE( "   Add sub entity with index: " << subEntityDef->getSubEntityIndex());
		} else {
			tmp =  seElem->Attribute("name");
			if (tmp) {
				notfound = false;
				subEntityDef = def->createSubEntityDefinition(tmp);
				S_LOG_VERBOSE( "   Add sub entity: " << subEntityDef->getSubEntityName());
			}
		}
		if (!notfound) {
			//material
			tmp =  seElem->Attribute("material");
			if (tmp)
			{
				subEntityDef->setMaterialName(tmp);
				//preload subEntityDef.Material
				//Ogre::MaterialManager::getSingleton().load( subEntityDef.Material,
								//Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );

			}

		} else {
			S_LOG_FAILURE( "A subentity name or index must be specified for each subentity." );
		}
	}

	if(notfound)
	{
		S_LOG_VERBOSE( "No sub entity found." );
	}
}
Beispiel #28
0
TaskQueue::TaskQueue(unsigned int numberOfExecutors) :
	mActive(true)
{
	S_LOG_VERBOSE("Creating task queue with " << numberOfExecutors << " executors.");
	for (unsigned int i = 0; i < numberOfExecutors; ++i) {
		TaskExecutor* executor = new TaskExecutor(*this);
		mExecutors.push_back(executor);
	}
}
void EmberPagingLandScapeData2D_HeightField::_unload()
{
	S_LOG_VERBOSE("Unloading terrain page at x: " << mPageX << " z:" << mPageZ << ".");
	EmberPagingSceneManager* emberPagingSceneManager = static_cast<EmberPagingSceneManager*> (mParent->getSceneManager());
	IPageDataProvider* provider = emberPagingSceneManager->getProvider();
	if (provider) {
		provider->removeBridge(IPageDataProvider::OgreIndex(mPageX, mPageZ));
	}
}
	//-----------------------------------------------------------------------
	void PagingLandScapePage::uninit()
	{
		if (mPageState == STATE_UNINITED) {
			S_LOG_WARNING("PagingLandScapePage at (" << mTableX << ", " << mTableZ << ") already uninited, ignoring request");
			return;
		}

		S_LOG_VERBOSE("Uniniting PagingLandScapePage at (" << mTableX << ", " << mTableZ << ")");

		// unload, if loaded
		if (isLoaded()) {
			// hide
			show(false);

			// unload the tiles
			for (size_t i = 0; i < mTiles.size(); ++i) {
				for (size_t j = 0; j < mTiles[i].size(); ++j) {
					mTiles[i][j]->uninit();
				}
			}
			mTiles.clear();

			// fire event
			fireEvent(EVENT_UNLOADED);

			// unload texture
			mPageMgr.getSceneManager()->getTextureManager()->unload(mTableX, mTableZ);

			// post unload
			mPageMgr.getSceneManager()->getData2DManager()->unload(mTableX, mTableZ);
			fireEvent(EVENT_POSTUNLOADED);
		}

		// destroy renderable
		if (mPageMgr.getOptions()->BigImage) {
			mPageNode->detachObject(mRenderable->getName());
			delete mRenderable;
			mRenderable = 0;
		}	

		// destroy page node
		if (mPageNode) {
			mPageNode->removeAndDestroyAllChildren();
			mPageMgr.getSceneManager()->destroySceneNode(mPageNode->getName());
			mPageNode = 0;
		}

		// update neighbors (tell them that we're gone)
		resetNeighbors();

		// restore state
		mBounds.setNull();
		mWorldPosition = Ogre::Vector3::ZERO;

		// set new state
		mPageState = STATE_UNINITED;
	}