void LodComponent::Deserialize(KeyedArchive *archive, SceneFileV2 *sceneFile) { if(NULL != archive) { if(archive->IsKeyExists("lc.flags")) flags = archive->GetUInt32("lc.flags"); if(archive->IsKeyExists("lc.forceDistance")) forceDistance = archive->GetFloat("lc.forceDistance"); if(archive->IsKeyExists("lc.forceDistanceSq")) forceDistanceSq = archive->GetFloat("lc.forceDistanceSq"); if(archive->IsKeyExists("lc.forceLodLayer")) forceLodLayer = archive->GetInt32("lc.forceLodLayer"); KeyedArchive *lodDistArch = archive->GetArchive("lc.loddist"); if(NULL != lodDistArch) { for(uint32 i = 0; i < MAX_LOD_LAYERS; ++i) { KeyedArchive *lodDistValuesArch = lodDistArch->GetArchive(KeyedArchive::GenKeyFromIndex(i)); if(NULL != lodDistValuesArch) { lodLayersArray[i].distance = lodDistValuesArch->GetFloat("ld.distance"); lodLayersArray[i].nearDistance = lodDistValuesArch->GetFloat("ld.neardist"); lodLayersArray[i].farDistance = lodDistValuesArch->GetFloat("ld.fardist"); lodLayersArray[i].nearDistanceSq = lodDistValuesArch->GetFloat("ld.neardistsq"); lodLayersArray[i].farDistanceSq = lodDistValuesArch->GetFloat("ld.fardistsq"); } } } KeyedArchive *lodDataArch = archive->GetArchive("lc.loddata"); if(NULL != lodDataArch) { for(uint32 i = 0; i < archive->GetUInt32("lc.loddatacount"); ++i) { KeyedArchive *lodDataValuesArch = lodDataArch->GetArchive(KeyedArchive::GenKeyFromIndex(i)); if(NULL != lodDataValuesArch) { LodData data; if(lodDataValuesArch->IsKeyExists("layer")) data.layer = lodDataValuesArch->GetInt32("layer"); if(lodDataValuesArch->IsKeyExists("isdummy")) data.isDummy = lodDataValuesArch->GetBool("isdummy"); KeyedArchive *lodDataIndexesArch = lodDataValuesArch->GetArchive("indexes"); if(NULL != lodDataIndexesArch) { for(uint32 j = 0; j < lodDataValuesArch->GetUInt32("indexescount"); ++j) { data.indexes.push_back(lodDataIndexesArch->GetInt32(KeyedArchive::GenKeyFromIndex(j))); } } lodLayers.push_back(data); } } } } flags |= NEED_UPDATE_AFTER_LOAD; Component::Deserialize(archive, sceneFile); }
// Read DB parameters from config file and set connection to it void AutotestingSystem::SetUpConnectionToDB() { KeyedArchive *option = new KeyedArchive(); bool res = option->LoadFromYamlFile("~res:/Autotesting/dbConfig.yaml"); if (!res) { ForceQuit("Couldn't open file ~res:/Autotesting/dbConfig.yaml"); } String dbName = option->GetString("name"); String dbAddress = option->GetString("hostname"); String collection = option->GetString("collection"); int32 dbPort = option->GetInt32("port"); Logger::Debug("AutotestingSystem::SetUpConnectionToDB %s -> %s[%s:%d]", collection.c_str(), dbName.c_str(), dbAddress.c_str(), dbPort); if(! AutotestingDB::Instance()->ConnectToDB(collection, dbName, dbAddress, dbPort)) { ForceQuit("Couldn't connect to Test DB"); } else { isDB = true; } SafeRelease(option); }
void VisibilityToolPanel::RestoreState() { SceneEditor2* sceneEditor = GetActiveScene(); bool enabled = sceneEditor->visibilityToolSystem->IsLandscapeEditingEnabled(); int32 brushSize = AreaSizeSystemToUI(sceneEditor->visibilityToolSystem->GetBrushSize()); VisibilityToolSystem::eVisibilityToolState state = sceneEditor->visibilityToolSystem->GetState(); int32 areaSizeMin = DEF_AREA_MIN_SIZE; int32 areaSizeMax = DEF_AREA_MAX_SIZE; KeyedArchive* customProperties = GetCustomPropertiesArchieve(sceneEditor); if (customProperties) { areaSizeMin = customProperties->GetInt32(ResourceEditor::VISIBILITY_TOOL_AREA_SIZE_MIN, DEF_AREA_MIN_SIZE); areaSizeMax = customProperties->GetInt32(ResourceEditor::VISIBILITY_TOOL_AREA_SIZE_MAX, DEF_AREA_MAX_SIZE); } SetWidgetsState(enabled); BlockAllSignals(true); sliderWidgetAreaSize->SetRangeMin(areaSizeMin); sliderWidgetAreaSize->SetRangeMax(areaSizeMax); sliderWidgetAreaSize->SetValue(brushSize); buttonSetVisibilityPoint->setChecked(state == VisibilityToolSystem::VT_STATE_SET_POINT); buttonSetVisibilityArea->setChecked(state == VisibilityToolSystem::VT_STATE_SET_AREA); BlockAllSignals(!enabled); }
void SceneValidator::ConvertLightmapSizeFromProperty(Entity *ownerNode, InstanceMaterialState *materialState) { KeyedArchive * props = ownerNode->GetCustomProperties(); Map<String, VariantType*> map = props->GetArchieveData(); for(Map<String, VariantType*>::iterator it = map.begin(); it != map.end(); it++) { String key = it->first; if(key.find("lightmap.size") != String::npos && ((RenderComponent*)ownerNode->GetComponent(Component::RENDER_COMPONENT))->GetRenderObject()->GetType() != RenderObject::TYPE_LANDSCAPE) { materialState->SetLightmapSize(props->GetInt32(key, 128)); props->DeleteKey(key); break; } } }
void QtLayerWin32::Resize(int32 width, int32 height) { DisplayMode currentMode = DisplayMode(width, height, 16, 0); KeyedArchive * options = Core::Instance()->GetOptions(); if (options) { currentMode.bpp = options->GetInt32("bpp"); } RenderManager::Instance()->ChangeDisplayMode(currentMode, false); RenderManager::Instance()->Init(currentMode.width, currentMode.height); UIControlSystem::Instance()->SetInputScreenAreaSize(currentMode.width, currentMode.height); Core::Instance()->SetPhysicalScreenSize(currentMode.width, currentMode.height); }
void ModificationsPanel::ChangeCollisionModeShow(Entity * node) { if (!node) return; if (modeCollision) { KeyedArchive * customProperties = node->GetCustomProperties(); if(customProperties && customProperties->IsKeyExists("CollisionType") && customProperties->GetInt32("CollisionType", 0) == modeCollision) { node->SetDebugFlags(node->GetDebugFlags() | (DebugRenderComponent::DEBUG_DRAW_RED_AABBOX)); return; } } else { node->SetDebugFlags(node->GetDebugFlags() & (~DebugRenderComponent::DEBUG_DRAW_RED_AABBOX)); } int size = node->GetChildrenCount(); for (int i = 0; i < size; i++) ChangeCollisionModeShow(node->GetChild(i)); }
bool SwitchToRenerObjectConverter::MergeSwitch(Entity * entity) { Vector<Entity*> entitiesToRemove; SwitchComponent * sw = GetSwitchComponent(entity); if(sw) { RenderComponent * rc = GetRenderComponent(entity); RenderObject * ro = 0; if(!rc) { ro = new Mesh(); rc = new RenderComponent(ro); ro->Release(); ro->SetAABBox(AABBox3(Vector3(0, 0, 0), Vector3(0, 0, 0))); entity->AddComponent(rc); } else { ro = rc->GetRenderObject(); } DVASSERT(ro); int32 size = entity->GetChildrenCount(); for(int32 i = 0; i < size; ++i) { Entity * sourceEntity = entity->GetChild(i); RenderObject * sourceRenderObject = GetRenderObject(sourceEntity); //workaround for custom properties for crashed model if(1 == i) // crash model { KeyedArchive *childProps = GetCustomPropertiesArchieve(sourceEntity); if(childProps && childProps->IsKeyExists("CollisionType")) { KeyedArchive *entityProps = GetOrCreateCustomProperties(entity)->GetArchive(); entityProps->SetInt32("CollisionTypeCrashed", childProps->GetInt32("CollisionType", 0)); } } //end of custom properties Vector<std::pair<Entity*, RenderObject*> > renderPairs; if(sourceRenderObject) { renderPairs.push_back(std::make_pair(sourceEntity, sourceRenderObject)); } else { FindRenderObjectsRecursive(sourceEntity, renderPairs); DVASSERT(renderPairs.size() == 1); sourceRenderObject = renderPairs[0].second; } if(sourceRenderObject) { TransformComponent * sourceTransform = GetTransformComponent(sourceEntity); if (sourceTransform->GetLocalTransform() != Matrix4::IDENTITY) { PolygonGroup * pg = sourceRenderObject->GetRenderBatchCount() > 0 ? sourceRenderObject->GetRenderBatch(0)->GetPolygonGroup() : 0; if(pg && bakedPolygonGroups.end() == bakedPolygonGroups.find(pg)) { sourceRenderObject->BakeGeometry(sourceTransform->GetLocalTransform()); bakedPolygonGroups.insert(pg); } } uint32 sourceSize = sourceRenderObject->GetRenderBatchCount(); while(sourceSize) { int32 lodIndex, switchIndex; RenderBatch * sourceRenderBatch = sourceRenderObject->GetRenderBatch(0, lodIndex, switchIndex); sourceRenderBatch->Retain(); sourceRenderObject->RemoveRenderBatch(sourceRenderBatch); ro->AddRenderBatch(sourceRenderBatch, lodIndex, i); sourceRenderBatch->Release(); sourceSize--; } } renderPairs[0].first->RemoveComponent(Component::RENDER_COMPONENT); LodComponent * lc = GetLodComponent(sourceEntity); if((0 != lc) && (0 == GetLodComponent(entity))) { LodComponent * newLod = (LodComponent*)lc->Clone(entity); entity->AddComponent(newLod); } renderPairs[0].first->RemoveComponent(Component::LOD_COMPONENT); if(sourceEntity->GetChildrenCount() == 0) { entitiesToRemove.push_back(sourceEntity); } } } uint32 entitiesToRemoveCount = entitiesToRemove.size(); for(uint32 i = 0; i < entitiesToRemoveCount; ++i) { entitiesToRemove[i]->GetParent()->RemoveNode(entitiesToRemove[i]); } return false; }
bool CoreWin32Platform::CreateWin32Window(HINSTANCE hInstance) { this->hInstance = hInstance; //single instance check TCHAR fileName[MAX_PATH]; GetModuleFileName(NULL, fileName, MAX_PATH); fileName[MAX_PATH-1] = 0; //string can be not null-terminated on winXP for(int32 i = 0; i < MAX_PATH; ++i) { if(fileName[i] == L'\\') //symbol \ is not allowed in CreateMutex mutex name { fileName[i] = ' '; } } hMutex = CreateMutex(NULL, FALSE, fileName); if(ERROR_ALREADY_EXISTS == GetLastError()) { return false; } windowedMode = DisplayMode(800, 600, 16, 0); fullscreenMode = DisplayMode(800, 600, 16, 0); currentMode = windowedMode; isFullscreen = false; // create the window, only if we do not use the null device LPCWSTR className = L"DavaFrameworkWindowsDevice"; // Register Class WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = 0; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = 0; wcex.lpszClassName = className; wcex.hIconSm = 0; RegisterClassEx(&wcex); // calculate client size RECT clientSize; clientSize.top = 0; clientSize.left = 0; clientSize.right = currentMode.width; clientSize.bottom = currentMode.height; ULONG style = WINDOWED_STYLE | WS_CLIPCHILDREN; // Create the rendering window if (isFullscreen) { style = WS_VISIBLE | WS_POPUP; } // End if Fullscreen AdjustWindowRect(&clientSize, style, FALSE); int32 realWidth = clientSize.right - clientSize.left; int32 realHeight = clientSize.bottom - clientSize.top; int32 windowLeft = -10000;//(GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; int32 windowTop = -10000;//(GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; if (isFullscreen) { windowLeft = 0; windowTop = 0; } // create window hWindow = CreateWindow( className, L"", style, windowLeft, windowTop, realWidth, realHeight, NULL, NULL, hInstance, NULL); ShowWindow(hWindow, SW_SHOW); UpdateWindow(hWindow); // fix ugly ATI driver bugs. Thanks to ariaci (Taken from Irrlight). MoveWindow(hWindow, windowLeft, windowTop, realWidth, realHeight, TRUE); #if defined(__DAVAENGINE_DIRECTX9__) RenderManager::Create(Core::RENDERER_DIRECTX9); #elif defined(__DAVAENGINE_OPENGL__) RenderManager::Create(Core::RENDERER_OPENGL); #endif RenderManager::Instance()->Create(hInstance, hWindow); FrameworkDidLaunched(); KeyedArchive * options = Core::GetOptions(); //fullscreenMode = GetCurrentDisplayMode(); fullscreenMode = GetCurrentDisplayMode();//FindBestMode(fullscreenMode); if (options) { windowedMode.width = options->GetInt32("width"); windowedMode.height = options->GetInt32("height"); windowedMode.bpp = options->GetInt32("bpp"); // get values from config in case if they are available fullscreenMode.width = options->GetInt32("fullscreen.width", fullscreenMode.width); fullscreenMode.height = options->GetInt32("fullscreen.height", fullscreenMode.height); fullscreenMode.bpp = windowedMode.bpp; fullscreenMode = FindBestMode(fullscreenMode); isFullscreen = (0 != options->GetInt32("fullscreen")); String title = options->GetString("title", "[set application title using core options property 'title']"); WideString titleW = StringToWString(title); SetWindowText(hWindow, titleW.c_str()); } Logger::FrameworkDebug("[PlatformWin32] best display fullscreen mode matched: %d x %d x %d refreshRate: %d", fullscreenMode.width, fullscreenMode.height, fullscreenMode.bpp, fullscreenMode.refreshRate); currentMode = windowedMode; if (isFullscreen) { currentMode = fullscreenMode; } clientSize.top = 0; clientSize.left = 0; clientSize.right = currentMode.width; clientSize.bottom = currentMode.height; AdjustWindowRect(&clientSize, style, FALSE); realWidth = clientSize.right - clientSize.left; realHeight = clientSize.bottom - clientSize.top; windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; MoveWindow(hWindow, windowLeft, windowTop, realWidth, realHeight, TRUE); RAWINPUTDEVICE Rid; Rid.usUsagePage = 0x01; Rid.usUsage = 0x02; Rid.dwFlags = 0; Rid.hwndTarget = 0; RegisterRawInputDevices(&Rid, 1, sizeof(Rid)); RenderManager::Instance()->ChangeDisplayMode(currentMode, isFullscreen); RenderManager::Instance()->Init(currentMode.width, currentMode.height); UIControlSystem::Instance()->SetInputScreenAreaSize(currentMode.width, currentMode.height); Core::Instance()->SetPhysicalScreenSize(currentMode.width, currentMode.height); return true; }