示例#1
0
void EntityManager::LoadCopyEntityFromDesc_r( CCopyEntityDescFileData& desc, CCopyEntity *pParentEntity )
{
	BaseEntityHandle base_entity_handle;

	base_entity_handle.SetBaseEntityName( desc.strBaseEntityName.c_str() );

	// load the base entity for this copy entity
	LoadBaseEntity( base_entity_handle );

	// create the copy entity
	desc.CopyEntityDesc.pBaseEntityHandle = &base_entity_handle;

	desc.CopyEntityDesc.pParent = pParentEntity;

//	CreateEntity( desc.CopyEntityDesc );
	CCopyEntity *pEntity = m_pStage->CreateEntity( desc.CopyEntityDesc );

	if( !pEntity )
        LOG_PRINT_ERROR( "Failed to create a copy entity: " + string(base_entity_handle.GetBaseEntityName()) );
	else
        LOG_PRINT_ERROR( "Created a copy entity: "          + string(base_entity_handle.GetBaseEntityName()) );

	size_t i, num_children = desc.vecChild.size();
	for( i=0; i<num_children; i++ )
	{
		LoadCopyEntityFromDesc_r( desc.vecChild[i], pEntity );
	}
}
示例#2
0
	AES() : m_ctx(NULL)
	{
		m_ctx = oaes_alloc();

		if( m_ctx == NULL )
			LOG_PRINT_ERROR( "oaes_alloc() returned NULL." );
	}
示例#3
0
bool EntityManager::LoadBaseEntity( BaseEntityHandle& base_entity_handle )
{
	const string base_entity_name = base_entity_handle.GetBaseEntityName();

	if( base_entity_name.length() == 0 )
	{
		base_entity_handle.SetState( BaseEntityHandle::STATE_INVALID );
		return false; // base entity name has to be specified.
	}

	// find the base entity from the current list
	BaseEntity *pBaseEntity = FindBaseEntity( base_entity_name.c_str() );

	if( pBaseEntity )
	{
		// already on the list - set the pointer to the handle and return
		base_entity_handle.SetBaseEntityPointer( pBaseEntity );
		base_entity_handle.SetState( BaseEntityHandle::STATE_VALID );
		return true;
	}

	// not loaded yet - load the base entity and set the base entity pointer to the handle
	pBaseEntity = GetBaseEntityManager().LoadBaseEntity( base_entity_name );

	if( !pBaseEntity )
	{
		// the requested base entity was not found in the database
		// - mark the handle as invalid and return
		base_entity_handle.SetState( BaseEntityHandle::STATE_INVALID );
		LOG_PRINT_ERROR( "the requested base entity '" + base_entity_name + "' was not found in the database" );
		return false;
	}

	// the base entity was successfully loaded from the database

	// set stage ptr
	pBaseEntity->SetStagePtr( m_pStage->GetWeakPtr() );

	m_vecpBaseEntity.push_back( pBaseEntity );

	// initialize - load textures, 3D models, other base entities, or so
	pBaseEntity->Init();

	// add to the sweep render table if all the copy entities should be rendered at once
	if( pBaseEntity->m_bSweepRender )
		m_pRenderManager->AddSweepRenderEntity( pBaseEntity );

	LOG_PRINT( " - name (confirm): " + pBaseEntity->GetNameString() );

	base_entity_handle.SetBaseEntityPointer( pBaseEntity );
	base_entity_handle.SetState( BaseEntityHandle::STATE_VALID );

	return true;
}
GLenum ToGLPrimitiveType( PrimitiveType::Name pt )
{
	switch( pt )
	{
	case PrimitiveType::TRIANGLE_LIST:  return GL_TRIANGLES;
	case PrimitiveType::TRIANGLE_FAN:   return GL_TRIANGLE_FAN;
	case PrimitiveType::TRIANGLE_STRIP: return GL_TRIANGLE_STRIP;
	default:
		LOG_PRINT_ERROR( "An unsupported primitive type: " + to_string((int)pt) );
		return GL_TRIANGLES;
	}
}
示例#5
0
	int Encrypt( const std::vector<unsigned char>& plaintext, std::vector<unsigned char>& ciphertext )
	{
		if( plaintext.size() == 0 )
			return -1;

		if( m_ctx == NULL )
		{
			LOG_PRINT_ERROR( "m_ctx == NULL." );
			return -1;
		}

		size_t encryption_buffer_size = 0;

		OAES_RET ret = oaes_encrypt( m_ctx, (const uint8_t *)&plaintext[0], plaintext.size(), NULL, &encryption_buffer_size );

		if( ret != OAES_RET_SUCCESS )
		{
			LOG_PRINTF_ERROR(( "Failed to retrieve required buffer size for encryption: %d", (int)ret ));
			return -1;
		}

		if( encryption_buffer_size == 0 )
		{
			LOG_PRINT_ERROR( "The required encryption buffer size == 0." );
			return -1;
		}

		ciphertext.resize( 0 );
		ciphertext.resize( encryption_buffer_size );

		ret = oaes_encrypt( m_ctx, (const uint8_t *)&plaintext[0], plaintext.size(), &ciphertext[0], &encryption_buffer_size );

		if( ret != OAES_RET_SUCCESS )
		{
			LOG_PRINTF_ERROR(( "Encryption failed: %d", (int)ret ));
			return -1;
		}

		return 0;
	}
