void CommandCopyPasteHeightmap::UpdateLandscapeTilemap(DAVA::Image *image) { Texture* texture = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(), image->GetWidth(), image->GetHeight(), false); texture->relativePathname = tilemapSavedPathname; texture->GenerateMipmaps(); texture->SetWrapMode(Texture::WRAP_REPEAT, Texture::WRAP_REPEAT); LandscapeEditorBase* editor = GetActiveEditor(); if (editor) { editor->UpdateLandscapeTilemap(texture); } else { SceneEditorScreenMain *screen = dynamic_cast<SceneEditorScreenMain *>(UIScreenManager::Instance()->GetScreen()); EditorScene* scene = screen->FindCurrentBody()->bodyControl->GetScene(); Landscape* landscape = scene->GetLandscape(scene); landscape->SetTexture(Landscape::TEXTURE_TILE_MASK, texture); landscape->UpdateFullTiledTexture(); ImageLoader::Save(image, tilemapSavedPathname); } SafeRelease(texture); }
void CNodeInfoWindow::OnClickUpdateTransformButton() { EditorScene* scene = EditorScene::getInstance(); SNodeInfo* info = scene->GetSelectedNodeInfo(); if (!info) return; f32 position[3]; f32 rotation[3]; f32 scaling[3]; char text[256]; for (u32 i = 0; i < 3; i++) { GetWindowTextA(mPosTextFields[i], text, 256); int err = sscanf_s(text, "%f", &position[i]); if (err < 1 || err == EOF) { MessageBoxA(mParentHwnd, "cannot convert position value", "Error", NULL); return; } } for (u32 i = 0; i < 3; i++) { GetWindowTextA(mRotTextFields[i], text, 256); int err = sscanf_s(text, "%f", &rotation[i]); if (err < 1 || err == EOF) { MessageBoxA(mParentHwnd, "cannot convert rotation value", "Error", NULL); return; } } for (u32 i = 0; i < 3; i++) { GetWindowTextA(mScaleTextFields[i], text, 256); int err = sscanf_s(text, "%f", &scaling[i]); if (err < 1 || err == EOF) { MessageBoxA(mParentHwnd, "cannot convert scale value", "Error", NULL); return; } } info->Position.x = position[0]; info->Position.y = position[1]; info->Position.z = position[2]; info->Rotation.x = rotation[0] * XM_PI / 180.0f; info->Rotation.y = rotation[1] * XM_PI / 180.0f; info->Rotation.z = rotation[2] * XM_PI / 180.0f; info->Scaling.x = scaling[0]; info->Scaling.y = scaling[1]; info->Scaling.z = scaling[2]; scene->UpdateNodeInfo(info); UpdateShowing(info); }
void CMeshNodePanel::ShowNodeInfo(u32 id) { EditorScene* scene = EditorScene::getInstance(); SNodeInfo* nodeinfo = scene->GetNodeInfoById(id); mNodeInfoWindow.UpdateShowing(nodeinfo); }
void CMeshNodePanel::SetActive(bool bActive) { mCreateMeshNodeWindow.SetVisible(bActive); mNodeInfoWindow.SetVisible(bActive); mInstanceNodeWindow.SetVisible(bActive); EditorScene* scene = EditorScene::getInstance(); if (bActive) { SNodeInfo* info = mCreateMeshNodeWindow.GetSelectedItemNodeInfo(); if (!info) return; if (info->Category == COLLECTION_CATEGORY) mInstanceNodeWindow.SetVisible(true); else { mInstanceNodeWindow.SetVisible(false); scene->SelectObject(info->Id); } ShowNodeInfo(info); } else { scene->CancelSelectObject(); } }
void QtMainWindow::MenuDynamicShadowBlendTriggered() { EditorScene *scene = SceneDataManager::Instance()->SceneGetActive()->GetScene(); ShadowVolumeRenderPass::eBlend blend = scene->GetShadowBlendMode(); ui->actionDynamicBlendModeAlpha->setChecked(blend == ShadowVolumeRenderPass::MODE_BLEND_ALPHA); ui->actionDynamicBlendModeMultiply->setChecked(blend == ShadowVolumeRenderPass::MODE_BLEND_MULTIPLY); }
void SceneEditorScreenMain::SettingsChanged() { for(int32 i = 0; i < (int32)bodies.size(); ++i) { EditorScene *scene = bodies[i]->bodyControl->GetScene(); scene->SetDrawGrid(EditorSettings::Instance()->GetDrawGrid()); } }
void CNodeInfoWindow::OnClickCancelTransformButton() { EditorScene* scene = EditorScene::getInstance(); SNodeInfo* info = scene->GetSelectedNodeInfo(); if (!info) return; UpdateShowing(info); }
void EditorMagnifierItem::paint(QPainter * painter, const QStyleOptionGraphicsItem *option, QWidget * widget) { Q_UNUSED(option); Q_UNUSED(widget); if ( !scene() ) return; QRectF rect = getRect(); EditorScene *scn = qobject_cast<EditorScene *>( scene() ); if (rect.isValid() && m_valid && scn) { updateMask(); painter->save(); // because clipping is active !! QPainterPath clipPath; clipPath.addEllipse(getRect().center(), getRect().width() / 2,getRect().width() / 2); painter->setClipPath(clipPath); painter->setClipping(true); // TODO add extracted image to a cache !!! QRectF extractRect( rect.translated( pos() - scn->getUnderlayOffset() ) ); int extractWidth = extractRect.width() / m_magnifyingFactor; extractRect.adjust(extractWidth,extractWidth,-extractWidth,-extractWidth); QRectF bgRect = scn->getUnderlayImage().rect(); QRectF croppedRect = extractRect.intersected(bgRect); if ( !croppedRect.isNull() ) { QImage background = scn->getUnderlayImage().copy( croppedRect.toRect() ); QImage mag = background.scaled(rect.size().toSize(),Qt::KeepAspectRatio,Qt::SmoothTransformation); painter->drawImage(rect,mag); } painter->drawPixmap(rect.topLeft(), m_imgMask); painter->restore(); } // draw a box if selected if( isSelected() ) { painter->save(); QPen pen; pen.setCosmetic(true); pen.setColor(Qt::black); pen.setWidth(1); pen.setStyle(Qt::DotLine); painter->setPen(pen); painter->drawRect(rect); painter->restore(); } }
void CMeshNodePanel::AddCollectionNode(const char* nodeName, const char* szMeshName, int maxNum) { EditorScene* scene = EditorScene::getInstance(); std::string meshName = szMeshName; int id = scene->AddCollectionNode(nodeName, meshName, maxNum); if (id != -1) { mCreateMeshNodeWindow.AddListItem(id); } }
void CCreateLightNodeWindow::OnClickCreateButton() { //char text[256]; //GetWindowTextA(mNameTextField, text, 256); EditorScene* scene = EditorScene::getInstance(); EditorWindow* window = EditorWindow::getInstance(); scene->PrepareAddingLight(); window->SetMouseState(EMS_ADD_LIGHT); EnableControl(IDC_CREATE_LIGHT_BTN, FALSE); }
void CInstanceInfoWindow::OnClickCreateButton() { EditorWindow* window = EditorWindow::getInstance(); EditorScene* scene = EditorScene::getInstance(); SNodeInfo* info = window->mMeshNodePanel.mCreateMeshNodeWindow.GetSelectedItemNodeInfo(); if (info->Category != COLLECTION_CATEGORY) return; scene->PrepareAddingInstance(info->Id); window->SetMouseState(EMS_ADD_INSTANCE); EnableControl(IDC_INSTANCE_CREATE_BTN, FALSE); }
void CCreateLightNodeWindow::OnClickListItem() { int itemIndex = ListBox_GetCurSel(mLightNodesList); if (itemIndex != LB_ERR) { u32 id = ListBox_GetItemData(mLightNodesList, itemIndex); EditorScene* scene = EditorScene::getInstance(); EditorWindow* window = EditorWindow::getInstance(); scene->SelectLight(id); window->ShowNodeInfo(id); SetFocus(mParentHwnd); } }
void CInstanceInfoWindow::OnClickListItem() { int itemIndex = ListBox_GetCurSel(mInstancesListBox); if (itemIndex != LB_ERR) { u32 id = ListBox_GetItemData(mInstancesListBox, itemIndex); EditorScene* scene = EditorScene::getInstance(); EditorWindow* window = EditorWindow::getInstance(); SNodeInfo* info = scene->GetNodeInfoById(id); scene->SelectObject(id); window->ShowNodeInfo(id); SetFocus(mParentHwnd); } }
void SceneEditorScreenMain::Input(DAVA::UIEvent *event) { if(UIEvent::PHASE_KEYCHAR == event->phase) { if(IsKeyModificatorPressed(DVKEY_ALT)) { int32 key = event->tid - DVKEY_1; if(0 <= key && key < 8) { BodyItem *iBody = FindCurrentBody(); Entity *node = iBody->bodyControl->GetSelectedSGNode(); EditorScene *editorScene = iBody->bodyControl->GetScene(); editorScene->SetForceLodLayer(node, key); } else if(DVKEY_0 == event->tid) { EditorSettings::Instance()->Save(); } } //ckecking help UITextField *tf = dynamic_cast<UITextField *>(UIControlSystem::Instance()->GetFocusedControl()); UITextField *tf1 = dynamic_cast<UITextField *>(focusedControl); if(!tf && !tf1) { if((DVKEY_F1 == event->tid) || (DVKEY_H == event->tid)) { if(helpDialog->GetParent()) { helpDialog->Close(); } else { helpDialog->Show(); } } if(DVKEY_ESCAPE == event->tid) { if(materialEditor && materialEditor->GetParent()) { MaterialsTriggered(); } } } } }
//多边形编辑模式 void Cocos2dxView::mousePressInPolygonEdit(QMouseEvent *event) { qDebug("press polygon1"); QPointF pos = event->localPos(); EditorScene *scene = getEditorScene(); //执行操作 if (m_curPolyOper == NULL) { m_curPolyOper = new PolygonEditOper(scene->getObjectLayer()); OperationManageX->exec(m_curPolyOper); } assert(m_curPolyOper); m_curPolyOper->pushPoint(convertToOpenglPoint(QCursor::pos())); }
void SceneEditorScreenMain::Input(DAVA::UIEvent *event) { if(UIEvent::PHASE_KEYCHAR == event->phase) { bool altIsPressed = InputSystem::Instance()->GetKeyboard()->IsKeyPressed(DVKEY_ALT); if(altIsPressed) { int32 key = event->tid - DVKEY_1; if(0 <= key && key < 8) { BodyItem *iBody = FindCurrentBody(); SceneNode *node = iBody->bodyControl->GetSelectedSGNode(); EditorScene *editorScene = iBody->bodyControl->GetScene(); editorScene->SetForceLodLayer(node, key); } else if(DVKEY_0 == event->tid) { // for(int32 i = 0; i < bodies.size(); ++i) // { // EditorScene *scene = bodies[i]->bodyControl->GetScene(); // scene->SetForceLodLayer(-1); // } // EditorSettings::Instance()->SetForceLodLayer(-1); EditorSettings::Instance()->Save(); } } //ckecking help if (event->phase == UIEvent::PHASE_KEYCHAR) { UITextField *tf = dynamic_cast<UITextField *>(UIControlSystem::Instance()->GetFocusedControl()); if(!tf) { if((DVKEY_F1 == event->tid) || (DVKEY_H == event->tid)) { if(helpDialog->GetParent()) { helpDialog->Close(); } else { helpDialog->Show(); } } } } } }
void Cocos2dxView::mouseReleaseInCommonEdit(QMouseEvent *event) { if (m_commonPos != event->localPos()) return; ListWidgetItem *item = (ListWidgetItem*)m_listwidget->currentItem(); if (!item) return; EditorScene *scene = getEditorScene(); //执行操作 std::string tpname = std::string(item->text().toLatin1().data()); std::string filename = std::string(item->getAbsoluteFilePath().toLatin1().data()); OperationManageX->exec(new CommonEditOper(tpname, scene->getObjectLayer(), convertToOpenglPoint(QCursor::pos()), item->file_info)); }
void CMeshNodePanel::OnKeyBoard(f32 delta) { EditorScene* scene = EditorScene::getInstance(); if (!scene) return; bool shift = false; if (GetAsyncKeyState(VK_SHIFT) & 0x8000) { updateSelectedObjectTransform(delta); } else { scene->UpdateCamera(delta); } }
void CLightPanel::MouseMove(int sx, int sy) { EditorScene* scene = EditorScene::getInstance(); EditorWindow* window = EditorWindow::getInstance(); if (!scene) return; E_MOUSE_STATE mouseState = window->GetMouseState(); if (mouseState == EMS_ADD_LIGHT) { scene->ChangeAddingLightPosition(sx, sy); } else if (mouseState == EMS_PICKING) { //scene->PickingLight(sx, sy); } }
void CNodeInfoWindow::OnClickPhysicsCheckBox() { EditorScene* scene = EditorScene::getInstance(); SNodeInfo* info = scene->GetSelectedNodeInfo(); if (!info) return; LRESULT r = SendMessage(mPhysicsCheckBox, BM_GETCHECK, 0, 0); if (r == BST_CHECKED) { info->BoundingPhysics = true; } else if (r == BST_UNCHECKED) { info->BoundingPhysics = false; } }
void CInstanceInfoWindow::OnDoubleClickListItem() { int itemIndex = ListBox_GetCurSel(mInstancesListBox); if (itemIndex != LB_ERR) { u32 id = ListBox_GetItemData(mInstancesListBox, itemIndex); EditorScene* scene = EditorScene::getInstance(); EditorWindow* window = EditorWindow::getInstance(); if (scene->SelectObject(id)) { scene->FocusSelectedObject(); window->ShowNodeInfo(id); } SetFocus(mParentHwnd); } }
void CCreateLightNodeWindow::OnClickDeleteButton() { int ret = MessageBoxA(mParentHwnd, "Are you sure to delete node?", "Delete Confirm", MB_OKCANCEL); if (ret == IDCANCEL) return; int id = GetSelectedItemId(); EditorScene* scene = EditorScene::getInstance(); if (scene->DeleteLight(id)) { int itemIndex = ListBox_GetCurSel(mLightNodesList); if (itemIndex != LB_ERR) { ListBox_DeleteString(mLightNodesList, itemIndex); } } }
void CMeshNodePanel::MouseDoubleClicked(int sx, int sy) { EditorScene* scene = EditorScene::getInstance(); EditorWindow* window = EditorWindow::getInstance(); if (!scene) return; E_MOUSE_STATE mouseState = window->GetMouseState(); if (mouseState == EMS_PICKING) { int id = scene->SelectObject(sx, sy); if (id != -1) { scene->FocusSelectedObject(); mCreateMeshNodeWindow.SelectListItem(id); } } }
ArrowsNode* EditorBodyControl::GetArrowsNode(bool createIfNotExist) { DVASSERT(scene); ArrowsNode* arrowsNode = dynamic_cast<ArrowsNode*>(scene->FindByName(ResourceEditor::EDITOR_ARROWS_NODE)); if (!arrowsNode && createIfNotExist) { arrowsNode = new ArrowsNode(); arrowsNode->SetName(ResourceEditor::EDITOR_ARROWS_NODE); EditorScene *scene = SceneDataManager::Instance()->SceneGetActive()->GetScene(); scene->AddEditorEntity(arrowsNode); arrowsNode->Release(); } return arrowsNode; }
void CInstanceInfoWindow::UpdateListBoxItems(u32 collectionId) { EditorScene* scene = EditorScene::getInstance(); std::vector<int> ids = scene->GetInstanceIdsInOneCollection(collectionId); int itemCount = ListBox_GetCount(mInstancesListBox); for (int i = itemCount - 1; i >= 0; i--) { ListBox_DeleteString(mInstancesListBox, i); } for (u32 i = 0; i < ids.size(); i++) { AddListBoxItem(ids[i]); } SetFocus(mParentHwnd); }
void LandscapesController::SetScene(DAVA::Scene *scene) { ReleaseScene(); this->scene = SafeRetain(scene); if(scene) { EditorScene *editorScene = dynamic_cast<EditorScene *>(scene); if(editorScene) { Landscape *landscape = editorScene->GetLandscape(editorScene); if(landscape) { SaveLandscape(landscape); } } } }
void CNodeInfoWindow::OnClickShadowCheckBox() { EditorScene* scene = EditorScene::getInstance(); SNodeInfo* info = scene->GetSelectedNodeInfo(); if (!info) return; LRESULT r = SendMessage(mShadowCheckBox, BM_GETCHECK, 0, 0); if (r == BST_CHECKED) { info->ShadowCasting = true; } else if (r == BST_UNCHECKED) { info->ShadowCasting = false; } scene->UpdateNodeInfo(info); }
int _tmain(int argc, _TCHAR* argv[]) { SDeviceContextSettings settings; settings.MultiSamplingCount = 1; settings.MultiSamplingQuality = 0; settings.WindowsProcedure = EditorWindow::WndProc; EditorWindow* window = new EditorWindow(SCREEN_WIDTH, SCREEN_HEIGHT); EditorWindow::_setInstance(window); IDevice* device = gf::createDevice(EDT_DIRECT3D11, SCREEN_WIDTH, SCREEN_HEIGHT, EWS_NONE, true, settings); IVideoDriver* driver = device->getVideoDriver(); EditorScene* scene = new EditorScene(device); EditorScene::_setInstance(scene); scene->setupInitialScene(); window->init(); ITimer* timer = device->getTimer(); timer->reset(); char caption[200]; while (device->run()) { const float clearColor[] = { 1.0f, 0.0f, 0.0f, 1.0f }; driver->beginScene(true, true, clearColor); f32 dt = timer->tick(); scene->update(dt); scene->drawAll(); driver->endScene(); sprintf(caption, "FPS:%f", getFps(dt)); device->setWindowCaption(caption); } delete scene; device->drop(); return 0; }
void LodDistanceControl::UpdateDistanceToCamera() { SceneData *activeScene = SceneDataManager::Instance()->SceneGetActive(); DVASSERT(activeScene); EditorScene *scene = activeScene->GetScene(); DVASSERT(scene); Entity *selection = scene->GetSelection(); if(selection) { Camera *activeCamera = scene->GetCurrentCamera(); Vector3 cameraPosition = activeCamera->GetPosition(); Vector3 selectionCenter = selection->GetWTMaximumBoundingBoxSlow().GetCenter(); float32 distanceToCamera = (cameraPosition-selectionCenter).Length(); distanceToCameraValue->SetText(Format(L"%f", distanceToCamera)); } }
void CInstanceInfoWindow::OnClickDeleteButton() { int id = GetSelectedListItemId(mInstancesListBox); if (id == -1) return; int ret = MessageBoxA(mParentHwnd, "Are you sure to delete instance?", "Delete Confirm", MB_OKCANCEL); if (ret == IDCANCEL) return; EditorScene* scene = EditorScene::getInstance(); scene->DeleteNode(id); scene->CancelSelectObject(); int itemIndex = ListBox_GetCurSel(mInstancesListBox); if (itemIndex != LB_ERR) { ListBox_DeleteString(mInstancesListBox, itemIndex); } }