Beispiel #1
0
void AssetsWindow::AddAsset(AssetPtr asset)
{
    ///\todo Check that the asset doesn't already exists
    AssetItem *item = new AssetItem(asset);
    AddChildren(asset, item);

    connect(asset.get(), SIGNAL(Loaded(AssetPtr)), SLOT(HandleAssetLoaded(AssetPtr)));
    connect(asset.get(), SIGNAL(Unloaded(IAsset *)), SLOT(HandleAssetUnloaded(IAsset *)));

    bool storageFound = false;
    AssetStoragePtr storage = asset->GetAssetStorage();
    if (storage)
        for(int i = 0; i < treeWidget->topLevelItemCount(); ++i)
        {
            QTreeWidgetItem *storageItem = treeWidget->topLevelItem(i);
            if (storageItem->text(0) == storage->ToString())
            {
                storageItem->addChild(item);
                storageFound = true;
                break;
            }
        }

    if (!storageFound)
        noProviderItem->addChild(item);

    noProviderItem->setHidden(noProviderItem->childCount() == 0);
}
Beispiel #2
0
void EC_Mesh::OnMaterialAssetLoaded(AssetPtr asset)
{
    OgreMaterialAsset *ogreMaterial = dynamic_cast<OgreMaterialAsset*>(asset.get());
    if (!ogreMaterial)
    {
        LogError("OnMaterialAssetLoaded: Material asset load finished for asset \"" +
            asset->Name().toStdString() + "\", but downloaded asset was not of type OgreMaterialAsset!");
        return;
    }

    Ogre::MaterialPtr material = ogreMaterial->ogreMaterial;
    bool assetUsed = false;

    AssetReferenceList materialList = meshMaterial.Get();
    for(int i = 0; i < materialList.Size(); ++i)
        if (materialList[i].ref == ogreMaterial->Name() ||
            framework_->Asset()->LookupAssetRefToStorage(materialList[i].ref) == ogreMaterial->Name()) ///<///\todo The design of whether the LookupAssetRefToStorage should occur here, or internal to Asset API needs to be revisited.
        {
            SetMaterial(i, ogreMaterial->Name());
            assetUsed = true;
        }

    if (!assetUsed)
    {
        LogWarning("OnMaterialAssetLoaded: Trying to apply material \"" + ogreMaterial->Name().toStdString() + "\" to mesh " +
            meshRef.Get().ref.toStdString() + ", but no submesh refers to the given material! The references are: ");
        for(int i = 0; i < materialList.Size(); ++i)
            LogWarning(QString::number(i).toStdString() + ": " + materialList[i].ref.toStdString());
    }
}
static duk_ret_t IAssetTransfer_Asset(duk_context* ctx)
{
    IAssetTransfer* thisObj = GetThisWeakObject<IAssetTransfer>(ctx);
    AssetPtr ret = thisObj->Asset();
    PushWeakObject(ctx, ret.Get());
    return 1;
}
/// Recursive function for resolving a package request.
///
/// @param[out] rspPackage   Resolved package.
/// @param[in]  packagePath  Package object path.
void CachePackageLoader::ResolvePackage( AssetPtr& rspPackage, AssetPath packagePath )
{
	HELIUM_ASSERT( !packagePath.IsEmpty() );

	rspPackage = Asset::FindObject( packagePath );
	if( !rspPackage )
	{
		AssetPtr spParent;
		AssetPath parentPath = packagePath.GetParent();
		if( !parentPath.IsEmpty() )
		{
			ResolvePackage( spParent, parentPath );
			HELIUM_ASSERT( spParent );
		}

		HELIUM_VERIFY( Asset::CreateObject(
			rspPackage,
			Package::GetStaticType(),
			packagePath.GetName(),
			spParent ) );
		HELIUM_ASSERT( rspPackage );
		HELIUM_ASSERT( rspPackage->IsA( Package::GetStaticType()->GetMetaClass() ) );
	}

	rspPackage->SetFlags( Asset::FLAG_PRELOADED | Asset::FLAG_LINKED | Asset::FLAG_LOADED );
}
static duk_ret_t IAsset_Clone_String(duk_context* ctx)
{
    IAsset* thisObj = GetThisWeakObject<IAsset>(ctx);
    String newAssetName = duk_require_string(ctx, 0);
    AssetPtr ret = thisObj->Clone(newAssetName);
    PushWeakObject(ctx, ret.Get());
    return 1;
}
std::string Agent::handleAssets (std::ostream &        aOut,
                                 const key_value_map & aQueries,
                                 const std::string &   aList)
{
    using namespace dlib;
    vector<AssetPtr> assets;

    if ( !aList.empty( ) )
    {
        auto_mutex         lock(*mAssetLock);
        istringstream      str(aList);
        tokenizer_kernel_1 tok;
        tok.set_stream(str);
        tok.set_identifier_token(tok.lowercase_letters( ) + tok.uppercase_letters( )
                                 + tok.numbers( ) + "_.@$%&^:+-_=",
                                 tok.lowercase_letters( ) + tok.uppercase_letters( )
                                 + tok.numbers( ) + "_.@$%&^:+-_=");

        int    type;
        string token;

        for ( tok.get_token(type, token); type != tok.END_OF_FILE; tok.get_token(type, token) )
        {
            if ( type == tok.IDENTIFIER )
            {
                AssetPtr ptr = mAssetMap[token];

                if ( ptr.getObject( ) == NULL )
                {
                    return XmlPrinter::printError(mInstanceId, 0, 0, "ASSET_NOT_FOUND",
                                                  (string) "Could not find asset: " + token);
                }
                assets.push_back(ptr);
            }
        }
    }
    else
    {
        auto_mutex lock(*mAssetLock);

        // Return all asssets, first check if there is a type attribute

        string type = aQueries["type"];

        list<AssetPtr>::iterator iter;

        for ( iter = mAssets.begin( ); iter != mAssets.end( ); ++iter )
        {
            if ( type.empty( ) || ( type == ( *iter )->getType( ) ) )
            {
                assets.push_back(*iter);
            }
        }
    }

    return XmlPrinter::printAssets(mInstanceId, mMaxAssets, mAssets.size( ), assets);
}
Beispiel #7
0
/// Test whether an object load request has completed, getting the result object if so.
///
/// Note that after a load request has completed (this function returns true), the request ID should no longer be
/// considered valid.
///
/// @param[in]  id         Load request ID.
/// @param[out] rspObject  Smart pointer set to the loaded object if loading has completed.  Note that this will be
///                        set to the object instance even if the object isn't finished loading (i.e. still being
///                        linked, etc.).
///
/// @return  True if the load request has completed, false if it is still being processed.
///
/// @see FinishLoad(), BeginLoadObject()
bool AssetLoader::TryFinishLoad( size_t id, AssetPtr& rspObject )
{
	HELIUM_ASSERT( IsValid( id ) );

	// Retrieve the load request and test whether it has completed.
	LoadRequest* pRequest = m_loadRequestPool.GetObject( id );
	HELIUM_ASSERT( pRequest );

	if( ( pRequest->stateFlags & LOAD_FLAG_FULLY_LOADED ) != LOAD_FLAG_FULLY_LOADED )
	{
		return false;
	}

	HELIUM_TRACE(
		TraceLevels::Debug,
		"AssetLoader::TryFinishLoad - Completed load for asset %s\n",
		*pRequest->path.ToString());

	HELIUM_ASSERT(  !pRequest->spObject.Get() || pRequest->spObject->IsFullyLoaded() || ( pRequest->spObject->GetFlags() & Asset::FLAG_BROKEN ) );

	rspObject = pRequest->spObject;

	// Acquire an exclusive lock to the request entry.
	AssetPath objectPath = pRequest->path;

	ConcurrentHashMap< AssetPath, LoadRequest* >::Accessor requestAccessor;
	HELIUM_VERIFY( m_loadRequestMap.Find( requestAccessor, objectPath ) );
	HELIUM_ASSERT( requestAccessor->Second() == pRequest );


	// Decrement the reference count on the load request, releasing it if the reference count reaches zero.
	int32_t newRequestCount = AtomicDecrementRelease( pRequest->requestCount );
	if( newRequestCount == 0 )
	{
		pRequest->spObject.Release();
		pRequest->resolver.Clear();

		m_loadRequestMap.Remove( requestAccessor );
		m_loadRequestPool.Release( pRequest );
	}

	requestAccessor.Release();

#if HELIUM_TOOLS
	if (rspObject)
	{
		if ( !(rspObject->SetFlags(Asset::FLAG_LOAD_EVENT_FIRED) & Asset::FLAG_LOAD_EVENT_FIRED) )
		{
			AssetTracker::GetStaticInstance()->NotifyAssetLoaded( rspObject.Get() );
		}
	}
#endif

	return true;
}
Beispiel #8
0
QWidget *UiAPI::LoadFromFile(const QString &filePath, bool addToScene, QWidget *parent)
{
    QWidget *widget = 0;

    if (AssetAPI::ParseAssetRefType(filePath) != AssetAPI::AssetRefLocalPath)
    {
        AssetPtr asset = owner->Asset()->GetAsset(filePath);
        if (!asset)
        {
            LogError(("LoadFromFile: Asset \"" + filePath + "\" is not loaded to the asset system. Call RequestAsset prior to use!").toStdString());
            return 0;
        }

        QtUiAsset *uiAsset = dynamic_cast<QtUiAsset*>(asset.get());
        if (!uiAsset)
        {
            LogError(("LoadFromFile: Asset \"" + filePath + "\" is not of type QtUiFile!").toStdString());
            return 0;
        }
        if (!uiAsset->IsLoaded())
        {
            LogError(("LoadFromFile: Asset \"" + filePath + "\" data is not valid!").toStdString());
            return 0;
        }

        // Get the asset data with the assetrefs replaced to point to the disk sources on the current local system.
        QByteArray data = uiAsset->GetRefReplacedAssetData();
        
        QUiLoader loader;
        QDataStream dataStream(&data, QIODevice::ReadOnly);
        widget = loader.load(dataStream.device(), parent);
    }
    else // The file is from absolute source location.
    {
        QFile file(filePath);
        QUiLoader loader;
        file.open(QFile::ReadOnly);
        widget = loader.load(&file, parent);
    }

    if (!widget)
    {
        LogError(("LoadFromFile: Failed to load widget from file \"" + filePath + "\"!").toStdString());
        return 0;
    }

    if (addToScene && widget)
        AddWidgetToScene(widget);

    return widget;
}
Beispiel #9
0
void EC_Sky::OnTextureAssetLoaded(AssetPtr tex)
{
    std::vector<std::string> texture_names;
    texture_names.reserve(cSkyBoxTextureCount);
    
    AssetReferenceList textureList = textureRefs.Get();

    const char * const defaultSkyTextures[cSkyBoxTextureCount] =
    {   "rex_sky_front.dds",
        "rex_sky_back.dds",
        "rex_sky_left.dds",
        "rex_sky_right.dds",
        "rex_sky_top.dds",
        "rex_sky_bot.dds"
    };

    for(size_t i = 0; i < textureAssets.size() || i < cSkyBoxTextureCount; ++i)
        if (i < textureAssets.size() && textureAssets[i])
        {
            AssetPtr asset = textureAssets[i]->Asset();
            TextureAsset *textureAsset = dynamic_cast<TextureAsset*>(asset.get());
            if (textureAsset)
                texture_names.push_back(textureAsset->ogreAssetName.toStdString());
            else
                texture_names.push_back(defaultSkyTextures[i]);
        }
        else
            texture_names.push_back(defaultSkyTextures[i]);

    assert(texture_names.size() == cSkyBoxTextureCount);

    ///\todo Use AssetAPI for the material.
    Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(materialRef.Get().ref.toStdString().c_str());
    if (materialPtr.isNull())
    {
        LogError("EC_Sky::OnTextureAssetLoaded: Cannot find Ogre material \"" + materialRef.Get().ref.toStdString() + "\"!");
        return;
    }
    if (materialPtr->getNumTechniques() == 0 || materialPtr->getTechnique(0) == 0 ||
        materialPtr->getTechnique(0)->getNumPasses() == 0 || materialPtr->getTechnique(0)->getPass(0) == 0 ||
        materialPtr->getTechnique(0)->getPass(0)->getNumTextureUnitStates() == 0 ||
        materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0) == 0)
    {
        LogError("EC_Sky::OnTextureAssetLoaded: Cannot use material \"" + materialRef.Get().ref.toStdString() + "\" as Skybox material: It has 0 techniques, passes or texture unit states!");
        return;
    }

    materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setCubicTextureName(&texture_names[0], false);
    
    CreateSky();    
}
Beispiel #10
0
void XmlPrinterTest::testPrintRemovedCuttingTool()
{
  vector<AssetPtr> assets;
  
  string document = getFile("asset1.xml");
  AssetPtr asset = config->parseAsset("KSSP300R4SD43L240.1", "CuttingTool", document);
  asset->setRemoved(true);
  CuttingToolPtr tool = (CuttingTool*) asset.getObject();
  
  
  assets.push_back(asset);
  
  {
    PARSE_XML(XmlPrinter::printAssets(123, 4, 2, assets));
    CPPUNITTEST_ASSERT_XML_PATH_EQUAL(doc, "//m:Assets//m:CuttingTool@removed", "true");
  }
}
Beispiel #11
0
void EC_Mesh::OnMeshAssetLoaded(AssetPtr asset)
{
    OgreMeshAsset *mesh = dynamic_cast<OgreMeshAsset*>(asset.get());
    if (!mesh)
    {
        LogError("OnMeshAssetLoaded: Mesh asset load finished for asset \"" + asset->Name().toStdString() + "\", but downloaded asset was not of type OgreMeshAsset!");
        return;
    }

    QString ogreMeshName = mesh->Name();
    if (mesh)
    {
        if (mesh->ogreMesh.get())
        {
            ogreMeshName = QString::fromStdString(mesh->ogreMesh->getName()).trimmed();

            // Do not reload if all of the following are met
            // 1. Ogre::Entity and Ogre::Mesh are valid (aka this is not the first load for this EC_Mesh) 
            // 2. Mesh name is same (aka asset reference with ogre sanitations)
            // 3. Content hash has not changed (aka data has not changed)
            if (entity_ && entity_->getMesh().get())
            {
                QString currentMeshName = QString::fromStdString(entity_->getMesh()->getName()).trimmed();
                if (currentMeshName == ogreMeshName && mesh->ContentHashChanged() == false)
                    return;
            }
        }
        else
            LogError("OnMeshAssetLoaded: Mesh asset load finished for asset \"" + asset->Name().toStdString() + "\", but Ogre::Mesh pointer was null!");
    }

    SetMesh(ogreMeshName);

    // Force a re-application of the skeleton on this mesh. ///\todo This path should be re-evaluated to see if we have potential performance issues here. -jj.
    if (skeletonAsset->Asset())
        OnSkeletonAssetLoaded(skeletonAsset->Asset());

    // Apply pending materials, these were tried to be applied before the mesh was loaded
    if (!pendingMaterialApplies.empty())
    {
        for(int idx = 0; idx < pendingMaterialApplies.size(); ++idx)
            SetMaterial(idx, pendingMaterialApplies[idx]);
        pendingMaterialApplies.clear();
    }
}
Beispiel #12
0
AssetPtr IAsset::Clone(QString newAssetName) const
{
    assert(assetAPI);
    if (!IsLoaded())
        return AssetPtr();

    AssetPtr existing = assetAPI->GetAsset(newAssetName);
    if (existing)
    {
        LogError("Cannot Clone() asset \"" + Name() + "\" to a new asset \"" + newAssetName + "\": An asset with that name already exists!");
        return AssetPtr();
    }

    std::vector<u8> data;
    bool success = SerializeTo(data);
    if (!success)
    {
        LogError("Cannot Clone() asset \"" + Name() + "\" to a new asset \"" + newAssetName + "\": Serializing the asset failed!");
        return AssetPtr();
    }
    if (data.size() == 0)
    {
        LogError("Cannot Clone() asset \"" + Name() + "\" to a new asset \"" + newAssetName + "\": Asset serialization succeeded with zero size!");
        return AssetPtr();
    }

    AssetPtr newAsset = assetAPI->CreateNewAsset(this->Type(), newAssetName);
    if (!newAsset)
    {
        LogError("Cannot Clone() asset \"" + Name() + "\" to a new asset \"" + newAssetName + "\": AssetAPI::CreateNewAsset failed!");
        return AssetPtr();
    }

    // Do not allow asynchronous loading due the caller of this 
    // expects the asset to be usable when this function returns.
    success = newAsset->LoadFromFileInMemory(&data[0], data.size(), false);
    if (!success)
    {
        LogError("Cannot Clone() asset \"" + Name() + "\" to a new asset \"" + newAssetName + "\": Deserializing the new asset from bytes failed!");
        assetAPI->ForgetAsset(newAsset, false);
        return AssetPtr();
    }

    return newAsset;
}
void AssetRefListener::OnAssetCreated(AssetPtr assetData)
{
    if (assetData.Get() && !currentWaitingRef.Empty() && currentWaitingRef == assetData->Name())
    {
        /// @todo Remove this logic once a EC_Material + EC_Mesh behaves correctly without failed requests, see generated:// logic in HandleAssetRefChange.
        /** Log the same message as before for non generated:// refs. This is good to do
            because AssetAPI has now said the request failed, so user might be confused when it still works. */
        if (!currentWaitingRef.ToLower().StartsWith("generated://"))
            LogInfo("AssetRefListener: Asset \"" + assetData->Name() + "\" was created, applying after it loads.");

        // The asset we are waiting for has been created, hook to the IAsset::Loaded signal.
        currentWaitingRef = "";
        asset = assetData;
        assetData->Loaded.Connect(this, &AssetRefListener::OnAssetLoaded);
        if (myAssetAPI)
            myAssetAPI->AssetCreated.Disconnect(this, &AssetRefListener::OnAssetCreated);
    }
}
Beispiel #14
0
	AssetPtr AssetManager::LoadAsset(const boost::filesystem::path& file)
	{
		AssetPtr pAsset = FindAsset(file);
		if(pAsset)
		{
			pAsset->IncRef();
			return pAsset;
		}

		AssetLoader loader = FindLoader(file);
		if(loader)
		{
			return AssetPtr();
		}
		pAsset = loader(file);

		m_assets[file.string()] = pAsset;
		return pAsset;
	}
