Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Many questions about DiagramView3D (Read 3371 times)
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Many questions about DiagramView3D
Mar 24th, 2013 at 2:03am
Print Post  
Stoyan,

Thanks for your suggestion about using the DiagramView3D.Paint event handler. This seems to be a viable way for me to draw floating floorplans to depict a multi-story building, where the images of the floorplans are "tilted" according to the camera position. (What I'm doing is using DiagramView3D.PointToClient on the four corners of the floorplan and then deforming the image to fit that polygon and then painting the deformed image. It looks OK, when I get the camera positioned correctly ...)

But I have a lot of questions. I hope you'll bear with me. And to understand what I'm asking, I'm considering the X coordinate to be east-west and the Y coordinate to be north-south, and Z up-down in the real world.

1. In the Developer's Guide in the "Display Graphs in 3D" topic it says "The Y axis is vertical and points upwards." Is this true? If so, it's different from everything else in MindFusion.Diagramming and the standard WinForms coordinate system, right? It will add (minor) complications for real-world objects, for example a node representing a building in Elsinore will have a Y value less than a building in Copenhagen (Elsinore is north of Copenhagen) for use in DiagramView, but for a satellite-view in DiagramView3D Elsinore's Y value needs to be greater than Copenhagen's?

2. I'm also unsure of how the Z coordinate is working. I'm setting a ground-floor floorplan to have Z = 0, and the floorplan for the next floor up to have Z = -20. Then the camera's default Z = -100 should imply that the camera is looking down from something like 15 m. above the ground, right? Then when I move the camera "down" towards zero, it does seem to get closer to the floors, but even at Z = 0 it still seems to be above the floorplan that is at Z = -20!

3. What does the "viewer distance" mean, exactly? My experiments indicate that when it is reduced from the default of 200, then the projected size of my images get smaller, and they rapidly approach being a tiny point as the viewer distance approaches zero. Conversly, when the viewer distance is made greater than 200 the images get larger. I'm confused.

In general, I find it very difficult to know what is going on when you're unsure of where the camera is and how the coordinate system works. Sometimes I can't figure out if my objects are in the wrong place or if maybe the camera is upside down. Very disconcerting.

Hope you can help - thanks.
« Last Edit: Mar 24th, 2013 at 12:56pm by Rennie »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Many questions about DiagramView3D
Reply #1 - Mar 25th, 2013 at 1:31pm
Print Post  
1) I think there are something like 12 or 24 possible coordinate systems in 3D. We are simply using one of the more popular systems used in various 3D modeling applications and game engines, where Y represents vertical position and Z represents depth. Our intent wasn't showing the same graph at matching 2D and 3D positions and the 3D viewer gets its node coordinates from a completely different property, so you will have to copy your coordinates from 2D points to 3D points anyway - while doing that, just assign your 2D.Y to 3D.Z.

2 & 3) Z represents depth, with positive coordinates meaning deeper inside / further behind the screen if you look from the origin. If you run this code upon a button click with the cube coordinates from previous thread (all positive), you will see that the cube becomes larger since the camera moves towards it from its original negative Z position:

Code
Select All
private void button1_Click(object sender, EventArgs e)
{
	var p3 = diagramView3D.CameraPosition;
	diagramView3D.CameraPosition = new Point3D(p3.X, p3.Y, p3.Z + 22);
	diagramView3D.ResetProjection();
} 



However as mentioned you will have to cull vertices that are behind the camera, or you get strange results. The projection math still works for them, but they will be drawn flipped and start to look smaller once the camera passes them by (e.g. try clicking the button with handler shown above until the cube gets behind to see the effect).

The viewer from viewer distance is what corresponds to the eye in this image, while the camera corresponds to the projection plane:
http://en.wikipedia.org/wiki/3d_projection#Diagram

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Re: Many questions about DiagramView3D
Reply #2 - Mar 25th, 2013 at 4:20pm
Print Post  
Stoyan,

Thanks for your answer. Sorry if I'm being dense, but my excuse is that I've never worked with 3D before.

