Example #1
0
/**
*  @brief
*    Sets the node position
*/
void GraphNode::SetPos(float fX, float fY, float fZ)
{
	// Set new position
	m_vPos.SetXYZ(fX, fY, fZ);

	{ // Calculate all node distances
		Iterator<Neighbour*> cIterator = m_lstNeighbours.GetIterator();
		while (cIterator.HasNext()) {
			Neighbour *pNeighbour = cIterator.Next();
			pNeighbour->fDistance = GetDistance(*pNeighbour->pNode);
		}
	}

	{ // Update all neighbour node distances
		Iterator<GraphNode*> cIterator = m_lstIsNeighbourFrom.GetIterator();
		while (cIterator.HasNext()) {
			// Find this node within the neighbour
			Iterator<Neighbour*> cNeighbourIterator = cIterator.Next()->m_lstNeighbours.GetIterator();
			while (cNeighbourIterator.HasNext()) {
				Neighbour *pNeighbour = cNeighbourIterator.Next();
				if (pNeighbour->pNode == this) {
					pNeighbour->fDistance = GetDistance(*pNeighbour->pNode);
					break;
				}
			}
		}
	}
}
Example #2
0
void Gui::DefaultCallBackHandler()
{
	// get the iterator for the windows
	Iterator<SRPWindows*> cIterator = m_pWindows->GetIterator();
	// loop trough the windows
	while (cIterator.HasNext())
	{
		SRPWindows *pSRPWindows = cIterator.Next();

		// check if callback is present
		if (pSRPWindows->GetNumberOfCallBacks() > 0)
		{
			if (pSRPWindows->GetCallBack(DRAGWINDOW))
			{
				m_pDragWindow = pSRPWindows;
			}

			if (pSRPWindows->GetCallBack(HIDEWINDOW))
			{
				/*hide window*/
			}

			if (pSRPWindows->GetCallBack(CLOSEWINDOW))
			{
				/*close window*/
			}

			// call back is processed so we clear them
			pSRPWindows->ClearCallBacks();
		}
	}
}
Example #3
0
/**
*  @brief
*    Destructor
*/
World::~World()
{
	// Destroy all visibility information
	Iterator<void*> cIterator = m_lstFreeBodyInformation.GetIterator();
	while (cIterator.HasNext())
		delete static_cast<Sensor::BodyInfo*>(cIterator.Next());
}
/**
*  @brief
*    Draws recursive
*/
void SRPDebugWireframesFixedFunctions::DrawRec(Renderer &cRenderer, const SQCull &cCullQuery) const
{
	// Get the fixed functions interface (when we're in here, we know that it must exist!)
	FixedFunctions *pFixedFunctions = cRenderer.GetFixedFunctions();

	// Get scene container
	SceneContainer &cSceneContainer = cCullQuery.GetSceneContainer();
	const VisContainer &cVisContainer = cCullQuery.GetVisContainer();

	// Set the new scissor rectangle
	cRenderer.SetScissorRect(&cVisContainer.GetProjection().cRectangle);

	// Draw the container scene node
	if (cSceneContainer.GetMeshHandler())
		DrawMesh(cRenderer, cVisContainer, *cSceneContainer.GetMeshHandler());

	// Render all visible scene nodes of this scene container
	Iterator<VisNode*> cIterator = cVisContainer.GetVisNodes().GetIterator();
	while (cIterator.HasNext()) {
		// Get visibility node and scene node
		const VisNode   *pVisNode   = cIterator.Next();
			  SceneNode *pSceneNode = pVisNode->GetSceneNode();
		if (pSceneNode) {
			// Set the current world matrix
			pFixedFunctions->SetTransformState(FixedFunctions::Transform::World, pVisNode->GetWorldMatrix());

			// Is this scene node a portal?
			if (pVisNode->IsPortal()) {
				// Get the target cell visibility container
				const VisContainer *pVisCell = static_cast<const VisPortal*>(pVisNode)->GetTargetVisContainer();
				if (pVisCell && pVisCell->GetCullQuery()) {
					// Draw the target cell
					DrawRec(cRenderer, *pVisCell->GetCullQuery());

					// Set the previous scissor rectangle
					cRenderer.SetScissorRect(&cVisContainer.GetProjection().cRectangle);
				}

				// Draw the portal itself
				if (pSceneNode->GetMeshHandler())
					DrawMesh(cRenderer, *pVisNode, *pSceneNode->GetMeshHandler());

			// Is this scene node a container? We do not need to check for cells because we will
			// NEVER receive cells from SQCull directly, they are ONLY visible through portals! (see above)
			} else if (pVisNode->IsContainer()) {
				// Draw this container without special processing
				if (static_cast<const VisContainer*>(pVisNode)->GetCullQuery())
					DrawRec(cRenderer, *static_cast<const VisContainer*>(pVisNode)->GetCullQuery());

				// Set the previous scissor rectangle
				cRenderer.SetScissorRect(&cVisContainer.GetProjection().cRectangle);

			// This must just be a quite boring scene node :)
			} else {
				if (pSceneNode->GetMeshHandler())
					DrawMesh(cRenderer, *pVisNode, *pSceneNode->GetMeshHandler());
			}
		}
	}
}
Example #5
0
/**
*  @brief
*    Removes a neighbour connection
*/
bool GraphNode::RemoveNeighbour(GraphNode &cNode)
{
	// Find neighbour list entry
	Neighbour *pNeighbour = nullptr;
	{
		Iterator<Neighbour*> cIterator = m_lstNeighbours.GetIterator();
		while (cIterator.HasNext()) {
			Neighbour *pNeighbourT = cIterator.Next();
			if (pNeighbourT->pNode == &cNode) {
				pNeighbour = pNeighbourT;
				break;
			}
		}
	}

	// Remove
	if (pNeighbour) {
		cNode.m_lstIsNeighbourFrom.Remove(this);
		delete pNeighbour;
		m_lstNeighbours.Remove(pNeighbour);

		// Done
		return true;
	} else return false; // Error!
}
Example #6
0
List<SRPWindows*> *Gui::GetMouseEnabledWindows()
{
	// create an empty list
	List<SRPWindows*> *pList = new List<SRPWindows*>;

	// get the iterator for all the windows
	Iterator<SRPWindows*> cIterator = m_pWindows->GetIterator();
	// loop trough the windows
	while (cIterator.HasNext())
	{
		SRPWindows *pSRPWindows = cIterator.Next();
		if (pSRPWindows->GetData()->bIsVisable && pSRPWindows->GetData()->bMouseEnabled)
		{
			// if the window is visible and the mouse for the window is enabled then add the window to the list
			pList->Add(pSRPWindows);
		}
	}

	if (pList->GetNumOfElements() > 0)
	{
		// list has items so return the list
		return pList;
	}
	else
	{
		// return nothing because the list is empty
		return nullptr;
	}
}
Example #7
0
Set<ElemType> *Set<ElemType>::Union(Set *otherSet)
{
	    Iterator<ElemType> *iterator;
    Set *result;
    
    result = new Set<ElemType>(cmp);
    iterator = CreateIterator();
    while (iterator->HasNext()) {
        result->AddElement(iterator->Next());
    }
    delete iterator;
    iterator = otherSet->CreateIterator();
    while (iterator->HasNext()) {
        result->AddElement(iterator->Next());
    }
    delete iterator;
    return (result);
}
Example #8
0
/**
*  @brief
*    Called when the scene node needs to be updated
*/
void PGSparkles::OnUpdate()
{
	// If this scene node wasn't drawn at the last frame, we can skip some update stuff
	if ((GetFlags() & ForceUpdate) || m_bUpdate) {
		m_bUpdate = true;

		// If there are free particles, create new particles
		if (!(System::GetInstance()->GetMicroseconds() % BuildPerSec)) {
			while (Math::GetRand() % 5) {
				Particle *pParticle = AddParticle();
				if (pParticle)
					InitParticle(*pParticle);
				else
					break;
			}
		}

		{ // Update particles
			float fTimeDiff = Timing::GetInstance()->GetTimeDifference();
			Iterator<Particle> cIterator = GetParticleIterator();
			while (cIterator.HasNext()) {
				Particle &cParticle = cIterator.Next();

				// Update velocity
				cParticle.vVelocity += GetGravity()*fTimeDiff*(200-cParticle.fEnergy)/10;
				cParticle.vVelocity -= cParticle.vVelocity*fTimeDiff;

				// Self induction to make the sparkles a bit more interesting ;-)
				if (!(System::GetInstance()->GetMicroseconds() % 500) && !(Math::GetRand() % 5)) {
					cParticle.fEnergy += 100;
					cParticle.fSize   += 0.2f;
				}

				// Update position
				Vector3 vMove = cParticle.vVelocity*fTimeDiff*cParticle.fEnergy/100;
				cParticle.vPos += vMove/10;

				// Update distortion
				cParticle.fCustom1 += fTimeDiff;
				float dLength = cParticle.fCustom1/vMove.GetLength()*5;
				cParticle.vDistortion = vMove*dLength;

				// Update energy, size and lifetime
				cParticle.fEnergy -= fTimeDiff*EnergyPerSec;
				cParticle.fSize   -= fTimeDiff;
				if (cParticle.fEnergy <= 0 || cParticle.fSize <= 0)
					InitParticle(cParticle);
				else
					cParticle.vColor[3] = cParticle.fEnergy/255;
			}
		}

		// We have to recalculate the current axis align bounding box in 'scene node space'
		DirtyAABoundingBox();
	}
}
Example #9
0
/**
*  @brief
*    Clears all neighbour connectivity
*/
void GraphNode::ClearNeighbours()
{
	{ // Update neighbour connections
		Iterator<GraphNode*> cIterator = m_lstIsNeighbourFrom.GetIterator();
		while (cIterator.HasNext()) {
			// Remove this node from the neighbours connectivity list
			cIterator.Next()->RemoveNeighbour(*this);
		}
	}
	m_lstIsNeighbourFrom.Clear();

	{ // Clear neighbours
		Iterator<Neighbour*> cIterator = m_lstNeighbours.GetIterator();
		while (cIterator.HasNext()) {
			Neighbour *pNN = cIterator.Next();
			pNN->pNode->m_lstIsNeighbourFrom.Remove(this);
			delete pNN;
		}
	}
	m_lstNeighbours.Clear();
}
Example #10
0
void Gui::UnFocusAllWindows()
{
	// focused window needs to be a nullptr
	m_pFocusedWindow = nullptr;
	// get the iterator for all the windows
	Iterator<SRPWindows*> cIterator = m_pWindows->GetIterator();
	// loop trough the windows
	while (cIterator.HasNext())
	{
		// unfocus the window
		cIterator.Next()->GetAwesomiumWindow()->Unfocus();
	}
}
Example #11
0
/**
*  @brief
*    Called when the scene node needs to be updated
*/
void PGImage::OnUpdate()
{
	// If this scene node wasn't drawn at the last frame, we can skip some update stuff
	if ((GetFlags() & ForceUpdate) || m_bUpdate) {
		m_bUpdate = false;

		{ // Update particles
			float fTimeDiff = Timing::GetInstance()->GetTimeDifference();
			Iterator<Particle> cIterator = GetParticleIterator();
			while (cIterator.HasNext()) {
				Particle &cParticle = cIterator.Next();

				cParticle.fSize = cParticle.fCustom1;
				for (int i=0; i<3; i++) {
					if (cParticle.vPos[i] > cParticle.vDistortion[i])
						cParticle.vVelocity[i] -= fTimeDiff*10;
					else {
						if (cParticle.vPos[i] < cParticle.vDistortion[i])
							cParticle.vVelocity[i] += fTimeDiff*10;
					}
					if (cParticle.vVelocity[i] > 100.0f)
						cParticle.vVelocity[i] = 100.0f;
					if (cParticle.vVelocity[i] < -100.0f)
						cParticle.vVelocity[i] = -100.0f;

					cParticle.vPos[i] += cParticle.vVelocity[i]*fTimeDiff;

					if ((cParticle.vPos[i] <= cParticle.vDistortion[i]+0.1f &&
						cParticle.vPos[i] >= cParticle.vDistortion[i]-0.1f) ||
						cParticle.vPos[i] >= cParticle.vFixPos[i]+0.2f ||
						cParticle.vPos[i] <= cParticle.vFixPos[i]-0.2f) {
						if (cParticle.vDistortion[i] != cParticle.vFixPos[i])
							cParticle.vVelocity[i] *= 0.8f;
						if (cParticle.vPos[i] > cParticle.vFixPos[i]+0.2f ||
							cParticle.vPos[i] < cParticle.vFixPos[i]-0.2f)
							cParticle.vDistortion[i] = cParticle.vFixPos[i];
						else {
							if (Math::GetRand() % 2)
								cParticle.vDistortion[i] = static_cast<float>(Math::GetRand() % 100)/1000+cParticle.vFixPos[i];
							else
								cParticle.vDistortion[i] = static_cast<float>(Math::GetRand() % 100)/1000-cParticle.vFixPos[i];
						}
					}
				}
			}
		}

		// We have to recalculate the current axis align bounding box in 'scene node space'
		DirtyAABoundingBox();
	}
}
Example #12
0
/**
*  @brief
*    Destructor
*/
VisContainer::~VisContainer()
{
	// Free all nodes
	FreeNodes();

	// Destroy the query
	SceneQuery *pSceneQuery = m_pQueryHandler->GetElement();
	if (pSceneQuery)
		pSceneQuery->GetSceneContainer().DestroyQuery(*pSceneQuery);
	delete m_pQueryHandler;

	{ // Destroy all containers
		Iterator<VisContainer*> cIterator = m_mapContainers.GetIterator();
		while (cIterator.HasNext())
			delete cIterator.Next();
	}

	{ // Destroy all portals
		Iterator<VisPortal*> cIterator = m_mapPortals.GetIterator();
		while (cIterator.HasNext())
			delete cIterator.Next();
	}
}
Example #13
0
bool Set<ElemType>::IsSubsetOf(Set *otherSet)
{
    Iterator<ElemType> *iterator;
    bool result;

    result = true;
    iterator = CreateIterator();
    while (result && iterator->HasNext()) {
        if (!otherSet->Contains(iterator->Next()))
	           result = false;
    }
    delete iterator;
    return (result);
}
Example #14
0
/**
*  @brief
*    Returns whether a node is a neighbour of this node or not
*/
bool GraphNode::IsNeighbour(const GraphNode &cNode) const
{
	// Check whether the given node is a neighbour of this node or not
	Iterator<Neighbour*> cIterator = m_lstNeighbours.GetIterator();
	while (cIterator.HasNext()) {
		if (cIterator.Next()->pNode == &cNode) {
			// The given node is a neighbour of this node
			return true;
		}
	}

	// The given node is no neighbour of this node
	return false;
}
Example #15
0
/**
*  @brief
*    Destroys all registered event user data (a kind of "disconnect all slots at once")
*/
void Script::DestroyEventUserData()
{
	// Iterate through the map content
	Iterator<String> cKeyIterator = m_mapEventUserData.GetKeyIterator();
	while (cKeyIterator.HasNext()) {
		// Get the event user data instance
		EventUserData *pEventUserData = m_mapEventUserData.Get(cKeyIterator.Next());
		
		// Destroy the event user data
		delete pEventUserData->pDynEventHandler;
		luaL_unref(m_pLuaState, LUA_REGISTRYINDEX, pEventUserData->nLuaFunctionReference);
		delete pEventUserData;
	}
}
Example #16
0
Set<ElemType> *Set<ElemType>::Intersection(Set *otherSet)
{
    Iterator<ElemType> *iterator;
    Set *result;

    result = new Set<ElemType>(cmp);
	    iterator = CreateIterator();
    while (iterator->HasNext()) {
        ElemType elem = iterator->Next();
        if (otherSet->Contains(elem))
            result->AddElement(elem);
    }
    delete iterator;
    return (result);
}
/**
*  @brief
*    Destructor
*/
SRPDirectionalLightingShaders::~SRPDirectionalLightingShaders()
{
	{ // SRPDirectionalLightingShaders-material cache cleanup
		Iterator<SRPDirectionalLightingShadersMaterial*> lstIterator = m_lstMaterialCache.GetIterator();
		while (lstIterator.HasNext())
			delete lstIterator.Next();
		m_lstMaterialCache.Clear();
	}

	// Destroy render states 'translator'
	delete m_pRenderStates;

	// Destroy the program generator
	if (m_pProgramGenerator)
		delete m_pProgramGenerator;
}
Example #18
0
/**
*  @brief
*    Draws recursive
*/
void SRPVolume::DrawRec(Renderer &cRenderer, const SQCull &cCullQuery)
{
	// Set the new scissor rectangle
	const VisContainer &cVisContainer = cCullQuery.GetVisContainer();
	cRenderer.SetScissorRect(&cVisContainer.GetProjection().cRectangle);

	// Render all visible scene nodes of this scene container
	Iterator<VisNode*> cIterator = (GetFlags() & DrawOrderFrontToBack) ? cVisContainer.GetVisNodes().GetIterator() : cVisContainer.GetVisNodes().GetEndIterator();
	while ((GetFlags() & DrawOrderFrontToBack) ? cIterator.HasNext() : cIterator.HasPrevious()) {
		// Get visibility node and scene node
		const VisNode   *pVisNode   = (GetFlags() & DrawOrderFrontToBack) ? cIterator.Next() : cIterator.Previous();
			  SceneNode *pSceneNode = pVisNode->GetSceneNode();
		if (pSceneNode) {
			// Is this scene node a portal?
			if (pVisNode->IsPortal()) {
				// Get the target cell visibility container
				const VisContainer *pVisCell = static_cast<const VisPortal*>(pVisNode)->GetTargetVisContainer();
				if (pVisCell && pVisCell->GetCullQuery()) {
					// Draw the target cell
					DrawRec(cRenderer, *pVisCell->GetCullQuery());

					// Set the previous scissor rectangle
					cRenderer.SetScissorRect(&cVisContainer.GetProjection().cRectangle);
				}

			// Is this scene node a container? We do not need to check for cells because we will
			// NEVER receive cells from SQCull directly, they are ONLY visible through portals! (see above)
			} else if (pVisNode->IsContainer()) {
				// Draw this container without special processing
				if (static_cast<const VisContainer*>(pVisNode)->GetCullQuery()) {
					DrawRec(cRenderer, *static_cast<const VisContainer*>(pVisNode)->GetCullQuery());

					// Set the previous scissor rectangle
					cRenderer.SetScissorRect(&cVisContainer.GetProjection().cRectangle);
				}

			// This must just be a quite boring scene node :)
			} else {
				// Do only take "PLVolume::SNVolume"-instances into account in here
				const static Class *pSNVolumeClass = ClassManager::GetInstance()->GetClass("PLVolume::SNVolume");
				if (pSceneNode->GetClass() == pSNVolumeClass)
					DrawVolumeSceneNode(cRenderer, cCullQuery, *pVisNode);
			}
		}
	}
}
Example #19
0
/**
*  @brief
*    Searches for the first (= nearest) visible clip plane scene node, recursive part
*/
const VisNode *SRPVolume::GetFirstClipPlaneRec(const SQCull &cCullQuery) const
{
	// Get visibility container
	const VisContainer &cVisContainer = cCullQuery.GetVisContainer();

	// Search through all visible scene nodes of this scene container
	Iterator<VisNode*> cIterator = cVisContainer.GetVisNodes().GetIterator();
	while (cIterator.HasNext()) {
		// Get visibility node and scene node
		const VisNode   *pVisNode   = cIterator.Next();
			  SceneNode *pSceneNode = pVisNode->GetSceneNode();
		if (pSceneNode) {
			// Is this scene node a portal?
			if (pVisNode->IsPortal()) {
				// Get the target cell visibility container
				const VisContainer *pVisCell = static_cast<const VisPortal*>(pVisNode)->GetTargetVisContainer();
				if (pVisCell && pVisCell->GetCullQuery()) {
					// Search within the target cell
					const VisNode *pFoundVisNode = GetFirstClipPlaneRec(*pVisCell->GetCullQuery());
					if (pFoundVisNode)
						return pFoundVisNode;
				}

			// Is this scene node a container? We do not need to check for cells because we will
			// NEVER receive cells from SQCull directly, they are ONLY visible through portals! (see above)
			} else if (pVisNode->IsContainer()) {
				// Search within this container without special processing
				if (static_cast<const VisContainer*>(pVisNode)->GetCullQuery()) {
					const VisNode *pFoundVisNode = GetFirstClipPlaneRec(*static_cast<const VisContainer*>(pVisNode)->GetCullQuery());
					if (pFoundVisNode)
						return pFoundVisNode;
				}

			// This must just be a quite boring scene node :)
			} else {
				// Is this a clip plane scene node?
				if (pSceneNode->IsInstanceOf("PLVolume::SNClipPrimitivePlane"))
					return pVisNode;
			}
		}
	}

	// Sorry, no result :/
	return nullptr;
}
Example #20
0
List<SRPWindows*> *Gui::GetMouseOverWindows(const List<SRPWindows*> *pEnabledWindows, const Vector2i &vMousePos)
{
	if (!pEnabledWindows)
	{
		// return nothing because the enabled windows list is not valid
		return nullptr;
	}

	// create an empty list
	List<SRPWindows*> *pList = new List<SRPWindows*>;

	// get the iterator for the enabled windows
	Iterator<SRPWindows*> cIterator = pEnabledWindows->GetIterator();
	// loop trough the enabled windows
	while (cIterator.HasNext())
	{
		SRPWindows *pSRPWindows = cIterator.Next();

		// get the relative mouse position for the window
		Vector2i vRelativeMousePos = pSRPWindows->GetRelativeMousePosition(vMousePos);

		if (vRelativeMousePos.x > 0 && vRelativeMousePos.y > 0 && vRelativeMousePos.x < pSRPWindows->GetSize().x && vRelativeMousePos.y < pSRPWindows->GetSize().y)
		{
			// the mouse is currently over the window, so we add the window to the list
			pList->Add(pSRPWindows);
		}
		else
		{
			// check if any widgets are drawn for the window
			/*maybe this needs to be implemented at a later point*/
		}
	}

	if (pList->GetNumOfElements() > 0)
	{
		// list has items so return the list
		return pList;
	}
	else
	{
		// return nothing because the list is empty
		return nullptr;
	}
}
Example #21
0
/**
*  @brief
*    Set default configuration settings
*/
bool Config::SetDefault(const String &sClass, const String &sVariable)
{
	// Set all classes to default settings?
	if (sClass.GetLength())
		return SetClassDefault(sClass, sVariable);
	else {
		// Set a class to default settings
		bool bResult = true; // No error by default
		Iterator<ConfigGroup*> cIterator = m_lstConfig.GetIterator();
		while (cIterator.HasNext()) {
			ConfigGroup *pClass = cIterator.Next();
			if (!SetClassDefault(pClass->GetClass()->GetClassName(), sVariable))
				bResult = false; // Something went wrong
		}

		// Done
		return bResult;
	}
}
Example #22
0
void Gui::OnUpdate()
{
	UpdateAwesomium();
	// mouse handler?
	KeyboardHandler();
	DefaultCallBackHandler();
	DragWindowHandler();
	// resize window handler

	// test for awesomium update

	// get the iterator for all the windows
	Iterator<SRPWindows*> cIterator = m_pWindows->GetIterator();
	// loop trough the windows
	while (cIterator.HasNext())
	{
		// unfocus the window
		cIterator.Next()->UpdateCall();
	}
}
/**
*  @brief
*    Draws recursive
*/
void SRPDeferredLighting::DrawRec(Renderer &cRenderer, const SQCull &cCullQuery, SRPDeferredGBuffer &cSRPDeferredGBuffer)
{
	// Get scene container
	const VisContainer &cVisContainer = cCullQuery.GetVisContainer();

	// Render all visible scene nodes of this scene container
	Iterator<VisNode*> cIterator = cVisContainer.GetVisNodes().GetIterator();
	while (cIterator.HasNext()) {
		// Get visibility node and scene node
		const VisNode   *pVisNode   = cIterator.Next();
			  SceneNode *pSceneNode = pVisNode->GetSceneNode();
		if (pSceneNode) {
			// Is this scene node a portal?
			if (pVisNode->IsPortal()) {
				// Get the target cell visibility container
				const VisContainer *pVisCell = static_cast<const VisPortal*>(pVisNode)->GetTargetVisContainer();
				if (pVisCell && pVisCell->GetCullQuery()) {
					// Draw the target cell
					DrawRec(cRenderer, *pVisCell->GetCullQuery(), cSRPDeferredGBuffer);
				}

			// Is this scene node a container? We do not need to check for cells because we will
			// NEVER receive cells from SQCull directly, they are ONLY visible through portals! (see above)
			} else if (pVisNode->IsContainer()) {
				// Draw this container without special processing
				if (static_cast<const VisContainer*>(pVisNode)->GetCullQuery())
					DrawRec(cRenderer, *static_cast<const VisContainer*>(pVisNode)->GetCullQuery(), cSRPDeferredGBuffer);

			// Is this a light?
			} else if (pSceneNode->IsLight()) {
				if (static_cast<SNLight*>(pSceneNode)->IsRenderLight()) {
					// Render the light
					RenderLight(cRenderer, cCullQuery, cSRPDeferredGBuffer, *static_cast<SNLight*>(pSceneNode), *pVisNode);
				}

			// This must just be a quite boring scene node, ignore it
			} else {
			}
		}
	}
}
Example #24
0
void Gui::DestroyWindows()
{
	if (m_bAwesomiumInitialized)
	{
		// get the iterator for all the windows created
		Iterator<SRPWindows*> cIterator = m_pWindows->GetIterator();
		// loop trough the windows
		while (cIterator.HasNext())
		{
			SRPWindows *pSRPWindows = cIterator.Next();
			// remove the scene render pass from the renderer
			pSRPWindows->RemoveSceneRenderPass();
			// destroy the window
			pSRPWindows->DestroyWindow();
			// cleanup the instance
			pSRPWindows->DestroyInstance();
		}
		// clear the hashmap
		m_pWindows->Clear();
	}
}
Example #25
0
SRPWindows *Gui::GetTopMostWindow(List<SRPWindows*> *pWindows)
{
	if (pWindows)
	{
		if (pWindows->GetNumOfElements() == 1)
		{
			// if the list has only one item return it
			return pWindows->Get(0);
		}
		else
		{
			// clear the current topmost window
			SRPWindows *pTopMostWindow = nullptr;

			int nHigherIndex = -1;

			// get the iterator for the windows in the list
			Iterator<SRPWindows*> cIterator = pWindows->GetIterator();
			// loop trough the windows
			while (cIterator.HasNext())
			{
				SRPWindows *pSRPWindows = cIterator.Next();
				if (pSRPWindows->GetSceneRenderPassIndex() > nHigherIndex)
				{
					// if the window is top most, keep it
					nHigherIndex = pSRPWindows->GetSceneRenderPassIndex();
					pTopMostWindow = pSRPWindows;
				}
			}

			// return the top most window
			return pTopMostWindow;
		}
	}
	else
	{
		// return nothing
		return nullptr;
	}
}
Example #26
0
/**
*  @brief
*    Returns a list of all visible scene node instances intersecting with the given scene node, recursive part
*/
void SRPVolume::GetIntersectingInstancesOfRec(const SQCull &cCullQuery, SceneNode &cSceneNode, const Class &cClass, Array<const VisNode*> &lstIntersecting) const
{
	// Get visibility container
	const VisContainer &cVisContainer = cCullQuery.GetVisContainer();

	// Search through all visible scene nodes of this scene container
	Iterator<VisNode*> cIterator = cVisContainer.GetVisNodes().GetIterator();
	while (cIterator.HasNext()) {
		// Get visibility node and scene node
		const VisNode   *pVisNode   = cIterator.Next();
			  SceneNode *pSceneNode = pVisNode->GetSceneNode();
		if (pSceneNode) {
			// Is this scene node a portal?
			if (pVisNode->IsPortal()) {
				// Get the target cell visibility container
				const VisContainer *pVisCell = static_cast<const VisPortal*>(pVisNode)->GetTargetVisContainer();
				if (pVisCell && pVisCell->GetCullQuery()) {
					// Search within the target cell
					GetIntersectingInstancesOfRec(*pVisCell->GetCullQuery(), cSceneNode, cClass, lstIntersecting);
				}

			// Is this scene node a container? We do not need to check for cells because we will
			// NEVER receive cells from SQCull directly, they are ONLY visible through portals! (see above)
			} else if (pVisNode->IsContainer()) {
				// Search within this container without special processing
				if (static_cast<const VisContainer*>(pVisNode)->GetCullQuery())
					GetIntersectingInstancesOfRec(*static_cast<const VisContainer*>(pVisNode)->GetCullQuery(), cSceneNode, cClass, lstIntersecting);

			// This must just be a quite boring scene node :)
			} else {
				// Is this a directional light scene node?
				if (pSceneNode->IsInstanceOfByReference(cClass)) {
					// [TODO] Intersection test
					lstIntersecting.Add(pVisNode);
				}
			}
		}
	}
}
Example #27
0
BNetworkCookieJar&
BNetworkCookieJar::operator=(const BNetworkCookieJar& other)
{
	if (&other == this)
		return *this;

	for (Iterator it = GetIterator(); it.Next() != NULL;)
		delete it.Remove();

	BArchivable::operator=(other);
	BFlattenable::operator=(other);

	fFlattened = other.fFlattened;

	delete fCookieHashMap;
	fCookieHashMap = new(std::nothrow) PrivateHashMap();

	for (Iterator it = other.GetIterator(); it.HasNext();) {
		const BNetworkCookie* cookie = it.Next();
		AddCookie(*cookie); // Pass by reference so the cookie is copied.
	}

	return *this;
}
Example #28
0
/**
*  @brief
*    Called when the scene node needs to be updated
*/
void PGLeaf::OnUpdate()
{
	// If this scene node wasn't drawn at the last frame, we can skip some update stuff
	if ((GetFlags() & ForceUpdate) || m_bUpdate) {
		m_bUpdate = false;

		// If there are free particles, create new particles
		Particle *pParticle = AddParticle();
		while (pParticle) {
			InitParticle(*pParticle);

			// Next particle, please
			pParticle = AddParticle();
		}

		{ // Update particles
			float fTimeDiff = Timing::GetInstance()->GetTimeDifference();
			Iterator<Particle> cIterator = GetParticleIterator();
			while (cIterator.HasNext()) {
				Particle &cParticle = cIterator.Next();

				// Update forces
				// One: gravity
				cParticle.vVelocity[1] -= fTimeDiff*(cParticle.vPos[1]-FloorHeight)/5;

				// Two wind (dot wind vector normal)
				Vector3 vRot;
				EulerAngles::FromQuaternion(*cParticle.pRot, vRot.x, vRot.y, vRot.z);
				vRot.x *= static_cast<float>(Math::RadToDeg);
				vRot.y *= static_cast<float>(Math::RadToDeg);
				vRot.z *= static_cast<float>(Math::RadToDeg);
				cParticle.vVelocity += Wind.Get()*fTimeDiff*Math::Abs(vRot.DotProduct(Wind.Get()));

				// Four collision (just check whether leaf would end up on wrong side)
				if (cParticle.vPos.y + cParticle.vVelocity.y*fTimeDiff < FloorHeight) {
					// Random bouncy and some friction
					cParticle.vVelocity.y *= -1.0;
					cParticle.vVelocity.z *= Math::GetRandNegFloat();
					cParticle.vVelocity.x *= Math::GetRandNegFloat();
					cParticle.nCustom1     = ((static_cast<int>(Math::GetRandNegFloat()*255.0f*8.0f))<<8) | (cParticle.nCustom1&0xff);
				}

				// Five check whether particle has left area and can die... if it is outside, let it die
				float  fDistx		 = GetTransform().GetPosition().x - cParticle.vPos.x;
				float  fDisty		 = GetTransform().GetPosition().z - cParticle.vPos.z;
				float  fDistToCenter = fDistx*fDistx + fDisty*fDisty;
				uint32 nStart		 = cParticle.nCustom1 & 0xff;
				if (nStart < 0xff) { // It is being spawned
					nStart += static_cast<uint32>(fTimeDiff*512.0f + 0.5f);
					if (nStart > 0xff)
						nStart = 0xff; // Clamp
					cParticle.nCustom1 = (cParticle.nCustom1&0xffffff00)|nStart; // Write to lower 8 bits
				}

				if (fDistToCenter > Radius*Radius) {
					// Start dying... set alpha according to how far it is away
					fDistToCenter = 255 - (Math::Sqrt(fDistToCenter) - Radius)*3.0f;
					cParticle.fSize = static_cast<float>(static_cast<int>(fDistToCenter*(cParticle.nCustom1 & 0xff))>>8)/255*cParticle.fCustom1;
					if (cParticle.fSize < 0.2f)
						InitParticle(cParticle);
				} else {
					cParticle.fSize = static_cast<float>(cParticle.nCustom1 &0xff)/255*cParticle.fCustom1;
				}

				// Update position
				cParticle.vPos += cParticle.vVelocity*fTimeDiff*cParticle.fSize/2;

				// Update spin
				Vector3 vAxis = cParticle.vVelocity;
				vAxis.SetLength(1);

				// Transform normal and distortion
				vAxis *= ((static_cast<float>(cParticle.nCustom1>>8))/255.0f)*fTimeDiff/10;
				Quaternion qRotInc;
				EulerAngles::ToQuaternion(static_cast<float>(vAxis.x*Math::DegToRad), static_cast<float>(vAxis.y*Math::DegToRad), static_cast<float>(vAxis.z*Math::DegToRad), qRotInc);
				*cParticle.pRot *= qRotInc;

				Vector3 d = cParticle.vDistortion;
				d.SetLength(cParticle.fSize);
				cParticle.vDistortion = (*cParticle.pRot)*d;

				// Update color
				EulerAngles::FromQuaternion(*cParticle.pRot, vRot.x, vRot.y, vRot.z);
				vRot.x *= static_cast<float>(Math::RadToDeg);
				vRot.y *= static_cast<float>(Math::RadToDeg);
				vRot.z *= static_cast<float>(Math::RadToDeg);
				vAxis = vRot.Normalize();
				fDistx  = vAxis.x+vAxis.y*2+vAxis.z*3;
				if (fDistx > 1.0f)
					fDistx = 1.0f;
				if (fDistx < 0.5f)
					fDistx = 0.5f;
				cParticle.vColor[0] = cParticle.vFixPos.x*fDistx;
				cParticle.vColor[1] = cParticle.vFixPos.y*fDistx;
				cParticle.vColor[2] = cParticle.vFixPos.z*fDistx;
			}
Example #29
0
void Gui::KeyboardHandler()
{
	/*i am not yet satisfied with this method*/

	if (m_pFocusedWindow)
	{
		if (m_pFocusedWindow->GetData()->bKeyboardEnabled)
		{
			if (m_pTextButtonHandler->GetNumOfElements() > 0)
			{
				Iterator<sButton*> cIterator = m_pTextButtonHandler->GetIterator();
				while (cIterator.HasNext())
				{
					sButton *psButton = cIterator.Next();
					if (psButton->bValid)
					{
						if (m_nTextKeyHitCount == 0)
						{
							//m_pFocusedWindow->GetAwesomiumWindow()->textEvent(psButton->sKey.GetUnicode(), psButton->sKey.GetLength());
							m_nLastTextKeySendTime = Timing::GetInstance()->GetPastTime();
							m_nTextKeyHitCount++;
						}
						else
						{
							if (m_nTextKeyHitCount == 1)
							{
								if ((Timing::GetInstance()->GetPastTime() - m_nLastTextKeySendTime) > 400)
								{
									//m_pFocusedWindow->GetAwesomiumWindow()->textEvent(psButton->sKey.GetUnicode(), psButton->sKey.GetLength());
									m_nLastTextKeySendTime = Timing::GetInstance()->GetPastTime();
									m_nTextKeyHitCount++;
								}
							}
							else
							{
								if ((Timing::GetInstance()->GetPastTime() - m_nLastTextKeySendTime) > 50)
								{
									//m_pFocusedWindow->GetAwesomiumWindow()->textEvent(psButton->sKey.GetUnicode(), psButton->sKey.GetLength());
									m_nLastTextKeySendTime = Timing::GetInstance()->GetPastTime();
									m_nTextKeyHitCount++;
								}
							}
						}
					}
				}
			}
			if (m_pKeyButtonHandler->GetNumOfElements() > 0)
			{
				Iterator<sButton*> cIterator = m_pKeyButtonHandler->GetIterator();
				while (cIterator.HasNext())
				{
					sButton *psButton = cIterator.Next();
					if (psButton->bValid)
					{
						if (m_nKeyHitCount == 0)
						{
							//m_pFocusedWindow->GetAwesomiumWindow()->keyEvent(true, 0, psButton->nKey, 0);
							m_nLastKeySendTime = Timing::GetInstance()->GetPastTime();
							m_nKeyHitCount++;
						}
						else
						{
							if (m_nKeyHitCount == 1)
							{
								if ((Timing::GetInstance()->GetPastTime() - m_nLastKeySendTime) > 400)
								{
									//m_pFocusedWindow->GetAwesomiumWindow()->keyEvent(true, 0, psButton->nKey, 0);
									m_nLastKeySendTime = Timing::GetInstance()->GetPastTime();
									m_nKeyHitCount++;
								}
							}
							else
							{
								if ((Timing::GetInstance()->GetPastTime() - m_nLastKeySendTime) > 50)
								{
									//m_pFocusedWindow->GetAwesomiumWindow()->keyEvent(true, 0, psButton->nKey, 0);
									m_nLastKeySendTime = Timing::GetInstance()->GetPastTime();
									m_nKeyHitCount++;
								}
							}
						}
					}
				}
			}
		}
	}
}
//[-------------------------------------------------------]
//[ Public virtual PLCompositing::SNMPostProcess functions ]
//[-------------------------------------------------------]
void SNMPostProcessBloomToneMap::SetParameters()
{
	// Call base implementation
	SNMPostProcess::SetParameters();

	{ // Strength
		// Update scale down parameters
		Parameter *pParameter = GetParameter("ScaleX", 0);
		if (pParameter)
			pParameter->SetValue1f(1.0f/Strength.Get().x);
		pParameter = GetParameter("ScaleY", 0);
		if (pParameter)
			pParameter->SetValue1f(1.0f/Strength.Get().y);

		// Update scale up parameters
		pParameter = GetParameter("ScaleX", 3);
		if (pParameter)
			pParameter->SetValue1f(Strength.Get().x);
		pParameter = GetParameter("ScaleY", 3);
		if (pParameter)
			pParameter->SetValue1f(Strength.Get().y);
	}

	{ // BloomScale
		Array<Parameter*> lstParameters;
		if (GetParameters("BloomScale", lstParameters)) {
			Iterator<Parameter*> cIterator = lstParameters.GetIterator();
			while (cIterator.HasNext())
				cIterator.Next()->SetValue1f(BloomScale.Get());
		}
	}

	{ // ExposureLevel
		Array<Parameter*> lstParameters;
		if (GetParameters("ExposureLevel", lstParameters)) {
			Iterator<Parameter*> cIterator = lstParameters.GetIterator();
			while (cIterator.HasNext())
				cIterator.Next()->SetValue1f(ExposureLevel.Get());
		}
	}

	{ // GammaLevel
		Array<Parameter*> lstParameters;
		if (GetParameters("GammaLevel", lstParameters)) {
			Iterator<Parameter*> cIterator = lstParameters.GetIterator();
			while (cIterator.HasNext())
				cIterator.Next()->SetValue1f(GammaLevel.Get());
		}
	}

	{ // DeFogLevel
		Array<Parameter*> lstParameters;
		if (GetParameters("DeFogLevel", lstParameters)) {
			Iterator<Parameter*> cIterator = lstParameters.GetIterator();
			while (cIterator.HasNext())
				cIterator.Next()->SetValue1f(DeFogLevel.Get());
		}
	}

	{ // FogColor
		Array<Parameter*> lstParameters;
		if (GetParameters("FogColor", lstParameters)) {
			Iterator<Parameter*> cIterator = lstParameters.GetIterator();
			while (cIterator.HasNext())
				cIterator.Next()->SetValue3fv(FogColor.Get());
		}
	}
}