30 June 2020 at 18 h 06 min #16756
I would like to add a visual model on a beam
To do so i’ve initially created an object:
model.createObject('MeshSTLLoader', name='surface', filename=#)
Then the MechanicalObject of the beam :
model.createObject('MechanicalObject', template='Rigid3d', name='frame1', position=#)
And finally the link between my visual and the beam :
visu = model.createChild('visu') visu.createObject('OglModel', name='VisualModel', src='@../surface') visu.createObject('IdentityMapping', input='@../frame1', output='@VisualModel')
But my result is not has expected :
I should have a curved cylinder but instead the mesh seems to be all messed up
I’ve also tried with “RigidMapping” without success
What did I miss ?
Regards,7 July 2020 at 23 h 01 min #16825
Could you replace with a RigidMapping instead?
RigidMapping links Rigid3d (beam) and any other type like Vec3d (OglModel).
I hope this helps
Hugo8 July 2020 at 9 h 12 min #16833
Hello @Hugo ,
This is the result with ‘RigidMapping’ :
The mesh doesn’t follow the beam
Regards,8 July 2020 at 21 h 28 min #16840
Beams are different than usual Rigid object.
Could you use the BeamLinearMapping instead? I should have pointed it out in the first place.
Hugo9 July 2020 at 9 h 29 min #16844
It’s getting closer but still not good, maybe is there something wrong with the way I’ve created my beam ?
The beam :
model = solverNode.createChild('model') model.createObject('MeshSTLLoader', name='surface', filename='mesh/#.stl') model.createObject('Mesh', name="meshBeam", position=#, lines=#) model.createObject('MechanicalObject', template='Rigid3d', name='frame1', position=#, printLog=0, translation="0 0 0") model.createObject('BeamInterpolation', dofsAndBeamsAligned='1', straight='1', defaultYoungModulus="1.8e18", radius=radius, name="interpolation") model.createObject('AdaptiveBeamForceFieldAndMass', name="BeamForceField", computeMass="1", massDensity="0.0001") model.createObject('PartialFixedConstraint', indices='0', fixedDirections="1 1 1 1 1 1") model.createObject('BoxROI', name='ROI1', box='5 10 2 -2 -2 2', drawBoxes='true')
Regards,21 July 2020 at 16 h 46 min #16916
Sorry for the latency, I was away last week.
I think the mapping you are looking for has been implemented in a private plugin (plugin name: BeamAdapter, mapping name: BeamLinearMapping). I can try to get an access to this code for you.
Now some devs handle the rendering part in external tools like Unity.
Maybe @remibessard could help us here.
Hugo21 July 2020 at 17 h 10 min #16920epernodParticipant
I’m not expert in Rigid and RigidMapping but I think in your case you need to define which indices of your visual mesh is mapped to each rigid dof using the option rigidIndexPerPoint of the RigidMapping.
I think this scene is similar to what you want to do:
where a set of visual cube meshes are mapped on each rigid dof of the beam.21 July 2020 at 17 h 25 min #16922remibessardParticipant
Agreed with @epernod, I would also precise these information to the RigidMapping when trying to make it work with this component.
As @Hugo mentionned I am using the BeamLinearMapping to map a collision model to a Beam model, but I think it is accessible in SOFA master without compiling any plugin.
Hope you can also find it and use it on your side.
(I have to say I am not mapping a volume into the beam (only a more discretized description of the same beam), so I don’t know if it will work with your visual volumetric model…)
As for me I use it that way in my scene configuration file:
endoCollNode.createObject('BeamLinearMapping', localCoord=False, applyRestPosition=True)
(feel free to play with these 2 parameters to fit your case)
Remi28 July 2020 at 10 h 58 min #16971
I’m sorry I’ve completely forgot to answer here
This is the solution that have been given to me :
visuNode = model.createChild('visualization') visuNode.createObject('CylinderGridTopology', name='topology', radius=radius, length='25', drawQuads='0', n='3 3 25', axis='1 0 0') visuNode.createObject('MechanicalObject', name='test') visuNode.createObject('AdaptiveBeamMapping', interpolation="@../interpolation", input="@../frame1", output="@test") oglNode = visuNode.createChild('ogl') oglNode.createObject('OglModel', color='0.2 0.2 0.2 1') oglNode.createObject('IdentityMapping')
EDIT : Just noticed that this solution isn’t what I was asking for in my first post, maybe I should have not hit the ‘solved’ button ?
- You must be logged in to reply to this topic.