Example #1
0
///
//	BuildRootNode()
//  
//      Build the first node in the tree which encloses all the triangles
//
int COctree::BuildRootNode(std::vector<CMeshBufferGroup*> &in)
{
	pOCT_NODE pRoot = new OCT_NODE;
	int		 i, mbCount=in.size();

	///
	//	Start by constructing a root node that contains
	//	all triangles
	//
	FindBox(in, &pRoot->BBox);

	for(i= 0; i < NUM_CHILDREN; i++)
		pRoot->ChildIdx[i]= NULL_NODE;

	for(i= 0; i < NUM_NEIGHBORS; i++)
		pRoot->NeighborIdx[i]= NULL_NODE;

	pRoot->meshBufferIndexStart= m_vecMeshBufferIndexPtr.size();
	pRoot->meshBufferIndexCount= mbCount;

	//	Fill the start of the meshIndexList with pointers to all
	//	the mesh
	for(i= 0; i < mbCount; i++)	{
		m_vecMeshBufferIndexPtr.push_back(i);
	}
	
	//	Add the root node to the table
	m_vecOctNode.push_back(pRoot);

	return 1;
}
	virtual TKeyResponse OfferKeyEventL  (  const TKeyEvent &  aKeyEvent,  
		TEventCode  aType )
	{
		if (aType==EEventKey && aKeyEvent.iCode==0xF845) {
			TInt idx=ListBox()->CurrentItemIndex();
			if (idx!=-1) {
				TBool selected=EFalse;
				const CArrayFix<TInt> *indexes = ListBox()->SelectionIndexes();
				if (indexes) {
					for (int i=0; i<indexes->Count(); i++) {
						if (indexes->At(i)==idx) {
							selected=ETrue;
							break;
						}
					}
				}
				if (!selected) {
					SelectionListProcessCommandL(EAknCmdMark);
				} else {
					SelectionListProcessCommandL(EAknCmdUnmark);
				}
			}
			return EKeyWasConsumed;
		} else {
			if (aType==EEventKey && aKeyEvent.iCode==KEY_C && FindBox()->TextLength()==0) {
				DeleteItemL();
				return EKeyWasConsumed;
			} else {
				return CAknMarkableListDialog::OfferKeyEventL(aKeyEvent, aType);
			}
		}
	}
Example #3
0
		int OcTree::BuildRootNode(const TRI* tris, int triCount)
		{
			OctNode root;
			int i;

			// start by construction a root node that contains all triangles
			root.BBox = engine->librarys->CreateResource<IBoundingBox>();
			FindBox(tris, triCount, root.BBox);
			
			for(i = 0; i < NUM_CHILDREN; i++)
				root.ChildIdx[i] = NULL_NODE;

			for(i = 0; i < NUM_NEIGHBORS; i++)
				root.NeighborIdx[i] = NULL_NODE;

			root.TriIdxStart = TriIdxList.GetCount();
			root.TriIdxCount = triCount;


			// Fill the start of the TriIdxList with pointers to all triangles
			for (i = 0; i < triCount; i++)
			{
				unsigned int index = (unsigned int) i;
				TriIdxList.Append(&index, sizeof(unsigned int));
			}

			// Add the root node to the table
			OctNodeList.Append(&root, sizeof(OctNode));

			return 1;
		}
Example #4
0
  bool PositionMap::GetRandomPosition (const float radius, float& xpos, float& zpos,
				       AreaID& area)
  {
    /* Collect candidates from areas from all buckets with a minRadius that
       is larger or equal to radius */
    float totalArea = 0;
    for (size_t b = 0; b < buckets.GetSize(); b++)
    {
      const Bucket& bucket = buckets[b];
      if (bucket.minSide < radius*2) break;
      if (bucket.freeAreas.GetSize() == 0) continue;
      totalArea += bucket.freeAreas[0].area;
    }
    // No space found.
    if (totalArea < SMALL_EPSILON) return false;
    
    /* Pick the area.
       Note it's guaranteed to be at least as large as radius on it's smaller
       side. */
    csBox2 freeArea;
    float theArea = totalArea * posGen.Get ();
    for (size_t b = 0; b < buckets.GetSize(); b++)
    {
      const Bucket& bucket = buckets[b];
      if (bucket.freeAreas.GetSize() == 0) continue;
      float bucketArea = bucket.freeAreas[0].area;
      if (theArea < bucketArea)
      {
	size_t areaIndex = FindBox (bucket, theArea);
	freeArea = *(bucket.freeAreas[areaIndex].box);
	area.first = b;
	area.second = areaIndex;
	break;
      }
      else
	theArea -= bucketArea;
    }
    
    CS_ASSERT ((freeArea.MaxX() - freeArea.MinX() >= radius*2) 
	       && (freeArea.MaxY() - freeArea.MinY() >= radius*2));

    float xAvail = freeArea.MinX() + radius;
    float yAvail = freeArea.MinY() + radius;
    float zAvail = freeArea.MaxX() - radius;
    float wAvail = freeArea.MaxY() - radius;

    xpos = freeArea.MinX() + radius + (zAvail - xAvail) * posGen.Get();
    zpos = freeArea.MinY() + radius + (wAvail - yAvail) * posGen.Get();

    return true;
  }
TKeyResponse CSymellaSearchContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
{
	if (aType == EEventKey) 
	{
		switch (aKeyEvent.iCode) 
		{
		case EKeyUpArrow:
		case EKeyDownArrow:
			return iListBox->OfferKeyEventL(aKeyEvent, aType);
		case EKeyDevice3: //EKeyOk
			{
				if (CurrentItemIndex() >= 0)
				{
					HBufC* info = CTR->DlManager()->CreateHitInfoL(CurrentItemIndex());
					CleanupStack::PushL(info);

					/*CAknNoteDialog* note = new (ELeave) CAknNoteDialog;
					CleanupStack::PushL(note);
					note->SetTextL(*info);
					CleanupStack::Pop();
					note->PrepareLC(R_HIT_INFO_NOTE);
					note->RunLD();*/
					CAknMessageQueryDialog* dlg = new (ELeave)CAknMessageQueryDialog();
					dlg->PrepareLC( R_MESSAGE_QUERY );
					dlg->SetMessageTextL(info->Des());
					dlg->QueryHeading()->SetTextL(_L("Hit info"));
					dlg->RunLD();

					CleanupStack::PopAndDestroy();
				}
			}
			break;
		case EKeyLeftArrow:
		case EKeyRightArrow:
		{
			// Empty FindBox Search Text		
			_LIT(KBlank, "");
			FindBox()->SetSearchTextL(KBlank);

			// Press Backspace on Empty FindBox to Close it
			TBool refresh = false;
			TKeyEvent key;
			key.iCode = 8;
			key.iScanCode = 1;
			key.iRepeats = 1;
			key.iModifiers = 0;
			AknFind::HandleFindOfferKeyEventL(key, EEventKey, this, ListBox(), FindBox(), ETrue, refresh);
		}
		break;
			
		default:
			{
				if (iFindBox)
				{
					

					TBool needRefresh( EFalse );
	            	TBool flagsOfPopup( EFalse );

					if ( AknFind::HandleFindOfferKeyEventL( aKeyEvent, aType, this,
		                                                    iListBox, iFindBox,
		                                                    ETrue,
		                                                    needRefresh ) ==
		                                                        EKeyWasConsumed )
		            {
		                if ( needRefresh )
		                {
		                	SizeChanged();
		                    DrawNow();
		                }

		                return EKeyWasConsumed;
		            }
				}
			}
			break;
		}
	}

	return EKeyWasNotConsumed;
}