当前位置: 首页>>代码示例>>C++>>正文


C++ Asset类代码示例

本文整理汇总了C++中Asset的典型用法代码示例。如果您正苦于以下问题:C++ Asset类的具体用法?C++ Asset怎么用?C++ Asset使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Asset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AssetEventArgs

void AssetTracker::OnAssetChanged( const Reflect::ObjectChangeArgs &args )
{
	Asset *pAsset = const_cast<Asset *>(Reflect::AssertCast< Asset >( args.m_Object ));
	pAsset->SetFlags( Asset::FLAG_CHANGED_SINCE_LOADED );

	e_AssetChanged.Raise( AssetEventArgs( pAsset ) );
}
开发者ID:HeliumProject,项目名称:Helium,代码行数:7,代码来源:AssetLoader.cpp

示例2: MessageBox

Asset* AssetManager::LoadAsset(const std::string& fileName)
{
	IdIter iter = mAssetNameReferece.find(fileName);
	if (iter == mAssetNameReferece.end())
	{
		//load asset
		AvailableAsset* asset = AvailableAsset::GetAvailableAssetFromFileName(fileName, false);
		if (!asset)
		{
			//asset never exists
			MessageBox(0, std::wstring(fileName.begin(), fileName.end()).c_str(), L"Asset not found", MB_OK);
			throw AssetException(AssetException::ASSETFILENOTFOUND);
		}
		meta::metafunction_method* loader = AssetManager::getInstance()->getmeta().getfunctionbyname("Load" + asset->Type());
		if (!loader)
		{
			//loader doesn't exist
			throw AssetException(AssetException::ASSETFAILEDTOLOAD);
		}
		Asset* newAsset = loader->invoke(AssetManager::getInstance(), fileName).GetAs<Asset*>();
		if (newAsset == 0)
		{
			Log("Asset failed to load for unknown reason: " + fileName);
			return 0;
		}
    newAsset->SetName(fileName);
	newAsset->SetType(asset->Type());
		//add to the lists
		if (newAsset)
			InsertAssetInMap(newAsset);
		return newAsset;
	}
	//asset exists
	return mAssetContainer[iter->second];
}
开发者ID:Reticulatas,项目名称:MochaEngineFinal,代码行数:35,代码来源:AssetManager.cpp

示例3: ExportData

inline Ref<Accessor> ExportData(Asset& a, std::string& meshName, Ref<Buffer>& buffer,
    unsigned int count, void* data, AttribType::Value typeIn, AttribType::Value typeOut, ComponentType compType, bool isIndices = false)
{
    if (!count || !data) return Ref<Accessor>();

    unsigned int numCompsIn = AttribType::GetNumComponents(typeIn);
    unsigned int numCompsOut = AttribType::GetNumComponents(typeOut);
    unsigned int bytesPerComp = ComponentTypeSize(compType);

    size_t offset = buffer->byteLength;
    size_t length = count * numCompsOut * bytesPerComp;
    buffer->Grow(length);

    // bufferView
    Ref<BufferView> bv = a.bufferViews.Create(a.FindUniqueID(meshName, "view"));
    bv->buffer = buffer;
    bv->byteOffset = unsigned(offset);
    bv->byteLength = length; //! The target that the WebGL buffer should be bound to.
    bv->target = isIndices ? BufferViewTarget_ELEMENT_ARRAY_BUFFER : BufferViewTarget_ARRAY_BUFFER;

    // accessor
    Ref<Accessor> acc = a.accessors.Create(a.FindUniqueID(meshName, "accessor"));
    acc->bufferView = bv;
    acc->byteOffset = 0;
    acc->byteStride = 0;
    acc->componentType = compType;
    acc->count = count;
    acc->type = typeOut;

    // copy the data
    acc->WriteData(count, data, numCompsIn*bytesPerComp);

    return acc;
}
开发者ID:3D4Medical,项目名称:assimp,代码行数:34,代码来源:glTFExporter.cpp

示例4: theName

