void SceneTest::transformation() { Scene3D scene; Object3D* scenePointer = &scene; scenePointer->setTransformation(Matrix4::translation({1.0f, 1.0f, 1.0f})); CORRADE_COMPARE(scene.transformation(), Matrix4()); }
void SceneTest::parent() { Scene3D scene; /* Scene parent cannot be changed */ Object3D* scenePointer = &scene; Object3D object; scenePointer->setParent(&object); CORRADE_VERIFY(scene.parent() == nullptr); CORRADE_VERIFY(scene.children().isEmpty()); CORRADE_VERIFY(object.children().isEmpty()); }
int main(int argc, char** argv) { QApplication app(argc, argv); Scene3D scene; scene.setWindowTitle("Surface"); // scene.resize(500, 500); scene.showMaximized(); scene.setMinimumSize(400, 400); scene.show(); return app.exec(); }
// handles window messages LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: break; case WM_SIZE: scene.Resize(); break; case WM_KEYDOWN: input.SetKeyDown(wParam); break; case WM_KEYUP: input.SetKeyUp(wParam); break; case WM_MOUSEMOVE: input.setMouseX(LOWORD(lParam)); input.setMouseY(HIWORD(lParam)); break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hwnd, message, wParam, lParam); }
void Setting::start(){ if(fileAdress->text().length()>1) { fileAdress->setStyleSheet(""); PathCalculator* pc= new PathCalculator(fileAdress->text().toUtf8().data(), ios->isChecked(), framesCouns->value(), lowPass->value(), gyro->isChecked()); qDebug()<<"POINTS NUM FROM MAIN: "<<pc->getRecNum(); Scene3D *scene = new Scene3D(pc); scene->show(); } else { fileAdress->setStyleSheet("QLineEdit{background: red;}"); } }
void SimpleCubeTool::Process(Request *req) { // We really don't need to override Process() here as the default implementation which calls CreateScene() is ok. We // are overriding it so you can get an idea of what the base implementation does if at some point the default implementation // is insufficient. For this SimpleCube example you could replace all the below code with "BaseClass::Process(req);". // Fusion tools pass Parameters between their inputs and outputs. Image, Number, Scene3D, and MtlGraph3D are examples // of subclasses of Parameter that plugin developers will typically see getting passed between inputs and outputs. // Transform3DOperator automatically adds an input(In3D) and output(Out3D) declared to take a Scene3D parameters. It is // the job of the SimpleCubeTool to create a new Scene3D containing the incoming Scene3D and the cube geometry and then // outputing the resulting scene. If we didn't inherit from Transform3DOperator we would have to manually add the main // input/output ourselves. // We're going to start off by setting the output Scene3D to be NULL. This will cause Fusion to fail the render of this // tool. Later on we'll set the output to something valid if we succeed. This is just to make error handling easier. Out3D->Set(req, NULL); Scene3D *inScene = (Scene3D *) In3D->GetValue(req); // get the incoming scene Node3D *root = CreateScene(req); // get the surface node we'll be merging into the incoming scene if (root) { Scene3D *outScene = new Scene3D(Document, req); // create the outgoing scene if (inScene && inScene->RootNode) { // Note that we have to take a copy of the incoming scene rather attaching it to root directly. Any Parameter you get // from an input (ie. via GetValue(req) in Process()) must be treated as read only. The reason is that Parameters are // reference counted shared objects. This is kind of unfortunate, but its not so bad because we're doing a shallow copy // of the node structure and all the heavy data is refcounted across. Node3D *inRoot = inScene->RootNode->Copy(); root->AddChild(inRoot); } ProcessTransform(req, root); // copy the transform from the inputs in the transform tab to the root node outScene->SetRootNode(root); // output the new scene Out3D->Set(req, outScene); } }
// Entry point. The program start here int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int nCmdShow) { MSG msg; RegisterMyWindow(hInstance); if (!InitialiseMyWindow(hInstance, nCmdShow)) return FALSE; scene.Init(&hwnd, &input); timer.Initialize(); bool running = true; userContinue = true; while (running) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } else { // update delta time timer.Frame(); // Update and render scene scene.Update(timer.GetTime()); userContinue = TestKeys(); } if (!userContinue) { running = UserContinue(); } } return msg.wParam; }
Scene3D* LightingApp::createScene() { Scene3D* tScene = new Scene3D(); tScene->setCamera(new SceneFlyCamera(), glm::vec3(0)); tScene->setClearColor(0.f, 0.f, 0.f, 1.f); tScene->addElement(new Cube(), glm::vec3(0.f)); tScene->addElement(new CubeWithMaterials(), glm::vec3(0.0f, 0.f, -7.f)); tScene->addLight(new Light(), glm::vec3(3.f, 3.f, -5.f)); return tScene; }
void BulletExample::drawEvent() { GL::defaultFramebuffer.clear(GL::FramebufferClear::Color|GL::FramebufferClear::Depth); /* Housekeeping: remove any objects which are far away from the origin */ for(Object3D* obj = _scene.children().first(); obj; ) { Object3D* next = obj->nextSibling(); if(obj->transformation().translation().dot() > 100*100) delete obj; obj = next; } /* Step bullet simulation */ _bWorld.stepSimulation(_timeline.previousFrameDuration(), 5); /* Draw the cubes */ if(_drawCubes) _camera->draw(_drawables); /* Debug draw. If drawing on top of cubes, avoid flickering by setting depth function to <= instead of just <. */ if(_drawDebug) { if(_drawCubes) GL::Renderer::setDepthFunction(GL::Renderer::DepthFunction::LessOrEqual); _debugDraw.setTransformationProjectionMatrix( _camera->projectionMatrix()*_camera->cameraMatrix()); _bWorld.debugDrawWorld(); if(_drawCubes) GL::Renderer::setDepthFunction(GL::Renderer::DepthFunction::Less); } swapBuffers(); _timeline.nextFrame(); redraw(); }
void DualQuaternionTransformationTest::setTransformation() { Object3D o; /* Can't transform with non-rigid transformation */ std::ostringstream out; Error redirectError{&out}; o.setTransformation(DualQuaternion({{1.0f, 2.0f, 3.0f}, 4.0f}, {})); CORRADE_COMPARE(out.str(), "SceneGraph::DualQuaternionTransformation::setTransformation(): the dual quaternion is not normalized\n"); /* Dirty after setting transformation */ o.setClean(); CORRADE_VERIFY(!o.isDirty()); o.setTransformation(DualQuaternion::rotation(Deg(17.0f), Vector3::xAxis())); CORRADE_VERIFY(o.isDirty()); CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))); /* Scene cannot be transformed */ Scene3D s; s.setClean(); CORRADE_VERIFY(!s.isDirty()); s.setTransformation(DualQuaternion::rotation(Deg(17.0f), Vector3::xAxis())); CORRADE_VERIFY(!s.isDirty()); CORRADE_COMPARE(s.transformationMatrix(), Matrix4()); }
void RigidMatrixTransformation3DTest::setTransformation() { Object3D o; /* Can't transform with non-rigid transformation */ std::ostringstream out; Error::setOutput(&out); o.setTransformation(Matrix4::scaling(Vector3(3.0f))); CORRADE_COMPARE(out.str(), "SceneGraph::RigidMatrixTransformation3D::setTransformation(): the matrix doesn't represent rigid transformation\n"); /* Dirty after setting transformation */ o.setClean(); CORRADE_VERIFY(!o.isDirty()); o.setTransformation(Matrix4::rotationX(Deg(17.0f))); CORRADE_VERIFY(o.isDirty()); CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))); /* Scene cannot be transformed */ Scene3D s; s.setClean(); CORRADE_VERIFY(!s.isDirty()); s.setTransformation(Matrix4::rotationX(Deg(17.0f))); CORRADE_VERIFY(!s.isDirty()); CORRADE_COMPARE(s.transformationMatrix(), Matrix4()); }