taking care of transforms with GetContourSegments and multiple models?

Anonymous 9 years ago 0
This discussion was imported from CodePlex

3dguy wrote at 2013-04-11 00:12:

I'm trying to us GetContourSegments as shown in the Contour example but it doesn't seem to apply post transform. I've examined the code and it appears Visual3DHelper.Traverse<GeometryModel3D>(model1, this.AddContours); should take care of transforms?

I put out the example below and it gives the contours for the original sphere and not the end resulting scaled sphere.

Also is there a way to compute contours of a model group or is the only way computing contours of each object then joining them together?


        //add a sphere to the model
        MeshBuilder myMeshBuilder = new MeshBuilder();
        myMeshBuilder.AddSphere(new Point3D(0, 0, 0), 2);

        GeometryModel3D mySphere = new GeometryModel3D { Geometry = myMeshBuilder.ToMesh(true), Material = MaterialHelper.CreateMaterial(Colors.Pink), BackMaterial = MaterialHelper.CreateMaterial(Colors.Blue) };

        ScaleTransform3D scaletrans = new ScaleTransform3D(2, 2, 2);
        mySphere.Transform = scaletrans;

        ModelVisual3D myMod3d = new ModelVisual3D();
        myMod3d.Content = mySphere;

        AddContours(myMod3d, 20, 20, 20);
//end result is the contoured original sphere and not the scaled up version

objo wrote at 2013-04-15 12:45:

I would like to keep the GetContourSegments function as it is - working on a single MeshGeometry3D and not transforming the positions.
To support the transforms I think you should inverse(?) transform the position and normal of the contour plane! I think this is the best choice for performance...