坐标系的显示时间:2023-02-02 10:59:29 正常状态显示: x轴被激活的时候: 预期效果: 选择坐标轴实现选中面的缩放和拉出操作 选择坐标面上的圆弧对面进行旋转 用VL写的,关键代码如下: // add the geometries to the VL's pipeline...void App_Axis::showAxis(){//basic render statesvl::ref<vl::Effect> effect = new vl::Effect;effect->shader()->setRenderState( new vl::Light(0) );effect->shader()->enable(vl::EN_LIGHTING);effect->shader()->enable(vl::EN_DEPTH_TEST);effect->shader()->gocMaterial()->setColorMaterialEnabled(true);//originGeometryPtr origin = vlut::makeUVSphere(vl::vec3(0,0,0));origin ->computeNormals();origin ->setColorArray(vlut::yellow);vl::Actor* originActor = sceneManager()->tree()->addActor(origin.get(), effect.get(), new vl::Transform);mOriginTr = originActor->transform();//basic axisGeometryPtr x_axis = vlut::makeCylinder(vl::vec3(0,0,0), g_AxisRadius, mLength);x_axis->computeNormals();x_axis->setColorArray(vlut::red);GeometryPtr xy_arc = makeArc(g_AxisRadius*0.5f, mLength*0.75);xy_arc->computeNormals();xy_arc->setColorArray(vlut::red);GeometryPtr x_arrow = vlut::makeCone(vl::vec3(0,0,0), 1, 2);x_arrow->computeNormals();x_arrow->setColorArray(vlut::red);GeometryPtr y_axis = vlut::makeCylinder(vl::vec3(0,0,0), g_AxisRadius, mLength);y_axis->computeNormals();y_axis->setColorArray(vlut::green);GeometryPtr yz_arc = makeArc(g_AxisRadius*0.5f, mLength*0.75);yz_arc->computeNormals();yz_arc->setColorArray(vlut::green);GeometryPtr y_arrow = vlut::makeCone(vl::vec3(0,0,0), 1, 2);y_arrow->computeNormals();y_arrow->setColorArray(vlut::green);GeometryPtr z_axis = vlut::makeCylinder(vl::vec3(0,0,0), g_AxisRadius, mLength);z_axis->computeNormals();z_axis->setColorArray(vlut::blue);GeometryPtr zx_arc = makeArc(g_AxisRadius*0.5f, mLength*0.75);zx_arc->computeNormals();zx_arc->setColorArray(vlut::blue);GeometryPtr z_arrow = vlut::makeCone(vl::vec3(0,0,0), 1, 2);z_arrow->computeNormals();z_arrow->setColorArray(vlut::blue);vl::Actor* act;//setup the x axis//-------------------------------------------------------------------------------------------TransformPtr xAxisTr = new vl::Transform( vl::mat4::translation(mLength/2.0f,0,0) * vl::mat4::rotation(90.0f, 0.0, 0.0, 1.0) );act = sceneManager()->tree()->addActor(x_axis.get(), effect.get(), xAxisTr.get());act->setName("x_axis");TransformPtr xyArcTr = new::vl::Transform();act = sceneManager()->tree()->addActor(xy_arc.get(), effect.get(), xyArcTr.get());act->setName("xy_arc");TransformPtr xArrowTr = new vl::Transform( vl::mat4::translation(mLength,0,0) * vl::mat4::rotation(-90.0f, 0.0, 0.0, 1.0) );act = sceneManager()->tree()->addActor(x_arrow.get(), effect.get(), xArrowTr.get());act->setName("x_arrow");//-------------------------------------------------------------------------------------------//setup the y axis//-------------------------------------------------------------------------------------------TransformPtr yAxisTr = new vl::Transform( vl::mat4::translation(0,mLength/2.0f,0) );act = sceneManager()->tree()->addActor(y_axis.get(), effect.get(), yAxisTr.get());act->setName("y_axis");TransformPtr yzArcTr = new::vl::Transform( vl::mat4::rotation(-90.0f, vl::vec3(0,1,0)) );act = sceneManager()->tree()->addActor(yz_arc.get(), effect.get(), yzArcTr.get());act->setName("yz_arc");TransformPtr yArrowTr = new vl::Transform( vl::mat4::translation(0,mLength,0) );act = sceneManager()->tree()->addActor(y_arrow.get(), effect.get(), yArrowTr.get());act->setName("y_arrow");//-------------------------------------------------------------------------------------------//setup the z axis//-------------------------------------------------------------------------------------------TransformPtr zAxisTr = new vl::Transform( vl::mat4::translation(0,0,mLength/2.0f) * vl::mat4::rotation(90.0f, 1.0, 0.0, 0.0) );act = sceneManager()->tree()->addActor(z_axis.get(), effect.get(), zAxisTr.get());act->setName("z_axis");TransformPtr zxArcTr = new::vl::Transform( vl::mat4::rotation(90.0f, vl::vec3(1,0,0)) );act = sceneManager()->tree()->addActor(zx_arc.get(), effect.get(), zxArcTr.get());act->setName("zx_arc");TransformPtr zArrowTr = new vl::Transform( vl::mat4::translation(0,0,mLength) * vl::mat4::rotation(90.0f, 1.0, 0.0, 0.0) );act = sceneManager()->tree()->addActor(z_arrow.get(), effect.get(), zArrowTr.get());act->setName("z_arrow");//-------------------------------------------------------------------------------------------vl::VisualizationLibrary::rendering()->as<vl::Rendering>()->transform()->addChild( mOriginTr.get() );// setup the transform treemOriginTr->addChild( xAxisTr.get() );mOriginTr->addChild( xyArcTr.get() );mOriginTr->addChild( xArrowTr.get() );mOriginTr->addChild( yAxisTr.get() );mOriginTr->addChild( yzArcTr.get() );mOriginTr->addChild( yArrowTr.get() );mOriginTr->addChild( zAxisTr.get() );mOriginTr->addChild( zxArcTr.get() );mOriginTr->addChild( zArrowTr.get() );}