Discussion of article "How to create 3D graphics using DirectX in MetaTrader 5"

 

New article How to create 3D graphics using DirectX in MetaTrader 5 has been published:

3D graphics provide excellent means for analyzing huge amounts of data as they enable the visualization of hidden patterns. These tasks can be solved directly in MQL5, while DireсtX functions allow creating three-dimensional object. Thus, it is even possible to create programs of any complexity, even 3D games for MetaTrader 5. Start learning 3D graphics by drawing simple three-dimensional shapes.

3D models are described using a mesh consisting of polygons. The division of polygons into triangles appeared long ago when early computer graphics had to run on weak graphics cards. The triangle enables the exact description of the position of a small surface part, as well as the calculation of related parameters, such as lights and light reflections. The collection of such small triangles allows creating a realistic three-dimensional image of the object. Hereinafter, the polygon and the triangle will be used as synonyms since it is much easier to imagine a triangle than a polygon with N vertices.


Cube made up of triangles.

A three-dimensional model of an object can be created by describing the coordinates of each vertex of the triangle, which allows further calculation of coordinates for each point of the object, even if the object moves or the viewer's position changes. Thus, we deal with vertices, the edges that connect them, and the face which is formed by the edges. If the position of a triangle is known, we can create a normal for the face using the laws of linear algebra (a normal is a vector that is perpendicular to the surface). This allows calculating how the face will be lighted and how the light will be reflected from it.


Examples of simple objects with vertices, edges, faces and normals. A normal is a red arrow.

Author: MetaQuotes

MetaQuotes
  • www.mql5.com
Trader's profile
 
Wow, Canvas3D has a lot of possibilities! Thank you. Without this article it would be a dark forest.
 
2020.04.18 08:39:08.454 Step1_Create_Box(EURUSD,H1) Error creating canvas: 5151
description of error 5151 is not in the help
 

give 3-dimensional charts as a practical application.

Metaquotes team.

 

I like the surface example, thanks. Is it possible to give the same short example for a 3D bar chart?


In the case of a surface, the points of the m_data array are smoothly connected during visualisation. This cannot be done for a diagram. Please show an example.

 
fxsaber:

Is it possible to give the same short example for a 3D bar chart?

I think it is easier to create a couple of dozens of CDXBoxes and fix one edge and move the opposite edge in height depending on the histogram data.

 
Igor Makanu:

I think it is easier to create a couple of dozens of CDXBoxes and fix one edge and move the opposite edge in height depending on the histogram data

You need a ready example for m_data.

 
fxsaber:

Need a ready example for m_data.

In the article there is

In this article we have shown how DirectX functions allow you to create simple geometric figures and animated 3D graphics for visual data analysis. More complex examples can be found in the MetaTrader 5 terminal installation folder: the "Correlation Matrix 3D" and "Math 3D Morpher" experts, as well as the "Remnant 3D" script.


 
Rashid Umarov:

I mean, there's an article in the article

Thank you, but unfortunately.

Error creating canvas: 5151
DXContextCreate returns INVALID_HANDLE.
 
fxsaber:

Thanks, but unfortunately.

DXContextCreate returns INVALID_HANDLE.

I'm getting error 5151 on my laptop too.

Here Renat explained why DirectX https://www.mql5.com/ru/forum/327001/page10#comment_14021506 won't work for me.

maybe your video driver is not compatible with DirecrX 11 either.

Новые графические возможности в MQL5 с прямым доступом к DirectX 11
Новые графические возможности в MQL5 с прямым доступом к DirectX 11
  • 2019.11.26
  • www.mql5.com
27 ноября 2019 года мы выпустим релиз с новыми графическими возможностями для построения сложных 3D визуализаций...
 
Igor Makanu:

I'm getting error 5151 on my laptop too.

here Renat explained why DirectX will not work for me https://www.mql5.com/ru/forum/327001/page10#comment_14021506

You may not have a compatible video driver with DirecrX 11 either.

Thanks, I'm not ready to upgrade my hardware.