Beispiel #15
0
void EC_Mesh::OnSkeletonAssetLoaded(AssetPtr asset)
{
    OgreSkeletonAsset *skeletonAsset = dynamic_cast<OgreSkeletonAsset*>(asset.get());
    if (!skeletonAsset)
    {
        LogError("OnSkeletonAssetLoaded: Skeleton asset load finished for asset \"" +
            asset->Name().toStdString() + "\", but downloaded asset was not of type OgreSkeletonAsset!");
        return;
    }

    Ogre::SkeletonPtr skeleton = skeletonAsset->ogreSkeleton;
    if (skeleton.isNull())
    {
        LogError("OnSkeletonAssetLoaded: Skeleton asset load finished for asset \"" +
            asset->Name().toStdString() + "\", but Ogre::Skeleton pointer was null!");
        return;
    }

    if(!entity_)
    {
        LogDebug("Could not set skeleton yet because entity is not yet created");
        return;
    }

    try
    {
        // If old skeleton is same as a new one no need to replace it.
        if (entity_->getSkeleton() && entity_->getSkeleton()->getName() == skeleton->getName())
            return;
        
        entity_->getMesh()->_notifySkeleton(skeleton);
        
//        LogDebug("Set skeleton " + skeleton->getName() + " to mesh " + entity_->getName());
        emit SkeletonChanged(QString::fromStdString(skeleton->getName()));
    }
    catch (...)
    {
        LogError("Exception while setting skeleton to mesh" + entity_->getName());
    }

    // Now we have to recreate the entity to get proper animations etc.
    SetMesh(entity_->getMesh()->getName().c_str(), false);
}
Beispiel #16
0
void RigidBody::OnCollisionMeshAssetLoaded(AssetPtr asset)
{
    IMeshAsset* meshAsset = dynamic_cast<IMeshAsset*>(asset.Get());
    if (!meshAsset)
        LogError("RigidBody::OnCollisionMeshAssetLoaded: Mesh asset load finished for asset \"" +
            asset->Name() + "\", but asset pointer was null!");

    if (shapeType.Get() == TriMesh)
    {
        impl->triangleMesh = impl->owner->GetTriangleMeshFromMeshAsset(meshAsset);
        CreateCollisionShape();
    }
    else if (shapeType.Get() == ConvexHull)
    {
        impl->convexHullSet = impl->owner->GetConvexHullSetFromMeshAsset(meshAsset);
        CreateCollisionShape();
    }

    impl->cachedShapeType = shapeType.Get();
    impl->cachedSize = size.Get();
}
Beispiel #17
0
void EC_MediaPlayer::OnMediaLoaded(AssetPtr asset)
{
    pendingMediaDownload_ = false;

    // Double check that same source finished as we have in the attribute.
    if (asset->Name() != getsourceRef().ref.trimmed())
        return;

    // Load media from local file
    QString diskSource = asset->DiskSource();
    if (!diskSource.isEmpty())
    {
        // Feed native separators for VLC
        if (!mediaPlayer_->LoadMedia(QDir::toNativeSeparators(diskSource)))
            LogError("EC_MediaPlayer: Source not supported: " + asset->Name());
        else
        {
            LogInfo("EC_MediaPlayer: Loaded source media after download '" + asset->Name() + "'");
            emit MediaDownloaded(true, asset->Name());
            mediaPlayer_->ForceUpdateImage();
        }
    }
    else
        LogError("EC_MediaPlayer: Downloaded media '" + asset->Name() + "' disk source is empty! Broken/disabled asset cache?");
}
Beispiel #18
0
// CuttingTool tests
void XmlPrinterTest::testPrintExtendedCuttingTool()
{
  vector<AssetPtr> assets;
  
  
  XmlPrinter::addAssetsNamespace("urn:Example.com:Assets:1.3",
                                  "/schemas/MTConnectAssets_1.3.xsd",
                                  "x");

  string document = getFile("ext_asset.xml");
  AssetPtr asset = config->parseAsset("B732A08500HP.1", "CuttingTool", document);
  CuttingToolPtr tool = (CuttingTool*) asset.getObject();
  
  assets.push_back(asset);
  
  {
    PARSE_XML(XmlPrinter::printAssets(123, 4, 2, assets));
    CPPUNITTEST_ASSERT_XML_PATH_EQUAL(doc, "//m:Assets//x:Color", "BLUE");
  }
  
  XmlPrinter::clearAssetsNamespaces();
}
Beispiel #19
0
QByteArray QtUiAsset::GetRefReplacedAssetData() const
{
    if (originalData.size() == 0)
        return QByteArray();
    QByteArray refRewrittenData((const char *)&originalData[0], originalData.size());

    // The AssetRef indices need to be adjusted with an offset after rewriting each ref, since the lengths of the refs change in the file.
    // This variable tracks the accumulated byte offset that takes this into account.
    int indexAdjustment = 0;

    for(size_t i = 0; i < refs.size(); ++i)
    {
        QString assetDiskSource = "";
        AssetPtr asset = assetAPI->GetAsset(refs[i].parsedRef);
        if (!asset.get())
        {
            LogError("ReplaceAssetReferences: Asset not found from asset system even when it was marked as a dependency earlier, skipping: " + refs[i].parsedRef.toStdString());
        }
        else
        {
            assetDiskSource = asset->DiskSource();
            if (assetDiskSource.isEmpty())
                LogWarning("ReplaceAssetReferences: Asset disk source empty, skipping: " + refs[i].parsedRef.toStdString());
        }
        assetDiskSource = assetDiskSource.trimmed();
        if (!assetDiskSource.isEmpty() && QFile::exists(assetDiskSource))
        {
            QByteArray refAsByteArray = (QString("\"") + assetDiskSource + QString("\"")).toUtf8();
            refRewrittenData.replace(refs[i].index + indexAdjustment, refs[i].length, refAsByteArray);
            indexAdjustment += refAsByteArray.length() - refs[i].length;
        }
        else
        {
            LogWarning("ReplaceAssetReferences: Asset disk source does not exist, skipping: " + refs[i].parsedRef.toStdString());
        }
    }
    return refRewrittenData;
}
 void OnSignal(AssetPtr param0)
 {
     duk_context* ctx = ctx_;
     duk_push_global_object(ctx);
     duk_get_prop_string(ctx, -1, "_OnSignal");
     duk_remove(ctx, -2);
     duk_push_number(ctx, (size_t)key_);
     duk_push_array(ctx);
     PushWeakObject(ctx, param0.Get());
     duk_put_prop_index(ctx, -2, 0);
     bool success = duk_pcall(ctx, 2) == 0;
     if (!success) LogError("[JavaScript] OnSignal: " + GetErrorString(ctx));
     duk_pop(ctx);
 }