void C2DPrimitiveRenderer_GL::Render( General2DVertex *paVertex, int num_vertices, PrimitiveType::Name primitive_type )
{
	ShaderHandle shader
		= sg_2DPrimitiveCommonShaders.GetShader( C2DPrimitiveCommonShaders::ST_DIFFUSE_COLOR );

	ShaderManager *pShaderMgr = shader.GetShaderManager();

	if( !pShaderMgr )
	{
		LOG_PRINT_ERROR( "The shader for 2D primitives is not available." );
		return;
	}

	pShaderMgr->Begin();

	RenderViaVertexAttribArray( paVertex, num_vertices, NULL, 0, ToGLPrimitiveType(primitive_type) );
}
示例#7
0
	/**
	 @brief Constructor that initializes the instance and imports an encryption key.

	 @param[in] key An encryption key. Note that a 256-bit key does not mean key.size() == 32
	 */
	AES( std::vector<unsigned char>& key ) : m_ctx(NULL)
	{
		m_ctx = oaes_alloc();

		if( m_ctx == NULL )
			LOG_PRINT_ERROR( "oaes_alloc() returned NULL." );

		if( key.empty() )
		{
			LOG_PRINT_WARNING( "key.empty()" );
			return;
		}

		OAES_RET ret = oaes_key_import( m_ctx, &key[0], key.size() );

		if( ret != OAES_RET_SUCCESS )
			LOG_PRINTF_ERROR(( "oaes_key_import() failed: %d", (int)ret ));
	}
示例#8
0
	int GenerateKey( unsigned int key_bit_length, std::vector<unsigned char>& key )
	{
		if( m_ctx == NULL )
			LOG_PRINT_ERROR( "m_ctx == NULL." );

//		OAES_RET ret = oaes_key_gen_256(m_ctx);
		int r = GenerateXbitKey(key_bit_length);

//		if( ret != OAES_RET_SUCCESS )
		if( r != 0 )
		{
//			LOG_PRINTF_ERROR(( "oaes_key_gen_256() failed: %d", (int)ret ));
			return -1;
		}

		size_t key_data_size = 0;

		OAES_RET ret = oaes_key_export(m_ctx, NULL, &key_data_size);

		if( ret != OAES_RET_SUCCESS )
		{
			LOG_PRINTF_ERROR(( "Failed to retrieve key length: %d", (int)ret ));
			return -1;
		}

		key.resize( 0 );
		key.resize( key_data_size, 0 );

		ret = oaes_key_export(m_ctx, &key[0], &key_data_size);

		if( ret != OAES_RET_SUCCESS )
		{
			LOG_PRINTF_ERROR(( "Failed to export key: %d", (int)ret ));
			return -1;
		}

		return 0;
	}
示例#9
0
bool EntityManager::LoadCopyEntitiesFromDescFile( char* pcFilename )
{
	CCopyEntityDescFileArchive entity_desc_archive;

	BinaryArchive_Input input_archive( pcFilename );

	if( !(input_archive >> entity_desc_archive) )
	{
		LOG_PRINT_ERROR( "wrong .ent file" + string(pcFilename) );
		return false;
	}

	size_t i, num_entities = entity_desc_archive.GetNumEntityDescs();

	for( i=0; i<num_entities; i++ )
	{
		CCopyEntityDescFileData& desc = entity_desc_archive.GetCopyEntityDesc( (int)i );

		LoadCopyEntityFromDesc_r( desc, NULL );
	}

	return true;
}
void CHumanoidMotionSynthesizer::LoadMotions( MotionDatabase& mdb, const std::string& motion_table_key_name )
{
	HumanoidMotionTable tbl;

	bool retrieved = mdb.GetHumanoidMotionTable( motion_table_key_name, tbl );

	if( !retrieved )
	{
		LOG_PRINT_ERROR( "Cannot find the motion table: " + motion_table_key_name );
	}

	std::map<std::string,int> motion_type_to_id;
	motion_type_to_id["Walk"]   = HumanoidMotion::Walk;
	motion_type_to_id["Run"]    = HumanoidMotion::Run;
	motion_type_to_id["Stop"]   = HumanoidMotion::Stop;
	motion_type_to_id["Jump"]   = HumanoidMotion::Jump;
	motion_type_to_id["Crawl"]  = HumanoidMotion::Crawl;
	motion_type_to_id["Crouch"] = HumanoidMotion::Crouch;

	BOOST_FOREACH( const CHumanoidMotionEntry& entry, tbl.m_vecEntry )
	{
		// get array index from motion type name
		std::map<std::string,int>::iterator itr = motion_type_to_id.find(entry.m_MotionType);

		if( itr != motion_type_to_id.end() )
		{
			int type_index = itr->second;
			
			BOOST_FOREACH( const std::string& motion_primitive_name, entry.m_vecMotionPrimitiveName )
			{
				shared_ptr<MotionPrimitive> pMotion = mdb.GetMotionPrimitive( motion_primitive_name );
				if( pMotion )
					m_aMotion[type_index].m_vecpMotion.push_back( pMotion );
			}
		}
	}
示例#11
0
INT32 NC_Initialize(INT32 iwidth, INT32 iheight, const Char* strRootPath, const Char* strMapPath, const Char* strLocatorPath) {
	INT32 result = NC_SUCCESS;
	E_SC_RESULT ret = e_SC_RESULT_SUCCESS;
	E_PAL_RESULT pal_res = e_PAL_RESULT_SUCCESS;
	SMCARSTATE carState = {};
	Char logDirPath[SC_MAX_PATH] = {};
	Char configDirPath[SC_MAX_PATH] = {};

	printf("\n");
	printf("navi-core version %s(" __DATE__ ") , api version %s\n",CORE_VERSION,API_VERSION);
	printf("Copyright (c) 2016  Hitachi, Ltd.\n");
	printf("This program is dual licensed under GPL version 2 or a commercial license.\n");
	printf("\n");

	SC_LOG_DebugPrint(SC_TAG_NC, SC_LOG_START);

	do {

		// パラメータチェック
		if (NULL == strRootPath) {
			LOG_PRINT_ERROR((char*)SC_TAG_NC, "param error[strRootPath]");
			result = NC_PARAM_ERROR;
			break;
		}
		if (NULL == strMapPath) {
			LOG_PRINT_ERROR((char*)SC_TAG_NC, "param error[strMapPath]");
			result = NC_PARAM_ERROR;
			break;
		}
		if (NULL == strLocatorPath) {
			LOG_PRINT_ERROR((char*)SC_TAG_NC, "param error[strLocatorPath]");
			result = NC_PARAM_ERROR;
			break;
		}

		// 各パス設定
		sprintf((char*) logDirPath, "%s%s", strRootPath, NC_LOG_FILE_PATH);
		sprintf((char*) configDirPath, "%sConfig/", strMapPath);

		// ログ初期化
		ret = SC_LOG_Initialize(SC_LOG_TYPE_BOTH, SC_LOG_LV_DEBUG, (Char*) logDirPath);
		if (e_SC_RESULT_SUCCESS != ret) {
			SC_LOG_ErrorPrint((char*) SC_TAG_NC, "SC_LOG_Initialize error, " HERE);
			result = NC_ERROR;
			break;
		}

		// POIDB初期化
		pal_res = SC_POI_Initialize((char*) strMapPath);
		if (e_PAL_RESULT_SUCCESS != pal_res) {
			SC_LOG_ErrorPrint((char*) SC_TAG_NC, "SC_POI_Initialize error, " HERE);
			result = NC_ERROR;
			break;
		}

		// コア初期化
		ret = SC_MNG_Initialize(strRootPath, configDirPath, strMapPath);
		if (e_SC_RESULT_SUCCESS != ret) {
			SC_LOG_ErrorPrint(SC_TAG_NC, (Char*) "SC_MNG_Initialize error(0x%08x), " HERE, ret);
			result = NC_ERROR;
			break;
		}

		// 解像度設定
		ret = SC_MNG_SetResolution((INT32) iwidth, (INT32) iheight);
		if (e_SC_RESULT_SUCCESS != ret) {
			SC_LOG_ErrorPrint(SC_TAG_NC, (Char*) "SC_MNG_SetResolution error(0x%08x), " HERE, ret);
			result = NC_ERROR;
			break;
		}

		// 車両状態情報を取得
		ret = SC_MNG_GetCarState(&carState, e_SC_CARLOCATION_REAL);
		if (e_SC_RESULT_SUCCESS != ret) {
			SC_LOG_ErrorPrint(SC_TAG_NC, (Char*) "SC_MNG_GetCarState error(0x%08x), " HERE, ret);
			result = NC_ERROR;
			break;
		}
#if 0	// kanagawa
		// ロケータ初期化
		ret = LC_InitLocator(strLocatorPath, &carState);
		if (e_SC_RESULT_SUCCESS != ret) {
			SC_LOG_ErrorPrint(SC_TAG_NC, (Char*) "LC_InitLocator error(0x%08x), " HERE, ret);
			result = NC_ERROR;
			break;
		}
#endif	// kanagawa
	} while (0);

	// 運転特性診断停止中
	mDrivingDiagnosingStatus = 0;

	// NaviCore初期化完了
	mIsInitialized = true;

	SC_LOG_DebugPrint(SC_TAG_NC, SC_LOG_END);

	return (result);
}
示例#12
0
CCopyEntity *EntityManager::CreateEntity( CCopyEntityDesc& rCopyEntityDesc )
{
	if( !rCopyEntityDesc.pBaseEntityHandle )
		return NULL;

	BaseEntityHandle& rBaseEntityHandle = *(rCopyEntityDesc.pBaseEntityHandle);

//	LOG_PRINT( "creating a copy entity of " + string(rBaseEntityHandle.GetBaseEntityName()) );

	BaseEntity *pBaseEntity = GetBaseEntity( rBaseEntityHandle );
	if( !pBaseEntity )
		return NULL;

	BaseEntity& rBaseEntity = *(pBaseEntity);

//	LOG_PRINT( "checking the initial position of " + rBaseEntity.GetNameString() );

	// determine the entity group id
	// priority (higher to lower):
	// (id set to copy entity desc) -> (id set to base entity)
	int entity_group_id = ENTITY_GROUP_INVALID_ID;
	if( rCopyEntityDesc.sGroupID != ENTITY_GROUP_INVALID_ID )
	{
		entity_group_id = rCopyEntityDesc.sGroupID;
	}
	else
	{
		// try the group of base entity
		entity_group_id = rBaseEntity.GetEntityGroupID();
	}

	if( false )
//	if( !rBaseEntity.m_bNoClip )
//	 && rCopyEntityDesc.DontCreateIfOverlapIsDetected )
	{	// check for overlaps with other entities
		// to see if the new entity is in a valid position
//		if( rCopyEnt.bvType == BVTYPE_AABB || rCopyEnt.bvType == BVTYPE_DOT )
//		{
			STrace tr;
			tr.sTraceType = TRACETYPE_IGNORE_NOCLIP_ENTITIES;
			tr.vEnd       = rCopyEntityDesc.WorldPose.vPosition;
			tr.bvType     = rBaseEntity.m_BoundingVolumeType;
			tr.aabb       = rBaseEntity.m_aabb;
			tr.GroupIndex = entity_group_id;
			if( rBaseEntity.m_bNoClipAgainstMap )
				tr.sTraceType |= TRACETYPE_IGNORE_MAP;
			m_pStage->CheckPosition( tr );
			if(tr.in_solid)
			{
				LOG_PRINT( " - cannot create a copy entity due to overlaps: " + string(rBaseEntityHandle.GetBaseEntityName()) );
				return NULL;	// specified position is invalid - cannot create entity
			}
//		}
	}

//	LOG_PRINT( "the copy entity of " + rBaseEntity.GetNameString() + " is in a valid position" );

	// create an entity
	shared_ptr<CCopyEntity> pNewEntitySharedPtr = m_pEntityFactory->CreateEntity( rCopyEntityDesc.TypeID );
	if( !pNewEntitySharedPtr )
	{
		/// too many entities or no entity is defined for rCopyEntityDesc.TypeID
		LOG_PRINT_ERROR( " - cannot create a copy entity of '" + string(rBaseEntityHandle.GetBaseEntityName()) + "'" );
		return NULL;
	}

	CCopyEntity *pNewCopyEnt = pNewEntitySharedPtr.get();

	pNewCopyEnt->m_TypeID    = rCopyEntityDesc.TypeID;

	// copy parameter values from base entity (entity attributes set)
	SetBasicEntityAttributes( pNewCopyEnt, rBaseEntity );

	// copy parameter values from entity desc

	pNewCopyEnt->SetName( rCopyEntityDesc.strName );

	pNewCopyEnt->SetWorldPose( rCopyEntityDesc.WorldPose );

	pNewCopyEnt->Velocity()  = rCopyEntityDesc.vVelocity;
	pNewCopyEnt->fSpeed      = rCopyEntityDesc.fSpeed;

	pNewCopyEnt->m_MeshHandle = rCopyEntityDesc.MeshObjectHandle;

	pNewCopyEnt->f1 = rCopyEntityDesc.f1;
	pNewCopyEnt->f2 = rCopyEntityDesc.f2;
	pNewCopyEnt->f3 = rCopyEntityDesc.f3;
	pNewCopyEnt->f4 = rCopyEntityDesc.f4;
	pNewCopyEnt->f5 = 0.0f;
	pNewCopyEnt->s1 = rCopyEntityDesc.s1;
	pNewCopyEnt->v1 = rCopyEntityDesc.v1;
	pNewCopyEnt->v2 = rCopyEntityDesc.v2;
	pNewCopyEnt->iExtraDataIndex = rCopyEntityDesc.iExtraDataIndex;
	pNewCopyEnt->pUserData = rCopyEntityDesc.pUserData;

	pNewCopyEnt->sState   = 0;
	pNewCopyEnt->bInSolid = false;

	pNewCopyEnt->GroupIndex = entity_group_id;

//	pNewCopyEnt->GroupIndex = rCopyEntityDesc.sGroupID;

	pNewCopyEnt->touch_plane.dist   = 0;
	pNewCopyEnt->touch_plane.normal = Vector3(0,0,0);

	InitEntity( pNewEntitySharedPtr, rCopyEntityDesc.pParent, pBaseEntity, rCopyEntityDesc.pPhysActorDesc );

	pNewCopyEnt->Init( rCopyEntityDesc );

	LOG_PRINT_VERBOSE( " - created a copy entity of " + rBaseEntity.GetNameString() );

	return pNewCopyEnt;
}
示例#13
0
/**
 Create Entity-Tree from BSP-Tree of the map.
 There are 4 cases we have to deal with 
 (1) frontchild - NO  / backchild - NO	... Create a leaf node
 (2) frontchild - YES / backchild - YES	... Create a diverging node and recurse down for both sides
 (3) frontchild - YES / backchild - NO	... Just recurse down to frontchild
 (4) frontchild - NO  / backchild - YES ... This is an exception. In this case,
										    1) create a diverging node.
										    2) create a leaf node as a frontchild.
*/
short EntityManager::MakeEntityNode_r(short sNodeIndex, BSPTree* pSrcBSPTree,
					   vector<EntityNode>* pDestEntityTree)
{
//	SNode_f& rThisNode = pSrcBSPTree->m_paNode[ sNodeIndex ];
	const SNode_f& rThisNode = pSrcBSPTree->GetNode( sNodeIndex );
	short sFrontChild = rThisNode.sFrontChild;
	short sBackChild = rThisNode.sBackChild;

//	LOG_PRINTF(( "NODE: %d / FC: %d / BC: %d", sNodeIndex, sFrontChild, sBackChild ));

	if( 0 <= sFrontChild && sBackChild < 0 )	//case (1)
		return MakeEntityNode_r(sFrontChild, pSrcBSPTree, pDestEntityTree);  //recurse down to front

	EntityNode newnode;
	short sThisEntNodeIndex = (short)pDestEntityTree->size();
	pDestEntityTree->push_back( newnode );
	EntityNode& rNewNode = pDestEntityTree->at( sThisEntNodeIndex );

//	rNewNode.m_pLightEntity = NULL;

	if( sFrontChild < 0 && 0 <= sBackChild )  //This shouldn't really happen
	{
		//current node 'rThisNode' has no front child but it should be treated as a diverging node
		rNewNode.leaf = false;
		rNewNode.sFrontChild = (short)pDestEntityTree->size();

		//We have to add one leaf node as a front child to this diverging node
		pDestEntityTree->push_back( newnode );
		EntityNode& rFrontLeafNode = pDestEntityTree->back();
		rFrontLeafNode.sFrontChild = -1;
		rFrontLeafNode.sBackChild = -1;
		rFrontLeafNode.sParent = sThisEntNodeIndex;  //Index to 'rNewNode' in pDestEntityTree
		rFrontLeafNode.leaf = true;
		rFrontLeafNode.m_AABB = rThisNode.aabb;

		//Recurse down to the back side
		pDestEntityTree->at( sThisEntNodeIndex ).sBackChild
			= MakeEntityNode_r(sBackChild, pSrcBSPTree, pDestEntityTree);
		
		EntityNode& rNewNode = pDestEntityTree->at( sThisEntNodeIndex );
		rNewNode.m_Plane = pSrcBSPTree->GetPlane( rThisNode );
		rNewNode.m_AABB.Merge2AABBs( rThisNode.aabb,
			pDestEntityTree->at( rNewNode.sBackChild ).m_AABB );
		return sThisEntNodeIndex;  //Return the index to this diverging-node
	}

	else if( sFrontChild < 0 && sBackChild < 0 )  // complete leaf-node
	{	
		rNewNode.m_AABB = rThisNode.aabb;
		rNewNode.leaf = true;
		rNewNode.sFrontChild = -1;
		rNewNode.sBackChild = -1;
		rNewNode.m_sCellIndex = rThisNode.sCellIndex;
		if( rThisNode.sCellIndex < 0 )
			LOG_PRINT_ERROR( fmt_string( "invalid cell index found in a bsp-tree node (node index: %d)", sNodeIndex ) );
		return  sThisEntNodeIndex;	//returns the index of this node
	}

	else  //diverging-node
	{	
		rNewNode.m_AABB = rThisNode.aabb;
		rNewNode.leaf = false;

		//Recurse down to the both sides to make 2 sub-trees (front & back)
		pDestEntityTree->at( sThisEntNodeIndex ).sFrontChild
			= MakeEntityNode_r(sFrontChild, pSrcBSPTree, pDestEntityTree);
		pDestEntityTree->at( sThisEntNodeIndex ).sBackChild
			= MakeEntityNode_r(sBackChild, pSrcBSPTree, pDestEntityTree);

		//The internal memory allocation of 'pDestEntityTree' may have changed
		//during the above recursions.
		//In other words, the variable 'rNewNode' may be no longer valid
		//due to memory re-allocation, so we have to update the reference variable
		EntityNode& rNewNode = pDestEntityTree->at( sThisEntNodeIndex );
		rNewNode.m_Plane = pSrcBSPTree->GetPlane( rThisNode );  //Set 'binary partition plane'
		pDestEntityTree->at( rNewNode.sFrontChild ).sParent = sThisEntNodeIndex;
		pDestEntityTree->at( rNewNode.sBackChild ).sParent = sThisEntNodeIndex;
		return sThisEntNodeIndex;
	}

}
bool D3DCubeTextureRenderTarget::CreateTextures( uint texture_size, TextureFormat::Format texture_format )
{
	m_CubeTextureSize = texture_size;
	m_TextureFormat = texture_format;

	D3DFORMAT d3d_fmt;
	if( texture_format == TextureFormat::Invalid )
	/* || any ohter texture formats invalid for cube mapping ) */
	{
		LOG_PRINT_ERROR( fmt_string("An unsupported texture format: %d", texture_format) );
		return false;
	}

	d3d_fmt = ConvertTextureFormatToD3DFORMAT( texture_format );

	LPDIRECT3DDEVICE9 pd3dDevice = DIRECT3D9.GetDevice();
	HRESULT hr;

	m_NumCubes = 1; // always use the single cube texture

/*	if( d3d_fmt == D3DFMT_A16B16G16R16F )
	{
		// Create the cube textures
		ZeroMemory( m_apCubeMapFp, sizeof( m_apCubeMapFp ) );
		hr = pd3dDevice->CreateCubeTexture( m_CubeTextureSize,
											1,
											D3DUSAGE_RENDERTARGET,
											D3DFMT_A16B16G16R16F,
											D3DPOOL_DEFAULT,
											&m_apCubeMapFp[0],
											NULL );

		m_pCurrentCubeMap = m_apCubeMapFp[0];
	}
*/

	hr = pd3dDevice->CreateCubeTexture( m_CubeTextureSize,
										1,
										D3DUSAGE_RENDERTARGET,
										d3d_fmt,
										D3DPOOL_DEFAULT,
										&m_pCubeMap32,
										NULL );

	if( FAILED(hr) || !m_pCubeMap32 )
	{
		LOG_PRINT_WARNING( "CreateCubeTexture() failed. Cannot create cube texture." );
		return false;
	}

	m_pCurrentCubeMap =  m_pCubeMap32;

//	DXUTDeviceSettings d3dSettings = DXUTGetDeviceSettings();

	LPDIRECT3DSWAPCHAIN9 pSwapChain;
	pd3dDevice->GetSwapChain( 0, &pSwapChain );

	D3DPRESENT_PARAMETERS pp;
	pSwapChain->GetPresentParameters( &pp );

    hr = pd3dDevice->CreateDepthStencilSurface( m_CubeTextureSize,
                                                m_CubeTextureSize,
//                                              d3dSettings.d3d9.pp.AutoDepthStencilFormat,
                                                pp.AutoDepthStencilFormat,
                                                D3DMULTISAMPLE_NONE,
                                                0,
                                                TRUE,
                                                &m_pDepthCube,
                                                NULL );

	if( FAILED(hr) || !m_pCurrentCubeMap )
	{
		LOG_PRINT_WARNING( "CreateDepthStencilSurface() failed. Cannot create depth stencil surface." );
		return false;
	}

/*
	// Initialize the number of cube maps required when using floating point format
//	IDirect3D9* pD3D = DXUTGetD3D9Object(); 
//	D3DCAPS9 caps;
//	hr = pD3D->GetDeviceCaps( pDeviceSettings->d3d9.AdapterOrdinal, pDeviceSettings->d3d9.DeviceType, &caps );

//	if( FAILED( pD3D->CheckDeviceFormat( caps.AdapterOrdinal, caps.DeviceType,
//										 pDeviceSettings->d3d9.AdapterFormat, D3DUSAGE_RENDERTARGET, 
//										 D3DRTYPE_CUBETEXTURE, D3DFMT_A16B16G16R16F ) ) )

	if( FAILED( pD3D->CheckDeviceFormat( D3DADAPTER_DEFAULT, DIRECT3D9.GetDeviceType(),
										 DIRECT3D9.GetAdapterFormat(), D3DUSAGE_RENDERTARGET, 
										 D3DRTYPE_CUBETEXTURE, D3DFMT_A16B16G16R16F ) ) )
	{
		m_NumCubes = m_NumFpCubeMap = 2;
	}
	else
	{
		m_NumCubes = m_NumFpCubeMap = 1;
	}

	// If device doesn't support HW T&L or doesn't support 1.1 vertex shaders in HW 
	// then switch to SWVP.
//	if( (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0 ||
//			caps.VertexShaderVersion < D3DVS_VERSION(1,1) )
//	{
//		pDeviceSettings->d3d9.BehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
//	}*/

	return true;
}