void ParticleColliderComponent::initialize()
{
    if( !d->item )
    {
        d->item = GluonGraphics::Engine::instance()->createItem( "default" );
    }

    if( d->material )
    {
        Asset* materialAsset = qobject_cast<Asset*>( d->material->parent() );
        if( materialAsset )
            materialAsset->load();

        Asset* texture = 0;
        if( d->material->property( "texture0" ).type() == QVariant::String )
        {
            QString theName( d->material->property( "texture0" ).toString() );
            QString theObjectName = GluonObject::nameToObjectName( theName );
            texture = gameProject()->findChild<Asset*>( theObjectName );
            if( !texture )
                debug( QString( "Texture failed to load - attempted to load texture named %1 (searched for %2)" ).arg( theName ).arg( theObjectName ) );
        }
        else
            texture = qobject_cast<Asset*>( GluonCore::GluonObjectFactory::instance()->wrappedObject( d->material->property( "texture0" ) ) );

        if( texture )
            texture->load();
        d->item->setMaterialInstance( d->material );
    }
}
开发者ID:pranavrc,项目名称:gluon,代码行数:30,代码来源:particlecomponent.cpp

示例5: GetAbsolutePathOfFile

Asset* AssetManager::LoadSubShaders(const std::string& subshaderFile)
{
  std::string fullPath = GetAbsolutePathOfFile(subshaderFile);
  std::wstring filepath = std::wstring(fullPath.begin(),fullPath.end());
  SUBSHADERTYPE sstype = GetSubShaderTypeFromFile(fullPath);

  Asset* pSubShader = 0;;

  switch (sstype)
  {
  case VERTEX_SHADER:

    pSubShader = new SubShader<ID3D11VertexShader>(filepath, sstype);
    break;

  case PIXEL_SHADER:

    pSubShader = new SubShader<ID3D11PixelShader>(filepath, sstype);
    break;
  case COMPUTE_SHADER:

	  pSubShader = new SubShader<ID3D11ComputeShader>(filepath, sstype);
	  break;

  case GEOMETRY_SHADER:

	  pSubShader = new SubShader<ID3D11GeometryShader>(filepath, sstype);
	  break;
  }

  pSubShader->SetAutoUnload(false);
  pSubShader->AddUseCounter();

  return pSubShader;
}  
开发者ID:Reticulatas,项目名称:MochaEngineFinal,代码行数:35,代码来源:AssetManager.cpp

示例6: HELIUM_TRACE

/// Perform shutdown of the Asset system.
///
/// This releases all final references to objects and releases all allocated memory.  This should be called during
/// the shutdown process after all types have been unregistered as well as after calling AssetType::Shutdown().
///
/// @see AssetType::Shutdown()
void Asset::Shutdown()
{
	HELIUM_TRACE( TraceLevels::Info, TXT( "Shutting down Asset system.\n" ) );
	
#if !HELIUM_RELEASE
	size_t objectCountActual = sm_objects.GetUsedSize();
	if( objectCountActual != 0 )
	{
		HELIUM_TRACE(
			TraceLevels::Error,
			TXT( "%" ) PRIuSZ TXT( " asset(s) still referenced during shutdown!\n" ),
			objectCountActual );

		size_t objectCount = sm_objects.GetSize();
		for( size_t objectIndex = 0; objectIndex < objectCount; ++objectIndex )
		{
			if( !sm_objects.IsElementValid( objectIndex ) )
			{
				continue;
			}

			Asset* pObject = sm_objects[ objectIndex ];
			if( !pObject )
			{
				continue;
			}
			
#if HELIUM_ENABLE_MEMORY_TRACKING
			Helium::RefCountProxy<Reflect::Object> *pProxy = pObject->GetRefCountProxy();
			HELIUM_ASSERT(pProxy);

			HELIUM_TRACE(
					TraceLevels::Error,
					TXT( "   - 0x%p: %s (%" ) PRIu16 TXT( " strong ref(s), %" ) PRIu16 TXT( " weak ref(s))\n" ),
					 pProxy,
					( pObject ? *pObject->GetPath().ToString() : TXT( "(cleared reference)" ) ),
					pProxy->GetStrongRefCount(),
					pProxy->GetWeakRefCount() );
#else
			HELIUM_TRACE( TraceLevels::Error, TXT( "- %s\n" ), *pObject->GetPath().ToString() );
#endif
		}
	}
#endif  // !HELIUM_RELEASE

	sm_objects.Clear();
	sm_wpFirstTopLevelObject.Release();

	delete sm_pNameInstanceIndexMap;
	sm_pNameInstanceIndexMap = NULL;

	delete sm_pEmptyNameInstanceIndexMap;
	sm_pEmptyNameInstanceIndexMap = NULL;

	delete sm_pEmptyInstanceIndexSet;
	sm_pEmptyInstanceIndexSet = NULL;

	sm_serializationBuffer.Clear();
}
开发者ID:Fantasticer,项目名称:Helium,代码行数:65,代码来源:Asset.cpp

