Display/Render with give physical unit

Started by
1 comment, last by Herakles 10 years, 7 months ago

Hi, I'm new on Direct3D using DirectX 9.

I have following problem:

I want to display a carstesian coordinate system with x-y-z.

When I'm looking in x-Direction orthogonal on the y-z plane, I want to have e.g. that '1' on the z-axis matches to physically '10 millimeter' on the screen. I.e. the distance of point1 = (0, 0, 0) to point2 = (0, 0, 1) should be after rendering 10 mm on the screen.

Is this possible? If yes, can you give me a tip how I can achieve this?

Hint: When drawing with GDI something in 2D the mapping mode would allow me to calculate how many pixels are required to draw a line with a length of 10 millimeter.

But with Direct3D I have no idea how this can be achieved, because all points will be put in a rendering/transformation pipeline and afterwards Direct3D draws all at it's own.

Thanks!

Advertisement

The default clip space of D3D is -1...+1 on both x and y directions.

D3D has no method of knowing how wide or high the physical display surface is (which is a prerequisite for physical dimension mapping). Some monitor drivers may be capable of giving this information, but D3D itself does not offer a mechanism for reading this type of info.

Should you know how wide your monitor (or more specifically your render target) is, you can calculate the width of a transformed object (after wvp transformation) by using the following formula:

PhysicalWidth = ObjectClipWidth / 2 * MonitorWidth

Since the clip space width is 2.

Note that D3D is specifically designed with abstract coordinate spaces in mind, so you specifically wouldn't have to care about the render target dimensions and physical dimensions.

Niko Suni

@Nik02
Thanks much for your answer!

I don't completely understand it all.
I agree, that it's not possible to get physical dimensions of a surface.

But (please look at attached drawing):
assuming a line starting from point_1 (0,0,0) and ending at point_2 (0, 0, 1) will be rendered finally to the line point_1s (0,0) - point_2s (0, 100) on the screen, then for the z-Values a certain mapping from 3D-points to Screen-Points is given: for 96 dpi, then 100 pixels were approximately 1 inch.
Vice versa: I'm looking for a transformation-matrix or solution where I can say I want to have 100 pixels (~ 1 inch) should correspond to 1 z-unit in my 3D-space.
A use case may be, that the user may print with this setting, so he has on his paper afterwards e.g. a cube with 1 inch per side.

Has anyone an idea how I could solve this problem?

Thanks!

This topic is closed to new replies.

Advertisement