Stereoscopic 3D on WPF - wpf

I have to show stereoscopic 3D graphics on a WPF control.
I already have the code which create two DirectX-9 textures to show, one texture for each eye.
I want to use 3D Vision (not anaglyph).
I considered the following ways to show the two pictures as 3D stereo:
Using OpenGL or DirectX 11.1 Stereo API.
Using NvAPI_Stereo_SetActiveEye as described here:
http://www.nvidia.com/docs/IO/40505/WP-05482-001_v01-final.pdf
Using NVidia stereo signature as described here:
NV_STEREO_IMAGE_SIGNATURE and DirectX 10/11 (nVidia 3D Vision)
Trying rendering the two picture one-after-one, hoping that CompositionTarget.Rendering not loosing too much VSyncs, and synchronizing if single VSyncs are lost. In addition turning on the 3D Vision emitter by some invisible control rendering a fictive stereoscopic image.
Rendering 3D scene and letting NVidia driver to make it stereoscopic automatically.
Rendering to some real Windows control (such as Winform control), and using WPF host (such as WinFormHost) to show the content.
The problems with the above methods are:
1-3: One of the first three ways seem to be the straight-forward solution, but are not possible in WPF since I cannot create the Device/Context and control the way that the picture is rendered.
4: With CompositionTarget.Rendering I get only about ~60Hz instead of 120Hz. I guess the problem is that EndScene() is called twice - one in my rendered scene and the other in WPF rendering mechanism, but am not sure. Anyway even if will work - that solution seems to be unstable.
5: Rendering 3D scene is not possible in my case for some technical reasons which forces me to render the two images for the two eyes by myself.
6: The problem with WinFormHost and its friends is that it is not a WPF control and it has unexpected behavior in terms of WPF controls. For example the WinForm control will hide WPF controls which are higher on the logical tree, it cannot be rotated using RotateTransform and more.
For now I chose the last solution - using WinFormHost. Does anyone know a solution for that unbreakable wall with making stereoscopic 3D within real WPF control?

Related

Rendering WPF controls on planes in 3D space

I have the following setup: I can track a surface very accuratly in a 3d space using a tracking system. Now I want to project on this plane with an overhead projector.
I want to develop my interface in WPF/XAML and then render it in real time to the surface that is tracked. But I don't know exactly how to do it...
This is what I think: I need to model the tracked surface in a 3D space, then I want to develop the interface using regular WPF/XAML controls use (maybe) directx to render these controls to model in 3D that represent the tracked surface.
I already found information of using directx in combination with wpf (Sharpdx.WPF) but here they demonstrate how to create 3d scenes with wpf... However, they don't show how to use regular WPF controls and render these to the 3d models.
Do I first need to convert the user control of WPF/XAML to an image and then render it to the 3d model or is there another way to do it?

Is silverlight better or wpf for graphics, 3d?

I learning wpf/silverlight currently. I want to ask which one of them is better for graphics, 3d, ... ?
People say "Silverlight is a subset of WPF" -- what they mean is that the programming model is the same (code + XAML), but Silverlight generally has a smaller API / less features than WPF.
I think a good example would be creating a reflection. In WPF you could use a VisualBrush, but Silverlight doesn't support it. Still you can create the same effect by creating a 2nd transformed element. You can pretty much acomplish the same task in both, although for Silverlight you may have to do some processing tasks on the server.
The choice of platform depends more on whether you want to target web deployment or not and possibly performance.
3D isn't implemented in Silverlight 4 (though there are 3D libraries out there). 3D will be part of Silverlight 5. (Beta coming soon, probably at MIX, and to be released this year.)
i would sugest wpf in WPF you have all the Viewport sutff where you can do real 3d, In Silverlight you have PlaneTransformation but it is not close to real 3d
WPF 3d tutorial
The deal is more deeper as I understand.
We will speak about WPF and Silverlight 5. There are two mechanisms of 3D Graphics. Before WPF it was a single one - so named pipeline graphics. It includes DirectX, OpenGL and multiple derivative and independent realizations (XNA from DirectX, for example). Although WPF is based internally on DirectX it realizes absolutely different conception of smart graphics. What is the difference for a pipeline and smart mechanism? The pipeline mechanism consists of infinity loop of drawing objects - typically primitives like vertex, triangles. It works by initialization of so named infinity loop by calling something like OnDraw/ReDraw method.
WPF does not use ReDraw and does not draw anything until we directly detect it. It is single correct way to use it. Therefore WPF allows to draw UI Elements with internal support of hundreds events, methods and full freedom of management (like usual WPF control - textbox, for example). (Helix 3D is good library for easy way to WPF 3D) And vice versa, Silverlight 5 has some API of XNA graphics - pipeline way without UIElement support for 3D objects.
There is Kit3D library http://kit3d.codeplex.com/ as very good idea for smart graphic realization for Silverlight and there are many other realizations (Balder, Babylon) on pipeline mechanism. If you are interesting to code an application like web 3D Game - choose pipeline Silverlight 3D graphics, if you are interesting about smart 3D applications - choose WPF 3D.
Author of WPF 3D CAE system TIMO Structural.

