Home › Forum › SOFA › Using SOFA › Bug. Mismatch between image plugin .obj and .png co-ordinate systems
- This topic has 4 replies, 2 voices, and was last updated 5 years, 11 months ago by mbarrow.
-
AuthorPosts
-
11 October 2018 at 16:11 #12163mbarrowBlocked
I have run into weird behavior in the flexible app and Image plugin.
It seems there is some slight mismatch between the coordinate systems. I’m not sure how to remedy the situation.I have a beam simulation where I want to map an ogl model to a mechanical object for display. The ogl model has a slight y and z offset that I did not specify. I can’t account for it and it will mess up some calculations I’d like to do down the road.
I’ve applied what I believe to be correct transforms to a .png when creating the mechanical object.
Can someone explain how to account for this offset or why it occurs at all?
I’ve attached a .scn that shows the issue. the .scn can be run in “src/applications/plugins/Flexible/examples/beam/” but it needs a 100×500 pix png called “beamr.png” that I couldn’t attach.
It also demonstrates a rendering bug of the image plugin in the “beamimage” node. This node does not render the beamr.png unless a redundant offset of one extra pixel is added to the dx parameter of that node. That shouldn’t be at all.
<?xml version="1.0"?> <Node name="Root" gravity="0 0 0 " dt="1" > <RequiredPlugin pluginName="Flexible"/> <RequiredPlugin pluginName="image"/> <VisualStyle displayFlags="showWireframe showBehaviorModels" /> <DefaultAnimationLoop /> <DefaultVisualManagerLoop /> <!-- just highlights the expected y and z for an obj loader. I added the x offset to make the other stuff easier to see --> <Node name="objCoOrds" > <VisualStyle displayFlags="hideWireframe" /> <OglModel template="ExtVec3f" name="Visual" fileMesh="beam.obj" color="0.5 0.5 0.5" translation="-1 0 0" rotation="90 0 0 "/> </Node> <Node name="Affine" > <VisualStyle displayFlags="showWireframe" /> <EulerImplicitSolver rayleighStiffness="0.1" rayleighMass="0.1" /> <CGLinearSolver iterations="200" tolerance="1e-15" threshold="1e-15"/> <ImageContainer name="loader" filename="beamr.png" drawBB="false" /> <ImageFilter name="selectchannel" src="@loader" filter="21" param="0"/> <!-- hand tuned parameters that do work. it is unacceptable to hand tune these y and z offsets. --> <!-- <ImageFilter name="pngCoOrds" inputImage="@selectchannel.outputImage" filter="20" param="-0.20 -0.998 -0.16 100.00 500.00 5.0 0.0040 0.0040 0.08 0" inputTransform="-0.20 -1.00 0 00.00 0.00 0.00 0.0040 0.0040 1.0 0 1 0"/> --> <!-- parameters one would expect to work but dont because of bizarre offsets issue. note that image viewer doesn't work unless width is 101 but the actual values appear to be sampled correctly never the less. --> <ImageFilter name="pngCoOrds" inputImage="@selectchannel.outputImage" filter="20" param="-0.20 -1.00 -0.2 100.00 500.00 5.0 0.0040 0.0040 0.08 0" inputTransform="-0.20 -1.00 0 00.00 0.00 0.00 0.0040 0.0040 1.0 0 1 0"/> <ImageContainer name="beamimage" image="@pngCoOrds.outputImage" transform="@pngCoOrds.outputTransform" drawBB="false"/> <TransferFunction name="youngMTF" template="ImageUC,ImageD" inputImage="@pngCoOrds.outputImage" param="0 0 1 7.843 255 2000.000"/> <ImageViewer template="ImageD" name="modulusviewer" image="@youngMTF.outputImage" transform="@pngCoOrds.outputTransform" display="1"/> <MeshObjLoader name="mesh" filename="beam.obj" triangulate="1" rotation="90 0 0 "/> <ImageContainer template="ImageUC" name="image" image="@pngCoOrds.outputImage" transform="@pngCoOrds.outputTransform" drawBB="true"/> <ImageSampler template="ImageUC" name="sampler" src="@image" method="1" param="0" fixedPosition="0 -1 0 0 -0.8 0 0 -0.6 0 0 -0.4 0 0 -0.2 0 0 0 0 0 0.2 0 0 0.4 0 0 0.6 0 0 0.8 0 0 1 0" printLog="false"/> <MergeMeshes name="merged" nbMeshes="2" position1="@sampler.fixedPosition" position2="@sampler.position" /> <MechanicalObject template="Affine" name="parent" showObject="true" src="@merged" /> <Mesh name="edges" position="@parent.rest_position" edges="0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10"/> <BarycentricShapeFunction position="@parent.rest_position" nbRef="2" /> <ShapeFunctionDiscretizer name="SF" src="@image" /> <Node name="behavior" > <ImageGaussPointSampler name="sampler" indices="@../SF.indices" weights="@../SF.weights" transform="@../SF.transform" method="2" order="4" targetNumber="1"/> <MechanicalObject template="F332" name="F" /> <LinearMapping template="Affine,F332" /> </Node> <Node name="visual" > <OglModel template="ExtVec3f" name="Visual" fileMesh="beam.obj" color="1 0.8 0.8" rotation="90 0 0"/> <LinearMapping template="Affine,ExtVec3f"/> </Node> </Node> </Node>
29 October 2018 at 13:37 #12290HugoKeymasterDear @mjbarrow,
Could you find a way to provide us a link (wetransfer or any other) of your image?
This would really ease the testing.Did you take a look at the BeamLinearMapping component?
Best,
Hugo
29 October 2018 at 17:40 #12294mbarrowBlockedsure, here is a 100×500 white beam png image
thanks for the suggestions I will try them. This link is also good for my other question which is actually quite a lot more pressing for me if you could take a look?
its here: how to use node output as “param” for ImageFilter?
Thanks very much for responding to my questions
22 November 2018 at 17:16 #1251523 November 2018 at 08:08 #12522mbarrowBlockedYes I don’t understand that component. I saw it used in beamFEMForceField.scn but I was not successful when I placed it in the same node as the RegularGridTopology that is used for the FEM forcefield. I can keep trying but just giving an update since you ask
-
AuthorPosts
- You must be logged in to reply to this topic.