I suddenly have an awful suspicion that I haven't understood anything at all about the 3D coordinate system. Can it just possibly be true that the coordinates of all objects in a 3D system have to be recomputed every time the camera is moved or tilted or whatever? That all coordinates are always relative to the camera?

If that is true then I haven't understood it at all - until now.

Edit: But wait a minute! If that's the case, if all coordinates are always relative to the camera, then why is it possible to specify the camera position? It would always be at 0, 0, 0.

Edit again: What I'm trying to understand is whether or not the 3D coordinate system is a "fixed" coordinate system, where all (non-moving) objects always have the same x, y and z coordinates, or is it some kind of fluid system where the coordinates of non-moving objects are changing depending on the view?

You talk about the z coordinate being "depth". But that depends on the view. When I first show a multi-story building from the top then "depth" is down into the ground. But then the user should be able to swing the camera down to a kind of elevated profile view, looking at the building from the side but from an angle maybe 20 degrees above horizontal. Now "depth" means something completely different, maybe a northernly-but-slightly-down-into-the-ground concept.

So are the coordinates of the four corners of each floorplan fixed or what?

Edit-edit-edit:

I've been reading up on 3D and projection, and I've come to the conclusion that what it says in the Developer's Guide must be wrong. What it should say is that DiagramView3D uses an arbitrary world-view coordinate system that conforms to the "right-hand rule", but that otherwise the x, y and z values have no particular meaning or direction. The default camera position and orientation do imply rendering of x to the right and y upwards, but the camera can be positioned and rotated in any crazy way you want, which makes the resultant rendering of x, y and z completely arbitrary, except that it will always conform to the right-hand rule.
« Last Edit: Mar 26th, 2013 at 2:34am by Rennie »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Many questions about DiagramView3D
Reply #3 - Mar 26th, 2013 at 9:45am
Print Post  
Quote:
Can it just possibly be true that the coordinates of all objects in a 3D system have to be recomputed every time the camera is moved or tilted or whatever? That all coordinates are always relative to the camera?


No, you specify fixed scene coordinates, and they do not change when the camera moves through the scene. If you are referring to my Z being depth / away from the screen explanation, check it again - I was talking about when the camera looks from the origin of the coordinate system. If you move and rotate the camera, Z might start looking as say left-to-right direction on your screen. So if you want Y to show depth in your case, you could move and rotate the camera to some point where it looks straight to the XY plane. I think Z will grow to the bottom of screen in such case with DiagramView3D's coordinate system.

If you don't mind doing some WPF interop, perhaps you should take a look at the WPF's Viewport3D control:
http://msdn.microsoft.com/en-us/library/ms747437.aspx
http://www.c-sharpcorner.com/uploadfile/mheydlauf/creating-a-simple-3d-scene-in-...

It implements the vertex Z culling you need out of the box, and also supports materials and lighting. It treats Y as the up direction in 3D too, so you will still have to assign your 2D Y values to 3D Z values.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Re: Many questions about DiagramView3D
Reply #4 - Mar 30th, 2013 at 9:18pm
Print Post  
Stoyan,

Thanks for your reply.

> If you don't mind doing some WPF interop ...

But is it possible to mix WPF and WinForms in the same program?

And I'll just mention once again that I really think you should change the Developer's Guide in the "Display Graphs in 3D" topic where it talks about the coordinate system and says "The X axis is horizontal and points to the right. The Y axis is vertical and points upwards. The Z axis specifies depth and its values grow with distance."

This is only true as long as you stick to the default camera position, and is thus more confusing than helpful.

My suggested text: DiagramView3D uses an arbitrary world-view coordinate system that conforms to the "right-hand rule", but otherwise the x, y and z values have no particular meaning or direction. The default camera position and orientation imply rendering of x to the right and y upwards, but the camera can be positioned and rotated in any way you want, making the resultant rendering of x, y and z completely arbitrary, except that it will always conform to the right-hand rule.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Many questions about DiagramView3D
Reply #5 - Apr 2nd, 2013 at 12:40pm
Print Post  
Quote:
But is it possible to mix WPF and WinForms in the same program?


Yes, using the System.Windows.Forms.Integration.ElementHost control (as long as you are targeting .NET 3.5 or newer version) :
http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.element...

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint