Ejemplo n.º 1
0
			CVertices<Vertex, Allocator>&
				CVertices<Vertex, Allocator>::SetByQuads(void)
			{
				const float halfWidth = 0.5f;
				const float halfHeight = 0.5f;

				Vertices().resize(4);
				Vertices()[0].Position() = CVector3({ -halfWidth, -halfHeight, 0 });
				Vertices()[0].UV()[0]	 =	0;
				Vertices()[0].UV()[1]	 =	1;

				Vertices()[1].Position() = CVector3({ -halfWidth, halfHeight, 0 });
				Vertices()[1].UV()[0]	 =	0;
				Vertices()[1].UV()[1]	 =	0;

				Vertices()[2].Position() = CVector3({ halfWidth, -halfHeight, 0 });
				Vertices()[2].UV()[0]	 =	1;
				Vertices()[2].UV()[1]	 =	1;

				Vertices()[3].Position() = CVector3({ halfWidth, halfHeight, 0 });
				Vertices()[3].UV()[0]	 =	1;
				Vertices()[3].UV()[1]	 =	0;

				SetVertexData(Vertices());

				SetPrimitiveType(
					TRIANGLE_STRIP);

				return *this;
			};
Ejemplo n.º 2
0
VertexBufferGL::VertexBufferGL(VertV3FUV0UV1* vertices, unsigned int vertexTotal)
: VertexBuffer(vertices, vertexTotal)
{	
	// create GL buffers
	m_bufferID = 0;	
	glGenBuffersARB(1, &m_bufferID);

	m_indicesGL = NULL;

	SetPrimitiveType(TRIANGLE_LIST);
}
Ejemplo n.º 3
0
UINT16 CQ931Pdu::WhatPrimitive(UINT16 mType, UINT8 ir)
{
	UINT16 pType;

	switch (mType)
	{
        case PSG_MSG_Q931_SETUP:
            pType = (ir) ? PSG_CC_SETUP_REQ : PSG_CC_SETUP_IND;
            break;

        case PSG_MSG_Q931_ALERTING:
            pType = (ir) ? PSG_CC_AC_REQ : PSG_CC_AC_IND;
            break;

        case PSG_MSG_Q931_CONNECT:
            pType = (ir) ? PSG_CC_ANSWER_REQ : PSG_CC_ANSWER_IND;
            break;

        case PSG_MSG_Q931_DISCONNECT:
        case PSG_MSG_Q931_RELEASE:
            pType = (ir) ? PSG_CC_RELEASE_REQ : PSG_CC_RELEASE_IND;
            break;

		case PSG_MSG_Q931_RELEASE_COM:
			pType = PSG_CC_RELEASE_IND;
			break;

		case PSG_MSG_Q931_RESTART:
		// case PSG_MSG_Q931_FAIL:
			pType = (ir) ? PSG_CC_CIRCUIT_REQ : PSG_CC_CIRCUIT_IND;
			break;

        default:
            pType = (ir) ? PSG_CC_EVENT_REQ : PSG_CC_EVENT_IND;
	} // End of switch(mType)

	SetPrimitiveType(pType);

	return pType;
}
Ejemplo n.º 4
0
	void OGL4GeometryData::BeginGeometry(PRIMITIVE_TYPE prim)
	{
		SetPrimitiveType(prim);
		glBindVertexArray(m_vao);
	}