示例7:

QDebug operator<<(QDebug debug, const Asset& asset)
{
  debug.nospace() << "Asset{mnem=" << asset.mnem() //
                  << ",display=" << asset.display() //
                  << ",type=" << asset.type() //
                  << '}';
  return debug;
}
开发者ID:swirlycloud,项目名称:swirly,代码行数:8,代码来源:Asset.cpp

示例8: addPending

Asset* AssetSystem::get(const char* pFileName)
{
	Asset* pAsset = addPending(pFileName);
	if (pAsset && !pAsset->getLoaded())
	{
	  pAsset->load();
	}
	
	return pAsset;
}
开发者ID:jpalves,项目名称:androidndkgame,代码行数:10,代码来源:AssetSystem.cpp

示例9: HELIUM_ASSERT

/// Construct an instance of this object in-place.
///
/// @param[in] pMemory           Memory buffer in which to construct an instance of this object.
/// @param[in] pDestroyCallback  Callback to use when notifying that this object should be destroyed (when its
///                              reference count reaches zero).  This must be specified.
///
/// @return  Pointer to the constructed object instance.
///
/// @see InPlaceDestroy(), GetInstanceSize()
Asset* Asset::InPlaceConstruct( void* pMemory, CUSTOM_DESTROY_CALLBACK* pDestroyCallback ) const
{
	HELIUM_ASSERT( pMemory );
	HELIUM_ASSERT( pDestroyCallback );

	Asset* pObject = new( pMemory ) Asset;
	pObject->SetCustomDestroyCallback( pDestroyCallback );

	return pObject;
}
开发者ID:Fantasticer,项目名称:Helium,代码行数:19,代码来源:Asset.cpp

示例10:

void BeamRendererComponent::Private::loadMaterial( GluonGraphics::MaterialInstance* material )
{
    Asset* materialAsset = qobject_cast<Asset*>( material->parent() );
    if( materialAsset )
        materialAsset->load();

    Asset* texture = Game::instance()->gameProject()->findChild<Asset*>( material->property( "texture0" ).toString() );
    if( texture )
        texture->load();
}
开发者ID:pranavrc,项目名称:gluon,代码行数:10,代码来源:beamrenderercomponent.cpp

示例11: GetShader

Shader* GetShader(std::string relative_path){
    Asset* assetClass = get_asset(relative_path);

    if (assetClass == NULL || assetClass->getType() != SHADER) return NULL;

    Shader* shader = static_cast<Shader *>(assetClass);

    if (shader) return shader;

    return NULL;
}
开发者ID:benbancroft,项目名称:2DEngine,代码行数:11,代码来源:shader.cpp

示例12: GetTexture

 Texture* GetTexture(std::string relative_path){
     Asset* assetClass = get_asset(relative_path);
     
     if (assetClass == NULL || assetClass->getType() != TEXTURE) return NULL;
     
     Texture* texture = static_cast<Texture *>(assetClass);
     
     if (texture) return texture;
     
     return NULL;
 }
开发者ID:benbancroft,项目名称:2DEngine,代码行数:11,代码来源:texture.cpp

示例13:

CameraControllerComponent::~CameraControllerComponent()
{
    if( d->material )
    {
        d->material->deref();
        Asset* materialAsset = qobject_cast<Asset*>( d->material->parent() );
        if( materialAsset )
            materialAsset->deref();
    }
    delete d;
}
开发者ID:pranavrc,项目名称:example-gluon,代码行数:11,代码来源:cameracontrollercomponent.cpp

示例14: initTexture

status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,
        const char* name) {
    Asset* asset = assets.open(name, Asset::ACCESS_BUFFER);
    if (!asset)
        return NO_INIT;
    SkBitmap bitmap;
    SkImageDecoder::DecodeMemory(asset->getBuffer(false), asset->getLength(),
            &bitmap, SkBitmap::kNo_Config, SkImageDecoder::kDecodePixels_Mode);
    asset->close();
    delete asset;

    // ensure we can call getPixels(). No need to call unlock, since the
    // bitmap will go out of scope when we return from this method.
    bitmap.lockPixels();

    const int w = bitmap.width();
    const int h = bitmap.height();
    const void* p = bitmap.getPixels();

    GLint crop[4] = { 0, h, w, -h };
    texture->w = w;
    texture->h = h;

    glGenTextures(1, &texture->name);
    glBindTexture(GL_TEXTURE_2D, texture->name);

    switch (bitmap.getConfig()) {
        case SkBitmap::kA8_Config:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA,
                    GL_UNSIGNED_BYTE, p);
            break;
        case SkBitmap::kARGB_4444_Config:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
                    GL_UNSIGNED_SHORT_4_4_4_4, p);
            break;
        case SkBitmap::kARGB_8888_Config:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
                    GL_UNSIGNED_BYTE, p);
            break;
        case SkBitmap::kRGB_565_Config:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB,
                    GL_UNSIGNED_SHORT_5_6_5, p);
            break;
        default:
            break;
    }

    glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    return NO_ERROR;
}
开发者ID:0359xiaodong,项目名称:platform_frameworks_base,代码行数:54,代码来源:BootAnimation.cpp

示例15: main

int main() {
    //Set up debug and info logging
    StreamAppender *appender = new StreamAppender(Logger::DEBUG | Logger::INFO, std::cout);
    Logger::add_appender(appender);
    fps::enable_fps_logging(true);
    
    //Create a window
    WindowManager &window_manager = WindowManager::get_instance();
    EasyWindow *easy_window = create_easy_window(640, 480);
    
    Window *window = easy_window->window;
    window->set_keyboard_callback(key_callback);
    
    //Create an object to add to the world
    Renderer *renderer = new Renderer(FLAT_VERTEX_SHADER,
                                      FLAT_FRAGMENT_SHADER);
    
    Mesh *mesh = new Mesh(2, Mesh::TRIANGLES);
    mesh->set_vertex_attribute(0, 3, 3, g_vertex_buffer_data);
    mesh->set_vertex_attribute(1, 3, 3, cube_colors);
    
    //Create an asset to wrap all of the above
    Asset *asset = new Asset;
    asset->set_mesh(mesh);
    asset->set_renderer(renderer);
    
    //Create a renderable to actually draw on the screen
    Renderable *renderable = new Renderable;
    renderable->asset = asset;
    renderable->set_position(0.0f, 0.0f, 0.3f);
    
    easy_window->world->add_child(renderable);
     
    //Set up the viewpoint
    viewpoint = new Viewpoint;
    viewpoint->set_far(100.0f);
    viewpoint->set_near(1.0f);
    viewpoint->set_position(0.0f, 0.0f, -0.5f);
    easy_window->screen->set_viewpoint(viewpoint);
    
    while(!window->get_should_close()) {
        window->render();
        window_manager.poll();
        fps::fps_tick();
    }
    
    destroy_easy_window(easy_window);
    delete viewpoint;
    
    //Clean up and exit
    Logger::shutdown();
    delete appender;
}
开发者ID:courageousillumination,项目名称:olympus,代码行数:53,代码来源:main.cpp


注:本文中的Asset类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。