Ejemplo n.º 1
0
//////////////////////////////////////////////////////////////////////////
// fileChunkReady
void ScnTexture::fileChunkReady( BcU32 ChunkIdx, BcU32 ChunkID, void* pData )
{
	// If we have no render core get chunk 0 so we keep getting entered into.
	if( RsCore::pImpl() == NULL )
	{
		requestChunk( 0 );
		return;
	}

	if( ChunkID == BcHash( "header" ) )
	{		
		// Request all texture levels.
		for( BcU32 iLevel = 0; iLevel < Header_.Levels_; ++iLevel )
		{
			requestChunk( ++ChunkIdx );
		}
		
		// We update the header, create a new texture rather than updating.
		CreateNewTexture_ = BcTrue;	
	}
	else if( ChunkID == BcHash( "body" ) )
	{
		// Grab pointer to data.
		BcAssert( pTextureData_ == NULL || pTextureData_ == pData );
		pTextureData_ = pData;
		
		// Setup.
		setup();
	}
}
Ejemplo n.º 2
0
//--------------------------------------------------------------------
// return true if all neighbors in memory
BOOL ChunkWorld::loadNeighbors(
  ChunkObj* chunk)
{
  ChunkObj* xmin = createChunk(chunk->m_originX - CHUNK_SIZE, chunk->m_originZ);
  if (xmin->m_status == CHUNK_UNLOADED)
    requestChunk(xmin);

  ChunkObj* xmax = createChunk(chunk->m_originX + CHUNK_SIZE, chunk->m_originZ);
  if (xmax->m_status == CHUNK_UNLOADED)
    requestChunk(xmax);

  ChunkObj* zmin = createChunk(chunk->m_originX, chunk->m_originZ - CHUNK_SIZE);
  if (zmin->m_status == CHUNK_UNLOADED)
    requestChunk(zmin);

  ChunkObj* zmax = createChunk(chunk->m_originX, chunk->m_originZ + CHUNK_SIZE);
  if (zmax->m_status == CHUNK_UNLOADED)
    requestChunk(zmax);

  if (xmin->m_status == CHUNK_UNLOADED ||
      xmax->m_status == CHUNK_UNLOADED ||
      zmin->m_status == CHUNK_UNLOADED ||
      zmax->m_status == CHUNK_UNLOADED)
    return false;

  return true;
}
Ejemplo n.º 3
0
//////////////////////////////////////////////////////////////////////////
// fileChunkReady
void ScnModel::fileChunkReady( BcU32 ChunkIdx, BcU32 ChunkID, void* pData )
{
	// If we have no render core get chunk 0 so we keep getting entered into.
	if( RsCore::pImpl() == NULL )
	{
		requestChunk( 0 );
		return;
	}

	if( ChunkID == BcHash( "header" ) )
	{
		pHeader_ = (ScnModelHeader*)pData;
	}
	else if( ChunkID == BcHash( "nodetransformdata" ) )
	{
		pNodeTransformData_ = (ScnModelNodeTransformData*)pData;
	}
	else if( ChunkID == BcHash( "nodepropertydata" ) )
	{
		pNodePropertyData_ = (ScnModelNodePropertyData*)pData;

		// Mark up node names.
		// TODO: Automate this process with reflection!
		for( BcU32 NodeIdx = 0; NodeIdx < pHeader_->NoofNodes_; ++NodeIdx )
		{
			ScnModelNodePropertyData* pNodePropertyNode = &pNodePropertyData_[ NodeIdx ];
			markupName( pNodePropertyNode->Name_ );
		}
	}
	else if( ChunkID == BcHash( "vertexdata" ) )
	{
		BcAssert( pVertexBufferData_ == NULL || pVertexBufferData_ == pData );
		pVertexBufferData_ = (BcU8*)pData;
	}
	else if( ChunkID == BcHash( "indexdata" ) )
	{
		BcAssert( pIndexBufferData_ == NULL || pIndexBufferData_ == pData );
		pIndexBufferData_ = (BcU8*)pData;
	}
	else if( ChunkID == BcHash( "vertexelements" ) )
	{
		pVertexElements_ = (RsVertexElement*)pData;
	}
	else if( ChunkID == BcHash( "meshdata" ) )
	{
		pMeshData_ = (ScnModelMeshData*)pData;

		RsVertexElement* pVertexElements = pVertexElements_;
		for( BcU32 Idx = 0; Idx < pHeader_->NoofPrimitives_; ++Idx )
		{
			pMeshData_->VertexElements_ = pVertexElements;
			pVertexElements += pMeshData_->NoofVertexElements_;
		}
		
		markCreate(); // All data loaded, time to create.
	}
}
Ejemplo n.º 4
0
//////////////////////////////////////////////////////////////////////////
// fileReady
void ScnModel::fileReady()
{
	// File is ready, get the header chunk.
	requestChunk( 0 );
	requestChunk( 1 );
	requestChunk( 2 );
	requestChunk( 3 );
	requestChunk( 4 );
	requestChunk( 5 );
	requestChunk( 6 );
}
Ejemplo n.º 5
0
//////////////////////////////////////////////////////////////////////////
// fileReady
void ScnTexture::fileReady()
{
	// File is ready, get the header chunk.
	requestChunk( 0, &Header_ );
}
Ejemplo n.º 6
0
//////////////////////////////////////////////////////////////////////////
// fileReady
//virtual
void AkBank::fileReady()
{
	requestChunk( 0, &Header_ );
}
Ejemplo n.º 7
0
//--------------------------------------------------------------
// update animation 
BOOL ChunkWorld::animate(
  double now,                       // current time (ms)
  double since)                     // milliseconds since last pass
{
  BOOL viewChanged = false;

  m_chunkLock->lock();

  // keep memory use under limits
  checkMemory();

  resetRequestList();

  // figure which chunk we are in
  int viewX = (int) floor(m_eyePt.x / CHUNK_SIZE);
  int viewZ = (int) floor(m_eyePt.z / CHUNK_SIZE);

  // for all coordinates in view list
  for (int i = m_viewListCount-1; i >= 0; i--)
  {
    ChunkOrigin* origin = &m_viewList[i];
    int chunkX = CHUNK_SIZE*(viewX + origin->x);
    int chunkZ = CHUNK_SIZE*(viewZ + origin->z);

    // find/create chunk
    ChunkObj* chunk = createChunk(chunkX, chunkZ);

    // if chunk within view
    if (chunk->withinFrustum())
    {
      switch (chunk->m_status)
      {
        case CHUNK_UNLOADED:
          // request the chunk (loads in memory)
          requestChunk(chunk);

          // request the neighbors
          loadNeighbors(chunk);
          break;

        case CHUNK_INMEMORY:
          // if all neighbors loaded, update chunk edges
          if (loadNeighbors(chunk))
          {
            updateEdges(chunk);

            // request the chunk (loads in display)
            requestChunk(chunk);
          }
          break;

        case CHUNK_INDISPLAY:
          // if we have an update, use it
          if (!chunk->m_active && chunk->m_hasUpdate)
          {
//            mgDebug("use update on (%d, %d)", chunk->m_originX, chunk->m_originZ);
            int oldSize = chunk->getDisplayMemUsed();
            chunk->useUpdate();
            int size = chunk->getDisplayMemUsed();
            m_displayMemUsed += size-oldSize;
            chunk->m_hasUpdate = false;
          }

          // if it needs an update, flag it
          if (!chunk->m_active && chunk->needsUpdate(m_eyePt))
          {
//            mgDebug("wants update on (%d, %d)", chunk->m_originX, chunk->m_originZ);
            chunk->m_status = CHUNK_NEEDSUPDATE;
            chunk->m_eyePt = m_eyePt;
            m_requestList.addToTail(chunk);
          }

          // if still in display, animate it, since we will draw it
          if (chunk->m_status == CHUNK_INDISPLAY ||
              chunk->m_status == CHUNK_NEEDSUPDATE)
            chunk->animate(now, since);
          break;

        case CHUNK_NEEDSUPDATE:
          // if needed update last pass, and not being processed, still needs update
          if (!chunk->m_active)
          {
//            mgDebug("still needs update on (%d, %d)", chunk->m_originX, chunk->m_originZ);
            m_requestList.addToTail(chunk);
            chunk->animate(now, since);
          }
          break;
      }

      // push to bottom of LRU list
      ChunkListNode* node = m_LRUList.find(chunk);
      if (node != NULL)
        m_LRUList.removeNode(node);
      m_LRUList.addToTail(chunk);
    }
  }

  if (m_chunksChanged)
  {
    viewChanged = true;
    m_chunksChanged = false;
  }

  m_chunkLock->unlock();

  // if we requested chunks, activate worker threads
  if (!m_requestList.isEmpty())
  {
    if (m_chunkThreads != NULL)
    {
      // signal the threads to look at requestList
      m_chunkEvent->signal();
    }
    else
    {
      // process one request in this thread (no worker threads)
      ChunkObj* found = dequeueRequest();
      if (found != NULL)
        processRequest(found);
    }
  }

  return viewChanged;
}
Ejemplo n.º 8
0
//////////////////////////////////////////////////////////////////////////
// fileReady
void ScnSound::fileReady()
{
	// File is ready, get the header chunk.
	requestChunk( 0 );
}
Ejemplo n.º 9
0
//////////////////////////////////////////////////////////////////////////
// fileReady
//virtual
void ScnRenderTarget::fileReady()
{
	requestChunk( 0, &Header_ );
}
Ejemplo n.º 10
0
//////////////////////////////////////////////////////////////////////////
// fileReady
void ScnComponent::fileReady()
{
	// File is ready, get the header chunk.
	requestChunk( 0 );
}