void FilesView::scanFiles() { DiZipArchive* zip = DiK2Configs::RESOURCE_PACK; if (!zip) return; DiTimer timer; mResources = nullptr; zip->GenerateFileTree(mResources, "*.mdf"); MyGUI::TreeControl::Node* root = mResourcesTree->getRoot(); root->removeAll(); DiFileTree* nullfile = nullptr; root->setData(nullfile); for (auto i = mResources->children.begin(); i != mResources->children.end(); ++i) { DiFileTree* cur = i->second; MyGUI::TreeControl::Node* pNode = new MyGUI::TreeControl::Node(cur->fileName.c_str(), cur->folder ? "Folder" : "File"); pNode->setData(cur); if (!cur->folder) pNode->setPrepared(true); root->add(pNode); } double loadingTime = timer.GetElapse(); DI_LOG("Zip files scanning time: %f", loadingTime); }
void DiRenderWindow::Init() { DI_LOG("Intializing render window : %s", mName.c_str()); Driver->GetWindowDimension(mWndHandle, mWidth, mHeight); mSceneManager = DI_NEW DiSceneManager(this); Driver->CreateWindowTarget(mRenderBuffer, mWndHandle); mMainCamera = mSceneManager->GetCamera(); DiString canvasName = "_canvas_" + mName; mCanvasTexture = DiAssetManager::GetInstance().CreateOrReplaceAsset<DiTexture>(canvasName); mCanvasTexture->SetDimensions(mWidth, mHeight); mCanvasTexture->SetFormat(PF_X8R8G8B8); mCanvasTexture->SetResourceUsage(RU_NONE); mCanvasTexture->SetUsage(TU_RENDER_TARGET); mCanvasTexture->CreateTexture(); mSceneCanvas = mCanvasTexture->GetRenderTarget(); mCanvasTexture->SetAdaptedRT(mRenderBuffer); mCanvasTexture->SetViewportScale(DiVec2::UNIT_SCALE); DiString depStencilName = "_can_ds_" + mName; mDepthStencil = DiAssetManager::GetInstance().CreateOrReplaceAsset<DiTexture>(depStencilName); mDepthStencil->SetDimensions(mWidth, mHeight); mDepthStencil->SetFormat(PF_D24S8); mDepthStencil->SetUsage(TU_DEPTH_STENCIL); mDepthStencil->SetResourceUsage(RU_NONE); mDepthStencil->CreateTexture(); mDepthStencil->SetAdaptedRT(mRenderBuffer); mPostEffectMgr = DI_NEW DiPostEffectManager(this); mGBuffer = DI_NEW DiGBuffer(this); }
void DiK2World::Load(const DiString& path) { DI_LOG("Loading world: %s", path.c_str()); DiK2WorldSerial serial; serial.Load(path,this); mRootNode->AttachObject(mTerrain); // sun light mSun = make_shared<DiDirLight>(); DiSceneManager* sm = DiBase::Driver->GetSceneManager(); DiCullNode* dirNode = sm->GetRootNode()->CreateChild(); dirNode->AttachObject(mSun); mSun->SetColor(DiColor()); DiRadian altitude(DiDegree(mConfigs.mSunAltitude)); DiVec3 dir(0,-DiMath::Sin(altitude),DiMath::Cos(altitude)); DiRadian azimuth(DiDegree(mConfigs.mSunAzimuth)); DiQuat rot(azimuth, DiVec3::UNIT_Y); dir = rot * dir; mSun->SetDirection(dir); sm->SetAmbientColor(DiColor()); Demi::DiRenderBatchGroup* group = Driver->GetPipeline()->GetBatchGroup(Demi::BATCH_MODEL); group->SetPreProcess([this](){ Driver->GetPipeline()->GetShaderEnvironment()->globalAmbient = mConfigs.mEntityAmbient; Driver->GetPipeline()->GetShaderEnvironment()->dirLightsColor[0] = mConfigs.mEntitySunColor; }); }
void DiK2World::Unload() { DI_LOG("Unloading world"); RemoveAllRenderObjs(); mTerrain->Unload(); }
void DiRenderWindow::Shutdown() { DI_LOG("Closing render window : %s", mName.c_str()); DiAssetManager::GetInstance().DestroyAsset(mCanvasTexture->GetName()); DiAssetManager::GetInstance().DestroyAsset(mDepthStencil->GetName()); SAFE_DELETE(mGBuffer); SAFE_DELETE(mPostEffectMgr); SAFE_DELETE(mSceneManager); SAFE_DELETE(mRenderBuffer); SAFE_DELETE(mWindow); }
DiBaseEditorObj* DiBaseEditorObj::_CreateChild(const DiString& type) { DI_LOG("Creating child object [type = %s]", type.c_str()); auto ret = DiEditorManager::Get()->CreateEditorObject(type); ret->mParent = this; ret->OnCreate(); ret->OnCreateUI(); ret->NotifyTransfromUpdate(); mChildren.push_back(ret); ret->PostCreate(); return ret; }
void DiK2Configs::SetK2ResourcePack(const DiString& resPack) { DiTimer timer; DiK2Configs::RESOURCE_PACK = DI_NEW DiZipArchive(resPack); DiK2Configs::TEXTURE_PACK = RESOURCE_PACK; CommandMgr->RegisterString("k2_resource_path", resPack, 0); CommandMgr->RegisterString("k2_texture_path", resPack, 0); DiK2Configs::RESOURCE_PACK->Load(); double loadingTime = timer.GetElapse(); DI_LOG("Zip files loading time: %f", loadingTime); }
void DiScriptManager::BindMiscLib() { DI_LOG("Binding DiMisc Libs"); }