void Tribe::HandlePersistItem(gemNPCItem* item) { csVector3 position; iSector* sector; psGameObject::GetPosition(item,position,sector); // Check if we have this item as an asset Asset* asset = GetAsset(item->GetUID()); if(asset) { asset->item = item; } else { // TODO: Find buildings and items and add them seperate, for now add as BUILDING. asset = GetAsset(Tribe::ASSET_TYPE_BUILDING, item->GetName(), position, sector); if(asset) { asset->item = item; asset->itemUID = item->GetUID(); SaveAsset(asset); } else { // Add the new tribe item as an asset. asset = AddAsset(Tribe::ASSET_TYPE_BUILDING, item->GetName(), position, sector, Tribe::ASSET_STATUS_CONSTRUCTED); asset->item = item; asset->itemUID = item->GetUID(); SaveAsset(asset); } } }
Ground::Ground() { AddAsset("main", "Assets/Environment/Ground.png"); SetCurrentAsset("main"); SetHitbox(3840, 100); SetSpeed(0); SetPhaseState(false); SetFloatState(true); }
/** * ImageManager::Initialize * Allocates memory for the ImageWrap array and loads in all the image files. */ void ImageManager::Init() { // TODO: This does not belong in the engine code. std::string name = "default"; ImageWrap imgDefault("assets/gfx/default.png", name); AddAsset( name, imgDefault ); name = "stick"; ImageWrap imgStick("assets/gfx/stick.png", name); AddAsset( name, imgStick ); name = "player"; ImageWrap imgPlayer("assets/gfx/delphine.png", name); AddAsset( name, imgPlayer ); name = "grass"; ImageWrap imgGrass("assets/gfx/fluffy-grass.png", name); AddAsset( name, imgGrass ); }
void ChPathFollowerDriver::Create() { // Reset the steering and speed controllers m_steeringPID.Reset(m_vehicle); m_speedPID.Reset(m_vehicle); // Create a fixed body to carry a visualization asset for the path auto road = std::shared_ptr<ChBody>(m_vehicle.GetSystem()->NewBody()); road->SetBodyFixed(true); m_vehicle.GetSystem()->AddBody(road); auto path_asset = std::make_shared<ChLineShape>(); path_asset->SetLineGeometry(std::make_shared<geometry::ChLineBezier>(m_steeringPID.GetPath())); path_asset->SetColor(ChColor(0.0f, 0.8f, 0.0f)); path_asset->SetName(m_pathName); road->AddAsset(path_asset); }
GLuint GLReadTexture(const char* pFilename) { if (pFilename[0] == 0) return 0xFFFFFFFF; TextureAsset* pAss; if (TextureExists(pFilename)) { pAss = gTextures[pFilename]; } else { char pPath[1024]; sprintf(pPath, "meshes/textures/%s", pFilename); AddAsset(pFilename, LoadImageG(pPath)); pAss = gTextures[pFilename]; if (pAss->im != NULL) { MakeGLTexture(pAss); } else { printf("**** Tex %s read failed\n", pFilename); } } return pAss->glTextureID; }
void AssetsWindow::Initialize() { // Init main widget setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("Assets")); // Append asset type if we're viewing only assets of specific type. if (!assetType.isEmpty()) setWindowTitle(windowTitle() + ": " + assetType); resize(300, 400); QVBoxLayout *layout = new QVBoxLayout(this); layout->setContentsMargins(5, 5, 5, 5); setLayout(layout); // Create child widgets treeWidget = new AssetTreeWidget(framework, this); treeWidget->setHeaderHidden(true); searchField = new QLineEdit(this); searchField->setText(tr("Search...")); searchField->setStyleSheet("color:grey;"); searchField->installEventFilter(this); expandAndCollapseButton = new QPushButton(tr("Expand All"), this); QHBoxLayout *hlayout= new QHBoxLayout; hlayout->addWidget(searchField); hlayout->addWidget(expandAndCollapseButton); layout->addLayout(hlayout); layout->addWidget(treeWidget); connect(searchField, SIGNAL(textEdited(const QString &)), SLOT(Search(const QString &))); connect(expandAndCollapseButton, SIGNAL(clicked()), SLOT(ExpandOrCollapseAll())); connect(framework->Asset(), SIGNAL(AssetCreated(AssetPtr)), SLOT(AddAsset(AssetPtr))); connect(framework->Asset(), SIGNAL(AssetAboutToBeRemoved(AssetPtr)), SLOT(RemoveAsset(AssetPtr))); connect(treeWidget, SIGNAL(itemCollapsed(QTreeWidgetItem*)), SLOT(CheckTreeExpandStatus(QTreeWidgetItem*))); connect(treeWidget, SIGNAL(itemExpanded(QTreeWidgetItem*)), SLOT(CheckTreeExpandStatus(QTreeWidgetItem*))); }
void AssetsWindow::PopulateTreeWidget() { treeWidget->clear(); alreadyAdded.clear(); // Create "No provider" for assets without storage. noProviderItem = new QTreeWidgetItem; noProviderItem->setText(0, tr("No provider")); AssetStoragePtr defaultStorage = framework->Asset()->GetDefaultAssetStorage(); foreach(const AssetStoragePtr &storage, framework->Asset()->GetAssetStorages()) { AssetStorageItem *item = new AssetStorageItem(storage); //item->setText(0, storage->ToString()); treeWidget->addTopLevelItem(item); // item->setData(0, Qt::UserRole, QVariant(storage->Name())); // The current default storage is bolded. if (storage == defaultStorage) { QFont font = item->font(0); font.setBold(true); item->setFont(0, font); } } std::pair<QString, AssetPtr> pair; foreach(pair, framework->Asset()->GetAllAssets()) if (alreadyAdded.find(pair.second) == alreadyAdded.end()) { // If we're viewing only specific asset type, ignore non-matching assets. if (!assetType.isEmpty() && assetType != pair.second->Type() && assetType != "Binary" ) continue; AddAsset(pair.second); } treeWidget->addTopLevelItem(noProviderItem); noProviderItem->setHidden(noProviderItem->childCount() == 0); }
void CPUTAssetLibrary::AddModel(const std::string &name, const std::string prefixDecoration, const std::string suffixDecoration, CPUTModel *pModel) { AddAsset(name, prefixDecoration, suffixDecoration, pModel, mpModelList); }
void CPUTAssetLibrary::AddRenderStateBlock(const std::string &name, const std::string prefixDecoration, const std::string suffixDecoration, CPUTRenderStateBlock *pRenderStateBlock) { AddAsset(name, prefixDecoration, suffixDecoration, pRenderStateBlock, mpRenderStateBlockList); }
void CPUTAssetLibrary::AddMaterial(const std::string &name, const std::string prefixDecoration, const std::string suffixDecoration, CPUTMaterial *pMaterial) { AddAsset(name, prefixDecoration, suffixDecoration, pMaterial, mpMaterialList); }
void CPUTAssetLibrary::AddLight(const std::string &name, const std::string prefixDecoration, const std::string suffixDecoration, CPUTLight *pLight) { AddAsset(name, prefixDecoration, suffixDecoration, pLight, mpLightList); }
void CPUTAssetLibrary::AddCamera(const std::string &name, const std::string prefixDecoration, const std::string suffixDecoration, CPUTCamera *pCamera) { AddAsset(name, prefixDecoration, suffixDecoration, pCamera, mpCameraList); }
void CPUTAssetLibrary::AddFont(const std::string &name, const std::string prefixDecoration, const std::string suffixDecoration, CPUTFont *pFont) { AddAsset(name, prefixDecoration, suffixDecoration, pFont, mpFontList); }
void CPUTAssetLibrary::AddNullNode(const std::string &name, const std::string prefixDecoration, const std::string suffixDecoration, CPUTNullNode *pNullNode) { AddAsset(name, prefixDecoration, suffixDecoration, pNullNode, mpNullNodeList); }
void CPUTAssetLibrary::AddAssetSet(const std::string &name, const std::string prefixDecoration, const std::string suffixDecoration, CPUTAssetSet *pAssetSet) { AddAsset(name, prefixDecoration, suffixDecoration, pAssetSet, mpAssetSetList); }
void CPUTAssetLibrary::AddConstantBuffer(const std::string &name, const std::string prefixDecoration, const std::string suffixDecoration, CPUTBuffer *pBuffer) { AddAsset(name, prefixDecoration, suffixDecoration, pBuffer, mpConstantBufferList); }
void CPUTAssetLibrary::AddTexture(const std::string &name, const std::string prefixDecoration, const std::string suffixDecoration, CPUTTexture *pTexture) { AddAsset(name, prefixDecoration, suffixDecoration, pTexture, mpTextureList); }