WPF-DirectX Interop Problem (D3DImage)

I'm writing a Video application utilizing D3DImage. Frames are from memory and rendered as textures in native code with DirectX9, finally exposed by D3DImage to the WPF GUI. I have some Overlays on top, created with WPF's painting framework (Text, shapes etc.). Up to this point, it works like a charm.
Now, I would like encode the composited image from my underlying native C++ code. Video is 640x480 BGR, 25 FPS and has to be rendered and encoded in parallel, also on older Hardware with Windows versions down to XP/SP3.
Problem is, I cannot find any documentation describing the composition process between WPF and D3DImage. They 'blend' in some sense, but what is the meaning of this? And is it possible to get a handle to the WPF's part of the drawing or even the composited image in my native C++ code?
p.s: I'm also open to managed solutions, but didn't found much performant up to now.
There is global static method called "CompositionTarget.Rendering". Add an event to that and every time WPF renders that method will be called before WPF presents(the FPS can vary though). So just updated your renderTarget accordingly.
There might be a better way, but i'm not aware of it.
NOTE:: Also for D3DImage on WindowsXP you use a D3D9 device with a lockable renderTarget while on Vista/7 you use a D3D9Ex device with a non-lockable renderTarget. Just a note.

WPF - Drawing 3D Object

I am newbie to WPF.
I have drawn simple 3D cube and rotate it with mouse
But my question is,
is it possible to draw wireframe object in WPF Without using any third party library(eg.Charles Petzold's libraty etc..)?
Unfortunatly the DirectX that WPF is built upon doesn't allow drawing lines, only rectangles which in turn means no wireframe. Sorry, you´ll have to look around for another solution.

WPF capabilities

In my company we have in mind a redesign of the user interface of an application and we would like to make it ... let say "fancy". We have in mind a simple story board but I doubt between WPF, XNA or DirectX. I prefer WPF so I'd need to know if it support the following capabilities and how difficult to implement are they:
Transparency: We'd like to display information layers on top of the main display.
3D support: We want network nodes (part of the interface is a network graphic) to be simple spheres connected with lines in a 3D enviroment, and the ability to control the camera so rotation of the screen is possible.
Effects: Such as shading, lens flare or glow to "signal" the discovery or deletion of a node.
Text animations: Specifically the ability to display the text as if it's being written... You know, the information text will be "filling" the panel top down, left to right...
Good news. WPF is the technology you want and it can handle your requirements with relative ease.
Transparency is simple.
3D support is good as well. For an example, check out Tim Sneath: Five Great WPF 3D Nuggets. You even get hardware acceleration.
Effects are definitely do-able via timeline animations.
The previous statement goes double for Text Animations.
...the hardest part would be the 3D support, but it's still going to be a lot easier than getting things done in XNA or using DirectX libraries directly.
AFAIK WPF 3.5 supports all of this, and even leverages hardware acceleration to get a decent performance.
It's possible to embed an XNA application in a WPF form so you could use XNA for the representation of your network and WPF controls for the GUI in front of it.

Resources