views:

36

answers:

0

Hi;

I'm new to WPF, and I'm trying to understand the underlying architecture, so please correct me if I'm wrong:

As far as I know, there are three possibilities to dynamically transform a GeometryModel3D during runtime:

a) Set the model's Transform-property to a Transform3DGroup once, to which you add new / duplicate Transformations.

b) Cast the model's Transform-property as a MatrixTransform3D and multiply its matrix with the Value-property of a Transformation (which i guess is pretty much case (a) )

c) Leave the Transform-property as a identity matrix and instead transform the model's Geometry.Positions property directly (provided you use a MeshGeometry3D) like such:

int i;
MeshGeometry3D mesh;

mesh = (_SomeModel.Geometry as MeshGeometry3D);
for (i = 0; i < mesh.Positions.Count; i++)
{
   mesh.Positions[i] = _SomeTransform.Transform(
     mesh.Positions[i]);
}

On first glance, option (c) seems like the best (though not most intuitive) choice, especially when you need the actual positions of the model(s); for example to calculate hit-detection.

Is there another way to easily access a model's current, transformed position(s)? And why does WPF transform a model's own space instead of just the actual coordinates?

Kind regards, Frank