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

Method init

source/MRViewer/MRObjectTransformWidget.cpp:539–621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

537}
538
539void TransformControls::init( std::shared_ptr<Object> parent )
540{
541 float radius = params_.sizeType == VisualParams::SizeType::LengthUnit ? params_.radius : 1.0f;
542 float width = params_.sizeType == VisualParams::SizeType::LengthUnit ? params_.width : params_.width / params_.radius;
543 for ( int i = int( Axis::X ); i < int( Axis::Count ); ++i )
544 {
545 if ( !translateControls_[i] )
546 {
547 translateControls_[i] = std::make_shared<ObjectMesh>();
548 translateControls_[i]->setAncillary( true );
549 translateControls_[i]->setFlatShading( true );
550 translateControls_[i]->setName( "TranslationC " + std::to_string( i ) );
551 if ( parent )
552 parent->addChild( translateControls_[i] );
553 }
554 translateControls_[i]->setFrontColor( params_.translationColors[i], false );
555 if ( !translateLines_[i] )
556 {
557 translateLines_[i] = std::make_shared<ObjectLines>();
558 translateLines_[i]->setAncillary( true );
559 translateLines_[i]->setVisualizeProperty( false, VisualizeMaskType::DepthTest, ViewportMask::all() );
560 translateLines_[i]->setName( "TranslationL " + std::to_string( i ) );
561 translateControls_[i]->addChild( translateLines_[i] );
562 }
563 translateLines_[i]->setFrontColor( params_.helperLineColor, false );
564 auto transPolyline = std::make_shared<Polyline3>();
565 std::vector<Vector3f> translationPoints =
566 {
567 getCenter() - radius * params_.negativeLineExtension * baseAxis[i],
568 getCenter() + radius * params_.positiveLineExtension * baseAxis[i]
569 };
570 transPolyline->addFromPoints( translationPoints.data(), translationPoints.size() );
571 translateLines_[i]->setPolyline( transPolyline );
572
573 translateControls_[i]->setMesh( std::make_shared<Mesh>(
574 makeArrow( translationPoints[0], translationPoints[1], width, params_.coneRadiusFactor * width, params_.coneSizeFactor * width ) ) );
575
576 auto xf = AffineXf3f::translation( getCenter() ) *
577 AffineXf3f::linear( Matrix3f::rotation( Vector3f::plusZ(), baseAxis[i] ) );
578
579 if ( !rotateControls_[i] )
580 {
581 rotateControls_[i] = std::make_shared<ObjectMesh>();
582 rotateControls_[i]->setAncillary( true );
583 rotateControls_[i]->setFlatShading( true );
584 rotateControls_[i]->setName( "RotationC " + std::to_string( i ) );
585 if ( parent )
586 parent->addChild( rotateControls_[i] );
587 }
588 rotateControls_[i]->setFrontColor( params_.rotationColors[i], false );
589 if ( !rotateLines_[i] )
590 {
591 rotateLines_[i] = std::make_shared<ObjectLines>();
592 rotateLines_[i]->setAncillary( true );
593 rotateLines_[i]->setVisualizeProperty( false, VisualizeMaskType::DepthTest, ViewportMask::all() );
594 rotateLines_[i]->setName( "RotationL " + std::to_string( i ) );
595 rotateControls_[i]->addChild( rotateLines_[i] );
596 }

Callers 1

createMethod · 0.45

Calls 15

makeArrowFunction · 0.85
makeTorusFunction · 0.85
setAncillaryMethod · 0.80
addChildMethod · 0.80
setVisualizePropertyMethod · 0.80
addFromPointsMethod · 0.80
setPolylineMethod · 0.80
setMeshMethod · 0.80
getFunction · 0.50
setFrontColorMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected