MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / initDefault

Method initDefault

source/MRViewer/MRViewportCornerController.cpp:705–826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

703}
704
705void CornerControllerObject::initDefault()
706{
707 std::shared_ptr<Mesh> arrowMeshCCW = std::make_shared<Mesh>( makeCornerControllerRotationArrowMesh( 0.4f, Vector2f( 1.1f, 0.1f ), true ) );
708 std::shared_ptr<Mesh> arrowMeshCW = std::make_shared<Mesh>( makeCornerControllerRotationArrowMesh( 0.4f, Vector2f( 1.1f, 0.0f ), false ) );
709 std::shared_ptr<Mesh> basisControllerMesh = std::make_shared<Mesh>( makeCornerControllerMesh( 0.8f ) );
710
711 auto basisViewControllerHoverable = std::make_shared<ObjectMesh>();
712 auto basisViewControllerNonHoverable = std::make_shared<ObjectMesh>();
713 auto arrowCCW = std::make_shared<ObjectMesh>();
714 auto arrowCW = std::make_shared<ObjectMesh>();
715
716 auto textures = loadCornerControllerTextures();
717
718 auto setupCube = [&] ( std::shared_ptr<ObjectMesh> obj, bool hoverable )
719 {
720 obj->setMesh( basisControllerMesh );
721 obj->setName( hoverable ? "CVC Hoverable" : "CVC Non-Hoverable" );
722 obj->setFlatShading( true );
723 obj->setVisualizeProperty( true, MeshVisualizePropertyType::BordersHighlight, ViewportMask::all() );
724 obj->setVisualizeProperty( true, MeshVisualizePropertyType::PolygonOffsetFromCamera, ViewportMask::all() );
725 obj->setVisualizeProperty( false, MeshVisualizePropertyType::EnableShading, ViewportMask::all() );
726
727 obj->setUVCoords( makeCornerControllerUVCoords() );
728 obj->setEdgeWidth( 0.2f );
729
730 if ( hoverable )
731 {
732 obj->setTextures( textures );
733 }
734 else
735 {
736 if ( !textures.empty() )
737 obj->setTextures( { textures.front() } );
738 }
739
740 if ( !obj->getTextures().empty() )
741 {
742 if ( hoverable )
743 obj->setTexturePerFace( getCornerControllerTextureMap() );
744 obj->setVisualizeProperty( true, MeshVisualizePropertyType::Texture, ViewportMask::all() );
745 }
746 };
747
748 auto setupArrow = [&] ( std::shared_ptr<ObjectMesh> obj, bool cw )
749 {
750 obj->setMesh( cw ? arrowMeshCW : arrowMeshCCW );
751 obj->setName( cw ? "CW" : "CCW" );
752 obj->setFlatShading( true );
753 obj->setVisualizeProperty( true, MeshVisualizePropertyType::BordersHighlight, ViewportMask::all() );
754 obj->setVisualizeProperty( true, MeshVisualizePropertyType::PolygonOffsetFromCamera, ViewportMask::all() );
755 obj->setVisualizeProperty( false, MeshVisualizePropertyType::EnableShading, ViewportMask::all() );
756 obj->setEdgeWidth( 0.3f );
757 };
758
759 setupCube( basisViewControllerHoverable, true );
760 setupCube( basisViewControllerNonHoverable, false );
761 basisViewControllerHoverable->setVisibilityMask( ViewportMask() );
762 setupArrow( arrowCW, true );

Callers 1

Calls 15

makeCornerControllerMeshFunction · 0.85
instanceFunction · 0.85
setMeshMethod · 0.80
setVisualizePropertyMethod · 0.80
setEdgeWidthMethod · 0.80
push_backMethod · 0.80
isPressedAnyMethod · 0.80
addChildMethod · 0.80
ViewportMaskClass · 0.50

Tested by

no test coverage detected