Beispiel #21
0
TEST(Engine, PackageObjectTest)
{
    {
        AssetPath testPath;
        HELIUM_VERIFY( testPath.Set( HELIUM_PACKAGE_PATH_CHAR_STRING TXT( "EngineTest" ) HELIUM_OBJECT_PATH_CHAR_STRING TXT( "TestObject" ) ) );

        AssetPtr spObject;
        HELIUM_VERIFY( gAssetLoader->LoadObject( testPath, spObject ) );
        HELIUM_ASSERT( spObject );

        Package* pTestPackageCast = Reflect::SafeCast< Package >( spObject.Get() );
        HELIUM_ASSERT( !pTestPackageCast );
        HELIUM_UNREF( pTestPackageCast );

        // The following line should not compile...
        //            Animation* pTestAnimationCast = Reflect::SafeCast< Animation >( pTestPackageCast );
        //            HELIUM_UNREF( pTestAnimationCast );

        Asset* pTestObjectCast = Reflect::SafeCast< Asset >( spObject.Get() );
        HELIUM_ASSERT( pTestObjectCast );
        HELIUM_UNREF( pTestObjectCast );
    }
}
Beispiel #22
0
std::vector<AssetReference> IAsset::FindReferencesRecursive() const
{
    std::set<AssetReference> refs;

    std::vector<AssetReference> unwalkedRefs = FindReferences();
    while(unwalkedRefs.size() > 0)
    {
        AssetReference ref = unwalkedRefs.back();
        unwalkedRefs.pop_back();
        if (refs.find(ref) == refs.end())
        {
            refs.insert(ref);
            AssetPtr asset = assetAPI->GetAsset(ref.ref);
            if (asset)
            {
                std::vector<AssetReference> newRefs = asset->FindReferences();
                unwalkedRefs.insert(unwalkedRefs.end(), newRefs.begin(), newRefs.end());
            }
        }
    }

    std::vector<AssetReference> finalRefs(refs.begin(), refs.end());
    return finalRefs;
}
bool Agent::updateAsset (Device *aDevice, const std::string & aId, AssetChangeList & aList,
                         const string & aTime)
{
    AssetPtr asset;
    string   time;

    if ( aTime.empty( ) )
    {
        time = getCurrentTime(GMT_UV_SEC);
    }
    else
    {
        time = aTime;
    }

    {
        dlib::auto_mutex lock(*mAssetLock);

        asset = mAssetMap[aId];

        if ( asset.getObject( ) == NULL )
        {
            return false;
        }

        if ( asset->getType( ) != "CuttingTool" )
        {
            return false;
        }

        CuttingToolPtr tool((CuttingTool *) asset.getObject( ));

        AssetChangeList::iterator iter;

        for ( iter = aList.begin( ); iter != aList.end( ); ++iter )
        {
            if ( iter->first == "xml" )
            {
                mXmlParser->updateAsset(asset, asset->getType( ), iter->second);
            }
            else
            {
                tool->updateValue(iter->first, iter->second);
            }
        }
        tool->setTimestamp(aTime);
        tool->setDeviceUuid(aDevice->getUuid( ));
        tool->changed( );
    }

    addToBuffer(aDevice->getAssetChanged( ), asset->getType( ) + "|" + aId, time);

    return true;
}
Beispiel #24
0
void OgreScriptEditor::SetScriptAsset(const AssetPtr &scriptAsset)
{
    asset = scriptAsset;
    assert(asset.lock());
    AssetPtr assetPtr = asset.lock();
    if (!assetPtr)
        LogError("OgreScriptEditor: null asset given.");
    if (assetPtr->Type() != "OgreMaterial" && assetPtr->Type() != "OgreParticle")
        LogWarning("Created OgreScriptEditor for non-supported asset type " + assetPtr->Type() + ".");

    lineEditName->setText((assetPtr?assetPtr->Name():QString()));
    setWindowTitle(tr("OGRE Script Editor:") + (assetPtr?assetPtr->Name():QString()));

    if (assetPtr && !assetPtr->IsLoaded())
    {
        AssetTransferPtr transfer = framework->Asset()->RequestAsset(assetPtr->Name(), assetPtr->Type(), true);
        connect(transfer.get(), SIGNAL(Succeeded(AssetPtr)), this, SLOT(OnAssetTransferSucceeded(AssetPtr)));
        connect(transfer.get(), SIGNAL(Failed(IAssetTransfer *, QString)), SLOT(OnAssetTransferFailed(IAssetTransfer *, QString)));
    }
void AssetRefListListener::OnAssetLoaded(AssetPtr asset)
{
    if (!asset)
        return;

    bool signaled = false;
    String completedRef = asset->Name();
    for(uint i = 0; i < current_.Size(); ++i)
    {
        const AssetReference &ref = current_[i];
        if (ref.ref.Compare(completedRef, false) == 0)
        {
            // Don't break/return. Same asset might be in multiple indexes!
            Loaded.Emit(i, asset);
            signaled = true;
        }
    }
    if (!signaled)
        LogWarning("AssetRefListListener: Failed to signal completion of " + completedRef + ". The asset ref is unknown to the local state.");
}
Beispiel #26
0
void Sky::OnMaterialAssetLoaded(AssetPtr asset)
{
    IMaterialAsset* mAsset = dynamic_cast<IMaterialAsset*>(asset.Get());

    if (mAsset)
    {
        material_.Reset();
        material_ = Urho3D::DynamicCast<IMaterialAsset>(asset);

        if (mAsset->textures_.Size() >= 6)
        {
            AssetReferenceList list;
            for (int i=0 ; i<6 ; ++i)
                list.Append(mAsset->textures_[i].second_);

            textureRefs.Set(list, AttributeChange::LocalOnly);
            // Update call is implicit via OnTextureAssetLoaded()
        }
        else
            Update();
    }
}
Beispiel #27
0
bool Agent::addAsset(Device *aDevice, const string &aId, const string &aAsset,
                     const string &aType,
                     const string &aTime)
{
    // Check to make sure the values are present
    if (aType.empty() || aAsset.empty() || aId.empty()) {
        sLogger << LWARN << "Asset '" << aId << "' missing required type, id, or body. Asset is rejected.";
        return false;
    }

    string time;
    if (aTime.empty())
        time = getCurrentTime(GMT_UV_SEC);
    else
        time = aTime;


    // Lock the asset addition to protect from multithreaded collisions. Releaes
    // before we add the event so we don't cause a race condition.
    {
        dlib::auto_mutex lock(*mAssetLock);

        AssetPtr old = mAssetMap[aId];
        if (old.getObject() != NULL)
            mAssets.remove(old);
        else
            mAssetCounts[aType] += 1;

        AssetPtr ptr;
        if (aType == "CuttingTool") {
            try {
                ptr = mXmlParser->parseAsset(aId, aType, aAsset);
            }
            catch (runtime_error &e) {
                sLogger << LERROR << "addAsset: Error parsing asset: " << aAsset << "\n" << e.what();
                return false;
            }
        } else {
            ptr.setObject(new Asset(aId, aType, aAsset), true);
            ptr->setTimestamp(time);
            ptr->setDeviceUuid(aDevice->getUuid());
        }

        if (ptr.getObject() == NULL) {
            sLogger << LWARN << "Asset could not be created";
            return false;
        } else {
            if (ptr->getTimestamp().empty())
                ptr->setTimestamp(time);
            if (ptr->getDeviceUuid().empty())
                ptr->setDeviceUuid(aDevice->getUuid());
        }

        // Check for overflow
        if (mAssets.size() >= mMaxAssets)
        {
            old = mAssets.front();
            mAssetCounts[old->getType()] -= 1;
            mAssets.pop_front();
            mAssetMap.erase(old->getAssetId());
        }

        mAssetMap[aId] = ptr;
        mAssets.push_back(ptr);

        // Add secondary keys
        AssetKeys &keys = ptr->getKeys();
        AssetKeys::iterator iter;
        for (iter = keys.begin(); iter != keys.end(); iter++)
        {
            AssetIndex &index = mAssetIndices[iter->first];
            index[iter->second] = ptr;
        }
    }

    // Generate an asset chnaged event.
    addToBuffer(aDevice->getAssetChanged(), aType + "|" + aId, time);

    return true;
}
void AssetRefListener::HandleAssetRefChange(AssetAPI *assetApi, String assetRef, const String& assetType)
{
    // Disconnect from any previous transfer we might be listening to
    if (!currentTransfer.Expired())
    {
        IAssetTransfer* current = currentTransfer.Get();
        current->Succeeded.Disconnect(this, &AssetRefListener::OnTransferSucceeded);
        current->Failed.Disconnect(this, &AssetRefListener::OnTransferFailed);
        currentTransfer.Reset();
    }
    
    assert(assetApi);

    // Store AssetAPI ptr for later signal hooking.
    if (!myAssetAPI)
        myAssetAPI = assetApi;

    // If the ref is empty, don't go any further as it will just trigger the LogWarning below.
    assetRef = assetRef.Trimmed();
    if (assetRef.Empty())
    {
        asset = AssetPtr();
        return;
    }
    currentWaitingRef = "";

    // Resolve the protocol for generated:// assets. These assets are never meant to be
    // requested from AssetAPI, they cannot be fetched from anywhere. They can only be either
    // loaded or we must wait for something to load/create them.
    String protocolPart = "";
    assetApi->ParseAssetRef(assetRef, &protocolPart);
    if (protocolPart.ToLower() == "generated")
    {
        AssetPtr loadedAsset = assetApi->FindAsset(assetRef);
        if (loadedAsset.Get() && loadedAsset->IsLoaded())
        {
            // Asset is loaded, emit Loaded with 1 msec delay to preserve the logic
            // that HandleAssetRefChange won't emit anything itself as before.
            // Otherwise existing connection can break/be too late after calling this function.
            asset = loadedAsset;
            assetApi->GetFramework()->Frame()->DelayedExecute(0.0f).Connect(this, &AssetRefListener::EmitLoaded);
            return;
        }
        else
        {
            // Wait for it to be created.
            currentWaitingRef = assetRef;
            myAssetAPI->AssetCreated.Connect(this, &AssetRefListener::OnAssetCreated);
        }
    }
    else
    {
        // This is not a generated asset, request normally from asset api.
        AssetTransferPtr transfer = assetApi->RequestAsset(assetRef, assetType);
        if (!transfer)
        {
            LogWarning("AssetRefListener::HandleAssetRefChange: Asset request for asset \"" + assetRef + "\" failed.");
            return;
        }
        currentWaitingRef = assetRef;

        transfer->Succeeded.Connect(this, &AssetRefListener::OnTransferSucceeded);
        transfer->Failed.Connect(this, &AssetRefListener::OnTransferFailed);

        currentTransfer = transfer;
    }
    
    // Disconnect from the old asset's load signal
    if (asset)
        asset->Loaded.Disconnect(this, &AssetRefListener::OnAssetLoaded);
    asset = AssetPtr();
}
void AssetRefListener::EmitLoaded(float /*time*/)
{
    AssetPtr currentAsset = asset.Lock();
    if (currentAsset.Get())
        Loaded.Emit(currentAsset);
}
Beispiel #30
0
int APIENTRY _tWinMain( HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpCmdLine*/, int nCmdShow )
{
	ForceLoadComponentsDll();

#if HELIUM_TOOLS
	ForceLoadEditorSupportDll();
#endif

	HELIUM_TRACE_SET_LEVEL( TraceLevels::Debug );

	Timer::StaticInitialize();
	
#if !HELIUM_RELEASE && !HELIUM_PROFILE
	Helium::InitializeSymbols();
#endif

	AsyncLoader::GetStaticInstance().Initialize();

	FilePath baseDirectory;
	if ( !FileLocations::GetBaseDirectory( baseDirectory ) )
	{
		HELIUM_TRACE( TraceLevels::Error, TXT( "Could not get base directory." ) );
		return -1;
	}

	HELIUM_VERIFY( CacheManager::InitializeStaticInstance( baseDirectory ) );
	Helium::Bullet::Initialize();

	int resultCode = -1;

	{
	Reflect::Initialize();

	Helium::Components::Initialize();
	
	Helium::TaskScheduler::CalculateSchedule();

#if HELIUM_TOOLS
#endif

	InitEngineJobsDefaultHeap();
	InitGraphicsJobsDefaultHeap();
	InitTestJobsDefaultHeap();

#if HELIUM_TOOLS
	//HELIUM_VERIFY( LooseAssetLoader::InitializeStaticInstance() );
	HELIUM_VERIFY( LooseAssetLoader::InitializeStaticInstance() );

	AssetPreprocessor* pAssetPreprocessor = AssetPreprocessor::CreateStaticInstance();
	HELIUM_ASSERT( pAssetPreprocessor );
	PlatformPreprocessor* pPlatformPreprocessor = new PcPreprocessor;
	HELIUM_ASSERT( pPlatformPreprocessor );
	pAssetPreprocessor->SetPlatformPreprocessor( Cache::PLATFORM_PC, pPlatformPreprocessor );
#else
	HELIUM_VERIFY( CacheAssetLoader::InitializeStaticInstance() );
#endif

#if !GTEST
	AssetLoader* gAssetLoader = NULL;
#endif

	gAssetLoader = AssetLoader::GetStaticInstance();
	HELIUM_ASSERT( gAssetLoader );

	Config& rConfig = Config::GetStaticInstance();
	rConfig.BeginLoad();
	while( !rConfig.TryFinishLoad() )
	{
		gAssetLoader->Tick();
	}

#if HELIUM_TOOLS
	ConfigPc::SaveUserConfig();
#endif

	uint32_t displayWidth;
	uint32_t displayHeight;
	//bool bFullscreen;
	bool bVsync;
	
	{
		StrongPtr< GraphicsConfig > spGraphicsConfig(
			rConfig.GetConfigObject< GraphicsConfig >( Name( TXT( "GraphicsConfig" ) ) ) );
		HELIUM_ASSERT( spGraphicsConfig );
		displayWidth = spGraphicsConfig->GetWidth();
		displayHeight = spGraphicsConfig->GetHeight();
		//bFullscreen = spGraphicsConfig->GetFullscreen();
		bVsync = spGraphicsConfig->GetVsync();
	}

	WNDCLASSEXW windowClass;
	windowClass.cbSize = sizeof( windowClass );
	windowClass.style = 0;
	windowClass.lpfnWndProc = WindowProc;
	windowClass.cbClsExtra = 0;
	windowClass.cbWndExtra = 0;
	windowClass.hInstance = hInstance;
	windowClass.hIcon = NULL;
	windowClass.hCursor = NULL;
	windowClass.hbrBackground = NULL;
	windowClass.lpszMenuName = NULL;
	windowClass.lpszClassName = L"HeliumTestAppClass";
	windowClass.hIconSm = NULL;
	HELIUM_VERIFY( RegisterClassEx( &windowClass ) );

	WindowData windowData;
	windowData.hMainWnd = NULL;
	windowData.hSubWnd = NULL;
	windowData.bProcessMessages = true;
	windowData.bShutdownRendering = false;
	windowData.resultCode = 0;

	DWORD dwStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU;
	RECT windowRect;

	windowRect.left = 0;
	windowRect.top = 0;
	windowRect.right = static_cast< LONG >( displayWidth );
	windowRect.bottom = static_cast< LONG >( displayHeight );
	HELIUM_VERIFY( AdjustWindowRect( &windowRect, dwStyle, FALSE ) );

	HWND hMainWnd = ::CreateWindowW(
		L"HeliumTestAppClass",
		L"Helium TestApp",
		dwStyle,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		windowRect.right - windowRect.left,
		windowRect.bottom - windowRect.top,
		NULL,
		NULL,
		hInstance,
		NULL );
	HELIUM_ASSERT( hMainWnd );

	windowRect.left = 0;
	windowRect.top = 0;
	windowRect.right = static_cast< LONG >( displayWidth );
	windowRect.bottom = static_cast< LONG >( displayHeight );
	HELIUM_VERIFY( AdjustWindowRect( &windowRect, dwStyle, FALSE ) );
#if MULTI_WINDOW
	HWND hSubWnd = ::CreateWindowW(
		L"HeliumTestAppClass",
		L"Helium TestApp (second view)",
		dwStyle,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		windowRect.right - windowRect.left,
		windowRect.bottom - windowRect.top,
		NULL,
		NULL,
		hInstance,
		NULL );
	HELIUM_ASSERT( hSubWnd );
#endif

	windowData.hMainWnd = hMainWnd;
	SetWindowLongPtr( hMainWnd, GWLP_USERDATA, reinterpret_cast< LONG_PTR >( &windowData ) );
	ShowWindow( hMainWnd, nCmdShow );
	UpdateWindow( hMainWnd );
#if MULTI_WINDOW
	windowData.hSubWnd = hSubWnd;
	SetWindowLongPtr( hSubWnd, GWLP_USERDATA, reinterpret_cast< LONG_PTR >( &windowData ) );
	ShowWindow( hSubWnd, nCmdShow );
	UpdateWindow( hSubWnd );
#endif

	HELIUM_VERIFY( D3D9Renderer::CreateStaticInstance() );

	Renderer* pRenderer = Renderer::GetStaticInstance();
	HELIUM_ASSERT( pRenderer );
	pRenderer->Initialize();

	Renderer::ContextInitParameters contextInitParams;

	contextInitParams.pWindow = hMainWnd;
	contextInitParams.displayWidth = displayWidth;
	contextInitParams.displayHeight = displayHeight;
	contextInitParams.bVsync = bVsync;
	HELIUM_VERIFY( pRenderer->CreateMainContext( contextInitParams ) );
#if MULTI_WINDOW
	contextInitParams.pWindow = hSubWnd;
	RRenderContextPtr spSubRenderContext = pRenderer->CreateSubContext( contextInitParams );
	HELIUM_ASSERT( spSubRenderContext );
#endif

	Input::Initialize(&hMainWnd, false);

	{
		AssetPath prePassShaderPath;
		HELIUM_VERIFY( prePassShaderPath.Set(
			HELIUM_PACKAGE_PATH_CHAR_STRING TXT( "Shaders" ) HELIUM_OBJECT_PATH_CHAR_STRING TXT( "PrePass.hlsl" ) ) );

		AssetPtr spPrePassShader;
		HELIUM_VERIFY( AssetLoader::GetStaticInstance()->LoadObject( prePassShaderPath, spPrePassShader ) );

		HELIUM_ASSERT( spPrePassShader.Get() );
	}

	RenderResourceManager& rRenderResourceManager = RenderResourceManager::GetStaticInstance();
	rRenderResourceManager.Initialize();
	rRenderResourceManager.UpdateMaxViewportSize( displayWidth, displayHeight );

	//// Create a scene definition
	SceneDefinitionPtr spSceneDefinition;
	gAssetLoader->LoadObject( AssetPath( TXT( "/ExampleGames/Empty/Scenes/TestScene:SceneDefinition" ) ), spSceneDefinition );

	EntityDefinitionPtr spEntityDefinition;
	gAssetLoader->LoadObject( AssetPath( TXT( "/ExampleGames/Empty/Scenes/TestScene:TestBull_Entity" ) ), spEntityDefinition );

	DynamicDrawer& rDynamicDrawer = DynamicDrawer::GetStaticInstance();
	HELIUM_VERIFY( rDynamicDrawer.Initialize() );

	RRenderContextPtr spMainRenderContext = pRenderer->GetMainContext();
	HELIUM_ASSERT( spMainRenderContext );
	
	WorldManager& rWorldManager = WorldManager::GetStaticInstance();
	HELIUM_VERIFY( rWorldManager.Initialize() );

	// Create a world
	WorldPtr spWorld( rWorldManager.CreateWorld( spSceneDefinition ) );
	HELIUM_ASSERT( spWorld );
	HELIUM_TRACE( TraceLevels::Info, TXT( "Created world \"%s\".\n" ), *spSceneDefinition->GetPath().ToString() );

	//Slice *pRootSlice = spWorld->GetRootSlice();
	//Entity *pEntity = pRootSlice->CreateEntity(spEntityDefinition);
			
	GraphicsScene* pGraphicsScene = spWorld->GetComponents().GetFirst<GraphicsManagerComponent>()->GetGraphicsScene();
	HELIUM_ASSERT( pGraphicsScene );
	GraphicsSceneView* pMainSceneView = NULL;
	if( pGraphicsScene )
	{
		uint32_t mainSceneViewId = pGraphicsScene->AllocateSceneView();
		if( IsValid( mainSceneViewId ) )
		{
			float32_t aspectRatio =
				static_cast< float32_t >( displayWidth ) / static_cast< float32_t >( displayHeight );

			RSurface* pDepthStencilSurface = rRenderResourceManager.GetDepthStencilSurface();
			HELIUM_ASSERT( pDepthStencilSurface );

			pMainSceneView = pGraphicsScene->GetSceneView( mainSceneViewId );
			HELIUM_ASSERT( pMainSceneView );
			pMainSceneView->SetRenderContext( spMainRenderContext );
			pMainSceneView->SetDepthStencilSurface( pDepthStencilSurface );
			pMainSceneView->SetAspectRatio( aspectRatio );
			pMainSceneView->SetViewport( 0, 0, displayWidth, displayHeight );
			pMainSceneView->SetClearColor( Color( 0x00202020 ) );

			//spMainCamera->SetSceneViewId( mainSceneViewId );

#if MULTI_WINDOW
			uint32_t subSceneViewId = pGraphicsScene->AllocateSceneView();
			if( IsValid( subSceneViewId ) )
			{
				GraphicsSceneView* pSubSceneView = pGraphicsScene->GetSceneView( subSceneViewId );
				HELIUM_ASSERT( pSubSceneView );
				pSubSceneView->SetRenderContext( spSubRenderContext );
				pSubSceneView->SetDepthStencilSurface( pDepthStencilSurface );
				pSubSceneView->SetAspectRatio( aspectRatio );
				pSubSceneView->SetViewport( 0, 0, displayWidth, displayHeight );
				pSubSceneView->SetClearColor( Color( 0x00202020 ) );

				//spSubCamera->SetSceneViewId( subSceneViewId );
			}
#endif
		}
	
#if !HELIUM_RELEASE && !HELIUM_PROFILE
		BufferedDrawer& rSceneDrawer = pGraphicsScene->GetSceneBufferedDrawer();
		rSceneDrawer.DrawScreenText(
			20,
			20,
			String( TXT( "CACHING" ) ),
			Color( 0xff00ff00 ),
			RenderResourceManager::DEBUG_FONT_SIZE_LARGE );
		rSceneDrawer.DrawScreenText(
			21,
			20,
			String( TXT( "CACHING" ) ),
			Color( 0xff00ff00 ),
			RenderResourceManager::DEBUG_FONT_SIZE_LARGE );

		//rSceneDrawer.Draw

		//Helium::DynamicDrawer &drawer = DynamicDrawer::GetStaticInstance();
		//drawer.
#endif
	}

	rWorldManager.Update();
	
	float time = 0.0f;

#if MULTI_WINDOW
	spSubRenderContext.Release();
#endif
	spMainRenderContext.Release();

	
	Helium::StrongPtr<Helium::Texture2d> texture;
	gAssetLoader->LoadObject( AssetPath( TXT( "/Textures:Triangle.png" ) ), texture);

	Helium::RTexture2d *rTexture2d = texture->GetRenderResource2d();


	while( windowData.bProcessMessages )
	{
#if GRAPHICS_SCENE_BUFFERED_DRAWER
		BufferedDrawer& rSceneDrawer = pGraphicsScene->GetSceneBufferedDrawer();
		rSceneDrawer.DrawScreenText(
			20,
			20,
			String( TXT( "RUNNING" ) ),
			Color( 0xffffffff ),
			RenderResourceManager::DEBUG_FONT_SIZE_LARGE );
		rSceneDrawer.DrawScreenText(
			21,
			20,
			String( TXT( "RUNNING" ) ),
			Color( 0xffffffff ),
			RenderResourceManager::DEBUG_FONT_SIZE_LARGE );

		time += 0.01f;
		DynamicArray<SimpleVertex> verticesU;

		verticesU.New( -100.0f, -100.0f, 750.0f );
		verticesU.New( 100.0f, -100.0f, 750.0f );
		verticesU.New( 100.0f, 100.0f, 750.0f );
		verticesU.New( -100.0f, 100.0f, 750.0f );
		
		rSceneDrawer.DrawLineList( verticesU.GetData(), static_cast<uint32_t>( verticesU.GetSize() ) );
		
		DynamicArray<SimpleTexturedVertex> verticesT;
		verticesT.New( Simd::Vector3( -100.0f, 100.0f, 750.0f ), Simd::Vector2( 0.0f, 0.0f ) );
		verticesT.New( Simd::Vector3( 100.0f, 100.0f, 750.0f ), Simd::Vector2( 1.0f, 0.0f ) );
		verticesT.New( Simd::Vector3( -100.0f, -100.0f, 750.0f ), Simd::Vector2( 0.0f, 1.0f ) );
		verticesT.New( Simd::Vector3( 100.0f, -100.0f, 750.0f ), Simd::Vector2( 1.0f, 1.0f ) );
		

		//rSceneDrawer.DrawTextured(
		//	RENDERER_PRIMITIVE_TYPE_TRIANGLE_STRIP,
		//	verticesT.GetData(),
		//	verticesT.GetSize(),
		//	NULL,
		//	2,
		//	rTexture2d, Helium::Color(1.0f, 1.0f, 1.0f, 1.0f), Helium::RenderResourceManager::RASTERIZER_STATE_DEFAULT, Helium::RenderResourceManager::DEPTH_STENCIL_STATE_NONE);

		//rSceneDrawer.DrawTexturedQuad(rTexture2d);

		Helium::Simd::Matrix44 transform = Helium::Simd::Matrix44::IDENTITY;
		
		Simd::Vector3 location(0.0f, 400.0f, 0.0f);
		Simd::Quat rotation(Helium::Simd::Vector3::BasisZ, time);
		Simd::Vector3 scale(1000.0f, 1000.0f, 1000.0f);
		


		transform.SetRotationTranslationScaling(rotation, location, scale);
		rSceneDrawer.DrawTexturedQuad(rTexture2d, transform, Simd::Vector2(0.0f, 0.0f), Simd::Vector2(0.5f, 0.5f));
#endif
		
		//Helium::Simd::Vector3 up = Simd::Vector3::BasisY;
		////Helium::Simd::Vector3 eye(5000.0f * sin(time), 0.0f, 5000.0f * cos(time));
		//Helium::Simd::Vector3 eye(0.0f, 0.0f, -1000.0f);
		//Helium::Simd::Vector3 forward = Simd::Vector3::Zero - eye;
		//forward.Normalize();

		////pMainSceneView->SetClearColor( Color( 0xffffffff ) );
		//pMainSceneView->SetView(eye, forward, up);




		if (Input::IsKeyDown(Input::KeyCodes::KC_A))
		{
			HELIUM_TRACE( TraceLevels::Info, TXT( "A is down" ) );
		}

		if (Input::IsKeyDown(Input::KeyCodes::KC_ESCAPE))
		{
			HELIUM_TRACE( TraceLevels::Info, TXT( "Exiting" ) );
			break;
		}

		MSG message;
		if( PeekMessage( &message, NULL, 0, 0, PM_REMOVE ) )
		{
			TranslateMessage( &message );
			DispatchMessage( &message );

			if( windowData.bShutdownRendering )
			{
				if( spWorld )
				{
					spWorld->Shutdown();
				}

				spWorld.Release();
				WorldManager::DestroyStaticInstance();

				spSceneDefinition.Release();
				spEntityDefinition.Release();

				DynamicDrawer::DestroyStaticInstance();
				RenderResourceManager::DestroyStaticInstance();

				Renderer::DestroyStaticInstance();

				break;
			}

			if( message.message == WM_QUIT )
			{
				windowData.bProcessMessages = false;
				windowData.resultCode = static_cast< int >( message.wParam );
				resultCode = static_cast< int >( message.wParam );

				break;
			}
		}

		rWorldManager.Update();

#if GRAPHICS_SCENE_BUFFERED_DRAWER
		if( pGraphicsScene )
		{
			BufferedDrawer& rSceneDrawer = pGraphicsScene->GetSceneBufferedDrawer();
			rSceneDrawer.DrawScreenText(
				20,
				20,
				String( TXT( "Debug text test!" ) ),
				Color( 0xffffffff ) );
		}
#endif
	}

	if( spWorld )
	{
		spWorld->Shutdown();
	}

	spWorld.Release();
	}
	WorldManager::DestroyStaticInstance();
	

	DynamicDrawer::DestroyStaticInstance();
	RenderResourceManager::DestroyStaticInstance();

	Helium::Input::Cleanup();

	Renderer::DestroyStaticInstance();
	

	JobManager::DestroyStaticInstance();

	Config::DestroyStaticInstance();

#if HELIUM_TOOLS
	AssetPreprocessor::DestroyStaticInstance();
#endif
	AssetLoader::DestroyStaticInstance();
	CacheManager::DestroyStaticInstance();
	
	Helium::Components::Cleanup();
	

	Reflect::Cleanup();
	AssetType::Shutdown();
	Asset::Shutdown();


	Reflect::ObjectRefCountSupport::Shutdown();
	Helium::Bullet::Cleanup();

	AssetPath::Shutdown();
	Name::Shutdown();

	FileLocations::Shutdown();

	ThreadLocalStackAllocator::ReleaseMemoryHeap();

#if HELIUM_ENABLE_MEMORY_TRACKING
	DynamicMemoryHeap::LogMemoryStats();
	ThreadLocalStackAllocator::ReleaseMemoryHeap();
#endif

	return resultCode;
}