Ejemplo n.º 5
0
int CRANAPptl::parse(unsigned char* pdata, int len)
{
    if(NULL == pdata || len < 4) return -1;
    int iRet = 0;
    asnContext context;
    ////////////////////////
    //activate Trace Management and create a traceStream (optional)
    //context.setEncodingTraceWhileEncoding(asnTRUE);
    //context.setValueTraceWhileDecoding(asnTRUE);
    //asnFileStream traceStream("traces.txt",          // file name
    //                          asnFSTREAM_TXT_WRITE );// write text stream
    //context.setTraceStream(&traceStream);

    ////////////////////////
	SetProtocolType(MOD_RANAP);
    try
    {
        asnMemoryStream instream(pdata, len,asnFSTREAM_WRITE);
        // decode the decoding stream into myDecodedValue
        RANAP_PDU pdu;
        asnMAXUINT iDecoded = pdu.PERdecode(&context, &instream);
        // here pdu contains the decoded value
        SetPrimitiveType(pdu.value->alternative);
        switch(pdu.value->alternative)
        {
            case RANAP_TRIGGERMSG_INITIAL:// 0 InitiatingMessage
            {
                asncinitiatingMessage *initMsg = (asncinitiatingMessage *)(pdu.value);
                SetMessageType(initMsg->procedureCode);
                switch(initMsg->procedureCode)
                {
                    case RANAP_DirectTransfer:// 20 DirectInformationTransfer
                        parseDirectTransfer(&context, (asnOpenType*)(initMsg->value));
                        break;
                    case RANAP_Paging:// 14 id-Paging
                        parsePaging(&context, (asnOpenType*)(initMsg->value));
                        break;
                    case RANAP_CommonID:// 15 id-CommonID
                        parseCommonID(&context, (asnOpenType*)(initMsg->value));
                        break;
                    case RANAP_InitialUE_Message:// 19 id-InitialUE-Message
                        parseInitialUEMessage(&context, (asnOpenType*)(initMsg->value));
                        break;
                    case RANAP_RAB_ASSIGNMENT:// 0 id-RAB-Assignment
                        parseRABAssignment(&context, (asnOpenType*)(initMsg->value));
                        break;
                    case RANAP_Iu_RELEASE:// 1 id-Iu-Release
                        parseIuRelease(&context, (asnOpenType*)(initMsg->value));
                        break;
                    default:
                        break;
                }
            }
            break;
            case RANAP_TRIGGERMSG_SUCCESS:// 1 SuccessfulOutcome
            {
                asncsuccessfulOutcome *pSuccess = (asncsuccessfulOutcome *)pdu.value;
                SetMessageType(pSuccess->procedureCode);
                switch(pSuccess->procedureCode)
                {
                    case RANAP_Iu_RELEASE:// 1 id-Iu-Release
                        parseIuReleaseComplete(&context, (asnOpenType*)(pSuccess->value));
                        break;
                    default:
                        break;
                }
            }
                break;
            case RANAP_TRIGGERMSG_UNSUCCESS:// 2 UnsuccessfulOutcome
            {
                asncunsuccessfulOutcome *pUnSuccess = (asncunsuccessfulOutcome*)(pdu.value);
                SetMessageType(pUnSuccess->procedureCode);
            }
                break;
            case RANAP_TRIGGERMSG_OUTCOME:// 3 Outcome
            {
                asncRANAP_PDU__outcome *pOutcome = (asncRANAP_PDU__outcome *)pdu.value;
                SetMessageType(pOutcome->procedureCode);
                switch(pOutcome->procedureCode)
                {
                    case RANAP_RAB_ASSIGNMENT:// 0 id-RAB-Assignment
                        parseRABAssignmentOutCome(&context, (asnOpenType*)(pOutcome->value));
                        break;
                    default:
                        break;
                }
            }
                break;
            default:
                printf("choice: %hd\n", pdu.value->alternative);
                break;
        }
    }
    catch(asnException& e)
    {
        iRet = -1;
        SetProtocolType(SV_CHINA_SCCP);
        SetPrimitiveType(0);
        SetMessageType(0);
        //Print("RANAP parser catch exception: %s - %s - %hd\n", context.getErrorLocation(), e.getLocation(), e.errorCode);
    }
    return iRet;
}
Ejemplo n.º 6
0
int CRANAPptl::parse(unsigned char* pdata, int len)
{
    int iRet = 0;
    //@zh 20100820 bug fixed
    if(NULL == pdata || len < 4) return -1;
    SetProtocolType(MOD_RANAP);
    //
	Buffer* buffer = wrapBuffer((char*)(&pdata[0]), len, ALIGNED_PACKED_ENCODING_RULES);
	if(buffer!=NULL)
    {
		struct RANAP_PDU pdu = {0}; //@zh 20100824 bug fixed
		//解码程序会修改源数据 pdata ???
		iRet = decode_RANAP_PDU(buffer, &pdu);
		if(iRet==0)
        {
			//print_RANAP_PDU(&pdu, printf);
			//printf("\n");
			SetPrimitiveType(pdu.choice); //@zh 20100820 bug fixed
			switch(pdu.choice)
			{
                case RANAP_PDU_initiatingMessage_chosen:
                    {
                        struct InitiatingMessage* pInitiatingMessage = &pdu.value.initiatingMessage;
                        SetMessageType(pInitiatingMessage->procedureCode); //@zh 20100820 bug fixed
                        switch(pInitiatingMessage->procedureCode)
                        {
                            case RANAP_RAB_ASSIGNMENT            :// 0
                            {
                                struct RAB_AssignmentRequest* pRAB_AssignmentRequest = &pInitiatingMessage->value.rAB_AssignmentRequest;
                                iRet = parseRABAssignment(pRAB_AssignmentRequest);
                            }
                            break;
                            case RANAP_Iu_RELEASE                :// 1
                            {
                                struct Iu_ReleaseCommand* pIu_ReleaseCommand = &pInitiatingMessage->value.iu_ReleaseCommand;
                                iRet = parseIuRelease(pIu_ReleaseCommand);
                            }
                            break;
                            case RANAP_RelocationPreparation     :// 2
                            break;
                            case RANAP_RelocationResAllocation   :// 3
                            break;
                            case RANAP_RelocationCancel          :// 4
                            break;
                            case RANAP_SRNS_ContextTransfer      :// 5
                            break;
                            case RANAP_SecurityNodeControl       ://6
                            break;
                            case RANAP_DataVolumeReport          ://7
                            break;
                            case RANAP_Reset                     ://9
                            break;
                            case RANAP_RAB_ReleaseRequest        ://10
                            break;
                            case RANAP_Iu_ReleaseRequest         ://11
                            break;
                            case RANAP_RelocationDetect          ://12
                            break;
                            case RANAP_RelocationComplete        ://13
                            break;
                            case RANAP_Paging                    ://14
                            {
                                struct Paging* pPaging = &pInitiatingMessage->value.paging;
                                iRet = parsePaging(pPaging);
                            }
                            break;
                            case RANAP_CommonID                  ://15
                            {
                                struct CommonID* pCommonID = &pInitiatingMessage->value.commonID;
                                iRet = parseCommonID(pCommonID);
                            }
                            break;
                            case RANAP_CN_InvokeTrace            ://16
                            break;
                            case RANAP_LocationReportingControl  ://17
                            break;
                            case RANAP_LocationReport            ://18
                            break;
                            case RANAP_InitialUE_Message         ://19
                            {
                                struct InitialUE_Message* pInitialUE_Message = &pInitiatingMessage->value.initialUE_Message;
                                iRet = parseInitialUEMessage(pInitialUE_Message);
                            }
                            break;
                            case RANAP_DirectTransfer            ://20
                            {
                                struct DirectTransfer* pDirectTransfer = &pInitiatingMessage->value.directTransfer;
                                iRet = parseDirectTransfer(pDirectTransfer);
                            }
                            break;
                            case RANAP_OverloadControl           ://21
                            break;
                            case RANAP_ErrorIndication           ://22
                            break;
                            case RANAP_SRNS_DataForward          ://23
                            break;
                            case RANAP_ForwardSRNS_Context       ://24
                            break;
                            case RANAP_privateMessage            ://25
                            break;
                            case RANAP_CN_DeactivateTrace        ://26
                            break;
                            case RANAP_ResetResource             ://27
                            break;
                            case RANAP_Relocation                ://28
                            break;
                            case RANAP_RAB_ModifyRequest         ://29
                            break;
                            case RANAP_LocationRelatedData       ://30
                            break;
                            case RANAP_InformationTransfer       ://31
                            break;
                            case RANAP_UESpecificInformation     ://32
                            break;
                            case RANAP_UplinkInformationExchange ://33
                            break;
                            case RANAP_DirectInformationTransfer ://34
                            break;
                            case RANAP_MBMSSessionStart          ://35
                            break;
                            case RANAP_MBMSSessionUpdate         ://36
                            break;
                            case RANAP_MBMSSessionStop           ://37
                            break;
                            case RANAP_MBMSUELinking             ://38
                            break;
                            case RANAP_MBMSRegistration          ://39
                            break;
                            case RANAP_MBMSCNDe_Registration_Procedure   ://40
                            break;
                            case RANAP_MBMSRABEstablishmentIndication    ://41
                            break;
                            case RANAP_MBMSRABRelease                    ://42
                            break;
                            case RANAP_enhancedRelocationComplete        ://43
                            break;
                            case RANAP_enhancedRelocationCompleteConfirm ://44
                            break;
                            case RANAP_enhancedRelocation                ://45
                            break;
                            case RANAP_SRVCCPreparation                  ://46
                            break;
                            default:
                                break;
                        }
                    }
                    break;

                case RANAP_PDU_successfulOutcome_chosen:
                    {
                        struct SuccessfulOutcome* pSuccessfulOutcome = &pdu.value.successfulOutcome;
                        SetMessageType(pSuccessfulOutcome->procedureCode); //@zh 20100820 bug fixed
                        switch(pSuccessfulOutcome->procedureCode)
                        {
                            case RANAP_RelocationPreparation     :// 2
                            break;
                            case RANAP_RelocationResAllocation   :// 3
                            break;
                            case RANAP_DataVolumeReport          ://7
                            break;
                            case RANAP_MBMSSessionStop           ://37
                            break;
                            case RANAP_UplinkInformationExchange ://33
                            break;
                            case RANAP_LocationRelatedData       ://30
                            break;
                            case RANAP_MBMSRABRelease            ://42
                            break;
                            case RANAP_SRNS_ContextTransfer      :// 5
                            break;
                            case RANAP_enhancedRelocation                ://45
                            break;
                            case RANAP_RelocationCancel          :// 4
                            break;
                            case RANAP_InformationTransfer       ://31
                            break;
                            case RANAP_MBMSCNDe_Registration_Procedure   ://40
                            break;
                            case RANAP_SecurityNodeControl       ://6
                            break;
                            case RANAP_MBMSSessionStart          ://35
                            break;
                            case RANAP_MBMSSessionUpdate         ://36
                            break;
                            case RANAP_MBMSRegistration          ://39
                            break;
                            case RANAP_enhancedRelocationComplete        ://43
                            break;
                            case RANAP_ResetResource             ://27
                            break;
                            case RANAP_Iu_RELEASE                :// 1
                            {
                                struct Iu_ReleaseComplete* pIu_ReleaseComplete = &pSuccessfulOutcome->value.iu_ReleaseComplete;
                            }
                            break;
                            case RANAP_Reset                     ://9
                            break;
                            default:
                                break;
                        }
                    }
                    break;

                case RANAP_PDU_unsuccessfulOutcome_chosen:
                    {
                        struct UnsuccessfulOutcome* pUnsuccessfulOutcome = &pdu.value.unsuccessfulOutcome;
                        SetMessageType(pUnsuccessfulOutcome->procedureCode); //@zh 20100820 bug fixed
                        switch(pUnsuccessfulOutcome->procedureCode)
                        {
                            case RANAP_MBMSSessionStart          ://35
                            break;
                            case RANAP_InformationTransfer       ://31
                            break;
                            case RANAP_MBMSRegistration          ://39
                            break;
                            case RANAP_MBMSRABRelease            ://42
                            break;
                            case RANAP_SecurityNodeControl       ://6
                            break;
                            case RANAP_RelocationPreparation     :// 2
                            break;
                            case RANAP_RelocationResAllocation   :// 3
                            break;
                            case RANAP_UplinkInformationExchange ://33
                            break;
                            case RANAP_MBMSSessionUpdate         ://36
                            break;
                            case RANAP_enhancedRelocationComplete        ://43
                            break;
                            case RANAP_LocationRelatedData       ://30
                            break;
                            default:
                                break;
                        }
                    }
                    break;

                case RANAP_PDU_outcome_chosen:
                    {
                        struct Outcome* pOutcome = &pdu.value.outcome;
                        SetMessageType(pOutcome->procedureCode); //@zh 20100820 bug fixed
                        switch(pOutcome->procedureCode)
                        {
                            case RANAP_RAB_ASSIGNMENT            :// 0
                            {
                                struct RAB_AssignmentResponse* pRAB_AssignmentResponse = &pOutcome->value.rAB_AssignmentResponse;
                            }
                            break;
                            /* @{procedureCode = 255} */
                            case RANAP_MBMSUELinking             ://38
                            break;
                            default:
                                break;
                        }
                    }
                    break;
            }
		}
		else
        {
			//printf("DeCode Error: %s\n", ASN_LIB_ERROR_STRING[iRet]);
            iRet = -1;
		}
        free_RANAP_PDU(&pdu);
		asn_free(buffer);
	}
    return iRet;
}
Ejemplo n.º 7
0
////////////////////////////////////////////////////////////////////////
///
/// Loads DirectX mesh file. 
///
/// @param  filename  Filename to load. 
///
/// @return success or failure. 
///
////////////////////////////////////////////////////////////////////////
const VCNBool VCNDXMesh::LoadFromFile( const VCNString& filename )
{
  VCND3D9* renderer = static_cast<VCND3D9*>( VCNRenderCore::GetInstance() );
  LPDIRECT3DDEVICE9 d3dDevice = renderer->GetD3DDevice();

  CComPtr<ID3DXMesh> systemMesh;
  CComPtr<ID3DXBuffer> materialBuffer;

  // Load the mesh from the specified file
  //
  DWORD numMaterials = 0;
  HRESULT hr = D3DXLoadMeshFromX(filename.c_str(), D3DXMESH_SYSTEMMEM,
    d3dDevice, NULL, &materialBuffer,NULL, &numMaterials, &systemMesh );
  if ( FAILED(hr) )
    return false;
  
  // Load materials
  //
  D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)materialBuffer->GetBufferPointer();
  for (DWORD i = 0; i < numMaterials; ++i)
  {
    VCN_ASSERT_MSG( i == 0 || mMaterialID == kInvalidResID, VCNTXT("We do not support multiple material per meshes") );
    
    // Create the texture if it exists - it may not
    if (d3dxMaterials[i].pTextureFilename)
    {
      VCNString texturePath = VCNTXT("Textures/");
      texturePath += VCN_A2W(d3dxMaterials[i].pTextureFilename);

      // Check if the texture is already loaded
      VCNResID texID = kInvalidResID;
      VCND3D9Texture* resTexture = VCNResourceCore::GetInstance()->GetResource<VCND3D9Texture>(texturePath);
      if (!resTexture)
      {
        LPDIRECT3DTEXTURE9 d3dTexture = NULL;
        hr = D3DXCreateTextureFromFile(d3dDevice, texturePath.c_str(), &d3dTexture);
        VCN_ASSERT_MSG( SUCCEEDED(hr), _T("Can't load texture [%s]"), texturePath.c_str() );

        resTexture = new VCND3D9Texture( d3dTexture );
        resTexture->SetName( texturePath );
        texID = VCNResourceCore::GetInstance()->AddResource( texturePath, resTexture );
      }
      else
      {
        texID = resTexture->GetResourceID();
      }

      VCNMaterial* material = new VCNMaterial();
      material->SetName( VCNString(VCNTXT("material_dx_mesh_")) + filename );
      material->SetAmbientColor( VCNColor((const VCNFloat*)&d3dxMaterials[i].MatD3D.Ambient) );
      material->SetDiffuseColor( VCNColor((const VCNFloat*)&d3dxMaterials[i].MatD3D.Diffuse) );
      material->SetSpecularColor( VCNColor((const VCNFloat*)&d3dxMaterials[i].MatD3D.Specular) );
      material->SetSpecularPower( d3dxMaterials[i].MatD3D.Power );

      VCNEffectParamSet& params = material->GetEffectParamSet();
      params.SetEffectID( eidLitTextured );
      params.AddResource( VCNTXT("DiffuseTexture"), texID );

      // Add material as a resource.
      mMaterialID = VCNResourceCore::GetInstance()->AddResource( material->GetName(), material );
    }
  }
  
  // Optimize the mesh if possible
  //
  const VCNUInt faceCount = systemMesh->GetNumFaces();
  DWORD* adjac = new DWORD[faceCount*3];
  hr = systemMesh->GenerateAdjacency(0.5f, adjac);
  hr = systemMesh->OptimizeInplace(D3DXMESHOPT_VERTEXCACHE, adjac, NULL, NULL, NULL);

  // Calculate Tangent and Binormal
  hr = D3DXComputeTangentFrameEx(systemMesh, 
                                    D3DDECLUSAGE_TEXCOORD, 0,
                                    D3DDECLUSAGE_TANGENT, 0,
                                    D3DDECLUSAGE_BINORMAL, 0,
                                    D3DDECLUSAGE_NORMAL, 0,
                                    D3DXTANGENT_DONT_ORTHOGONALIZE | D3DXTANGENT_WEIGHT_BY_AREA,
                                    adjac,
                                    -1.01f, -0.01f, -1.01f,
                                    &systemMesh,
                                    NULL);
  delete [] adjac;

  // Load caches
  //
  const VCNUInt vertexCount = systemMesh->GetNumVertices();
  const DWORD meshFVF = systemMesh->GetFVF();
  const DWORD stride = D3DXGetFVFVertexSize( meshFVF );
  const DWORD positionStride = D3DXGetFVFVertexSize( D3DFVF_XYZ );
  const DWORD normalStride = D3DXGetFVFVertexSize( D3DFVF_NORMAL );
  const DWORD diffuseStride = D3DXGetFVFVertexSize( D3DFVF_DIFFUSE );
  const DWORD textureStride = D3DXGetFVFVertexSize( D3DFVF_TEX1 );

  VCNFloat* vtPositionBufStart = new VCNFloat[vertexCount * kCacheStrides[VT_POSITION]];
  VCNFloat* vtNormalBufStart = new VCNFloat[vertexCount * kCacheStrides[VT_LIGHTING]];
  VCNFloat* vtTextureBufStart = new VCNFloat[vertexCount * kCacheStrides[VT_DIFFUSE_TEX_COORDS]];
  
  VCNFloat* vtPositionBuf = vtPositionBufStart;
  VCNFloat* vtNormalBuf = vtNormalBufStart;
  VCNFloat* vtTextureBuf = vtTextureBufStart;
  
  BYTE* vbptr = NULL;
  systemMesh->LockVertexBuffer(D3DLOCK_READONLY, (LPVOID*)&vbptr);
  
  for(VCNUInt i = 0; i < vertexCount; ++i)
  {
    if ( meshFVF == (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1) )
    {
      // Read position
      D3DXVECTOR3* pos = (D3DXVECTOR3*)vbptr;
      *vtPositionBuf = pos->x; vtPositionBuf++;
      *vtPositionBuf = pos->y; vtPositionBuf++;
      *vtPositionBuf = pos->z; vtPositionBuf++;

      // Read normal
      D3DXVECTOR3* normal = (D3DXVECTOR3*)(vbptr + positionStride);
      *vtNormalBuf = normal->x; vtNormalBuf++;
      *vtNormalBuf = normal->y; vtNormalBuf++;
      *vtNormalBuf = normal->z; vtNormalBuf++;

      // Set default diffuse color
      std::fill(vtNormalBuf, vtNormalBuf+3, 1.0f);
      vtNormalBuf += 3;

      float* texCoords = (float*)(vbptr + positionStride + normalStride);
      *vtTextureBuf = texCoords[0]; vtTextureBuf++;
      *vtTextureBuf = texCoords[1]; vtTextureBuf++;

      vbptr += stride;
    }
    else
    {
      VCN_ASSERT_FAIL( VCNTXT("Mesh FVF not supported [FVF(%d) stride = %d]"), meshFVF, stride );
    }
  }
  systemMesh->UnlockVertexBuffer();

  VCNResID positionCache = renderer->CreateCache(VT_POSITION, vtPositionBufStart, vertexCount * kCacheStrides[VT_POSITION]);
  VCNResID lightingCache = renderer->CreateCache(VT_LIGHTING, vtNormalBufStart, vertexCount * kCacheStrides[VT_LIGHTING]);
  VCNResID textureCache = renderer->CreateCache(VT_DIFFUSE_TEX_COORDS, vtTextureBufStart, vertexCount * kCacheStrides[VT_DIFFUSE_TEX_COORDS]);

  SetCacheID(VT_POSITION, positionCache);
  SetCacheID(VT_LIGHTING, lightingCache);
  SetCacheID(VT_DIFFUSE_TEX_COORDS, textureCache);

  delete [] vtPositionBufStart;
  delete [] vtNormalBufStart;
  delete [] vtTextureBufStart;

  VCNUShort* ibptr = NULL;
  VCNUShort* indices = new VCNUShort[faceCount * 3];
  systemMesh->LockIndexBuffer(D3DLOCK_READONLY, (LPVOID*)&ibptr);

  for(VCNUInt i = 0; i < systemMesh->GetNumFaces(); i++)
  {
    indices[(i * 3) + 0] = *(ibptr++);
    indices[(i * 3) + 1] = *(ibptr++);
    indices[(i * 3) + 2] = *(ibptr++);
  }

  systemMesh->UnlockIndexBuffer();

  VCNResID indexCacheID = renderer->CreateCache(VT_INDEX, indices, faceCount * 3 * kCacheStrides[VT_INDEX]);
  SetFaceCache(indexCacheID);
  SetFaceCount(faceCount);
  SetPrimitiveType(PT_TRIANGLELIST);

  delete [] indices;
  
  // Compute bounding sphere
  if ( !ComputeBoundingSphere(systemMesh) )
    return false;

  return true;
}