Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WCF and WF
  4. Transform a model's positions directly

Transform a model's positions directly

Scheduled Pinned Locked Moved WCF and WF
questioncsharpwpfarchitecturetutorial
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Frank Boettcher
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • F Frank Boettcher

      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

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      Try Silverlight/WPF forum.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups