0

I have a Viewport3D object containing a scene of hierarchical Model3D objects (grouped in Model3DGroups).
I need to "attach" 2D objects to 3D elements in the scene.
I read some articles on 3D projection but I couldn't fully understand how to apply my WPF scene data to those solutions.
What is the proper way to do that? I also tried Petzold.Media3D library but I didn't understand how to use it...

Thanks

Oren
  • 937
  • 1
  • 10
  • 34
  • possible duplicate of [Projecting a 3D point to a 2D screen coordinate](http://stackoverflow.com/questions/519106/projecting-a-3d-point-to-a-2d-screen-coordinate), specifically [check out this answer using `TransformToAncestor`](http://stackoverflow.com/a/2037128/7116). – user7116 Jan 29 '12 at 16:02
  • Not quite, what I'm missing in those solutions is how to get the location in 3D space of the object I want to attach to... – Oren Jan 29 '12 at 17:41
  • Your title says the 2D location of a 3D object, which is what the other answer entails. You can then use the 2D location to place the object in a Canvas or Grid over top of the 3D object. If this is not what you're looking for, you should revise your title accordingly. – user7116 Jan 29 '12 at 17:44
  • I changed the title to "Attaching 2D objects to 3D objects in WPF", thanks – Oren Jan 29 '12 at 17:50

1 Answers1

1

I think you are looking for the Viewport2DVisual3D class. It allows you to render any Visual2D into the 3D space.

Searching the web for more info on this class will give you examples and videos explaining how it works.

Anyway, if you are doing any WPF 3D you also need to know about the Helix Toolkit - an awesome (free) WPF 3D toolkit.

It has two classes added recently that might also be relevant to what you are doing:

  • BillboardVisual3D (quad that always faces camera) and
  • TextBillboardVisual3D (text that always faces camera).

There are useful if you want to make some 2D image that must always face towards the 3D camera.

Govert
  • 16,387
  • 4
  • 60
  • 70
  • Thanks, seems to address what I was looking for - I need to display objects that are attached to 3D objects but always face the camera. I'll look into it and update... – Oren Jan 30 '12 at 09:01
  • I checked this Toolkit, and though it is very rich it does not address this issue – Oren Jan 31 '12 at 16:42