creating real 3D shapes - c#

Hello
I saw that there are some laptops with 3D support. I know that they use polarization for each eye. How can I write a program in C# that shows a simple 3D object in such system? I don't want to show a 3D object in a 2 D medium (Perspective view), but showing a 3D object similar to what you can see in a 3D film using a 3D glass.
Any suggestion for further study is highly appreciated.
Regards

What you need to do is display two images one for each eye. Each image is a perspective view but taken from two slightly different viewpoints - about the distance of your eyes apart.
When viewed through polarising or more likely LCD Shutter glasses you get the illusion of 3D objects.
In this case each eye's view is presented on the screen alternately and a signal is sent to the glasses to become clear or opaque so that the correct image is seen in each eye.
For a passive system you have to use two projectors for the left and right eye images and make sure that they are perfectly aligned so the images overlap correctly. If you get it wrong you won't get a very good 3D effect.
In both cases you need to create two views of your model and render each one for each frame you display. I used to work in this area and a while back wrote a blog post which included an overview on how we did stereo systems.

I think that you need to program directly using OpenGL or Direct3D. For the screen to display the polarized views necessary to achieve the 3D effect, the graphics card will need to know what it has to display. See here for some ideas.

Related

Leadtools images stiching with overlap

We're developing system of getting combined image from camera, which being moved by step motors to make pictures of the whole area. The problem is that when we combine separate frames, the edges are not accurate because of step motors discretization. So we came up with idea to make frames with little overlap, so we can put them over each other to get continual image with no blanks. We're using c# + LeadTools. So I'm wondering is there any option in Lead Tools (or maybe some other sdk) to detect areas, which are equal on both images, so we can stitch them correctly? Thanks in advance.

Pix-elated Drawing and 3D representations

I am writing a program to imitate Natural Physics. I want to know whether there is a better way to draw an object other than overriding the OnDraw method, and FillRectangle(x,y,1,1) for each pixel.
Is there a way to do a similar action using DirectX or OpenGL? Because to my knowledge the Graphics does not utilize the video card of ones computer (please correct me if I am wrong).
Saying this I would like some thoughts in relation to creating a 3D environment using mathematical calculations to work out the relative quadrant sizes so that objects appear to be farther away then in reality (as a monitor is only 2D), or closer.
Yes. Drawing pixel by pixel with FillRectangle will be very inefficient and slow things down a huge amount. As you say, you should use a graphics rendering system such as DirectX or OpenGL. The choice of which is up to you. If you do a simple search on the web you will find many tutorials on how to get started with 3d graphics.
OpenGL focuses on "Draw me this object in space", and it will take care of rendering it, taking advantage of your graphics card if possible. You do not worry about the pixels, you specify dimensions, camera angles, shaders etc.
You can draw pixels with OpenGL, but that is not the 'correct' way to draw 3d graphics with it.
EDIT in response to Vasa's questions:
I believe OpenGL does what's best based on your graphics card capabilities and drivers. In general OpenGL isn't going to be your best option for drawing direct pixels. BUT remember that
Pixels are different sizes on different machines. Are you expecting to just live with this? Or live with a big display on low-res screens and a tiny one on high-res screens? There may be multiplications involved. If you use literal pixels then once you start multiplying for different screens you are going to get artefacts and inaccuracies.
You want a direct mapping of X to pixels. OpenGL uses float values. They aren't integer 1 to 1 mappings, but they do use a direct proportion. If you choose a scale then OpenGL is not going to suddenly start distorting ratios.
The important thing is proportions not absolute pixels. Although I accept that it's possible for your case to be different.
See this for 2d drawing:
http://basic4gl.wikispaces.com/2D+Drawing+in+OpenGL

ideas to create a software where shows views of cubes?

