Esempio n. 1
0
    void SceneEditorApp::RenderDragTemplate() {
        if (currentLevel == nullptr) {
            return;
        }
        if (dragNow == false) {
            return;
        }
        // qDebug() << dragTemplateName.c_str();
        if (dragTemplateName != "") {
            SceneObjectGeometry* g =
                GetGeometryManager().GetGeometry(dragTemplateName);
            if (g == nullptr) {
                return;
            }

            SceneObjectParams params;
            Vec3f position;
            Vec2f cpos = GetCursorPos();

            Plane plane;
            plane.SetNormal(Vec3f(0, 0, 1));
            plane.SetPoint(Vec3f(0, 0, 0));

            //        LOG_INFO(cpos);
            camera->CastRay(cpos, plane, position);
            //        v = vv;
            params.pos = position;
            //        LOG_INFO(position);
            GetDebugRenderer().RenderObject(*g, params);
        }
    }
Esempio n. 2
0
    void SceneEditorApp::SetDragDropProcessors() {
        GetEventSystem().SetProcessor("DRL", AppEventProcessor([this]() {
                                                 dragNow = false;
                                                 // dragTemplateName = "";
                                             }));

        GetEventSystem().SetProcessor(
            "DRDP", AppEventProcessor([this]() {
                                          if (currentLevel != nullptr) {
                                              // qDebug() << "Proccess enter";
                                              dragTemplateName =
                                                  getSelectedTemplateHandler();
                                              dragNow = true;
                                          }
                                      },
                                      [this]() {}, [this]() {

                        if (dragNow == true) {
                            Plane plane;
                            plane.SetNormal(Vec3f(0, 0, 1));
                            plane.SetPoint(Vec3f(0, 0, 0));

                            Vec3f position;
                            Vec2f cpos = GetCursorPos();
                            camera->CastRay(cpos, plane, position);
                            AddObject(dragTemplateName, position);

                            dragNow = false;
                            dragTemplateName = "";
                        }
                    }));
    }