I'm planning to draw these shapes in WPF. It's for an educational software.
What idea's do you have in how to implement these cubes and views?
I was planning at the beginning starting using canvas and draw, but I guess it will be become eternal. So I supposed if exists some library to help me drawing them?
The ability to draw 3D shapes (such as cubes) and render them from different angles is built right into WPF. From the look of your cubes, you're going to want an orthographic camera, rather than a perspective camera, because the lines composing your cubes are parallel.
You might also find the Petzold.Media3D library helpful, because it has objects like cubes built in (you don't have to write your own algorithms to build them).
Finally, you might this primer helpful in getting started with WPF 3D.
Once you have some idea of how to use 3D, it will just be a matter of putting cubes in your scene at the proper locations and positioning the cameras properly for viewing the cubes. You will probably want to keep reusing the same four camera positions: one for the "3D view", and one each for the top, side, and front views.
This should be a lot less work than trying to draw the cubes using 2D.

WPF Card Design

How can I design an application that contains a card that can be flipped and have content on both side?
The card is something like a post card which has images on 1 side and then the messages on another side. It should be able to be rotated smoothly as well.
The download site has moved around and there doesn't seem to be a documentation page for it anymore, but I think the Bag of Tricks still includes a FlipTile3D control that lets you define both sides of a tile, and lets you flip it over like a playing card.
If you want content on two sides, I recommend Josh Smith's ContentControl3D:
Introducing ContentControl3D
It does exactly what you want and includes a variety of configurable 3D transition effects.
There is also a detailed CodeProject article on the control:
Rotating WPF Content in 3D Space
Rotating from one content to another is a basic WPF/silverlight skill.
Here is a link to a blog post that shows how to rotate to display a cube. If you wanted to show only two faces, rotate 180 degrees instead of 90.
http://oldschooldotnet.blogspot.com/2009/11/how-to-create-your-own-silverlight-cube.html
just have a look at this post
http://www.interact-sw.co.uk/iangblog/2007/05/17/wpf-flippable-3D-list
You need to create the card as a 3d panel with the necessary controls on each side. I would recommend referencing this control as a starting point:
http://flipcontrol.codeplex.com/releases/view/22358

C# Create "wireframe"/3D "map"

image http://prod.triplesign.com/map.jpg
How can I produce a similar output in C# window forms in the easiest way?
Is there a good library for this purpose?
I just needs to be pointed in the direction of which graphic library is best for this.
You should just roll your own in a 3d graphics library. You could use directx. If using WPF it is built-in, you can lookup viewport3d. http://msdn.microsoft.com/en-us/magazine/cc163449.aspx
In graphics programming what you are building is a very simple version of a heightmap. I think building your own would give your greater flexibility in the long run.
So a best library doesn't exist. There are plenty of them and some are just for different purposes. Here a small list of possibilities:
Tao: Make anything yourself with OpenGL
OpenTK: The successor of the Tao framework
Dundas: One of the best but quite expensive (lacks in real time performance)
Nevron: Quite good, but much cheaper (also has problems with real time data)
National Instruments: Expensive, not the best looking ones, but damn good in real time data.
... Probably someone else made some other experiences.
Checkout Microsoft Chart Controls library.
Here's how I'd implement this using OpenGL.
First up, you will need a wrapper to import the OpenGL API into C#. A bit of Googling led me to this:
CsGL - OpenGL .NET
There a few example programs available to demonstrate how the OpenGL interface works. Play around with them to get an idea of how the system works.
To implement the 3D map:
Create an array of vectors (that's not the std::vector/List type but x,y,z triplets) where x and y are along the horizontal plane and z is the up amount.
Set the Z compare to less-than-or-equal (so the overlaid line segments are visible).
Create a list of quads where the vertices of the quads are taken from the array in (1)
Calculate the colour of the quad. Use a dot-product of the quad's normal and a light source direction to get a value to shade value, i.e. normal.light of 1 is black and -1 is white.
Create a list of line segments, again from the array in (1).
Calculate the screen position of the various projected axes points.
Set up your camera and world->view transform (use the example programs to get an idea of how to do this).
Render the quads and lines, OpenGL will do the transformation from world co-ordinates (the list in (1)) to screen space. Draw the labels, you might not want to do this using OpenGL as the labels shouldn't scale with distance from camera, otherwise they could get too small to read.
Since the above is quite a lot of stuff, there isn't really the space (and time on my part) to post working code (but someone else might add something if you're lucky). You could break the task down and ask questions on the parts you don't quite understand.
Have you tried this... gigasoft data visualization tools (Its not free)
And you can checkout the online wireframe demo here

Categories